X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=doc%2Fwebserver%2Factions%2Fstep2.php;h=bdc08cd33d830fde9a356b00cbcb58b6094fa729;hb=56e38dc0aae22a1b09359b04dfbf90952ab87569;hp=f0dcd18fb35e3a784fc3e53502c444f6403f243b;hpb=acfe700ddafd7570cd1475629a45d1146e521549;p=privoxy.git diff --git a/doc/webserver/actions/step2.php b/doc/webserver/actions/step2.php index f0dcd18f..bdc08cd3 100644 --- a/doc/webserver/actions/step2.php +++ b/doc/webserver/actions/step2.php @@ -1,108 +1,339 @@ + + + + + + + + + + + + + ]*?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) +{ + if ($title == "invalid") /* shortcut */ + { + $title = "Invalid Feedback Submission"; + } + + echo (" Privoxy: $title + + +
+

+ Privoxy: $title +

+
+
+
+ $message +
+
+

Valid HTML 4.01 Transitional

+ + \n"); + exit; +} /* * Cannot start with step 2: */ if (!isset($referrer_url)) { - echo ("Invalid Feedback Submission -

Invalid Feedback Submission

-

When submitting your feedback please start with - step 1.

- - "); - exit; + 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.

- - "); - 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: + * If the protocol is missing from $referrer_url, prepend "http://" */ +if (!preg_match('|^https?://|i', $referrer_url, $dummy)) +{ + $referrer_url = "http://" . $referrer_url; +} -$ch = curl_init ($referrer_url); -curl_setopt ($ch, CURLOPT_HEADER, 0); -curl_setopt ($ch, CURLOPT_FAILONERROR, 1); - -ob_start(); -$success = curl_exec ($ch); -$page = ob_get_contents(); -ob_end_clean(); - -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

- - - "); - 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 = ""; } /* @@ -120,118 +351,168 @@ 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 . -

+ Privoxy Action List Feedback - Step 2 of 2 + + +
+

+ Privoxy Action List Feedback - Step 2 of 2 +

+
-

-

+
+ You are about to report that on + . +
- - +
+ +

+ + +

-
+
]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches); - $count = count($matches[0]); + $image_urls = get_image_urls($page, $referrer_url); + $count = count($image_urls); + if ($count > 0) { - $referrer_base = substr($referrer_url, 0, -strpos(strrev($referrer_url), '/')); - $referrer_host = "http://".strrev(strrchr(strrev(substr($referrer_url, 7)), "/")); - - echo ("
Choose the images to be blocked from the following list:

\n"); - echo ("\n"); - echo ("\n"); - for ($i=0; $i< $count; $i++) { - $image_url = $matches[1][$i]; - if (strncmp("http://", $image_url, 7)) - { - if ($image_url{0} == "/") - { - $image_url = $referrer_host.$image_url; - } - else - { - $image_url = $referrer_base.$image_url; - } - } - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); + /* + * Open section in
; Open table: + */ + echo ("
Choose the images you want blocked from the following list:
+
+

+ +

$image_url:
\n"); + /* + * Print one table row for each image found: + */ + for ($i=0; $i< $count; $i++) + { + $image_url = link_to_absolute($referrer_url, $image_urls[$i]); + + /* + * Print the row(s): + */ + echo (" + + + + + + + \n"); } - echo ("
+ + + $image_url: + + +
+ \"banner +

If the banner that you saw is not listed above, enter the URL here\n"); + echo (" + + +
+ If the banner that you saw is not listed above, enter the URL here\n"); } else { - echo ("
URL of the advertisment image:\n"); + echo ("
+ URL of the advertisment image:\n"); } } ?> -
Hint: right-click the image, select "Copy image location" and paste the URL here.
-
-

-
+
Hint: right-click the image, select "Copy image location" and paste the URL here. + +
+

+ +

+
+ ") ?> -
URL of the innocent image: -
Hint: right-click the image, select "Copy image location" and paste the URL here. -
This may not work if the image was blocked by size or if +image-blocker is set to redirect.
-
-

-
-") ?> +
+

URL of the innocent image: +
Hint: right-click the image, select "Copy image location" and paste the URL here. +
This may not work if the image was blocked by size or if +image-blocker is set to redirect.
+

+
+
+

+ +

+
+ +") ?> -
Severity:
-
-

- -

-
- -
Remarks: (optional)
-
-

-
- -
Your Name: (optional)
-
-

-
- -
 
-
- -
- -
- -

- - +
Severity:
+
+

+ +

+
+ +
+ Remarks: (optional) +
+
+

+ +

+
+ +
+ Your Name: (optional, public) +
+
+

+ +

+
+ +
 
+
+ +
+ +
+ +
+ +

Valid HTML 4.01 Transitional

+ +