two files proxy.php and image.php

proxy downloads the website and image downloads the pictures

proxy.php------------------------------------------------------
<?php

/************************************************\
* Check to see if a web address is present...    *
* iproxy is where the imagaes are loaded         *
* myproxy is the addres of the proxy php page    *
\************************************************/

if(isset($_GET['web']))
{

$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];

  $web = $_GET['web'];
  $iproxy = 'http://www.website.com/image.php?image=';
  $myproxy = 'http://www.website.com/proxy.php?web=';
  $site = '<a href="'.$myproxy.$web;

/************************************************\
* opens the remote page for reading              *
* and loads it into alltext                      *
\************************************************/

  $fd = fopen($web,"rb");
  $alltext = "";
  do
  {
    $data = fread($fd, 8192);
    if (strlen($data) == 0)
    {
      break;
    }
    $alltext .= $data;
  }
  while (true);
  fclose($fd);

/************************************************\
* strips the address down to its root            *
* unless it already is                           *
\************************************************/

  $web1 = dirname ($web);
  if($web1 !== "http:")
  {
    $web = $web1;
  }

/************************************************\
* removes current web address from tags and      *
* checks for all variants of spacing and quotes  *
* and then prints it out onto the screen         *
\************************************************/

$pattern = array(
'{src[ ]*=[ ]*("|\')}i',
'{src=("|\')'.$web.'}i',
'{src=("|\')/}i',
'{src=("|\')http}i',
'{src=("|\')}i',
'{("|\'):::}i',
'{\.src[ ]*=[ ]*}i',
'{\.src="'.$web.'}i',
'{\.src="/}i',
'{\.src="http}i',
'{\.src="}i',
'{:::}i',
'{newImage\(("|\')'.$web.'}i',
'{newImage\(("|\')/}i',
'{newImage\(("|\')}i',
'{<a href[ ]*=[ ]*("|\')}i',
'{<a href=("|\')'.$web.'}i',
'{<a href=("|\')/}i',
'{<a href=("|\')http}i',
'{<a href=("|\')}i',
'{("|\'):::}i',
'{url\(}i',
'{background[ ]*=[ ]*("|\')}i',
'{background=("|\')'.$web.'}i',
'{background=("|\')/}i',
'{background=("|\')}i',
'{(\w)&(\w)}i'
);

$replace = array(
'src=\1',
'src=\1',
'src=\1',
'\1:::',
'src=\1'.$iproxy.$web.'/',
'src=\1'.$iproxy.'http',
'.src="',
'.src="',
'.src="',
':::',
'.src= "'.$iproxy.$web.'/" + ',
'src="'.$iproxy.'http'.'" + ',
'newImage(\1',
'newImage(\1',
'newImage(\1'.$iproxy.$web.'/',
'<a href=\1',
'<a href=\1',
'<a href=\1',
'\1:::',
'<a href=\1'.$myproxy.$web.'/',
'<a href=\1'.$myproxy.'http',
'url('.$iproxy.$web.'/',
'background=\1',
'background=\1',
'background=\1',
'background=\1'.$iproxy.$web.'/',
'\1 \2'
);

  $alltext = preg_replace($pattern, $replace, $alltext);

  $alltext = preg_replace('{<a
href=("|\')http://www\.website\.com/proxy\.php\?web=([^>]*)(gif|jpeg)}i',
'<a href=\1'.$iproxy.'\2\3', $alltext);

//-------------------------------------------------

$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
echo '<p style="margin:auto; text-align:center">';
printf( "Script timer: <b>%f</b> seconds. Parsed ".strlen($alltext)."
chars.", ($etimer-$stimer) );
echo '</p>';

  echo $alltext;
}

?>

image.php------------------------------------------------------
<?php

/************************************************\
* gets the image name an location from proxy.php *
* loads the image as image.php for proxy to call *
\************************************************/

$img = $_GET['image'];
$img = preg_replace("{ }", "&", $img);
$fd = fopen("$img","rb");
$alltext = "";
do
{
  $data = fread($fd, 8192);
  if (strlen($data) == 0)
  {
    break;
  }
  $alltext .= $data;
  //set_time_limit(1);
}
while (true);
fclose($fd);

echo $alltext;
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to