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