1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 File : $Source: /cvsroot/ijbswa/current/doc/webserver/actions/step2.php,v $
7 Purpose : Submit form for actions file feedback (step 2)
9 ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
11 $Id: step2.php,v 1.6 2002/04/02 07:22:19 oes Exp $
14 Revision 1.6 2002/04/02 07:22:19 oes
15 Elimnating duplicate images; using relative link for step3
17 Revision 1.4 2002/04/01 19:13:47 oes
18 Extended, fixed bugs, beefed up design, made IE-safe
20 Revision 1.1 2002/03/30 03:20:30 oes
21 Added Feedback mechanism for actions file
24 Copyright (C) 2002 the SourceForge Privoxy team.
25 http://www.privoxy.org/
27 Written by Andreas Oesterhelt
29 This program is free software; you can redistribute it
30 and/or modify it under the terms of the GNU General
31 Public License as published by the Free Software
32 Foundation; either version 2 of the License, or (at
33 your option) any later version.
35 This program is distributed in the hope that it will
36 be useful, but WITHOUT ANY WARRANTY; without even the
37 implied warranty of MERCHANTABILITY or FITNESS FOR A
38 PARTICULAR PURPOSE. See the GNU General Public
39 License for more details.
41 The GNU General Public License should be included with
42 this file. If not, you can view it at
43 http://www.gnu.org/copyleft/gpl.html
44 or write to the Free Software Foundation, Inc., 59
45 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
50 <meta http-equiv="Content-Style-Type" content="text/css">
51 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
52 <link rel="stylesheet" type="text/css" href="../p_feedback.css">
54 <script language="javascript" type="text/javascript">
57 // Could be as easy as style="max-wdith: 300px; max-height..." inside the
58 // <img> tag, but IE doesn't do that. Setting the values directly also
59 // screws IE for some weird reason. All praise MS.
62 function prettyscale(image)
67 if (image.width > 300)
72 if (image.height > 50)
82 if (image.height < 20)
89 image.width = newwidth
94 image.height = newheight
107 error_reporting(E_ALL);
108 //error_reporting(E_NONE);
111 * Function: link_to_absolute
112 * Purpose: Make links from $base absolute
114 function link_to_absolute($base, $link)
117 * If $link already is absolute, we're done:
119 if (!strncmp("http://", $link, 7) || !strncmp("https://", $link, 8))
125 * Cut the base to it's proto://host/ or to its proto://host/dir/,
126 * depending whether $link is host-relative or path-relative.
133 preg_match('|^(https?://[^/]+)|i', $base, $results);
141 if (strpos($base, '/') != strlen($base))
143 $base = substr($base, 0, -strpos(strrev($base), '/'));
150 * Function: error_abort
151 * Purpose: Return an error page with $title and $message
153 function error_abort($title, $message)
155 if ($title == "invalid") /* shortcut */
157 $title = "Invalid Feedback Submission";
160 echo (" <title>Privoxy: $title</title>
163 <div class=\"title\">
165 <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
169 <div class=\"errorbox\">
173 <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
180 * Cannot start with step 2:
182 if (!isset($referrer_url))
184 error_abort("invalid", "When submitting your feedback please start with
185 <a href=\"index.php\">step 1</a>.");
190 * Cannot work on unknown problem:
192 if (!isset($problem) || $problem == "INVALID")
194 error_abort("invalid", "You need to select the nature of the problem in
195 <a href=\"javascript:history.back();\">step 1</a>.");
200 * If the protocol is missing from $referrer_url, prepend "http://"
202 if (strncmp("http://", $referrer_url, 7))
204 $referrer_url = "http://" . $referrer_url;
209 * Check if URL really exists and buffer its contents:
211 * FIXME: Curl is not installed on SF; Filed as Alexandria
212 * Feature Request #537014.
213 * PHP's fopen() supports URLs, but it seems that
214 * curls options for Timeouts and HTTP error handling
215 * are not supported by fopen().
222 $ch = curl_init ($referrer_url);
224 curl_setopt ($ch, CURLOPT_HEADER, 0);
225 curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
226 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
227 curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
230 $success = curl_exec ($ch);
231 $page = ob_get_contents();
240 <p><b>Confirm the URL:</b></p>
244 The URL that you entered could not be retrieved. Please make sure that
246 <p class=\"important\">
247 <a href=\"$referrer_url\">$referrer_url</a>
250 is correct and publicly accssible.
253 <input type=\"checkbox\" name=\"url_confirmed\" value=\"user\"> Yes, I'm sure.
259 $url_confirm = "<input type=\"hidden\" name=\"url_confirmed\" value=\"automatic\">";
263 * Create description from problem code:
267 case "P1": $problem_description="an advertisment was not blocked"; break;
268 case "P2": $problem_description="an innocent image was blocked"; break;
269 case "P3": $problem_description="the whole page was erraneously blocked"; break;
270 case "P4": $problem_description="the page needs popups but they don't work"; break;
271 case "P5": $problem_description="a problem occured"; break;
272 default: $problem_description="AN UNPROCESSABLE PROBLEM OCCURED";
277 <title>Privoxy Action List Feedback - Step 2 of 2</title>
283 <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Step 2 of 2
288 <b>You are about to report that <?php echo ($problem_description) ?> on
289 <a href="<?php echo ($referrer_url) ?>"><?php echo ($referrer_url) ?></a>.</b>
293 <form action="step3.php" method="post">
295 <input type="hidden" name="problem" value="<?php echo ($problem) ?>">
296 <input type="hidden" name="referrer_url" value="<?php echo ($referrer_url) ?>">
304 * Include the confirmation for an unretrievable URL if
310 * Create / suppress form elements depending on type of
313 if ($problem != "P1")
320 * Extract all image links from page, make them
321 * absolute, and present them (scaled to reasonable size)
322 * in a table for the user to select
325 preg_match_all('|<img\s+[^>]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches);
326 $image_urls = array_values(array_unique($matches[1]));
327 $count = count($image_urls);
332 * Open section in <dl>; Open table:
334 echo (" <dt><b>Choose the images you want blocked from the following list:</b></dt>
337 <input type=\"hidden\" name=\"num_images\" value=\"$count\">
338 <table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">\n");
340 * Print one table row for each image found:
342 for ($i=0; $i< $count; $i++)
344 $image_url = link_to_absolute($referrer_url, $image_urls[$i]);
351 <input type=\"checkbox\" name=\"block_image[$i]\" value=\"off\">
354 <a href=\"$image_url\">$image_url</a>:
357 <input type=\"hidden\" name=\"image_url[$i]\" value=\"$image_url\">
362 <img onload=\"prettyscale(this);\" src=\"$image_url\" alt=\"banner or not?\">
370 <b>If the banner that you saw is not listed above, enter the URL here</b>\n");
375 <b>URL of the advertisment image:</b>\n");
381 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.</i>
385 <input name="manual_image_url" type="text" size="45" maxlength="255">
389 <?php if($problem != "P1") echo ("-->") ?>
391 <?php if($problem != "P2") echo ("<!--") ?>
394 <p><b>URL of the innocent image:</b>
395 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.
396 <br>This may not work if the image was blocked by size or if +image-blocker is set to redirect.</i>
401 <input name="image_url" value="unknown" type="text" size="45" maxlength="255">
405 <?php if($problem != "P2") echo ("-->") ?>
407 <dt><b>Severity:</b></dt>
410 <select name="severity">
411 <option value="3">drives me crazy</option>
412 <option selected value="2">normal</option>
413 <option value="1">cosmetic</option>
419 <b>Remarks:</b> <i>(optional)</i>
423 <textarea wrap="hard" style="font-size: 10px" name="remarks" cols="35" rows="3">None.</textarea>
428 <b>Your Name:</b> <i>(optional, public)</i>
432 <input name="name" size="45">
438 <input type="submit" value="Submit">
445 <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>