deb79a341fe1939895e98d85a27b5981bb58fd41
[privoxy.git] / doc / webserver / actions / step3.php
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3  <!--
4
5   File :  $Source: /cvsroot/ijbswa/current/doc/webserver/actions/step3.php,v $
6
7   Purpose  :  Submit form for actions file feedback (step 1)
8               This file belongs in
9               ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
10
11   $Id: step3.php,v 1.5 2002/04/02 07:22:43 oes Exp $
12
13   $Log: step3.php,v $
14   Revision 1.5  2002/04/02 07:22:43  oes
15   Cosmetics
16
17   Revision 1.4  2002/04/01 19:13:47  oes
18   Extended, fixed bugs, beefed up design, made IE-safe
19
20   Revision 1.1  2002/03/30 03:20:30  oes
21   Added Feedback mechanism for actions file
22
23
24   Written by and Copyright (C) 2002 the SourceForge
25   Privoxy team. http://www.privoxy.org/
26
27   This program is free software; you can redistribute it
28   and/or modify it under the terms of the GNU General
29   Public License as published by the Free Software
30   Foundation; either version 2 of the License, or (at
31   your option) any later version.
32
33   This program is distributed in the hope that it will
34   be useful, but WITHOUT ANY WARRANTY; without even the
35   implied warranty of MERCHANTABILITY or FITNESS FOR A
36   PARTICULAR PURPOSE.  See the GNU General Public
37   License for more details.
38
39   The GNU General Public License should be included with
40   this file.  If not, you can view it at
41   http://www.gnu.org/copyleft/gpl.html
42   or write to the Free Software Foundation, Inc., 59
43   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
44
45  -->
46
47  <head>
48   <meta http-equiv="Content-Style-Type" content="text/css">
49   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
50   <link rel="stylesheet" type="text/css" href="../p_feedback.css">
51
52
53 <?php
54
55 /* 
56  * Config:
57  */
58 $logfile = "results/actions-feedback.txt";
59
60
61 /* 
62  * Debug:
63  */
64 //phpinfo();
65 //error_reporting(E_ALL);
66 error_reporting(E_NONE);
67
68 /*
69  * Function: error_abort
70  * Purpose:  Return an error page with $title and $message
71  */
72 function error_abort($title, $message)
73 {
74    if ($title == "invalid") /* shortcut */
75    {
76       $title = "Invalid Feedback Submission";
77    }
78
79    echo ("  <title>Privoxy: $title</title>
80            </head>
81            <body>
82             <div class=\"title\">
83              <h1>
84               <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
85               </h1>
86              </div>
87             <center>
88              <div class=\"errorbox\">
89               $message
90              </div>
91             </center>
92             <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
93            </body>
94           </html>\n");
95    exit; 
96 }
97
98
99 /* 
100  * Cannot start with step 3:
101  */
102 if (!isset($referrer_url))
103 {
104    error_abort("invalid", "When submitting your feedback please start with <a href=\"index.php\">step 1</a>.");
105 }
106
107
108 /* 
109  * Cannot work on unknown problem:
110  */
111 if (!isset($problem))
112 {
113    error_abort("invalid", "You need to select the nature of the problem in <a href=\"index.php\">step 1</a>.");
114 }
115
116
117 /* 
118  * Don't accept unconfirmed URLs
119  */
120 if (!isset($url_confirmed))
121 {
122    error_abort("invalid", "When submitting URLs that this script can't retrieve, you need to check \"Yes, I'm sure\"
123                 <a href=\"javascript:history.back();\">step 2</a>.");
124 }
125
126
127 /*
128  * Handle optional text fields:
129  */
130 if (!isset($name) || ($name == ""))
131 {
132    $name = "anonymous";
133 }
134
135
136 /* 
137  * Open the logfile or fail:
138  */
139 $fp = fopen($logfile, "a");
140
141 if(!$fp)
142 {
143    echo ("  <title>Internal Script Error</title>
144            </head>
145            <body>
146             <div class=\"title\">
147               <h1><a href=\"http://www.privoxy.org/\">Privoxy</a>: Internal Script Error</h1>
148             </div>
149             <center>
150              <div class=\"errorbox\">
151               <p>
152                This script was unable to open its logfile.
153               </p>
154               <p>
155                Please <a href=\"mailto:info@privoxy.org?SUBJECT=Feedback-Script-Broken\">mail its owner</a>!
156               </p>
157              </div>
158             </center>
159            </body>
160           </html>");
161    exit; 
162 }
163
164
165 /*
166  * Write Head (type, severity, user, client-ip)
167  * and remarks field:
168  */
169 fwrite($fp, "\n#FEEDBACK TYPE $problem SEVERITY $severity FROM $name ON $REMOTE_ADDR VERIFIED $url_verified TIME " . date("r") ."\n");
170 if (isset($remarks))
171 {
172    $lines = explode("\n", $remarks);
173    foreach ($lines as $line)
174    {
175       fwrite($fp, "#REMARKS: $line\n");
176    }
177 }
178
179
180 /*
181  * Depending on the type of problem reported,
182  * we need to write additional data:
183  */
184 switch ($problem)
185 {
186    /*
187     * Banner not blocked:
188     */
189    case "P1":
190       fwrite($fp, "#BLOCK-REFERRER: $referrer_url\n");
191       if (isset($num_images))
192       {
193          for($i=0; $i < $num_images; $i++)
194          {
195              if (isset($block_image[$i]))
196              {
197                 fwrite($fp, "#BLOCK-URL: $image_url[$i]\n");
198              }
199          }
200       }
201       if (isset($manual_image_url) && ($manual_image_url != ""))
202       {
203          fwrite($fp, "#BLOCK-URL: $manual_image_url\n");
204       }
205       break;
206
207    /*
208     * Innocent image blocked:
209     */
210    case "P2":
211       fwrite($fp, "#UNBLOCK-REFERRER: $referrer_url\n");
212       if (isset($image_url) && ($image_url != ""))
213       {
214          fwrite($fp, "#UNBLOCK-URL: $image_url\n");
215       }
216       break;
217
218    /*
219     * All other problems:
220     */
221    default:
222       fwrite($fp, "#PROBLEM-URL: $referrer_url\n");
223       break;
224 }        
225             
226 fclose($fp);
227
228 ?>
229
230   <title>Privoxy Action List Feedback - Result</title>
231  </head>
232
233  <body>
234   <div class="title">
235    <h1>
236     <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Result
237    </h1>
238   </div>
239
240   <div class="box">
241    <p>
242     <b>Thank you very much for taking the time to submit your feedback!</b>
243    </p>
244
245    <p>
246     It will be reviewed by the developers and used to improve the
247     distribution actions file.
248    </p>
249    
250    <p align=center>
251     <input type="submit" value="Close this window" onclick="window.close();">
252    </p>
253
254   </div>
255
256   <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>
257
258  </body>
259 </html>