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