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