X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=doc%2Fwebserver%2Factions%2Fstep2.php;h=bdc08cd33d830fde9a356b00cbcb58b6094fa729;hb=64fd99987b48fe38fda76d602874dcac11090c65;hp=635f1d11175e5fc1dd1f9c7adfbd2df8654015b9;hpb=273aaf5afed7e955586373e2e70fd23e29ce1514;p=privoxy.git diff --git a/doc/webserver/actions/step2.php b/doc/webserver/actions/step2.php index 635f1d11..bdc08cd3 100644 --- a/doc/webserver/actions/step2.php +++ b/doc/webserver/actions/step2.php @@ -8,15 +8,51 @@ This file belongs in ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/ - $Id: step2.php,v 1.1 2002/03/30 03:20:30 oes Exp $ + $Id: step2.php,v 1.13 2002/04/09 13:08:21 oes Exp $ $Log: step2.php,v $ + Revision 1.13 2002/04/09 13:08:21 oes + declare script type + + Revision 1.12 2002/04/08 17:04:05 oes + Adapt to unified stylesheet + + Revision 1.11 2002/04/07 15:00:20 oes + Descand into framesets to harvest all image URLs + + Revision 1.10 2002/04/06 15:19:35 oes + Cosmetics Clean-up, smarter handling of unreachable URLs + + Revision 1.9 2002/04/06 11:34:44 oes + Reactivating the scripts ,-) Cosmetics + + Revision 1.7 2002/04/03 19:36:04 swa + consistent look + + Revision 1.6 2002/04/02 07:22:19 oes + Elimnating duplicate images; using relative link for step3 + + Revision 1.5 2002/04/02 06:14:47 oes + Follow redirects + + Revision 1.4 2002/04/01 19:13:47 oes (based on 1.2) + Extended, fixed bugs, beefed up design, made IE-safe + + Revision 1.3 2002/03/30 20:44:46 swa + have consistent look and feel. part 2. + use correct urls. + + Revision 1.2 2002/03/30 19:49:34 swa + have consistent look and feel + Revision 1.1 2002/03/30 03:20:30 oes Added Feedback mechanism for actions file - Written by and Copyright (C) 2002 the SourceForge - Privoxy team. http://www.privoxy.org/ + Copyright (C) 2002 the SourceForge Privoxy team. + http://www.privoxy.org/ + + Written by Andreas Oesterhelt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General @@ -39,19 +75,17 @@ --> - - - - ]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches); + + foreach (array_unique($matches[1]) as $image_link) + { + $result[] = link_to_absolute($url, $image_link); + } + + return count($result) ? $result : 0; +} + +/* + * Function: get_image_urls + * + * Purpose: If the page is a frameset, rerurn the image URLs from all + * its frame SRCes, else from the page itself. + */ +function get_image_urls($page, $url) +{ + + preg_match_all('|]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches); + + if (count($matches[1])) + { + foreach(array_unique($matches[1]) as $frame_link) + { + $framebuf = slurp_page(link_to_absolute($url, $frame_link)); + $result = array_merge($result, get_image_urls_sp($framebuf, link_to_absolute($url, $frame_link))); + } + } + else + { + $result = get_image_urls_sp($page, $url); + } + + return array_values(array_unique($result)); +} + + +/* + * Function: error_abort + * Purpose: Return an error page with $title and $message + */ +function error_abort($title, $message) { - echo (" Invalid Feedback Submission + if ($title == "invalid") /* shortcut */ + { + $title = "Invalid Feedback Submission"; + } + + echo (" Privoxy: $title -
Invalid Feedback Submission
-
-
When submitting your feedback please start with - step 1. +
+

+ Privoxy: $title +

+
+
+
+ $message
-
+ +

Valid HTML 4.01 Transitional

\n"); exit; } +/* + * Cannot start with step 2: + */ +if (!isset($referrer_url)) +{ + error_abort("invalid", "When submitting your feedback please start with + step 1."); +} + /* * Cannot work on unknown problem: */ if (!isset($problem) || $problem == "INVALID") { - echo (" Invalid Feedback Submission - - -
Invalid Feedback Submission
-
-
You need to select the nature of the problem in - step 1. -
-
- - \n"); - exit; + error_abort("invalid", "You need to select the nature of the problem in + step 1."); } /* - * Check if URL really exists and buffer its contents: - * - * FIXME: Curl is not installed on SF; Filed as Alexandria - * Feature Request #537014. - * PHP's fopen() supports URLs, but it seems that - * curls options for Timeouts and HTTP error handling - * are not supported by fopen(). + * If the protocol is missing from $referrer_url, prepend "http://" */ -$ch = curl_init ($referrer_url); - -curl_setopt ($ch, CURLOPT_HEADER, 0); -curl_setopt ($ch, CURLOPT_FAILONERROR, 1); -curl_setopt ($ch, CURLOPT_TIMEOUT, 15); - -ob_start(); -$success = curl_exec ($ch); -$page = ob_get_contents(); -ob_end_clean(); +if (!preg_match('|^https?://|i', $referrer_url, $dummy)) +{ + $referrer_url = "http://" . $referrer_url; +} -curl_close ($ch); -if (!$success) +/* + * Check if URL really exists and buffer its contents: + */ +if (($page = slurp_page($referrer_url)) == "FAILED") { - echo (" Invalid Feedback Submission - - -
Invalid Feedback Submission
-
-
-

The URL that you entered ($referrer_url) -
could not be retrieved. -

-

Make sure the URL is correct and publicly accessible.

-

Back to step 1

-
-
- - \n"); - exit; + $url_confirm = " +
+

Confirm the URL:

+
+
+

+ The URL that you entered could not be retrieved. Please make sure that +

+

+ $referrer_url +

+

+ is correct and publicly accssible. +

+

+ Yes, I'm sure. +

+
"; +} +else +{ + $url_confirm = ""; } - /* * Create description from problem code: @@ -208,7 +355,11 @@ switch($problem) -
Privoxy Action List Feedback - Step 2 of 2
+
+

+ Privoxy Action List Feedback - Step 2 of 2 +

+
You are about to report that on @@ -216,7 +367,7 @@ switch($problem)
-
+

@@ -227,7 +378,13 @@ switch($problem) ]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches); - $count = count($matches[0]); + $image_urls = get_image_urls($page, $referrer_url); + $count = count($image_urls); + if ($count > 0) { - /* - * Base URL ends in slash: don't touch. - */ - if (strpos(strrev($referrer_url), '/') == 0) - { - $referrer_base = $referrer_url; - } - /* - * Else grab URL up to last slash as base. - */ - else - { - $referrer_base = substr($referrer_url, 0, -strpos(strrev($referrer_url), '/')); - } - - /* - * Get the protocol + host info for relative links - * that start with slash. FIXME: Cut trailing slash off! - */ - $referrer_host = "http://".strrev(strrchr(strrev(substr($referrer_url, 7)), "/")); - /* * Open section in

; Open table: */ @@ -279,28 +411,13 @@ else */ for ($i=0; $i< $count; $i++) { - $image_url = $matches[1][$i]; - - /* - * Make image URLs absolute: - */ - if (strncmp("http://", $image_url, 7)) - { - if ($image_url{0} == "/") - { - $image_url = $referrer_host.$image_url; - } - else - { - $image_url = $referrer_base.$image_url; - } - } + $image_url = link_to_absolute($referrer_url, $image_urls[$i]); /* * Print the row(s): */ echo (" - + @@ -378,7 +495,7 @@ else
- Your Name: (optional) + Your Name: (optional, public)

@@ -388,12 +505,14 @@ else

 
- +
+

Valid HTML 4.01 Transitional

+