Added Feedback mechanism for actions file
[privoxy.git] / doc / webserver / actions / step2.php
1 <?php
2
3 error_reporting(E_NONE);
4 #error_reporting(E_ALL);
5
6
7 //  File :  $Source: $
8 //
9 //  Purpose  :  Submit form for actions file feedback (step 2)
10 //              This file belongs in
11 //              ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
12 //
13 //  $Id: $
14 //
15 //  $Log: $
16 //
17 //  Written by and Copyright (C) 2001 the SourceForge
18 //  Privoxy team. http://www.privoxy.org/
19 //
20 //  Based on the Internet Junkbuster originally written
21 //  by and Copyright (C) 1997 Anonymous Coders and
22 //  Junkbusters Corporation.  http://www.junkbusters.com
23 //
24 //  This program is free software; you can redistribute it
25 //  and/or modify it under the terms of the GNU General
26 //  Public License as published by the Free Software
27 //  Foundation; either version 2 of the License, or (at
28 //  your option) any later version.
29 //
30 //  This program is distributed in the hope that it will
31 //  be useful, but WITHOUT ANY WARRANTY; without even the
32 //  implied warranty of MERCHANTABILITY or FITNESS FOR A
33 //  PARTICULAR PURPOSE.  See the GNU General Public
34 //  License for more details.
35 //
36 //  The GNU General Public License should be included with
37 //  this file.  If not, you can view it at
38 //  http://www.gnu.org/copyleft/gpl.html
39 //  or write to the Free Software Foundation, Inc., 59
40 //  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
41 //
42 //
43
44 /*
45  * For testing: 
46  */
47 #$base_url = "http://www.oesterhelt.org/actions";
48 $base_url = "http://www.privoxy.org/actions";
49
50 /* 
51  * Cannot start with step 2:
52  */
53 if (!isset($referrer_url))
54 {
55      echo ("<html><head><title>Invalid Feedback Submission</title></head>
56                 <body><h2>Invalid Feedback Submission</h2>
57                       <p>When submitting your feedback please start with
58                          <a href=\"index.php\">step 1</a>.</p>
59                  </body>
60           </html>");
61    exit; 
62 }
63
64 /* 
65  * Cannot work on unknown problem:
66  */
67 if (!isset($problem) || $problem == "INVALID")
68 {
69      echo ("<html><head><title>Invalid Feedback Submission</title></head>
70                 <body><h2>Invalid Feedback Submission</h2>
71                       <p>You need to select the nature of the problem in
72                          <a href=\"javascript:back()\">step 1</a>.</p>
73                  </body>
74           </html>");
75    exit; 
76 }
77
78
79 /*
80  * Check if URL really exists and buffer its contents:
81  */
82
83 $ch = curl_init ($referrer_url);
84 curl_setopt ($ch, CURLOPT_HEADER, 0);
85 curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
86
87 ob_start();
88 $success = curl_exec ($ch);
89 $page = ob_get_contents();
90 ob_end_clean();
91
92 curl_close ($ch);
93
94 if (!$success)
95 {
96    echo ("<html><head><title>Invalid Feedback Submission</title></head>
97                 <body><h2>Invalid Feedback Submission</h2>
98                       <p>The URL that you entered (<a href=\"$referrer_url\">$referrer_url</a>)
99                          <br>could not be retrieved.</p>
100                          <p>Make sure the URL is correct and publicly accessible.</p>
101                          <p><a href=\"javascript:back()\">Back to step 1</a></p>
102                          
103                  </body>
104           </html>");
105    exit; 
106 }
107
108 /* 
109  * Create description from problem code:
110  */
111 switch($problem)
112 {
113    case "P1": $problem_description="an advertisment was not blocked"; break;
114    case "P2": $problem_description="an innocent image was blocked"; break;
115    case "P3": $problem_description="the whole page was erraneously blocked"; break;
116    case "P4": $problem_description="the page needs popups but they don't work"; break;
117    case "P5": $problem_description="a problem occured"; break;
118    default: $problem_description="AN UNPROCESSABLE PROBLEM OCCURED";
119 }
120
121 ?>
122
123 <html>
124   <head>
125     <title>Privoxy Action List Feedback - Step 2 of 2</title>
126     <link rel="stylesheet" type="text/css" href="../p_web.css">
127 </head>
128
129 <h2><a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Step 2 of 2</h2>
130 <p>
131 You are about to report that <?php echo ($problem_description) ?>
132 <br>on <a href="<?php echo ($referrer_url) ?>"><?php echo ($referrer_url) ?></a>.
133 </p>
134
135
136 <p>
137 <form action="<?php echo($base_url); ?>/step3.php" method="post">
138
139 <input type="hidden" name="problem" value="<?php echo ($problem) ?>">
140 <input type="hidden" name="referrer_url" value="<?php echo ($referrer_url) ?>">
141
142 <dl>
143
144 <?php
145
146 if ($problem != "P1")
147 {
148    echo ("<!--");
149 }
150 else
151 {
152    preg_match_all('|<img\s+[^>]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches);
153    $count = count($matches[0]);
154    if ($count > 0)
155    {
156       $referrer_base = substr($referrer_url, 0, -strpos(strrev($referrer_url), '/'));
157       $referrer_host = "http://".strrev(strrchr(strrev(substr($referrer_url, 7)), "/"));
158
159       echo ("<dt><b>Choose the images to be blocked from the following list:</b></dt><dd><p>\n");
160       echo ("<input type=\"hidden\" name=\"num_images\" value=\"$count\">\n");
161       echo ("<table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">\n");
162       for ($i=0; $i< $count; $i++) {
163          $image_url = $matches[1][$i];
164          if (strncmp("http://", $image_url, 7))
165          {
166             if ($image_url{0} == "/")
167             {
168                $image_url = $referrer_host.$image_url;
169             }
170             else
171             {
172                $image_url = $referrer_base.$image_url;
173             }
174          }
175          echo ("<tr><td rowspan=2><input type=\"checkbox\" name=\"block_image[$i]\" value=\"off\"></td>\n");
176          echo ("<td><a href=\"$image_url\">$image_url</a>:</td>\n");
177          echo ("<td><input type=\"hidden\" name=\"image_url[$i]\" value=\"$image_url\"></td></tr>\n");
178          echo ("<tr><td><img style=\"max-width: 300; max-height: 50; min-width: 20; min-height: 20\" src=\"$image_url\"></td></tr>\n");
179       }
180       echo ("</table></p></dd><dt><b>If the banner that you saw is not listed above, enter the URL here</b>\n");
181    }
182    else
183    {
184       echo ("<dt><b>URL of the advertisment image:</b>\n");
185    }
186 }
187
188 ?>
189
190 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.</i></dt>
191 <dd>
192 <p><input name="manual_image_url" type="text" size="45" maxlength="255"></p>
193 </dd>
194 <?php if($problem != "P1") echo ("-->") ?>
195
196 <?php if($problem != "P2") echo ("<!--") ?>
197 <dt><b>URL of the innocent image:</b>
198 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.
199 <br>This may not work if the image was blocked by size or if +image-blocker is set to redirect.</i></dt>
200 <dd>
201 <p><input name="image_url" value="unknown" type="text" size="45" maxlength="255"></p>
202 </dd>
203 <?php if($problem != "P2") echo ("-->") ?>
204
205
206 <dt><b>Severity:</b></dt>
207 <dd>
208 <p>
209 <select name="severity">
210 <option value="3">drives me crazy</option>
211 <option selected value="2">vanilla banner</option>
212 <option value="1">cosmetic</option>
213 </select>
214 </p>
215 </dd>
216
217 <dt><b>Remarks:</b> <i>(optional)</i></dt>
218 <dd>
219 <p><textarea name="remarks" cols="35" rows="3">None.</textarea></p>
220 </dd>
221
222 <dt><b>Your Name:</b> <i>(optional)</i></dt>
223 <dd>
224 <p><input name="name" size="45"></p>
225 </dd>
226
227 <dt>&nbsp;</dt>
228 <dd>
229 <input type=submit value="Submit">
230 </dd>
231
232 </dl>
233 </form>
234 </p>
235
236 </body>
237 </html>