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