First version of CGI-based edit interface. This is very much a
authorjongfoster <jongfoster@users.sourceforge.net>
Sun, 16 Sep 2001 15:47:37 +0000 (15:47 +0000)
committerjongfoster <jongfoster@users.sourceforge.net>
Sun, 16 Sep 2001 15:47:37 +0000 (15:47 +0000)
work-in-progress, and you can't actually use it to edit anything
yet.  You must #define FEATURE_CGI_EDIT_ACTIONS for these changes
to have any effect.

12 files changed:
actionlist.h
actions.c
actions.h
cgi.c
cgiedit.c [new file with mode: 0644]
cgiedit.h [new file with mode: 0644]
showargs.c
templates/edit-actions [new file with mode: 0644]
templates/edit-actions-list [new file with mode: 0644]
templates/edit-actions-list-section [new file with mode: 0644]
templates/edit-actions-list-url [new file with mode: 0644]
templates/edit-actions-submit [new file with mode: 0644]

index cc65b2a..626be45 100644 (file)
@@ -39,6 +39,9 @@
  *
  * Revisions   :
  *    $Log: actionlist.h,v $
  *
  * Revisions   :
  *    $Log: actionlist.h,v $
+ *    Revision 1.5  2001/07/18 12:27:03  oes
+ *    Changed deanimate-gifs to string action
+ *
  *    Revision 1.4  2001/07/13 13:52:12  oes
  *     - Formatting
  *     - Introduced new action ACTION_DEANIMATE
  *    Revision 1.4  2001/07/13 13:52:12  oes
  *     - Formatting
  *     - Introduced new action ACTION_DEANIMATE
  *********************************************************************/
 \f
 
  *********************************************************************/
 \f
 
