Virtual Brain Online Logo

Bookmark: Root \ PHP \ Talk to Webserver directly

Talk to Webserver directly


Last Updated: 2005-12-20

I have found this on php-list@yahoogroups.com I have not tested it yet but I will eventually.

function sendToSocket($server,$send)
{
$fp = fsockopen ($server, 80, $errno, $errstr);
if (!$fp)
$result = "$errstr ($errno)\r\n";
else{
fputs ($fp, "$send\r\n\r\n");

$ind=0;

while (!feof($fp))
{
$res=fgets ($fp,1024);

if($ind>10)
$content .= $res;
$header .= $res;
$ind++;
}
}
return $content;
}

//Settings to fetch file
function fetchWebPage($PATH)
{
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
$PATH = trim($PATH);
$TEMP = parse_url($PATH);
$path = $TEMP['path'].'?'.$TEMP['query'];
$server = $TEMP['host'];
$send = "GET $path HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash,
Referer: $PATH
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: $agent
Host: $server
Connection: Keep-Alive
Cache-Control: no-cache";

$HTML = sendToSocket($server, $send, $FLAG);
return $HTML;
}

Use the above 2 function(PHP code) and save in a file.

With regards,
Arun
Last update by Skylinux @ 2005-12-20 00:14:34

 

No Comments yet .....

 

Add Your Comment:

Note: All posts require administrator approval. Please allow 24 hours for message approval.

Name:
E-Mail:
Title
Plain text only, less then 65 000 characters.

Adding ten and five is?

Please answer the question above and type the answer into the text box below.