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.12 2002/04/08 17:04:05 oes Exp $
14 Revision 1.12 2002/04/08 17:04:05 oes
15 Adapt to unified stylesheet
17 Revision 1.11 2002/04/07 15:00:20 oes
18 Descand into framesets to harvest all image URLs
20 Revision 1.10 2002/04/06 15:19:35 oes
21 Cosmetics Clean-up, smarter handling of unreachable URLs
23 Revision 1.9 2002/04/06 11:34:44 oes
24 Reactivating the scripts ,-) Cosmetics
26 Revision 1.7 2002/04/03 19:36:04 swa
29 Revision 1.6 2002/04/02 07:22:19 oes
30 Elimnating duplicate images; using relative link for step3
32 Revision 1.5 2002/04/02 06:14:47 oes
35 Revision 1.4 2002/04/01 19:13:47 oes (based on 1.2)
36 Extended, fixed bugs, beefed up design, made IE-safe
38 Revision 1.3 2002/03/30 20:44:46 swa
39 have consistent look and feel. part 2.
42 Revision 1.2 2002/03/30 19:49:34 swa
43 have consistent look and feel
45 Revision 1.1 2002/03/30 03:20:30 oes
46 Added Feedback mechanism for actions file
49 Copyright (C) 2002 the SourceForge Privoxy team.
50 http://www.privoxy.org/
52 Written by Andreas Oesterhelt
54 This program is free software; you can redistribute it
55 and/or modify it under the terms of the GNU General
56 Public License as published by the Free Software
57 Foundation; either version 2 of the License, or (at
58 your option) any later version.
60 This program is distributed in the hope that it will
61 be useful, but WITHOUT ANY WARRANTY; without even the
62 implied warranty of MERCHANTABILITY or FITNESS FOR A
63 PARTICULAR PURPOSE. See the GNU General Public
64 License for more details.
66 The GNU General Public License should be included with
67 this file. If not, you can view it at
68 http://www.gnu.org/copyleft/gpl.html
69 or write to the Free Software Foundation, Inc., 59
70 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
75 <meta http-equiv="Content-Style-Type" content="text/css">
76 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
77 <meta http-equiv="Content-Script-Type" content="text/javascript">
78 <link rel="stylesheet" type="text/css" href="../privoxy.css">
79 <link rel="stylesheet" type="text/css" href="../p_feedback.css">
81 <script language="javascript" type="text/javascript">
84 // Could be as easy as style="max-wdith: 300px; max-height..." inside the
85 // <img> tag, but IE doesn't understand that. Setting the values directly also
86 // screws IE for some weird reason. All praise MS.
89 function prettyscale(image)
94 if (image.width > 300)
99 if (image.height > 50)
104 if (image.width < 20)
109 if (image.height < 20)
116 image.width = newwidth
121 image.height = newheight
133 //error_reporting(E_ALL);
134 error_reporting(E_NONE);
137 * Function: link_to_absolute
138 * Purpose: Make $link from $base absolute
140 function link_to_absolute($base, $link)
143 * If $link already is absolute, we're done:
145 if (!strncmp("http://", $link, 7) || !strncmp("https://", $link, 8))
151 * Cut the base to it's proto://host/ or to its proto://host/dir/,
152 * depending whether $link is host-relative or path-relative.
159 preg_match('|^(https?://[^/]+)|i', $base, $results);
167 if (strpos($base, '/') != strlen($base))
169 preg_match('|(.*/)|i', $base, $results);
178 * Function: slurp_page
180 * Purpose: Retrieve a URL with curl, and return the contents
181 * or "FAILED" if it fails.
184 function slurp_page($url)
186 $ch = curl_init ($url);
188 curl_setopt ($ch, CURLOPT_HEADER, 0);
189 curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
190 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
191 curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
194 $success = curl_exec ($ch);
195 $page = ob_get_contents();
200 return $success ? $page : "FAILED";
204 * Function: get_image_urls_sp
206 * Purpose: Return the image URLs from a single page
208 function get_image_urls_sp($page, $url)
210 preg_match_all('|<img\s+[^>]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches);
212 foreach (array_unique($matches[1]) as $image_link)
214 $result[] = link_to_absolute($url, $image_link);
217 return count($result) ? $result : 0;
221 * Function: get_image_urls
223 * Purpose: If the page is a frameset, rerurn the image URLs from all
224 * its frame SRCes, else from the page itself.
226 function get_image_urls($page, $url)
229 preg_match_all('|<frame\s+[^>]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches);
231 if (count($matches[1]))
233 foreach(array_unique($matches[1]) as $frame_link)
235 $framebuf = slurp_page(link_to_absolute($url, $frame_link));
236 $result = array_merge($result, get_image_urls_sp($framebuf, link_to_absolute($url, $frame_link)));
241 $result = get_image_urls_sp($page, $url);
244 return array_values(array_unique($result));
249 * Function: error_abort
250 * Purpose: Return an error page with $title and $message
252 function error_abort($title, $message)
254 if ($title == "invalid") /* shortcut */
256 $title = "Invalid Feedback Submission";
259 echo (" <title>Privoxy: $title</title>
262 <div class=\"title\">
264 <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
268 <div class=\"warning\">
272 <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
279 * Cannot start with step 2:
281 if (!isset($referrer_url))
283 error_abort("invalid", "When submitting your feedback please start with
284 <a href=\"index.php\">step 1</a>.");
289 * Cannot work on unknown problem:
291 if (!isset($problem) || $problem == "INVALID")
293 error_abort("invalid", "You need to select the nature of the problem in
294 <a href=\"javascript:history.back();\">step 1</a>.");
299 * If the protocol is missing from $referrer_url, prepend "http://"
301 if (strncmp("http://", $referrer_url, 7))
303 $referrer_url = "http://" . $referrer_url;
308 * Check if URL really exists and buffer its contents:
310 if (($page = slurp_page($referrer_url)) == "FAILED")
314 <p><b>Confirm the URL:</b></p>
318 The URL that you entered could not be retrieved. Please make sure that
320 <p class=\"important\">
321 <a href=\"$referrer_url\">$referrer_url</a>
324 is correct and publicly accssible.
327 <input type=\"checkbox\" name=\"url_confirmed\" value=\"user\"> Yes, I'm sure.
333 $url_confirm = "<input type=\"hidden\" name=\"url_confirmed\" value=\"automatic\">";
337 * Create description from problem code:
341 case "P1": $problem_description="an advertisment was not blocked"; break;
342 case "P2": $problem_description="an innocent image was blocked"; break;
343 case "P3": $problem_description="the whole page was erraneously blocked"; break;
344 case "P4": $problem_description="the page needs popups but they don't work"; break;
345 case "P5": $problem_description="a problem occured"; break;
346 default: $problem_description="AN UNPROCESSABLE PROBLEM OCCURED";
351 <title>Privoxy Action List Feedback - Step 2 of 2</title>
357 <a href="http://www.privoxy.org" target="_blank">Privoxy</a> Action List Feedback - Step 2 of 2
362 <b>You are about to report that <?php echo ($problem_description) ?> on
363 <a href="<?php echo ($referrer_url) ?>"><?php echo ($referrer_url) ?></a>.</b>
367 <form action="step3.php" method="post">
369 <input type="hidden" name="problem" value="<?php echo ($problem) ?>">
370 <input type="hidden" name="referrer_url" value="<?php echo ($referrer_url) ?>">
378 * Include the confirmation for an unretrievable URL if
384 * Create / suppress form elements depending on type of
387 if ($problem != "P1")
393 $image_urls = get_image_urls($page, $referrer_url);
394 $count = count($image_urls);
399 * Open section in <dl>; Open table:
401 echo (" <dt><b>Choose the images you want blocked from the following list:</b></dt>
404 <input type=\"hidden\" name=\"num_images\" value=\"$count\">
405 <table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">\n");
407 * Print one table row for each image found:
409 for ($i=0; $i< $count; $i++)
411 $image_url = link_to_absolute($referrer_url, $image_urls[$i]);
418 <input type=\"checkbox\" name=\"block_image[$i]\" value=\"off\">
421 <a href=\"$image_url\">$image_url</a>:
424 <input type=\"hidden\" name=\"image_url[$i]\" value=\"$image_url\">
429 <img onload=\"prettyscale(this);\" src=\"$image_url\" alt=\"banner or not?\">
437 <b>If the banner that you saw is not listed above, enter the URL here</b>\n");
442 <b>URL of the advertisment image:</b>\n");
448 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.</i>
452 <input name="manual_image_url" type="text" size="45" maxlength="255">
456 <?php if($problem != "P1") echo ("-->") ?>
458 <?php if($problem != "P2") echo ("<!--") ?>
461 <p><b>URL of the innocent image:</b>
462 <br><i>Hint: right-click the image, select "Copy image location" and paste the URL here.
463 <br>This may not work if the image was blocked by size or if +image-blocker is set to redirect.</i>
468 <input name="image_url" value="unknown" type="text" size="45" maxlength="255">
472 <?php if($problem != "P2") echo ("-->") ?>
474 <dt><b>Severity:</b></dt>
477 <select name="severity">
478 <option value="3">drives me crazy</option>
479 <option selected value="2">normal</option>
480 <option value="1">cosmetic</option>
486 <b>Remarks:</b> <i>(optional)</i>
490 <textarea wrap="hard" style="font-size: 10px" name="remarks" cols="35" rows="3">None.</textarea>
495 <b>Your Name:</b> <i>(optional, public)</i>
499 <input name="name" size="45">
505 <input type="submit" value="Submit">
512 <p>Valid <a href="http://validator.w3.org/">HTML 4.01 Transitional</a></p>