Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

HTTP Class

Code Wizard, 12-30-2006

Sends redirection and notifies users if site is up or down. Example included in header... (Used and Modified from Wrox Press)

<?php

//
// $http = new http;
// $fp = $http->http_sess("http://evilwalrus.com","/");
// if(!$fp) {
// print "Server not available";
// exit;
// }
// print "<BASE HREF="http://evilwalrus.com/"><p>";
// fpassthru($fp);
//

class http {

var $prooxy_host = "";
var $proxy_port = 0;

function http_sess($host,$path,$port=80) {
if(empty($this->proxy_host)) {
$conn_host = $host;
$conn_port = $port;
} else {
$conn_host = $this->proxy_host;
$conn_port = $this->proxy_port;
}

$abs_url = "http://$host:$port$path";

$query = "GET $abs_url HTTP/1.0
".
"Host: $host:$port
".
"User-agent: PHP/Class HttpSess 1.xE
".
"
";

$fp = fsockopen($conn_host,$conn_port);
if(!$fp) {
return false;
}
fputs($fp,$query);
while(trim($fp,1024)) != "");
return $fp;
}
}

?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions