Trying to make a script that gets another and resends it.

Begin proxy.php
<?php

$scriptpath = "http://".getenv(SERVER_NAME).getenv(SCRIPT_NAME);


   // Log the request
$fp = fopen("/www/htdocs/heim/test/heim/test/log.txt", "a");
if ($fp){
fputs($fp, "$REMOTE_ADDR - GET $url\n");
fclose($fp);
}

if ((substr($url, 0, 7) == "http://") && (substr_count($url, "http://") ==
1)){


$pagedata = implode("", file($url));


//try to make absolute links go through the proxy script

$pagedata = str_replace("href=\"http://", "href=" $scriptpath "?url="$url,
$pagedata);


echo $pagedata;


}
else{
echo "something went wrong";
}

?>


The script works great, as long as the line beginning $pagedata is commented
out. But, I would like to use that line to convert all absolute links in the
page to also go through the proxy.php

Also, any ideas of how to process relative links and make them into absolute
links?

Ex.  (lets say $scriptpath is http://www.host.com/proxy.php)

    <a href="about.html">  which is actually www.abc123.com/about.html

Becomes:

    <a 
href="http://www.host.com/proxy.php?url=http://www.abc123.com/about.html

Any help on converting these links would be very much appreciated


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to