Adding support for a 404 error when an invalid CGI page is requested.
authorjongfoster <jongfoster@users.sourceforge.net>
Sun, 14 Oct 2001 22:00:32 +0000 (22:00 +0000)
committerjongfoster <jongfoster@users.sourceforge.net>
Sun, 14 Oct 2001 22:00:32 +0000 (22:00 +0000)
cgisimple.c
cgisimple.h
templates/cgi-error-404 [new file with mode: 0644]

index 005a83f..fcf71e7 100644 (file)
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.4 2001/10/02 15:31:12 oes Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.5 2001/10/07 15:30:41 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.4 2001/10/02 15:31:12 oes Exp
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
+ *    Revision 1.5  2001/10/07 15:30:41  oes
+ *    Removed FEATURE_DENY_GZIP
+ *
  *    Revision 1.4  2001/10/02 15:31:12  oes
  *    Introduced show-request cgi
  *
  *    Revision 1.4  2001/10/02 15:31:12  oes
  *    Introduced show-request cgi
  *
@@ -129,6 +132,37 @@ int cgi_default(struct client_state *csp, struct http_response *rsp,
 }
 
 
 }
 
 
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_error_404
+ *
+ * Description :  CGI function that is called if an unknow action was
+ *                given.
+ *               
+ * Parameters  :
+ *           1 :  csp = Current client state (buffers, headers, etc...)
+ *           2 :  rsp = http_response data structure for output
+ *           3 :  parameters = map of cgi parameters
+ *
+ * Returns     :  0
+ *
+ *********************************************************************/
+int cgi_error_404(struct client_state *csp,
+                  struct http_response *rsp,
+                  struct map *parameters)
+{
+   struct map *exports = default_exports(csp, NULL);
+
+   rsp->status = strdup("404 JunkBuster configuration page not found");
+   rsp->body = template_load(csp, "cgi-error-404");
+   template_fill(&rsp->body, exports);
+   free_map(exports);
+   return 0;
+}
+
+
 /*********************************************************************
  *
  * Function    :  cgi_show_request
 /*********************************************************************
  *
  * Function    :  cgi_show_request
index 37f9b20..6be066d 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef CGISIMPLE_H_INCLUDED
 #define CGISIMPLE_H_INCLUDED
 #ifndef CGISIMPLE_H_INCLUDED
 #define CGISIMPLE_H_INCLUDED
-#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.1 2001/09/16 17:08:54 jongfoster Exp $"
+#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.2 2001/10/02 15:31:20 oes Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.h,v $
@@ -38,6 +38,9 @@
  *
  * Revisions   :
  *    $Log: cgisimple.h,v $
  *
  * Revisions   :
  *    $Log: cgisimple.h,v $
+ *    Revision 1.2  2001/10/02 15:31:20  oes
+ *    Introduced show-request cgi
+ *
  *    Revision 1.1  2001/09/16 17:08:54  jongfoster
  *    Moving simple CGI functions from cgi.c to new file cgisimple.c
  *
  *    Revision 1.1  2001/09/16 17:08:54  jongfoster
  *    Moving simple CGI functions from cgi.c to new file cgisimple.c
  *
@@ -57,6 +60,9 @@ extern "C" {
 extern int cgi_default             (struct client_state *csp,
                                     struct http_response *rsp,
                                     struct map *parameters);
 extern int cgi_default             (struct client_state *csp,
                                     struct http_response *rsp,
                                     struct map *parameters);
+extern int cgi_error_404           (struct client_state *csp,
+                                    struct http_response *rsp,
+                                    struct map *parameters);
 extern int cgi_robots_txt          (struct client_state *csp,
                                     struct http_response *rsp,
                                     struct map *parameters);
 extern int cgi_robots_txt          (struct client_state *csp,
                                     struct http_response *rsp,
                                     struct map *parameters);
diff --git a/templates/cgi-error-404 b/templates/cgi-error-404
new file mode 100644 (file)
index 0000000..d7d7ed6
--- /dev/null
@@ -0,0 +1,138 @@
+##########################################################
+#
+# No-Such-Domain Error Output template for junkbuster 2.9.x.
+#
+#
+# USING HTML TEMPLATES:
+# ---------------------
+#
+# Template files are written win plain HTML, with a few
+# additions:
+# 
+# - Lines that start with a '#' character like this one
+#   are ignored
+#
+# - Each item in the below list of exported symbols will
+#   be replaced by dynamically generated text, if they
+#   are enclosed in '@'-characters. E.g. The string @version@
+#   will be replaced by the version number of Junkbuster.
+#
+# - One special application of this is to make whole blocks
+#   of the HTML template disappear if the condition <name>
+#   is not given. Simply enclose the block between the two
+#   strings @if-<name>start and if-<name>-end@. The strings
+#   should be placed in HTML comments (<!-- -->), so the
+#   html structure won't be messed when the magic happens.
+#   
+# USABLE SYMBOLS IN THIS TEMPLATE:
+# --------------------------------
+#
+#  my-ip-addr:
+#    The IP-address that the client used to reach this proxy
+#  my-hostname:
+#    The hostname associated with my-ip-addr
+#  admin-address:
+#    The email address of the pxoxy's administrator, as configured
+#    in the config file
+#  default-cgi:
+#    The URL for the "main menu" builtin CGI of this proxy
+#  menu:
+#    List of <li> elements linking to the other available CGIs
+#  version:
+#    The version number of the proxy software
+#  code-status:
+#    The development status of the proxy software: "alpha", "beta",
+#    or "stable".
+#  homepage:
+#    The URL of the SourceForge ijbswa project, who maintains this
+#    software.
+#
+# CONDITIONAL SYMBOLS FOR THIS TEMPLATE AND THEIR DEPANDANT SYMBOLS:
+# ------------------------------------------------------------------
+#
+#  unstable:
+#    this is an alpha or beta release of the proxy software
+#  have-proxy-info:
+#    A URL for online documentation about this proxy has been
+#    specified and is available through the "proxy-info-url"
+#    symbol
+#
+<html>
+
+<head>
+  <title>404 - JunkBuster Configuration Page not found</title>
+  <style type="text/css">
+    BODY, P, H1, H2, UL, OL, LI { font-family: Helvetica, Helv, Arial, Sans-Serif, sans-serif }
+  </style>
+</head>
+
+<body bgcolor="#ffffff">
+
+  <table cellpadding=20 cellspacing=10 border=0 width=100%>
+    <tr>
+      <td bgcolor=#ff0000>
+        <p><font size=+5 color=#ffffff><b>404</b></font></p>
+      </td>
+      <td bgcolor=#dddddd width=100%>
+        <p><font size=+2><b>This is the Internet J</b></font><font size=+1><b>UNK<i></font><font color="red">BUSTER</font></i></b>
+          <font size=+2><b>@version@ on @my-hostname@ (@my-ip-address@), port @my-port@</b></font></p>
+      </td>
+    </tr>
+
+<!-- @if-unstable-start -->
+# This will only appear if CODE_STATUS is "alpha" or "beta". See configure.in
+    <tr>
+      <td bgcolor=#ffdddd colspan=2>
+        <p><b>Please note that this <font color=red>@code-status@</font> release
+          of the proxy software is not intended for production systems!
+          <br>Use at your own risk. See the <a href="http://www.gnu.org/copyleft/gpl.html">license</a> for details.</b>
+        </p>
+
+        <p>Feel free to <a href=mailto:ijbswa-developers@lists.sourceforge.net>mail the developers</a>
+          with any problems you encounter.
+        </p>
+      </td>
+    </tr>
+<!-- if-unstable-end@ -->
+
+    <tr>
+      <td bgcolor=#eeeeee colspan=2>
+        <h2>JunkBuster Configuration page not found</h2>
+          <blockquote>
+            <p>You typed in what looks like a URL used to configure
+               JunkBuster, but it cannot be recognised.  Maybe it's
+               for a different JunkBuster version, or you typed it
+               in wrong?  Or maybe the JunkBuster administrator
+               has decided to disable the feature.</p>
+            <p>If you got here by clicking a link in the
+               configuration interface, please file a bug report!</p>
+            <p>You can use the menu below to select from the available
+               configuration options</p>
+          </blockquote>
+      </td>
+    </tr>
+
+    <tr>
+      <td bgcolor=#dddddd colspan=2>
+        <h2>More Junkbuster:</h2>
+        <ul>@menu@</ul>
+      </td>
+    </tr>
+
+    <tr>
+      <td bgcolor=#dddddd colspan=2>
+        <p>If you have any questions about this service,
+
+<!-- @if-have-proxy-info-start -->
+          consult the <a href="@proxy-info-url@">online documentation</a> or
+<!-- if-have-proxy-info-end@ -->
+
+          <a href=mailto:@admin-address@>send mail to <code>@admin-address@</code></a>
+          who will be glad to help you.
+        </p>
+      </td>
+    </tr>
+  </table>
+
+</body>
+</html>