Elimnating duplicate images; using relative link for step3
[privoxy.git] / doc / webserver / actions / step2.php
index 635f1d1..9020ffd 100644 (file)
@@ -8,9 +8,12 @@
               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.4 2002/04/01 19:13:47 oes Exp $
 
   $Log: step2.php,v $
+  Revision 1.4  2002/04/01 19:13:47  oes
+  Extended, fixed bugs, beefed up design, made IE-safe
+
   Revision 1.1  2002/03/30 03:20:30  oes
   Added Feedback mechanism for actions file
 
 /*
  * For testing: 
  */
-$base_url = "http://www.oesterhelt.org/actions";
-//$base_url = "http://privoxy.org/actions";
-//$base_url = "http://localhost/actions";
 //phpinfo();
-//error_reporting(E_NONE);
-error_reporting(E_ALL);
+//error_reporting(E_ALL);
+error_reporting(E_NONE);
 
 
 /* 
@@ -159,7 +159,8 @@ $ch = curl_init ($referrer_url);
 
 curl_setopt ($ch, CURLOPT_HEADER, 0);
 curl_setopt ($ch, CURLOPT_FAILONERROR, 1);
-curl_setopt ($ch, CURLOPT_TIMEOUT, 15);
+curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
+curl_setopt ($ch, CURLOPT_TIMEOUT, 20);            
 
 ob_start();
 $success = curl_exec ($ch);
@@ -216,7 +217,7 @@ switch($problem)
   </div>
 
   <div class="box">
-   <form action="<?php echo($base_url); ?>/step3.php" method="post">
+   <form action="step3.php" method="post">
     <p>
      <input type="hidden" name="problem" value="<?php echo ($problem) ?>">
      <input type="hidden" name="referrer_url" value="<?php echo ($referrer_url) ?>">
@@ -242,7 +243,9 @@ else
     * in a table for the user to select
     */
    preg_match_all('|<img\s+[^>]*?src=[\'"]?(.*?)[\'" >]|i', $page, $matches);
-   $count = count($matches[0]);
+   $image_urls = array_values(array_unique($matches[1]));
+   $count = count($image_urls);
+
    if ($count > 0)
    {
       /* 
@@ -279,7 +282,7 @@ else
        */
       for ($i=0; $i< $count; $i++)
       {
-         $image_url = $matches[1][$i];
+         $image_url = $image_urls[$i];
  
          /*
           * Make image URLs absolute: