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