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