Rebuild HTML docs for 3.0.24
[privoxy.git] / doc / webserver / redirect.php
1 <?php
2
3 error_reporting(E_ALL);
4
5 // redirect.php
6 //
7 // Copyright (C) 2001 The SourceForge ijbswa team.
8 // May be used under the GNU GPL, version 2 or later.
9
10
11 // Parse the v= and to= paramaters
12 function parse_parameters()
13 {
14    global $v, $to;
15    global $version_major, $version_minor, $version_point;
16
17    $version_major = 0;
18    $version_minor = 0;
19    $version_point = 0;
20
21    if (isset($v))
22    {
23       // Version specified
24
25       $v = trim($v);
26
27       // Check if it's valid.
28       // Valid versions have the form "n.n.n", where n=digit(s).
29       if ( (strspn($v,"0123456789.") == strlen($v)) )
30       {
31          // Probably valid.  Copy into globals.
32          $version_pieces = explode (".", $v, 4);
33          if (isset($version_pieces[0]))
34          {
35             $version_major = 0 + $version_pieces[0];
36          }
37          if (isset($version_pieces[1]))
38          {
39             $version_minor = 0 + $version_pieces[1];
40          }
41          if (isset($version_pieces[2]))
42          {
43             $version_point = 0 + $version_pieces[2];
44          }
45       }
46    }
47
48    if (isset($to))
49    {
50       // Trim whitespace and convert to lowercase.
51       $to = strtolower(trim($to));
52
53       // Restrict the characters in the string by removing everything
54       // from the first disallowed character onwards.
55       //
56       // Allowed characters are 0-9, a-z, ".", "_", "-".
57       //
58       $to = substr($to, 0, strspn($to, "0123456789abcdefghijklmnopqrstuvwxyz._-"));
59    }
60    else
61    {
62       $to = "";
63    }
64 }
65
66 parse_parameters();
67
68 // For debugging:
69 // print "Version {$version_major}.{$version_minor}.{$version_point}<br>";
70 // print "Target \"{$to}\"<br>";
71
72
73 // Please do NOT delete any of these redirects.  Even if you take them
74 // out of Privoxy, they may be in use by older releases.
75
76 // Note 2: Should *not* include #target part in these URLs.
77 // (It works with MS IE, but is not valid HTTP.)
78 //http://ijbswa.sourceforge.net/user-manual/configuration.html
79 switch($to)
80 {
81    case "faq":
82       // Used by 2.9.0+
83 //      header ("Location: http://www.junkbusters.com/ht/en/ijb2faq.html");
84         header ("Location: http://www.privoxy.org/faq/");
85     exit;
86    case "option":
87       // Used by 2.9.0+
88       // Config file options
89       // called as redirect.php?v=X.X.X&to=option#optionname
90 //      header ("Location: http://www.junkbusters.com/ht/en/ijb2man.html");
91       header ("Location: http://www.privoxy.org/user-manual/configuration.html");
92       exit;
93    case "win":
94       // Used by 2.9.0+ on WIN32
95 //      header ("Location: http://www.junkbusters.com/ht/en/ijbwin.html");
96       header ("Location: http://www.privoxy.org/user-manual/configuration.html");
97       exit;
98 //   case "home":
99 //      // Currently hard-wired into the code.
100 //      header ("Location: http://ijbswa.sourceforge.net/");
101 //      exit;
102 //   case "gpl":
103 //      // Currently hard-wired into the code.
104 //      header ("Location: http://www.fsf.org/copyleft/gpl.html");
105 //      exit;
106    default:
107       header ("Location: http://www.privoxy.org/");
108       exit;
109 }
110
111 exit;
112 ?>