-
- <script language="javascript" type="text/javascript">
- <!--
- //
- // Could be as easy as style="max-wdith: 300px; max-height..." inside the
- // <img> tag, but IE doesn't understand that. Setting the values directly also
- // screws IE for some weird reason. All praise MS.
- //
-
- function prettyscale(image)
- {
- newwidth = 0
- newheight = 0
-
- if (image.width > 300)
- {
- newwidth = 300
- }
-
- if (image.height > 50)
- {
- newheight = 50
- }
-
- if (image.width < 20)
- {
- newwidth = 20
- }
-
- if (image.height < 20)
- {
- newheight = 20
- }
-
- if (newwidth != 0)
- {
- image.width = newwidth
- }
-
- if (newheight != 0)
- {
- image.height = newheight
- }
- }
- //-->
- </script>
-
-<?php
-
-/*
- * For testing:
- */
-//phpinfo();
-//error_reporting(E_ALL);
-error_reporting(E_NONE);
-
-/*
- * Function: link_to_absolute
- * Purpose: Make $link from $base absolute
- */
-function link_to_absolute($base, $link)
-{
- /*
- * If $link already is absolute, we're done:
- */
- if (!strncmp("http://", $link, 7) || !strncmp("https://", $link, 8))
- {
- return $link;
- }
-
- /*
- * Cut the base to it's proto://host/ or to its proto://host/dir/,
- * depending whether $link is host-relative or path-relative.
- */
- if ($link{0} == "/")
- {
- /*
- * host-relative:
- */
- preg_match('|^(https?://[^/]+)|i', $base, $results);
- $base = $results[1];
- }
- else
- {
- /*
- * path-relative:
- */
- if (strpos($base, '/') != strlen($base))
- {
- preg_match('|(.*/)|i', $base, $results);
- $base = $results[1];
- }
- }
- return $base.$link;
-}
-
-
-/*
- * Function: slurp_page
- *
- * Purpose: Retrieve a URL with curl, and return the contents
- * or "FAILED" if it fails.
- */
-
-function slurp_page($url)
-{
- $ch = curl_init ($url);
-
- curl_setopt ($ch, CURLOPT_HEADER, 0);
- curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
- curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
-
- ob_start();
- $success = curl_exec ($ch);
- $page = ob_get_contents();
- ob_end_clean();
-
- curl_close ($ch);
-
- return $success ? $page : "FAILED";
-}
-
-/*
- * Function: get_image_urls_sp
- *
- * Purpose: Return the image URLs from a single page
- */
-function get_image_urls_sp($page, $url)
-{
- preg_match_all('|<img\s+[^>]*?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('|<frame\s+[^>]*?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 (" <title>Privoxy: $title</title>
- </head>
- <body>
- <div class=\"title\">
- <h1>
- <a href=\"http://www.privoxy.org/\">Privoxy</a>: $title
- </h1>
- </div>
- <center>
- <div class=\"errorbox\">
- $message
- </div>
- </center>
- <p>Valid <a href=\"http://validator.w3.org/\">HTML 4.01 Transitional</a></p>
- </body>
- </html>\n");
- exit;
-}
-
-/*
- * Cannot start with step 2:
- */
-if (!isset($referrer_url))
-{
- error_abort("invalid", "When submitting your feedback please start with
- <a href=\"index.php\">step 1</a>.");
-}
-
-
-/*
- * Cannot work on unknown problem:
- */
-if (!isset($problem) || $problem == "INVALID")
-{
- error_abort("invalid", "You need to select the nature of the problem in
- <a href=\"javascript:history.back();\">step 1</a>.");
-}
-
-
-/*
- * If the protocol is missing from $referrer_url, prepend "http://"
- */
-if (strncmp("http://", $referrer_url, 7))
-{
- $referrer_url = "http://" . $referrer_url;
-}
-
-
-/*
- * Check if URL really exists and buffer its contents:
- */
-if (($page = slurp_page($referrer_url)) == "FAILED")
-{
- $url_confirm = "
- <dt>
- <p><b>Confirm the URL:</b></p>
- </dt>
- <dd>
- <p>
- The URL that you entered could not be retrieved. Please make sure that
- </p>
- <p class=\"important\">
- <a href=\"$referrer_url\">$referrer_url</a>
- </p>
- <p>
- is correct and publicly accssible.
- </p>
- <p>
- <input type=\"checkbox\" name=\"url_confirmed\" value=\"user\"> Yes, I'm sure.
- </p>
- </dd>";
-}
-else
-{
- $url_confirm = "<input type=\"hidden\" name=\"url_confirmed\" value=\"automatic\">";
-}
-
-/*
- * Create description from problem code:
- */
-switch($problem)
-{
- case "P1": $problem_description="an advertisment was not blocked"; break;
- case "P2": $problem_description="an innocent image was blocked"; break;
- case "P3": $problem_description="the whole page was erraneously blocked"; break;
- case "P4": $problem_description="the page needs popups but they don't work"; break;
- case "P5": $problem_description="a problem occured"; break;
- default: $problem_description="AN UNPROCESSABLE PROBLEM OCCURED";
-}
-
-?>
-
- <title>Privoxy Action List Feedback - Step 2 of 2</title>