php3-list | 200003
Date: 03/21/00
- Next message: John Coggeshall: "Re: [PHP3] Re: [PHP Template] Re: [PHP3] PHP Template Engine spec revision 0.52"
- Previous message: Ciprian: "Re: [PHP3] chmod, chgrp, chown & and all that admin stuff"
- In reply to: Matt G. Ellis: "[PHP3] "Stealing" an HTML page"
- Next in thread: Zeev Suraski: "[PHP3] Re: [PHP Template] Re: [PHP3] PHP Template Engine spec revision 0.52"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tuesday, March 21, 2000, 06:47, Matt G. Ellis wrote:
> I'd like to know how i could go about creating a gateway, like anonimizer,
> that would take a URL, Fetch it, and then send it to the web browser that
> sent of the request, but from my script, not from the actual site you
> requested.
You can always do a HTTP connection, issue a GET request, put the
results in a file, strip leading HTTP headers and HTML <head></head>
and starting <body>, then output everything else.
Of course, you realize you should also do some tag escaping on the
fetched page, otherwise a malicious user of your system could design
a page of his own that, when displayed by your script, could do bad
things on *your* server, just as if it were your page.
Here's a simple PHP script that will start a connection, get the
resource and simply echo it out. It's straightforward and you
shouldn't have any problems with it.
<?php
$ht=fsockopen('www.domain.com',80) or die('*** FAILED ***');
fputs($ht,"GET /path/file.html?var=value HTTP/1.0\n");
fputs($ht,"Host: www.domain.com\n");
// Browser ID, might want to use a well known one to be sure no
// rejections occur
fputs($ht,"User-Agent: Mozilla/4.7 [en] (Win98; I) **YEAH RIGHT**\n");
// This mentions the page which led you to the page you're trying to
// fetch, put their own homepage in to be sure.
fputs($ht,"Referer: http://www.domain.com\n");
// following stuff added just to be sure --some scripts/servers might check
fputs($ht,"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\n");
fputs($ht,"Accept-Charset: iso-8859-1,*,utf-8\n");
fputs($ht,"Accept-Encoding: gzip\n");
fputs($ht,"Accept-Language: en\n");
// EOF
fputs($ht,"\n.");
// request sent, stand by for response:
while (!feof($ht))
{
$s=fgets($ht,4096);
// You might wanna do some ereg_replace here, change < and > into <
// and > Also, I output everything, you might want to check for the
// first occurance of <body, then start echo'ing.
echo $s;
}
//Bye-bye!
fclose($ht);
?>
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: John Coggeshall: "Re: [PHP3] Re: [PHP Template] Re: [PHP3] PHP Template Engine spec revision 0.52"
- Previous message: Ciprian: "Re: [PHP3] chmod, chgrp, chown & and all that admin stuff"
- In reply to: Matt G. Ellis: "[PHP3] "Stealing" an HTML page"
- Next in thread: Zeev Suraski: "[PHP3] Re: [PHP Template] Re: [PHP3] PHP Template Engine spec revision 0.52"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

