first version of the script that writes the
[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.11 2002/04/06 15:54:08 swa Exp $
12
13   $Log: step3.php,v $
14   Revision 1.11  2002/04/06 15:54:08  swa
15   prework: list of what needs to
16   be submitted to the tracker.
17
18   Revision 1.10  2002/04/06 15:19:35  oes
19   Clean-up, smarter handling of unreachable URLs
20
21   Revision 1.5  2002/04/02 07:22:43  oes
22   Cosmetics
23
24   Revision 1.4  2002/04/01 19:13:47  oes
25   Extended, fixed bugs, beefed up design, made IE-safe
26
27   Revision 1.1  2002/03/30 03:20:30  oes
28   Added Feedback mechanism for actions file
29
30
31   Written by and Copyright (C) 2002 the SourceForge
32   Privoxy team. http://www.privoxy.org/
33
34   This program is free software; you can redistribute it
35   and/or modify it under the terms of the GNU General
36   Public License as published by the Free Software
37   Foundation; either version 2 of the License, or (at
38   your option) any later version.
39
40   This program is distributed in the hope that it will
41   be useful, but WITHOUT ANY WARRANTY; without even the
42   implied warranty of MERCHANTABILITY or FITNESS FOR A
43   PARTICULAR PURPOSE.  See the GNU General Public
44   License for more details.
45
46   The GNU General Public License should be included with
47   this file.  If not, you can view it at
48   http://www.gnu.org/copyleft/gpl.html
49   or write to the Free Software Foundation, Inc., 59
50   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
51
52  -->
53
54  <head>
55   <meta http-equiv="Content-Style-Type" content="text/css">
56   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
57   <link rel="stylesheet" type="text/css" href="../p_feedback.css">
58
59
60 <?php
61
62 /* 
63  * Config:
64  */
65 $logfile = "results/actions-feedback.txt";
66
67
68 /* 
69  * Debug:
70  */
71 //phpinfo();
72 //error_reporting(E_ALL);
73 error_reporting(E_NONE);
74
75 // // Debug short cut
76 // $referrer_url="http://informer2.comdirect.de/de/my/homepage/index.html?Show=main.html&callerPage=%2fde%2fmy%2fhomepage%2findex.html";
77 // $problem="P1";
78 // $url_confirmed="yes";
79 // $severity="1";
80 // $remarks="this is the first line of text\nthe 2nd line\nthird line.";
81 // //$block_image="";
82 // $num_images=0;
83 // $manual_image_url="http://www.someimage.de/de/my/homepage/index.html?Show=main.html&callerPage=%2fde%2fmy%2fhomepage%2findex.html";
84 // $image_url="http://www.someimage.de/de/my/homepage/index.html?Show=main.html&callerPage=%2fde%2fmy%2fhomepage%2findex.html";
85 // // end debug short cut
86
87 /*
88  * Function: error_abort
89  * Purpose:  Return an error page with $title and $message
90  */
91 function error_abort($title, $message)
92 {
93    if ($title == "invalid") /* shortcut */
94    {
95       $title = "Invalid Feedback Submission";
96    }
97
98    echo ("  <title>Privoxy: $title</title>
99            </head>
100            <body>
101             <div class=\"title\">
102              <h1>
103               <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
104               </h1>
105              </div>
106             <center>
107              <div class=\"errorbox\">
108               $message
109              </div>
110             </center>
111             <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
112            </body>
113           </html>\n");
114    exit; 
115 }
116
117
118 /* 
119  * Cannot start with step 3:
120  */
121 if (!isset($referrer_url))
122 {
123    error_abort("invalid", "When submitting your feedback please start with <a href=\"index.php\">step 1</a>.");
124 }
125
126
127 /* 
128  * Cannot work on unknown problem:
129  */
130 if (!isset($problem))
131 {
132    error_abort("invalid", "You need to select the nature of the problem in <a href=\"index.php\">step 1</a>.");
133 }
134
135
136 /* 
137  * Don't accept unconfirmed URLs
138  */
139 if (!isset($url_confirmed))
140 {
141    error_abort("invalid", "When submitting URLs that this script can't retrieve, you need to check \"Yes, I'm sure\"
142                 <a href=\"javascript:history.back();\">step 2</a>.");
143 }
144
145
146 /*
147  * Handle optional text fields:
148  */
149 if (!isset($name) || ($name == ""))
150 {
151    $name = "anonymous";
152 }
153
154
155 /* 
156  * Open the logfile or fail:
157  */
158 $fp = fopen($logfile, "a");
159
160 if(!$fp)
161 {
162    echo ("  <title>Internal Script Error</title>
163            </head>
164            <body>
165             <div class=\"title\">
166               <h1><a href=\"http://www.privoxy.org/\">Privoxy</a>: Internal Script Error</h1>
167             </div>
168             <center>
169              <div class=\"errorbox\">
170               <p>
171                This script was unable to open its logfile.
172               </p>
173               <p>
174                Please <a href=\"mailto:info@privoxy.org?SUBJECT=Feedback-Script-Broken\">mail its owner</a>!
175               </p>
176              </div>
177             </center>
178            </body>
179           </html>");
180    exit; 
181 }
182
183
184 /*
185  * Write Head (type, severity, user, client-ip)
186  * and remarks field:
187  */
188 fwrite($fp, "\n#FEEDBACK TYPE $problem SEVERITY $severity FROM $name ON $REMOTE_ADDR VERIFIED $url_verified TIME " . date("r") ."\n");
189 if (isset($remarks))
190 {
191    $lines = explode("\n", $remarks);
192    foreach ($lines as $line)
193    {
194       fwrite($fp, "#REMARKS: $line\n");
195    }
196 }
197
198
199 /*
200  * Depending on the type of problem reported,
201  * we need to write additional data:
202  */
203 switch ($problem)
204 {
205    /*
206     * Banner not blocked:
207     */
208    case "P1":
209       fwrite($fp, "#BLOCK-REFERRER: $referrer_url\n");
210       if (isset($num_images))
211       {
212          for($i=0; $i < $num_images; $i++)
213          {
214              if (isset($block_image[$i]))
215              {
216                 fwrite($fp, "#BLOCK-URL: $image_url[$i]\n");
217              }
218          }
219       }
220       if (isset($manual_image_url) && ($manual_image_url != ""))
221       {
222          fwrite($fp, "#BLOCK-URL: $manual_image_url\n");
223       }
224       break;
225
226    /*
227     * Innocent image blocked:
228     */
229    case "P2":
230       fwrite($fp, "#UNBLOCK-REFERRER: $referrer_url\n");
231       if (isset($image_url) && ($image_url != ""))
232       {
233          fwrite($fp, "#UNBLOCK-URL: $image_url\n");
234       }
235       break;
236
237    /*
238     * All other problems:
239     */
240    default:
241       fwrite($fp, "#PROBLEM-URL: $referrer_url\n");
242       break;
243 }        
244             
245 fclose($fp);
246
247 // now fill the tracker on sf with all the necessary values:
248 //
249 // <FORM ACTION="/tracker/index.php?group_id=11118&atid=460288" METHOD="POST" enctype="multipart/form-data">
250 // <INPUT TYPE="HIDDEN" NAME="func" VALUE="postadd">
251 //
252 // <SELECT NAME="category_id">
253 // <OPTION VALUE="100">None</OPTION>
254 // <OPTION VALUE="412811">filter: ad-incorrectly-blocked</OPTION>
255 // <OPTION VALUE="412810">filter: ad-not-blocked</OPTION>
256 // <OPTION VALUE="412814">filter: other problem</OPTION>
257 // <OPTION VALUE="412812">filter: page-incorrectly-block</OPTION>
258 // <OPTION VALUE="412813">filter: popups-incorrectly blo</OPTION>
259 //
260 //  <SELECT NAME="artifact_group_id">
261 //  <OPTION VALUE="100">None</OPTION>
262 //  <OPTION VALUE="195870">action file version 1.0</OPTION>
263 //  <OPTION VALUE="195871">action file version 1.1</OPTION>
264 //  <OPTION VALUE="195872">action file version 1.2</OPTION>
265 //  <OPTION VALUE="195873">action file version 1.3</OPTION>
266 //  <OPTION VALUE="195874">action file version 1.4</OPTION>
267 //  <OPTION VALUE="195875">action file version 1.5</OPTION>
268 //  <OPTION VALUE="195876">action file version 1.6</OPTION>
269 //  <OPTION VALUE="195877">action file version 1.7</OPTION>
270 //  <OPTION VALUE="195878">action file version 1.8</OPTION>
271 //  <OPTION VALUE="195879">action file version 1.9</OPTION>
272 //  <OPTION VALUE="195880">action file version 2.0</OPTION> 
273 //
274 // <SELECT NAME="assigned_to">
275 // <OPTION VALUE="100">None</OPTION>
276 // <OPTION VALUE="128588">bart1803</OPTION>
277 // <OPTION VALUE="249980">david__schmidt</OPTION>
278 // <OPTION VALUE="79346">gliptak</OPTION>
279 // <OPTION VALUE="322640">hal9</OPTION>
280 // <OPTION VALUE="108873">joergs</OPTION>
281 // <OPTION VALUE="199289">jongfoster</OPTION>
282 // <OPTION VALUE="10857">morcego</OPTION>
283 // <OPTION VALUE="78811">oes</OPTION>
284 // <OPTION VALUE="43129">roro</OPTION>
285 // <OPTION VALUE="249832">steudten</OPTION>
286 // <OPTION VALUE="74317">swa</OPTION>
287 //
288 // <SELECT NAME="priority">
289 // <OPTION VALUE="1">1 - Lowest</OPTION>
290 // <OPTION VALUE="2">2</OPTION>
291 // <OPTION VALUE="3">3</OPTION>
292 // <OPTION VALUE="4">4</OPTION>
293 // <OPTION VALUE="5" SELECTED>5 - Medium</OPTION>
294 // <OPTION VALUE="6">6</OPTION>
295 // <OPTION VALUE="7">7</OPTION>
296 // <OPTION VALUE="8">8</OPTION>
297 // <OPTION VALUE="9">9 - Highest</OPTION>
298 //
299 // <INPUT TYPE="TEXT" NAME="summary" SIZE="35" MAXLENGTH="40">
300 // 
301 // we can either put everything in here (nicely formatted) ..
302 // <TEXTAREA NAME="details" ROWS="30" COLS="55" WRAP="HARD"></TEXTAREA>
303 //
304 // ... or attach a file (with the html header so it gets displayed
305 // as if it is a html file
306 // <input type="checkbox" name="add_file" VALUE="1">
307 // <input type="file" name="input_file" size="30">
308 // <input type="text" name="file_description" size="40" maxlength="255">
309 //
310 // <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT">
311
312 //
313 // TODO: - set all variables above this point
314 //       - evaluate alternative: file attachment
315 //
316
317 // INFORMATION:
318 // below this point, all variables _must_ be set (no checking is performed)
319 //
320
321 //  need to switch the following statement for type of problem
322 switch($problem)
323 {
324    case "P1": $sf_cat_id="412811"; $sf_summary="an advertisment was not blocked"; break;
325    case "P2": $sf_cat_id="412810"; $sf_summary="an innocent image was blocked"; break;
326    case "P3": $sf_cat_id="412812"; $sf_summary="the whole page was erraneously blocked"; break;
327    case "P4": $sf_cat_id="412813"; $sf_summary="the page needs popups but they don't work"; break;
328    case "P5": $sf_cat_id="412814"; $sf_summary="a problem occured"; break;
329    default: $sf_cat_id="412814"; $sf_summary="AN UNPROCESSABLE PROBLEM OCCURED"; break;
330 }
331 // need to switch the following statement for action file version
332 $sf_agroup_id="195870"; // assume 1.0 for the time being
333 // this is always set to nobody
334 $sf_assigned_to="100";
335 // need to set values from [1...9]
336 switch($severity)
337 {
338    case "1": $sf_prio="1"; break;  // low
339    case "2": $sf_prio="5"; break;  // medium
340    case "3": $sf_prio="9"; break;  // high
341    default: $sf_cat_id="1"; break;
342 }
343 // here comes the beef
344 $sf_trackertext="\n\n\nIt would be awesome if the links below were clickable :-)\n\n";
345 $sf_trackertext=$sf_trackertext . "This item was submitted by $name\n\n";
346 $sf_trackertext=$sf_trackertext . "Where did it happen?\n$referrer_url\n\n";
347 $sf_trackertext=$sf_trackertext . "What happened?\n$sf_summary (" . date("r") . ")\n\n";
348 switch($problem)
349 {
350    case "P1":
351      $sf_trackertext=$sf_trackertext."These URLs are likely advertisements\n";
352      for($i=0; $i < $num_images; $i++)
353        {
354          if (isset($block_image[$i]))
355            {
356              $sf_trackertext = $sf_trackertext . "$image_url[$i]\n\n";
357            }
358        }
359      if ($manual_image_url != "")
360        {
361          $sf_trackertext=$sf_trackertext . "$manual_image_url";
362        }
363      $sf_trackertext= $sf_trackertext . "\n\n";
364      break;
365    case "P2": $sf_trackertext= $sf_trackertext . "The URL of the image that was incorrectly blocked:\n$image_url\n\n"; break;
366    case "P3": $sf_trackertext= $sf_trackertext . "\n\n"; break;
367    case "P4": $sf_trackertext= $sf_trackertext . "\n\n"; break;
368    case "P5": $sf_trackertext= $sf_trackertext . "\n\n"; break;
369    default: $sf_trackertext= $sf_trackertext . "\n\n"; break; break;
370 }
371 $sf_trackertext= $sf_trackertext . "Remarks:\n--------\n$remarks\n\n\n";
372
373 ?>
374
375 <div class="title">
376 <h1>
377 <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Step 3 of 4.
378 </h1>
379 </div>
380 </head>
381 <body>
382 <div class="box">
383 <p>
384 Thank you. We have preliminary validated you input. Please click on "Submit"
385 to transfer you feedback to our tracker.
386 </p>
387 <p align=center>
388 <form action="http://sourceforge.net/tracker/index.php?group_id=11118&atid=460288" method="post" enctype="multipart/form-data">
389 <input type="hidden" name="func" value="postadd">
390 <input type="hidden" name="category_id" value="<?php echo ($sf_cat_id) ?>">
391 <input type="hidden" name="artifact_group_id" value="<?php echo ($sf_agroup_id) ?>">
392 <input type="hidden" name="assigned_to" value="<?php echo ($sf_assigned_to) ?>">
393 <input type="hidden" name="priority" value="<?php echo ($sf_prio) ?>">
394 <input type="hidden" name="summary" value="<?php echo ($sf_summary) ?>">
395 <input type="hidden" name="details" value="<?php echo ($sf_trackertext) ?>">
396 <input type="submit" name="submit" value="Submit">
397 </form>
398 The script will take you to Sourceforge where all submissions are collected.
399 </p>
400 </div>
401 <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>
402 </body>
403 </html>
404
405 <!--
406
407   <title>Privoxy Action List Feedback - Result</title>
408  </head>
409
410  <body>
411   <div class="title">
412    <h1>
413     <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Result
414    </h1>
415   </div>
416
417   <div class="box">
418    <p>
419     <b>Thank you very much for taking the time to submit your feedback!</b>
420    </p>
421
422    <p>
423     It will be reviewed by the developers and used to improve the
424     distribution actions file.
425    </p>
426    
427    <p align=center>
428     <input type="submit" value="Close this window" onclick="window.close();">
429    </p>
430
431   </div>
432
433   <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>
434
435  </body>
436 </html>
437
438  -->