-DEFINE_ACTION_MULTI ("add-header",      ACTION_MULTI_ADD_HEADER)
-DEFINE_ACTION_BOOL  ("block",           ACTION_BLOCK)
-DEFINE_ACTION_STRING("deanimate-gifs",  ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE)
-DEFINE_ACTION_BOOL  ("fast-redirects",  ACTION_FAST_REDIRECTS)
-DEFINE_ACTION_BOOL  ("filter",          ACTION_FILTER)
-DEFINE_ACTION_BOOL  ("hide-forwarded",  ACTION_HIDE_FORWARDED)
-DEFINE_ACTION_STRING("hide-from",       ACTION_HIDE_FROM,       ACTION_STRING_FROM)
-DEFINE_ACTION_STRING("hide-referer",    ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
-DEFINE_ACTION_STRING("hide-user-agent", ACTION_HIDE_USER_AGENT, ACTION_STRING_USER_AGENT)
-DEFINE_ACTION_BOOL  ("image",           ACTION_IMAGE)
-DEFINE_ACTION_STRING("image-blocker",   ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER)
-DEFINE_ACTION_BOOL  ("no-cookies-read", ACTION_NO_COOKIE_READ)
-DEFINE_ACTION_BOOL  ("no-cookies-set",  ACTION_NO_COOKIE_SET)
-DEFINE_ACTION_BOOL  ("no-popups",       ACTION_NO_POPUPS)
-DEFINE_ACTION_BOOL  ("vanilla-wafer",   ACTION_VANILLA_WAFER)
-DEFINE_ACTION_MULTI ("wafer",           ACTION_MULTI_WAFER)
+#if !(defined(DEFINE_ACTION_BOOL) && defined(DEFINE_ACTION_MULTI) && defined(DEFINE_ACTION_STRING))
+#error Please define lots of macros before including "actionlist.h".
+#endif /* !defined(all the DEFINE_ACTION_xxx macros) */
+
+#ifndef DEFINE_CGI_PARAM_RADIO
+#define DEFINE_CGI_PARAM_RADIO(name, bit, index, value, is_default)
+#define DEFINE_CGI_PARAM_CUSTOM(name, bit, index, default_val)
+#define DEFINE_CGI_PARAM_NO_RADIO(name, bit, index, default_val)
+#endif /* ndef DEFINE_CGI_PARAM_RADIO */
+
+DEFINE_ACTION_MULTI      ("add-header",      ACTION_MULTI_ADD_HEADER)
+DEFINE_ACTION_BOOL       ("block",           ACTION_BLOCK)
+DEFINE_ACTION_STRING     ("deanimate-gifs",  ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE)
+DEFINE_CGI_PARAM_RADIO   ("deanimate-gifs",  ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE,     "first", 0)
+DEFINE_CGI_PARAM_RADIO   ("deanimate-gifs",  ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE,     "last",  1)
+DEFINE_ACTION_BOOL       ("fast-redirects",  ACTION_FAST_REDIRECTS)
+DEFINE_ACTION_BOOL       ("filter",          ACTION_FILTER)
+DEFINE_ACTION_BOOL       ("hide-forwarded",  ACTION_HIDE_FORWARDED)
+DEFINE_ACTION_STRING     ("hide-from",       ACTION_HIDE_FROM,       ACTION_STRING_FROM)
+DEFINE_CGI_PARAM_RADIO   ("hide-from",       ACTION_HIDE_FROM,       ACTION_STRING_FROM,          "block", 1)
+DEFINE_CGI_PARAM_CUSTOM  ("hide-from",       ACTION_HIDE_FROM,       ACTION_STRING_FROM,          "spam_me_senseless@sittingduck.xyz")
+DEFINE_ACTION_STRING     ("hide-referer",    ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
+DEFINE_CGI_PARAM_RADIO   ("hide-referer",    ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "forge", 1)
+DEFINE_CGI_PARAM_RADIO   ("hide-referer",    ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "block", 0)
+DEFINE_CGI_PARAM_CUSTOM  ("hide-referer",    ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "http://www.google.com/")
+DEFINE_ACTION_STRING     ("hide-user-agent", ACTION_HIDE_USER_AGENT, ACTION_STRING_USER_AGENT)
+DEFINE_CGI_PARAM_NO_RADIO("hide-user-agent", ACTION_HIDE_USER_AGENT, ACTION_STRING_FROM,          "JunkBuster/3.0 (Anonymized)")
+DEFINE_ACTION_BOOL       ("image",           ACTION_IMAGE)
+DEFINE_ACTION_STRING     ("image-blocker",   ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER)
+DEFINE_CGI_PARAM_RADIO   ("image-blocker",   ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER, "logo", 1)
+DEFINE_CGI_PARAM_RADIO   ("image-blocker",   ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER, "blank", 0)
+DEFINE_CGI_PARAM_CUSTOM  ("image-blocker",   ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER, "http://")
+DEFINE_ACTION_BOOL       ("no-cookies-read", ACTION_NO_COOKIE_READ)
+DEFINE_ACTION_BOOL       ("no-cookies-set",  ACTION_NO_COOKIE_SET)
+DEFINE_ACTION_BOOL       ("no-popups",       ACTION_NO_POPUPS)
+DEFINE_ACTION_BOOL       ("vanilla-wafer",   ACTION_VANILLA_WAFER)
+DEFINE_ACTION_MULTI      ("wafer",           ACTION_MULTI_WAFER)
 #if DEFINE_ACTION_ALIAS
 #if DEFINE_ACTION_ALIAS
-DEFINE_ACTION_BOOL  ("no-popup",        ACTION_NO_POPUPS)
-DEFINE_ACTION_STRING("hide-referrer",   ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
+DEFINE_ACTION_BOOL       ("no-popup",        ACTION_NO_POPUPS)
+DEFINE_ACTION_STRING     ("hide-referrer",   ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
 #endif /* if DEFINE_ACTION_ALIAS */
 #endif /* if DEFINE_ACTION_ALIAS */
+
+#undef DEFINE_ACTION_MULTI
+#undef DEFINE_ACTION_STRING
+#undef DEFINE_ACTION_BOOL
+#undef DEFINE_ACTION_ALIAS
+#undef DEFINE_CGI_PARAM_CUSTOM
+#undef DEFINE_CGI_PARAM_RADIO
+#undef DEFINE_CGI_PARAM_NO_RADIO
+
index 0bc413a..a09f95a 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -1,4 +1,4 @@
-const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.12 2001/09/16 13:21:27 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/actions.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/actions.c,v $
@@ -33,6 +33,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster
  *
  * Revisions   :
  *    $Log: actions.c,v $
  *
  * Revisions   :
  *    $Log: actions.c,v $
+ *    Revision 1.12  2001/09/16 13:21:27  jongfoster
+ *    Changes to use new list functions.
+ *
  *    Revision 1.11  2001/09/14 00:17:32  jongfoster
  *    Tidying up memory allocation. New function init_action().
  *
  *    Revision 1.11  2001/09/14 00:17:32  jongfoster
  *    Tidying up memory allocation. New function init_action().
  *
@@ -87,6 +90,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster
 #include "miscutil.h"
 #include "errlog.h"
 #include "loaders.h"
 #include "miscutil.h"
 #include "errlog.h"
 #include "loaders.h"
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+#include "encode.h"
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
 
 const char actions_h_rcs[] = ACTIONS_H_VERSION;
 
 
 const char actions_h_rcs[] = ACTIONS_H_VERSION;
 
@@ -655,6 +661,106 @@ char * actions_to_text(struct action_spec *action)
 }
 
 
 }
 
 
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+/*********************************************************************
+ *
+ * Function    :  actions_to_html
+ *
+ * Description :  Converts a actionsfile entry from numeric form
+ *                ("mask" and "add") to a <br>-seperated HTML string.
+ *
+ * Parameters  :
+ *          1  :  mask = As from struct url_actions
+ *          2  :  add  = As from struct url_actions
+ *
+ * Returns     :  A string.  Caller must free it.
+ *
+ *********************************************************************/
+char * actions_to_html(struct action_spec *action)
+{
+   unsigned mask = action->mask;
+   unsigned add  = action->add;
+   char * result = strdup("");
+   char * enc_str;
+   struct list_entry * lst;
+
+   /* sanity - prevents "-feature +feature" */
+   mask |= add;
+
+
+#define DEFINE_ACTION_BOOL(__name, __bit)      \
+   if (!(mask & __bit))                        \
+   {                                           \
+      result = strsav(result, "\n<br>-" __name); \
+   }                                           \
+   else if (add & __bit)                       \
+   {                                           \
+      result = strsav(result, "\n<br>+" __name); \
+   }
+
+#define DEFINE_ACTION_STRING(__name, __bit, __index) \
+   if (!(mask & __bit))                              \
+   {                                                 \
+      result = strsav(result, "\n<br>-" __name);       \
+   }                                                 \
+   else if (add & __bit)                             \
+   {                                                 \
+      result = strsav(result, "\n<br>+" __name "{");   \
+      enc_str = html_encode(action->string[__index]);\
+      result = strsav(result, enc_str);              \
+      freez(enc_str);                                \
+      result = strsav(result, "}");                  \
+   }
+
+#define DEFINE_ACTION_MULTI(__name, __index)         \
+   if (action->multi_remove_all[__index])            \
+   {                                                 \
+      result = strsav(result, "\n<br>-" __name "{*}"); \
+   }                                                 \
+   else                                              \
+   {                                                 \
+      lst = action->multi_remove[__index]->first;    \
+      while (lst)                                    \
+      {                                              \
+         result = strsav(result, "\n<br>-" __name "{");\
+         enc_str = html_encode(lst->str);            \
+         result = strsav(result, enc_str);           \
+         freez(enc_str);                             \
+         result = strsav(result, "}");               \
+         lst = lst->next;                            \
+      }                                              \
+   }                                                 \
+   lst = action->multi_add[__index]->first;          \
+   while (lst)                                       \
+   {                                                 \
+      result = strsav(result, "\n<br>+" __name "{");   \
+      result = strsav(result, lst->str);             \
+      result = strsav(result, "}");                  \
+      lst = lst->next;                               \
+   }
+
+#define DEFINE_ACTION_ALIAS 0 /* No aliases for output */
+
+#include "actionlist.h"
+
+#undef DEFINE_ACTION_MULTI
+#undef DEFINE_ACTION_STRING
+#undef DEFINE_ACTION_BOOL
+#undef DEFINE_ACTION_ALIAS
+
+   /* trim leading <br> */
+   if (result && *result)
+   {
+      char * s = result;
+      result = strdup(result + 5);
+      free(s);
+   }
+
+   return result;
+}
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
+
+
 /*********************************************************************
  *
  * Function    :  current_actions_to_text
 /*********************************************************************
  *
  * Function    :  current_actions_to_text
index 63250b3..c823a65 100644 (file)
--- a/actions.h
+++ b/actions.h
@@ -1,6 +1,6 @@
 #ifndef ACTIONS_H_INCLUDED
 #define ACTIONS_H_INCLUDED
 #ifndef ACTIONS_H_INCLUDED
 #define ACTIONS_H_INCLUDED
-#define ACTIONS_H_VERSION "$Id: actions.h,v 1.2 2001/07/29 19:01:11 jongfoster Exp $"
+#define ACTIONS_H_VERSION "$Id: actions.h,v 1.3 2001/09/14 00:17:32 jongfoster Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/actions.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/actions.h,v $
@@ -35,6 +35,9 @@
  *
  * Revisions   :
  *    $Log: actions.h,v $
  *
  * Revisions   :
  *    $Log: actions.h,v $
+ *    Revision 1.3  2001/09/14 00:17:32  jongfoster
+ *    Tidying up memory allocation. New function init_action().
+ *
  *    Revision 1.2  2001/07/29 19:01:11  jongfoster
  *    Changed _FILENAME_H to FILENAME_H_INCLUDED.
  *    Added forward declarations for needed structures.
  *    Revision 1.2  2001/07/29 19:01:11  jongfoster
  *    Changed _FILENAME_H to FILENAME_H_INCLUDED.
  *    Added forward declarations for needed structures.
@@ -62,6 +65,9 @@ extern void merge_actions (struct action_spec *dest,
 extern void copy_action (struct action_spec *dest, 
                          const struct action_spec *src);
 extern char * actions_to_text     (struct action_spec *action);
 extern void copy_action (struct action_spec *dest, 
                          const struct action_spec *src);
 extern char * actions_to_text     (struct action_spec *action);
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+extern char * actions_to_html     (struct action_spec *action);
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
 
 extern void init_current_action     (struct current_action_spec *dest);
 extern void free_current_action     (struct current_action_spec *src);
 
 extern void init_current_action     (struct current_action_spec *dest);
 extern void free_current_action     (struct current_action_spec *src);
diff --git a/cgi.c b/cgi.c
index ea63193..de82743 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.24 2001/09/16 11:38:01 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.25 2001/09/16 15:02:35 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -36,6 +36,10 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.24 2001/09/16 11:38:01 jongfoster Exp $";
  *
  * Revisions   :
  *    $Log: cgi.c,v $
  *
  * Revisions   :
  *    $Log: cgi.c,v $
+ *    Revision 1.25  2001/09/16 15:02:35  jongfoster
+ *    Adding i.j.b/robots.txt.
+ *    Inlining add_stats() since it's only ever called from one place.
+ *
  *    Revision 1.24  2001/09/16 11:38:01  jongfoster
  *    Splitting fill_template() into 2 functions:
  *    template_load() loads the file
  *    Revision 1.24  2001/09/16 11:38:01  jongfoster
  *    Splitting fill_template() into 2 functions:
  *    template_load() loads the file
@@ -200,6 +204,9 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.24 2001/09/16 11:38:01 jongfoster Exp $";
 #include "miscutil.h"
 #include "showargs.h"
 #include "loadcfg.h"
 #include "miscutil.h"
 #include "showargs.h"
 #include "loadcfg.h"
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+#include "cgiedit.h"
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
 
 const char cgi_h_rcs[] = CGI_H_VERSION;
 
 
 const char cgi_h_rcs[] = CGI_H_VERSION;
 
@@ -219,6 +226,17 @@ const struct cgi_dispatcher cgi_dispatcher[] = {
    { "send-banner",
          11, cgi_send_banner, 
          "HIDE Send the transparent or \"Junkbuster\" gif" },
    { "send-banner",
          11, cgi_send_banner, 
          "HIDE Send the transparent or \"Junkbuster\" gif" },
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+   { "edit-actions-list",
+         17, cgi_edit_actions_list, 
+         "Edit the actions list" },
+   { "edit-actions-submit",
+         19, cgi_edit_actions_submit, 
+         "HIDE Change the actions for (a) specified URL(s)" },
+   { "edit-actions",
+         12, cgi_edit_actions, 
+         "HIDE Edit the actions for (a) specified URL(s)" },
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
    { "",
          0, cgi_default,
          "Junkbuster main page" },
    { "",
          0, cgi_default,
          "Junkbuster main page" },
@@ -311,6 +329,7 @@ struct http_response *dispatch_cgi(struct client_state *csp)
       return NULL;
    }
 
       return NULL;
    }
 
+
    /* Remove leading slash */
    if (*argstring == '/')
    {
    /* Remove leading slash */
    if (*argstring == '/')
    {
diff --git a/cgiedit.c b/cgiedit.c
new file mode 100644 (file)
index 0000000..4b727c8
--- /dev/null
+++ b/cgiedit.c
@@ -0,0 +1,503 @@
+const char cgiedit_rcs[] = "$Id: cgi.c,v 1.25 2001/09/16 15:02:35 jongfoster Exp $";
+/*********************************************************************
+ *
+ * File        :  $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
+ *
+ * Purpose     :  CGI-based actionsfile editor.
+ *                
+ *                Functions declared include:
+ * 
+ *
+ * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
+ *                IJBSWA team.  http://ijbswa.sourceforge.net
+ *
+ *                Based on the Internet Junkbuster originally written
+ *                by and Copyright (C) 1997 Anonymous Coders and 
+ *                Junkbusters Corporation.  http://www.junkbusters.com
+ *
+ *                This program is free software; you can redistribute it 
+ *                and/or modify it under the terms of the GNU General
+ *                Public License as published by the Free Software
+ *                Foundation; either version 2 of the License, or (at
+ *                your option) any later version.
+ *
+ *                This program is distributed in the hope that it will
+ *                be useful, but WITHOUT ANY WARRANTY; without even the
+ *                implied warranty of MERCHANTABILITY or FITNESS FOR A
+ *                PARTICULAR PURPOSE.  See the GNU General Public
+ *                License for more details.
+ *
+ *                The GNU General Public License should be included with
+ *                this file.  If not, you can view it at
+ *                http://www.gnu.org/copyleft/gpl.html
+ *                or write to the Free Software Foundation, Inc., 59
+ *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Revisions   :
+ *    $Log: cgi.c,v $
+ *
+ **********************************************************************/
+\f
+
+#include "config.h"
+
+/*
+ * FIXME: Following includes copied from cgi.c - which are actually needed?
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif /* def _WIN32 */
+
+#include "project.h"
+#include "cgi.h"
+#include "cgiedit.h"
+#include "list.h"
+#include "encode.h"
+#include "ssplit.h"
+#include "jcc.h"
+#include "filters.h"
+#include "actions.h"
+#include "errlog.h"
+#include "miscutil.h"
+#include "showargs.h"
+#include "loadcfg.h"
+
+const char cgiedit_h_rcs[] = CGIEDIT_H_VERSION;
+
+
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_edit_actions_list
+ *
+ * Description :  CGI function that edits the actions list.
+ *
+ * Parameters  :
+ *           1 :  csp = Current client state (buffers, headers, etc...)
+ *           2 :  rsp = http_response data structure for output
+ *           3 :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  0
+ *
+ *********************************************************************/
+int cgi_edit_actions_list(struct client_state *csp, struct http_response *rsp,
+                                struct map *parameters)
+{
+   struct file_list *fl;
+   struct url_actions *actions;
+   char * actions_html;
+   char * next_actions_html;
+   char * section_template;
+   char * url_template;
+   char * sections;
+   char * urls;
+   struct map * exports = default_exports(csp, NULL);
+   struct map * section_exports;
+   struct map * url_exports;
+   int urlid;
+   char buf[50];
+   char * s;
+   int url_1_2;
+
+   if (((fl = csp->actions_list) == NULL) || ((actions = fl->f) == NULL))
+   {
+      /* FIXME: Oops, no file to edit */
+      free_map(exports);
+      return cgi_default(csp, rsp, parameters);
+   }
+
+   /* Should do all global exports above this point */
+
+   section_template = template_load(csp, "edit-actions-list-section");
+   url_template = template_load(csp, "edit-actions-list-url");
+
+   template_fill(&section_template, exports);
+   template_fill(&url_template, exports);
+
+   urlid = 0;
+   sections = strdup("");
+
+   ++urlid;
+   actions = actions->next;
+   if (actions != NULL)
+   {
+      actions_html = actions_to_html(actions->action);
+   }
+
+   while (actions != NULL)
+   {
+      section_exports = new_map();
+
+      snprintf(buf, 50, "%d", urlid);
+      map(section_exports, "sectionid", 1, buf, 1);
+
+      map(section_exports, "actions", 1, actions_html, 1);
+
+      /* Should do all section-specific exports above this point */
+
+      urls = strdup("");
+      url_1_2 = 2;
+
+      next_actions_html = NULL;
+      do
+      {
+         freez(next_actions_html);
+
+         url_exports = new_map();
+
+         snprintf(buf, 50, "%d", urlid);
+         map(url_exports, "urlid", 1, buf, 1);
+
+         snprintf(buf, 50, "%d", url_1_2);
+         map(url_exports, "url-1-2", 1, buf, 1);
+
+         s = html_encode(actions->url->spec);
+         map(url_exports, "url", 1, s, 1);
+
+         s = strdup(url_template);
+         template_fill(&s, section_exports);
+         template_fill(&s, url_exports);
+         urls = strsav(urls, s);
+         free_map(url_exports);
+
+         ++urlid;
+         url_1_2 = 3 - url_1_2;
+         actions = actions->next;
+         if (actions)
+         {
+            next_actions_html = actions_to_html(actions->action);
+         }
+      }
+      while (actions && (0 == strcmp(actions_html, next_actions_html)));
+
+      map(section_exports, "urls", 1, urls, 0);
+
+      /* Could also do section-specific exports here, but it wouldn't be as fast */
+
+      s = strdup(section_template);
+      template_fill(&s, section_exports);
+      sections = strsav(sections, s);
+      free_map(section_exports);
+
+      freez(actions_html);
+      actions_html = next_actions_html;
+   }
+
+   map(exports, "sections", 1, sections, 0);
+
+   /* Could also do global exports here, but it wouldn't be as fast */
+
+   rsp->body = template_load(csp, "edit-actions-list");
+   template_fill(&rsp->body, exports);
+   free_map(exports);
+
+   return(0);
+}
+
+
+/*********************************************************************
+ *
+ * Function    :  map_radio
+ *
+ * Description :  Map a set of radio button values.  E.g. if you have
+ *                3 radio buttons, declare them as:
+ *                  <option type="radio" name="xyz" @xyz-a@>
+ *                  <option type="radio" name="xyz" @xyz-b@>
+ *                  <option type="radio" name="xyz" @xyz-c@>
+ *                Then map one of the @xyz-?@ variables to "checked"
+ *                and all the others to empty by calling:
+ *                map_radio(exports, "xyz", "abc", sel)
+ *                Where 'sel' is 'a', 'b', or 'c'.
+ *
+ * Parameters  :
+ *           1 :  exports = Exports map to modify.
+ *           2 :  optionname = name for map
+ *           3 :  values = null-terminated list of values;
+ *           4 :  value = Selected value.
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  0 on success, nonzero on error.
+ *
+ *********************************************************************/
+static int map_radio(struct map * exports, const char * optionname, 
+                     const char * values, char value)
+{
+   int len;
+   char * buf;
+   char * p;
+   char c;
+   
+   assert(exports);
+   assert(optionname);
+   assert(values);
+
+   len = strlen(optionname);
+   buf = malloc(len + 3);
+   if (buf == NULL)
+   {
+      return 1;
+   }
+
+   strcpy(buf, optionname);
+   p = buf + len;
+   *p++ = '-';
+   p[1] = '\0';
+
+   while ((c = *values++) != '\0')
+   {
+      if (c != value)
+      {
+         *p = c;
+         if (map(exports, buf, 1, "", 1))
+         {
+            free(buf);
+            return 1;
+         }
+      }
+   }
+
+   *p = value;
+   if (map(exports, buf, 0, "checked", 1))
+   {
+      free(buf);
+      return 1;
+   }
+
+   return 0;
+}
+
+
+/*********************************************************************
+ *
+ * Function    :  actions_to_radio
+ *
+ * Description :  Converts a actionsfile entry FIXME
+ *
+ * Parameters  :
+ *          1  :  exports = FIXME
+ *          2  :  action  = FIXME
+ *
+ * Returns     :  0 on success, nonzero on error.
+ *
+ *********************************************************************/
+static int actions_to_radio(struct map * exports, struct action_spec *action)
+{
+   unsigned mask = action->mask;
+   unsigned add  = action->add;
+   int mapped_param;
+   int checked;
+
+   /* sanity - prevents "-feature +feature" */
+   mask |= add;
+
+
+#define DEFINE_ACTION_BOOL(name, bit)       \
+   if (!(mask & bit))                       \
+   {                                        \
+      map_radio(exports, name, "ynx", 'n'); \
+   }                                        \
+   else if (add & bit)                      \
+   {                                        \
+      map_radio(exports, name, "ynx", 'y'); \
+   }                                        \
+   else                                     \
+   {                                        \
+      map_radio(exports, name, "ynx", 'x'); \
+   }
+
+#define DEFINE_ACTION_STRING(name, bit, index)  \
+   DEFINE_ACTION_BOOL(name, bit);               \
+   mapped_param = 0;
+
+#define DEFINE_CGI_PARAM_RADIO(name, bit, index, value, is_default) \
+   if (add & bit)                                        \
+   {                                                     \
+      checked = !strcmp(action->string[index], value);   \
+   }                                                     \
+   else                                                  \
+   {                                                     \
+      checked = is_default;                              \
+   }                                                     \
+   mapped_param |= checked;                              \
+   map(exports, name "-param-" value, 1, (checked ? "checked" : ""), 1);
+
+#define DEFINE_CGI_PARAM_CUSTOM(name, bit, index, default_val)    \
+   map(exports, name "-param-custom", 1,                      \
+      ((!mapped_param) ? "checked" : ""), 1);                     \
+   map(exports, name "-param", 1,                             \
+      (((add & bit) && !mapped_param) ?                           \
+      action->string[index] : default_val), 1);
+
+#define DEFINE_CGI_PARAM_NO_RADIO(name, bit, index, default_val)  \
+   map(exports, name "-param", 1,                             \
+      ((add & bit) ? action->string[index] : default_val), 1);
+
+#define DEFINE_ACTION_MULTI(name, index)        \
+   if (action->multi_add[index]->first)         \
+   {                                            \
+      map_radio(exports, name, "ynx", 'y');     \
+   }                                            \
+   else if (action->multi_remove_all[index])    \
+   {                                            \
+      map_radio(exports, name, "ynx", 'n');     \
+   }                                            \
+   else if (action->multi_remove[index]->first) \
+   {                                            \
+      map_radio(exports, name, "ynx", 'y');     \
+   }                                            \
+   else                                         \
+   {                                            \
+      map_radio(exports, name, "ynx", 'x');     \
+   }
+
+#define DEFINE_ACTION_ALIAS 0 /* No aliases for output */
+
+#include "actionlist.h"
+
+#undef DEFINE_ACTION_MULTI
+#undef DEFINE_ACTION_STRING
+#undef DEFINE_ACTION_BOOL
+#undef DEFINE_ACTION_ALIAS
+#undef DEFINE_CGI_PARAM_CUSTOM
+#undef DEFINE_CGI_PARAM_RADIO
+#undef DEFINE_CGI_PARAM_NO_RADIO
+
+   return 0;
+}
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_edit_actions
+ *
+ * Description :  CGI function that edits the Actions list.
+ *
+ * Parameters  :
+ *           1 :  csp = Current client state (buffers, headers, etc...)
+ *           2 :  rsp = http_response data structure for output
+ *           3 :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  0
+ *
+ *********************************************************************/
+int cgi_edit_actions(struct client_state *csp, struct http_response *rsp,
+                           struct map *parameters)
+{
+   struct file_list *fl;
+   struct url_actions *actions;
+   struct map * exports = default_exports(csp, NULL);
+   int sectionid;
+   int i;
+   const char * s;
+   char c;
+
+   if (((fl = csp->actions_list) == NULL) || ((actions = fl->f) == NULL))
+   {
+      /* FIXME: Oops, No file to edit */
+      free_map(exports);
+      return cgi_default(csp, rsp, parameters);
+   }
+
+   s = lookup(parameters, "section");
+   if (!*s)
+   {
+      /* FIXME: Oops, No file to edit */
+      free_map(exports);
+      return cgi_default(csp, rsp, parameters);
+   }
+
+   sectionid = 0;
+   while ((c = *s++) != '\0')
+   {
+      /* Note:
+       * (((unsigned)(-1)) >> 1) == MAXINT.
+       * (MAXINT - 9) / 10 is the largest number that 
+       * can be safely multiplied by 10 then have 9 added.
+       */
+      if (c < '0' || c > '9' || sectionid > ((((unsigned)(-1)) >> 1) - 9) / 10)
+      {
+         /* FIXME: Oops, bad paramaters */
+         free_map(exports);
+         return cgi_default(csp, rsp, parameters);
+      }
+
+      sectionid *= 10;
+      sectionid += c - '0';
+   }
+
+   for (i = 0; actions != NULL && i < sectionid; i++)
+   {
+      actions = actions->next;
+   }
+
+   if (actions == NULL || i != sectionid || sectionid < 1)
+   {
+      free_map(exports);
+      return cgi_default(csp, rsp, parameters);
+   }
+
+   /* FIXME: need to fill in exports here */
+   actions_to_radio(exports, actions->action);
+
+   rsp->body = template_load(csp, "edit-actions");
+   template_fill(&rsp->body, exports);
+   free_map(exports);
+
+   return(0);
+}
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_edit_actions_submit
+ *
+ * Description :  CGI function that actually edits the Actions list.
+ *
+ * Parameters  :
+ *           1 :  csp = Current client state (buffers, headers, etc...)
+ *           2 :  rsp = http_response data structure for output
+ *           3 :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  0
+ *
+ *********************************************************************/
+int cgi_edit_actions_submit(struct client_state *csp, struct http_response *rsp,
+                           struct map *parameters)
+{
+   struct map * exports = default_exports(csp, NULL);
+
+   map(exports, "cgi-parameters", 1, dump_map(parameters), 0);
+
+   rsp->body = template_load(csp, "edit-actions-submit");
+   template_fill(&rsp->body, exports);
+   free_map(exports);
+
+   return(0);
+}
+
+
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
+
+
+/*
+  Local Variables:
+  tab-width: 3
+  end:
+*/
diff --git a/cgiedit.h b/cgiedit.h
new file mode 100644 (file)
index 0000000..038bdac
--- /dev/null
+++ b/cgiedit.h
@@ -0,0 +1,80 @@
+#ifndef CGIEDIT_H_INCLUDED
+#define CGIEDIT_H_INCLUDED
+#define CGIEDIT_H_VERSION "$Id: cgiedit.h,v 1.15 2001/09/16 15:02:35 jongfoster Exp $"
+/*********************************************************************
+ *
+ * File        :  $Source: /cvsroot/ijbswa/current/cgi.h,v $
+ *
+ * Purpose     :  CGI-based actionsfile editor.
+ *                
+ *                Functions declared include:
+ * 
+ *
+ * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
+ *                IJBSWA team.  http://ijbswa.sourceforge.net
+ *
+ *                Based on the Internet Junkbuster originally written
+ *                by and Copyright (C) 1997 Anonymous Coders and 
+ *                Junkbusters Corporation.  http://www.junkbusters.com
+ *
+ *                This program is free software; you can redistribute it 
+ *                and/or modify it under the terms of the GNU General
+ *                Public License as published by the Free Software
+ *                Foundation; either version 2 of the License, or (at
+ *                your option) any later version.
+ *
+ *                This program is distributed in the hope that it will
+ *                be useful, but WITHOUT ANY WARRANTY; without even the
+ *                implied warranty of MERCHANTABILITY or FITNESS FOR A
+ *                PARTICULAR PURPOSE.  See the GNU General Public
+ *                License for more details.
+ *
+ *                The GNU General Public License should be included with
+ *                this file.  If not, you can view it at
+ *                http://www.gnu.org/copyleft/gpl.html
+ *                or write to the Free Software Foundation, Inc., 59
+ *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Revisions   :
+ *    $Log: cgi.h,v $
+ *
+ **********************************************************************/
+\f
+
+#include "project.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * CGI functions
+ */
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+extern int cgi_edit_actions        (struct client_state *csp,
+                                    struct http_response *rsp,
+                                    struct map *parameters);
+extern int cgi_edit_actions_list   (struct client_state *csp,
+                                    struct http_response *rsp,
+                                    struct map *parameters);
+extern int cgi_edit_actions_submit (struct client_state *csp,
+                                    struct http_response *rsp,
+                                    struct map *parameters);
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
+
+
+/* Revision control strings from this header and associated .c file */
+extern const char cgiedit_rcs[];
+extern const char cgiedit_h_rcs[];
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* ndef CGI_H_INCLUDED */
+
+/*
+  Local Variables:
+  tab-width: 3
+  end:
+*/
index b80b199..8a56347 100644 (file)
@@ -1,4 +1,4 @@
-const char showargs_rcs[] = "$Id: showargs.c,v 1.23 2001/08/02 22:03:23 jongfoster Exp $";
+const char showargs_rcs[] = "$Id: showargs.c,v 1.24 2001/08/05 16:06:20 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/showargs.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/showargs.c,v $
@@ -34,6 +34,13 @@ const char showargs_rcs[] = "$Id: showargs.c,v 1.23 2001/08/02 22:03:23 jongfost
  *
  * Revisions   :
  *    $Log: showargs.c,v $
  *
  * Revisions   :
  *    $Log: showargs.c,v $
+ *    Revision 1.24  2001/08/05 16:06:20  jongfoster
+ *    Modifiying "struct map" so that there are now separate header and
+ *    "map_entry" structures.  This means that functions which modify a
+ *    map no longer need to return a pointer to the modified map.
+ *    Also, it no longer reverses the order of the entries (which may be
+ *    important with some advanced template substitutions).
+ *
  *    Revision 1.23  2001/08/02 22:03:23  jongfoster
  *    Fixing an unterminated character constant.
  *
  *    Revision 1.23  2001/08/02 22:03:23  jongfoster
  *    Fixing an unterminated character constant.
  *
@@ -307,6 +314,10 @@ char *show_rcs(void)
    SHOW_RCS(actions_rcs)
    SHOW_RCS(cgi_h_rcs)
    SHOW_RCS(cgi_rcs)
    SHOW_RCS(actions_rcs)
    SHOW_RCS(cgi_h_rcs)
    SHOW_RCS(cgi_rcs)
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+   SHOW_RCS(cgiedit_rcs)
+   SHOW_RCS(cgiedit_h_rcs)
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
 #ifdef __MINGW32__
    SHOW_RCS(cygwin_h_rcs)
 #endif
 #ifdef __MINGW32__
    SHOW_RCS(cygwin_h_rcs)
 #endif
diff --git a/templates/edit-actions b/templates/edit-actions
new file mode 100644 (file)
index 0000000..af1ced7
--- /dev/null
@@ -0,0 +1,397 @@
+#
+#
+# Available variables:
+#
+# deanimate-gifs-param-first
+# deanimate-gifs-param-last
+# hide-from-param-block
+# hide-from-param-custom
+# hide-from-param
+# hide-referer-param-forge
+# hide-referer-param-block
+# hide-referer-param-custom
+# hide-referer-param
+# hide-user-agent-param
+# image-blocker-param-logo
+# image-blocker-param-blank
+# image-blocker-param-custom
+# image-blocker-param-logo
+#
+#
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+
+<head>
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta http-equiv="Content-Script-Type" content="text/javascript">
+<meta name="robots" content="noindex,nofollow">
+
+<title>JunkBuster: Edit actions</title>
+
+<style type="text/css">
+body         { font-family: Helvetica, Helv, Arial, Sans-Serif, sans-serif }
+td.action    { font-weight: bold; font-style: italic; white-space: nowrap }
+th           { font-weight: bold; background-color: #999999 }
+# This is the key to the color names below:
+# bg=background, en="Enable", dis="Disable", noc="No Change"
+# 1=odd rows, 2=even rows, h=Table header
+tr.bg1       { background-color: #EEEEEE }
+td.en1       { background-color: #EEFFEE }
+td.dis1      { background-color: #FFEEEE }
+td.noc1      { background-color: #EEEEFF }
+tr.bg2       { background-color: #DDDDDD }
+td.en2       { background-color: #DDFFDD }
+td.dis2      { background-color: #FFDDDD }
+td.noc2      { background-color: #DDDDFF }
+th.enh       { background-color: #99FF99 }
+th.dish      { background-color: #FF9999 }
+th.noch      { background-color: #9999FF }
+</style>
+
+<script type="text/javascript">
+<!--
+function show_more(target, checkbox)
+{
+   if (checkbox.checked)
+   { target.style.display = ""; }
+   else
+   { target.style.display = "none"; }
+}
+
+function disable_unless(target, checkbox)
+{
+   target.disabled = !(checkbox.checked);
+}
+//-->
+</script>
+</head>
+
+<body>
+
+<p>&nbsp;</p>
+<form method="GET" action="http://i.j.b/edit-actions-submit" id="myform">
+  <table border="0" width="100%" cellspacing="0">
+    <tr align="left">
+      <th>Action</th>
+      <th>Description</th>
+      <th class="enh" align="center">Enable</th>
+      <th class="dish" align="center">Disable</th>
+      <th class="noch" align="center">No Change</th>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+add-header</td>
+      <td>Adds HTTP headers.</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="add-header" id="add_header_y" value="Y" @add-header-y@
+        onclick="show_more(add_header_opts,add_header_y)"></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="add-header" value="N" @add-header-n@
+        onclick="show_more(add_header_opts,add_header_y)"></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="add-header" value="X" @add-header-x@
+        onclick="show_more(add_header_opts,add_header_y)"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top" id="add_header_opts">
+      <td>&nbsp;</td>
+      <td colspan="4">To edit the settings for this option, <input
+        type="checkbox" name="add-header-edit" id="add_header_edit"
+        value="ON"><label for="add_header_edit">check here</label> and then
+        click &quot;Submit&quot;.</td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+block</td>
+      <td>Block the request</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="block" value="Y" @block-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="block" value="N" @block-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="block" value="X" @block-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+deanimate-gifs</td>
+      <td>Replace animated GIFs with their (first/last) frame.</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="deanimate-gifs" id="deanimate_gifs_y" value="Y" @deanimate-gifs-y@
+        onclick="show_more(deanimate_opts,deanimate_gifs_y)"></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="deanimate-gifs" value="N" @deanimate-gifs-n@
+        onclick="show_more(deanimate_opts,deanimate_gifs_y)"></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="deanimate-gifs" value="X" @deanimate-gifs-x@
+        onclick="show_more(deanimate_opts,deanimate_gifs_y)"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top" id="deanimate_opts">
+      <td>&nbsp;</td>
+      <td colspan="4">Use the <input type="radio" name="deanimate-gifs-mode"
+        value="first" id="deanimate_first" @deanimate-gifs-param-first@><label
+        for="deanimate_first">first frame</label>&nbsp;&nbsp; <input
+        type="radio" name="deanimate-gifs-mode" value="last" 
+        id="deanimate_last" @deanimate-gifs-param-last@><label
+        for="deanimate_last">last frame</label></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+fast-redirects</td>
+      <td>Bypass some tracking URLs.</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="fast-redirects" value="Y" @fast-redirects-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="fast-redirects" value="N" @fast-redirects-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="fast-redirects" value="X" @fast-redirects-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+filter</td>
+      <td>Filter the website through the re_filterfile</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="filter" value="Y" @filter-y@
+        ></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="filter" value="N" @filter-n@ 
+        ></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="filter" value="X" @filter-x@
+         ></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+hide-forwarded</td>
+      <td>Block any existing X-Forwarded-for header, and do not add a new one.</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="hide-forwarded" value="Y" @hide-forwarded-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="hide-forwarded" value="N" @hide-forwarded-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="hide-forwarded" value="X" @hide-forwarded-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+hide-from</td>
+      <td>Stop old web browsers from sending the user's e-mail address with
+        every request.</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="hide-from" id="hide_from_y" value="Y" @hide-from-y@
+        onclick="show_more(hide_from_opts,hide_from_y)"></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="hide-from" value="N" @hide-from-n@
+        onclick="show_more(hide_from_opts,hide_from_y)"></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="hide-from" value="X" @hide-from-x@
+        onclick="show_more(hide_from_opts,hide_from_y)"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top" id="hide_from_opts">
+      <td>&nbsp;</td>
+      <td colspan="4"><input type="radio" name="from-mode" value="block"
+        onclick="disable_unless(from_param, from_mode_set)"
+        @hide-from-param-block@ id="from_mode_block"><label
+        for="from_mode_block">Remove completely</label><br>
+        <input type="radio" name="from-mode" value="CUSTOM" 
+        onclick="disable_unless(from_param, from_mode_set)"
+        @hide-from-param-custom@ id="from_mode_set"><label
+        for="from_mode_set">Fake e-mail address:</label><br>
+        <input type="text" name="from-param" id="from_param" size="40"
+        value="@hide-from-param@"></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+hide-referer</td>
+      <td>Helps prevent tracking by not sending the URL of the previous web
+        page.&nbsp;</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="hide-referer" id="hide_referer_y" value="Y" @hide-referer-y@
+        onclick="show_more(hide_referer_opts,hide_referer_y)"></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="hide-referer" id="hide_referer_n" value="N" @hide-referer-n@
+        onclick="show_more(hide_referer_opts,hide_referer_y)"></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="hide-referer" id="hide_referer_x" value="X" @hide-referer-x@
+        onclick="show_more(hide_referer_opts,hide_referer_y)"
+        ></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top" id="hide_referer_opts">
+      <td>&nbsp;</td>
+      <td colspan="4"><input type="radio" name="hide-referer-mode" value="block"
+        onclick="disable_unless(hide_referer_param, referer_mode_set)"
+        @hide-referer-param-block@ id="referer_mode_block"><label
+        for="referer_mode_block">Remove completely</label> (breaks images
+        on some free web hosts).<br>
+        <input type="radio" name="hide-referer-mode" value="forge"
+        onclick="disable_unless(hide_referer_param, referer_mode_set)"
+        @hide-referer-param-forge@ id="referer_mode_forge"><label
+        for="referer_mode_forge">Fake as the root directory of the
+        site</label> (fools checks for in-site links.)<br>
+        <input type="radio" name="hide-referer-mode" value="CUSTOM"
+        onclick="disable_unless(hide_referer_param, referer_mode_set)"
+        @hide-referer-param-custom@ id="referer_mode_set"><label
+        for="referer_mode_set">Fake as this web address:</label><br>
+        <input type="text" name="hide-referer-param" 
+        id="hide_referer_param" size="40"
+        value="@hide-referer-param@"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+hide-user-agent</td>
+      <td>Pretend to be using a different web browser.&nbsp; (Breaks many web
+        sites).</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="hide-user-agent" id="hide_user_agent_y" value="Y" @hide-user-agent-y@
+        onclick="show_more(user_agent_opts,hide_user_agent_y)"></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="hide-user-agent" value="N" @hide-user-agent-n@
+        onclick="show_more(user_agent_opts,hide_user_agent_y)"></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="hide-user-agent" value="X" @hide-user-agent-x@
+        onclick="show_more(user_agent_opts,hide_user_agent_y)"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top" id="user_agent_opts">
+      <td>&nbsp;</td>
+      <td colspan="4">User Agent string to send:<br>
+        <input type="text" name="hide-user-agent-mode" size="40"
+        value="@hide-user-agent-param@"></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+image</td>
+      <td>Request is for an image (only useful in conjunction with the <i><b>+block</b></i>
+        and <i><b>+image-blocker</b></i> options).</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="image" value="Y" @image-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="image" value="N" @image-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="image" value="X" @image-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+image-blocker</td>
+      <td>Specifies how to block images.&nbsp; Disable to always send a HTML
+        &quot;blocked&quot; page.</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="image-blocker" id="image_blocker_y" value="Y" @image-blocker-y@
+        onclick="show_more(image_blocker_opts,image_blocker_y)"></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="image-blocker" value="N" @image-blocker-n@
+        onclick="show_more(image_blocker_opts,image_blocker_y)"></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="image-blocker" value="X" @image-blocker-x@
+        onclick="show_more(image_blocker_opts,image_blocker_y)"></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top" id="image_blocker_opts">
+      <td>&nbsp;</td>
+      <td colspan="4"><input type="radio" name="image-blocker-mode"
+        onclick="disable_unless(image_blocker_param, image_blocker_mode_set)"
+        value="logo" id="image_blocker_mode_logo" @image-blocker-param-logo@><label
+        for="image_blocker_mode_logo">Send Junkbuster logo</label><br>
+        <input type="radio" name="image-blocker-mode" value="blank"
+        onclick="disable_unless(image_blocker_param, image_blocker_mode_set)"
+        id="image_blocker_mode_blank" @image-blocker-param-blank@><label 
+        for="image_blocker_mode_blank">Send a 1x1 transparent GIF</label><br>
+        <input type="radio" name="image-blocker-mode" value="CUSTOM"
+        onclick="disable_unless(image_blocker_param, image_blocker_mode_set)"
+        id="image_blocker_mode_set" @image-blocker-param-custom@><label
+        for="image_blocker_mode_set">Redirect
+        the browser to this image URL:</label><br>
+        <input type="text" name="image-blocker-param" id="image_blocker_param"
+        size="40" value="@image-blocker-param@"></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+no-cookies-read</td>
+      <td>Prevent the website from reading cookies</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="no-cookies-read" value="Y" @no-cookies-read-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="no-cookies-read" value="N" @no-cookies-read-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="no-cookies-read" value="X" @no-cookies-read-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+no-cookies-set</td>
+      <td>Prevent the website from setting cookies</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="no-cookies-set" value="Y" @no-cookies-set-y@
+        ></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="no-cookies-set" value="N" @no-cookies-set-n@
+        ></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="no-cookies-set" value="X" @no-cookies-set-x@
+        ></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+no-popups</td>
+      <td>Filter the website through a built-in filter to disable JavaScript
+        pop-up windows.</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="no-popups" value="Y" @no-popups-y@
+        ></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="no-popups" value="N" @no-popups-n@
+        ></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="no-popups" value="X" @no-popups-x@
+        ></td>
+    </tr>
+    <tr class="bg1" align="left" valign="top">
+      <td class="action">+vanilla-wafer</td>
+      <td>If you use a jarfile, automatically adds a special wafer.</td>
+      <td class="en1" align="center" valign="middle"><input type="radio"
+        name="vanilla-wafer" value="Y" @vanilla-wafer-y@
+        ></td>
+      <td class="dis1" align="center" valign="middle"><input type="radio"
+        name="vanilla-wafer" value="N" @vanilla-wafer-n@
+        ></td>
+      <td class="noc1" align="center" valign="middle"><input type="radio"
+        name="vanilla-wafer" value="X" @vanilla-wafer-x@
+        ></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top">
+      <td class="action">+wafer</td>
+      <td>Adds user-specified cookies.</td>
+      <td class="en2" align="center" valign="middle"><input type="radio"
+        name="wafer" id="wafer_y" value="Y" @wafer-y@
+        onclick="show_more(wafer_opts,wafer_y)"></td>
+      <td class="dis2" align="center" valign="middle"><input type="radio"
+        name="wafer" id="wafer_n" value="N" @wafer-n@
+        onclick="show_more(wafer_opts,wafer_y)"></td>
+      <td class="noc2" align="center" valign="middle"><input type="radio"
+        name="wafer" id="wafer_x" value="X" @wafer-x@
+        onclick="show_more(wafer_opts,wafer_y)"></td>
+    </tr>
+    <tr class="bg2" align="left" valign="top" id="wafer_opts">
+      <td>&nbsp;</td>
+      <td colspan="4">To edit the settings for this option, <input
+        type="checkbox" name="wafer-edit" id="wafer_edit" value="ON"><label
+        for="wafer_edit">check here</label> and then click
+        &quot;Submit&quot;.</td>
+    </tr>
+  </table>
+<script type="text/javascript">
+<!--
+disable_unless(myform.from_param,          myform.from_mode_set);
+disable_unless(myform.hide_referer_param,  myform.referer_mode_set);
+disable_unless(myform.image_blocker_param, myform.image_blocker_mode_set);
+show_more(add_header_opts,    myform.add_header_y);
+show_more(deanimate_opts,     myform.deanimate_gifs_y);
+show_more(hide_from_opts,     myform.hide_from_y);
+show_more(hide_referer_opts,  myform.hide_referer_y);
+show_more(user_agent_opts,    myform.hide_user_agent_y);
+show_more(image_blocker_opts, myform.image_blocker_y);
+show_more(wafer_opts,         myform.wafer_y);
+//-->
+</script>
+  <p><input type="submit" value="Submit" name="Submit"></p>
+</form>
+<p>&nbsp;</p>
+
+</body>
+
+</html>
diff --git a/templates/edit-actions-list b/templates/edit-actions-list
new file mode 100644 (file)
index 0000000..b975947
--- /dev/null
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+
+<head>
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta http-equiv="Content-Script-Type" content="text/javascript">
+<meta name="robots" content="noindex,nofollow">
+
+<title>JunkBuster: Edit actions list</title>
+
+<style type="text/css">
+body         { font-family: Helvetica, Helv, Arial, Sans-Serif, sans-serif }
+tr.actions   { background-color: #EEFFEE }
+tr.url1      { background-color: #D0D0FF }
+tr.url2      { background-color: #EEEEFF }
+tr.rule      { background-color: #C0C0C0; height: 3 }
+tr.adv       { background-color: #FFFFD0 }
+td.header    { font-weight: bold }
+td.url       { font-weight: bold }
+td.action    { font-weight: bold; font-style: italic }
+</style>
+
+<script type="text/javascript">
+<!--
+function edit_pattern(b,p,ct)
+{
+   ct=unescape(ct);
+       nt=window.prompt("Edit this URL pattern:",ct);
+       if ((nt!=null)&&(nt!=ct)&&(nt!=""))
+       { window.location.href="http://i.j.b/change-pattern?section="+b+"&pattern="+p+"&newval="+escape(nt)+"#s"+b+"url"+p; }
+}
+
+function add_pattern(b)
+{
+       nt=window.prompt("Enter URL pattern to add:", "");
+       if ((nt!=null)&&(nt!=""))
+       { window.location.href="http://i.j.b/change-pattern?section="+b+"&pattern=new&newval="+escape(nt)+"#s"+b+"urls"; }
+}
+
+function edit_actions(b)
+{
+       window.location.href="http://i.j.b/edit-actions?section="+b;
+}
+
+function not_yet()
+{
+       window.alert("The feature you are trying to use has not been implemented yet.");
+}
+//-->
+</script>
+</head>
+
+<body>
+
+@sections@
+
+</body>
+
+</html>
diff --git a/templates/edit-actions-list-section b/templates/edit-actions-list-section
new file mode 100644 (file)
index 0000000..d624902
--- /dev/null
@@ -0,0 +1,51 @@
+<form action="http://i.j.b/">
+  <table border="0" width="100%" cellspacing="0">
+    <tr class="actions" valign="top">
+      <td class="header" align="right"><a name="s@sectionid@"></a>Actions:</td>
+      <td align="center"><input type="button" onclick="edit_actions(@sectionid@)"
+        value="Edit"></td>
+      <td class="action" align="left">@actions@</td>
+    </tr>
+    <tr class="rule">
+      <td colspan="3"><img src="http://i.j.b/send-banner?type=trans" width="2"
+        height="1" alt="----"></td>
+    </tr>
+    <tr class="url1" valign="top">
+      <td class="header" align="right"><a name="s@sectionid@urls">URLs:</a></td>
+      <td align="center"><input type="button" onclick="add_pattern(@sectionid@)"
+        value="Add"></td>
+      <td align="left">&nbsp;</td>
+    </tr>
+
+@urls@
+
+    <tr class="rule">
+      <td colspan="3"><img src="http://i.j.b/send-banner?type=trans" width="2"
+        height="1" alt="----"></td>
+    </tr>
+    <tr class="adv" valign="top">
+      <td class="header" align="right"><b>Advanced:</b></td>
+      <td colspan="2">
+        <table border="0" cellspacing="0" cellpadding="4">
+          <tr valign="middle" align="center">
+            <td>&nbsp;&nbsp;&nbsp;<input type="button" onclick="not_yet()"
+              value="Move section up">&nbsp;&nbsp;&nbsp;</td>
+            <td>&nbsp;&nbsp;&nbsp;<input type="button" onclick="not_yet()"
+              value="Split section">&nbsp;&nbsp;&nbsp;</td>
+          </tr>
+          <tr valign="middle" align="center">
+            <td>&nbsp;&nbsp;&nbsp;<input type="button" onclick="not_yet()"
+              value="Move section down">&nbsp;&nbsp;&nbsp;</td>
+            <td>&nbsp;&nbsp;&nbsp;<input type="button" onclick="not_yet()"
+              value="Merge with next">&nbsp;&nbsp;&nbsp;</td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+</form>
+<p>&nbsp;</p>
+<p>&nbsp;</p>
+
+
+
diff --git a/templates/edit-actions-list-url b/templates/edit-actions-list-url
new file mode 100644 (file)
index 0000000..57b4bdb
--- /dev/null
@@ -0,0 +1,8 @@
+    <tr class="url@url-1-2@" valign="top">
+      <td align="left">&nbsp;</td>
+      <td align="center"><a name="s@sectionid@url@urlid@"></a><input type="button"
+        onclick="edit_pattern(@sectionid@,@urlid@,'@url@');"
+        value="Edit"></td>
+      <td class="url" align="left">@url@</td>
+    </tr>
+
diff --git a/templates/edit-actions-submit b/templates/edit-actions-submit
new file mode 100644 (file)
index 0000000..b9635ba
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+
+<head>
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta http-equiv="Content-Script-Type" content="text/javascript">
+<meta name="robots" content="noindex,nofollow">
+
+<title>JunkBuster: Edit actions</title>
+
+<style type="text/css">
+body         { font-family: Helvetica, Helv, Arial, Sans-Serif, sans-serif }
+</style>
+
+</head>
+
+<body>
+
+<p>@cgi-parameters@</p>
+
+</body>
+
+</html>