first import of project's documentation for the webserver.
[privoxy.git] / doc / webserver / redirect.php
1 M<?php
2
3 error_reporting(E_ALL);
4
5 // File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
6 //
7 // Purpose     :  redirects requests to a specific paragraph in the online docs
8 //                This file belongs into
9 //                ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
10 //                
11 // $Id: Makefile.in,v 1.12 2001/06/12 17:15:56 swa Exp $
12 //
13 // Written by and Copyright (C) 2001 the SourceForge
14 // IJBSWA team.  http://ijbswa.sourceforge.net
15 //
16 // Based on the Internet Junkbuster originally written
17 // by and Copyright (C) 1997 Anonymous Coders and 
18 // Junkbusters Corporation.  http://www.junkbusters.com
19
20
21 // Parse the v= and to= paramaters
22 function parse_parameters()
23 {
24    global $v, $to;
25    global $version_major, $version_minor, $version_point;
26
27    $version_major = 0;
28    $version_minor = 0;
29    $version_point = 0;
30
31    if (isset($v))
32    {
33       // Version specified
34
35       $v = trim($v);
36
37       // Check if it's valid.
38       // Valid versions have the form "n.n.n", where n=digit(s).
39       if ( (strspn($v,"0123456789.") == strlen($v)) )
40       {
41          // Probably valid.  Copy into globals.
42          $version_pieces = explode (".", $v, 4);
43          if (isset($version_pieces[0]))
44          {
45             $version_major = 0 + $version_pieces[0];
46          }
47          if (isset($version_pieces[1]))
48          {
49             $version_minor = 0 + $version_pieces[1];
50          }
51          if (isset($version_pieces[2]))
52          {
53             $version_point = 0 + $version_pieces[2];
54          }
55       }
56    }
57
58    if (isset($to))
59    {
60       // Trim whitespace and convert to lowercase.
61       $to = strtolower(trim($to));
62
63       // Restrict the characters in the string by removing everything
64       // from the first disallowed character onwards.
65       //
66       // Allowed characters are 0-9, a-z, ".", "_", "-".
67       //
68       $to = substr($to, 0, strspn($to, "0123456789abcdefghijklmnopqrstuvwxyz._-"));
69    }
70    else
71    {
72       $to = "";
73    }
74 }
75
76 parse_parameters();
77
78 // For debugging:
79 // print "Version {$version_major}.{$version_minor}.{$version_point}<br>";
80 // print "Target \"{$to}\"<br>";
81
82
83 // Please do NOT delete any of these redirects.  Even if you take them
84 // out of JunkBuster, they may be in use by older releases.
85
86 // Note 2: Should *not* include #target part in these URLs.
87 // (It works with MS IE, but is not valid HTTP.)
88
89 switch($to)
90 {
91    case "faq":
92       // Used by 2.9.0+
93       header ("Location: http://www.junkbusters.com/ht/en/ijb2faq.html");
94       exit;
95    case "option":
96       // Used by 2.9.0+
97       // Config file options
98       // called as redirect.php?v=X.X.X&to=option#optionname
99       header ("Location: http://www.junkbusters.com/ht/en/ijb2man.html");
100       exit;
101    case "win":
102       // Used by 2.9.0+ on WIN32
103       header ("Location: http://www.junkbusters.com/ht/en/ijbwin.html");
104       exit;
105 //   case "home":
106 //      // Currently hard-wired into the code.
107 //      header ("Location: http://ijbswa.sourceforge.net/");
108 //      exit;
109 //   case "gpl":
110 //      // Currently hard-wired into the code.
111 //      header ("Location: http://www.fsf.org/copyleft/gpl.html");
112 //      exit;
113    default:
114       header ("Location: http://ijbswa.sourceforge.net/");
115       exit;
116 }
117
118 exit;
119 ?>
120
121 // This program is free software; you can redistribute it 
122 // and/or modify it under the terms of the GNU General
123 // Public License as published by the Free Software
124 // Foundation; either version 2 of the License, or (at
125 // your option) any later version.
126 //
127 // This program is distributed in the hope that it will
128 // be useful, but WITHOUT ANY WARRANTY; without even the
129 // implied warranty of MERCHANTABILITY or FITNESS FOR A
130 // PARTICULAR PURPOSE.  See the GNU General Public
131 // License for more details.
132 //
133 // The GNU General Public License should be included with
134 // this file.  If not, you can view it at
135 // http://www.gnu.org/copyleft/gpl.html
136 // or write to the Free Software Foundation, Inc., 59
137 // Temple Place - Suite 330, Boston, MA  02111-1307, USA.
138 //
139 //
140 // $Log: Makefile.in,v $
141 //