Move all doc build stuff to doc/source/GNUmakefile, leaving a 'make dok'
[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.15 2002/04/09 15:08:10 oes Exp $
12
13   $Log: step3.php,v $
14   Revision 1.15  2002/04/09 15:08:10  oes
15   Restoring lost text change
16
17   Revision 1.14  2002/04/08 17:04:05  oes
18   Adapt to unified stylesheet
19
20   Revision 1.13  2002/04/07 17:11:40  oes
21   Tracker submit via curl (no need for user to see), fixing problems, removing monster comments
22
23   Revision 1.12  2002/04/06 18:57:38  swa
24   first version of the script that writes the
25   logfile with all submissions and additionally
26   submits the entries to our tracker.
27
28   Revision 1.11  2002/04/06 15:54:08  swa
29   prework: list of what needs to
30   be submitted to the tracker.
31
32   Revision 1.10  2002/04/06 15:19:35  oes
33   Clean-up, smarter handling of unreachable URLs
34
35   Revision 1.9  2002/04/06 11:34:44  oes
36   Cosmetics
37
38   Revision 1.8  2002/04/04 19:48:11  oes
39   Reactivating the scripts ,-)
40
41   Revision 1.7  2002/04/04 10:29:58  oes
42   Keeping feedback confidential
43
44   Revision 1.6  2002/04/03 19:36:04  swa
45   consistent look
46
47   Revision 1.5  2002/04/02 07:22:43  oes
48   Cosmetics
49
50   Revision 1.4  2002/04/01 19:13:47  oes
51   Extended, fixed bugs, beefed up design, made IE-safe
52
53   Revision 1.3  2002/03/30 20:44:46  swa
54   have consistent look and feel. part 2.
55   use correct urls.
56
57   Revision 1.2  2002/03/30 19:49:34  swa
58   have consistent look and feel
59
60   Revision 1.1  2002/03/30 03:20:30  oes
61   Added Feedback mechanism for actions file
62
63
64   Copyright (C) 2002 the SourceForge Privoxy team.
65   http://www.privoxy.org/
66
67   Written by Andreas Oesterhelt
68
69   This program is free software; you can redistribute it
70   and/or modify it under the terms of the GNU General
71   Public License as published by the Free Software
72   Foundation; either version 2 of the License, or (at
73   your option) any later version.
74
75   This program is distributed in the hope that it will
76   be useful, but WITHOUT ANY WARRANTY; without even the
77   implied warranty of MERCHANTABILITY or FITNESS FOR A
78   PARTICULAR PURPOSE.  See the GNU General Public
79   License for more details.
80
81   The GNU General Public License should be included with
82   this file.  If not, you can view it at
83   http://www.gnu.org/copyleft/gpl.html
84   or write to the Free Software Foundation, Inc., 59
85   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
86
87  -->
88
89  <head>
90   <meta http-equiv="Content-Style-Type" content="text/css">
91   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
92   <link rel="stylesheet" type="text/css" href="../privoxy.css">
93   <link rel="stylesheet" type="text/css" href="../p_feedback.css">
94
95 <?php
96
97 /* 
98  * Config:
99  */
100 $logfile = "results/actions-feedback.txt";
101
102
103 /* 
104  * Debug:
105  */
106 //phpinfo();
107 //error_reporting(E_ALL);
108 error_reporting(E_NONE);
109
110 /*
111  * Function: error_abort
112  * Purpose:  Return an error page with $title and $message
113  */
114 function error_abort($title, $message)
115 {
116    if ($title == "invalid") /* shortcut */
117    {
118       $title = "Invalid Feedback Submission";
119    }
120
121    echo ("  <title>Privoxy: $title</title>
122            </head>
123            <body>
124             <div class=\"title\">
125              <h1>
126               <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
127               </h1>
128              </div>
129             <center>
130              <div class=\"warning\">
131               $message
132              </div>
133             </center>
134             <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
135            </body>
136           </html>\n");
137    exit; 
138 }
139
140
141 /* 
142  * Cannot start with step 3:
143  */
144 if (!isset($referrer_url))
145 {
146    error_abort("invalid", "When submitting your feedback please start with <a href=\"index.php\">step 1</a>.");
147 }
148
149
150 /* 
151  * Cannot work on unknown problem:
152  */
153 if (!isset($problem))
154 {
155    error_abort("invalid", "You need to select the nature of the problem in <a href=\"index.php\">step 1</a>.");
156 }
157
158
159 /* 
160  * Don't accept unconfirmed URLs
161  */
162 if (!isset($url_confirmed))
163 {
164    error_abort("invalid", "When submitting URLs that this script can't retrieve, you need to check \"Yes, I'm sure\"
165                 <a href=\"javascript:history.back();\">step 2</a>.");
166 }
167
168
169 /*
170  * Handle optional text fields:
171  */
172 if (!isset($name) || ($name == ""))
173 {
174    $name = "anonymous";
175 }
176
177 /*
178  * Assign unique ID:
179  */
180 $item_id = date("U");
181
182
183 /* 
184  * Open the logfile or fail:
185  */
186 $fp = fopen($logfile, "a");
187
188 if(!$fp)
189 {
190    echo ("  <title>Internal Script Error</title>
191            </head>
192            <body>
193             <div class=\"title\">
194               <h1><a href=\"http://www.privoxy.org/\">Privoxy</a>: Internal Script Error</h1>
195             </div>
196             <center>
197              <div class=\"warning\">
198               <p>
199                This script was unable to open its logfile.
200               </p>
201               <p>
202                Please <a href=\"mailto:info@privoxy.org?SUBJECT=Feedback-Script-Broken\">mail its owner</a>!
203               </p>
204              </div>
205             </center>
206            </body>
207           </html>");
208    exit; 
209 }
210
211
212 /*
213  * Write Head (type, severity, user, client-ip)
214  * and remarks field:
215  */
216 fwrite($fp, "\n#FEEDBACK ID $item_id TYPE $problem SEVERITY $severity FROM $name ON $REMOTE_ADDR VERIFIED $url_confirmed TIME " . date("r") ."\n");
217 if (isset($remarks))
218 {
219    $lines = explode("\n", $remarks);
220    foreach ($lines as $line)
221    {
222       fwrite($fp, "#REMARKS: $line\n");
223    }
224 }
225
226
227 /*
228  * Depending on the type of problem reported,
229  * we need to write additional data:
230  */
231 switch ($problem)
232 {
233    /*
234     * Banner not blocked:
235     */
236    case "P1":
237       fwrite($fp, "#BLOCK-REFERRER: $referrer_url\n");
238       if (isset($num_images))
239       {
240          for($i=0; $i < $num_images; $i++)
241          {
242              if (isset($block_image[$i]))
243              {
244                 fwrite($fp, "#BLOCK-URL: $image_url[$i]\n");
245                 $trackertext .= "Block image: $image_url[$i]\n\n";
246              }
247          }
248       }
249       if (isset($manual_image_url) && ($manual_image_url != ""))
250       {
251          fwrite($fp, "#BLOCK-URL: $manual_image_url\n");
252          $trackertext .= "Block image: $manual_image_url\n\n";
253       }
254       break;
255
256    /*
257     * Innocent image blocked:
258     */
259    case "P2":
260       fwrite($fp, "#UNBLOCK-REFERRER: $referrer_url\n");
261       if (isset($image_url) && ($image_url != ""))
262       {
263          fwrite($fp, "#UNBLOCK-URL: $image_url\n");
264          $trackertext .= "Unblock image: $image_url\n\n";
265       }
266       break;
267
268    /*
269     * All other problems:
270     */
271    default:
272       fwrite($fp, "#PROBLEM-URL: $referrer_url\n");
273       break;
274 }        
275             
276 fclose($fp);
277
278 /*
279  * Notify our SF tracker that new data is waiting to be
280  * processed
281  */
282 switch($problem)
283 {
284    case "P1": $category_id="412811"; $summary = "Ad not blocked "; break;
285    case "P2": $category_id="412810"; $summary = "Image blocked ";break;
286    case "P3": $category_id="412812"; $summary = "Page plocked ";break;
287    case "P4": $category_id="412813"; $summary = "Popups blocked ";break;
288    case "P5": $category_id="412814"; $summary = "Other problem ";break;
289    default:   $category_id="412814"; $summary = "IMPOSSIBLE ";break;
290 }
291
292 $summary .= "on " . $referrer_url . " (" .$item_id . ")";
293 $priority = 3 * $severity;
294
295 $details = urlencode("On " . date("r") . " new data was received from $name:\n\n"
296                     ."URL: $referrer_url\n\n$trackertext\nRemarks:\n$remarks");
297
298 $postfields = ( "group_id=11118&atid=460288&func=postadd&category_id=$category_id&artifact_group_id=195890" .
299                 "&priority=$priority&summary=$summary&details=$details" );
300
301 $ch = curl_init ("http://sourceforge.net/tracker/index.php");
302 curl_setopt($ch, CURLOPT_HEADER, 0);
303 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
304 curl_setopt($ch, CURLOPT_TIMEOUT, 20);            
305 curl_setopt($ch, CURLOPT_POST, 1);
306 curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
307
308 ob_start();
309 curl_exec($ch);
310 ob_end_clean();
311
312 curl_close ($ch);
313
314 ?>
315
316   <title>Privoxy Action List Feedback - Result</title>
317  </head>
318
319  <body>
320   <div class="title">
321    <h1>
322     <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Result
323    </h1>
324   </div>
325
326   <div class="box">
327    <p>
328     <b>Thank you very much for taking the time to submit your feedback!</b>
329    </p>
330
331    <p>
332     The developers will review and use your submission to improve the
333     distribution actions file.
334    </p>
335    
336    <p align=center>
337     <input type="submit" value="Close this window" onclick="window.close();">
338    </p>
339
340   </div>
341
342   <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>
343
344  </body>
345 </html>