PHP Classes

load url with port 1080

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  load url with port 1080  >  (Un) Subscribe thread alerts  
Subject:load url with port 1080
Summary:load url with port 1080
Messages:3
Author:Orion Tiller
Date:2009-06-24 22:18:01
Update:2009-06-24 23:12:26
 

  1. load url with port 1080   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2009-06-24 22:18:01

Where would I change the code to set the port to 1080 for a load_url function call? In the http.php file or somewhere in the load_url function?


Thanks




function load_url( $url ) {
$returnvalue = "";
set_time_limit(0);

$http=new http_class;

$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$error=$http->GetRequestArguments($url,$arguments);
$error=$http->Open($arguments);
if($error) return "An Error Occurred: $error";

$error=$http->SendRequest($arguments);
if($error) return "An Error Occurred: $error";

$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) return "An Error Occurred: $error";
for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++) {
$header_name=Key($headers);
if(GetType($headers[$header_name])=="array")
{
for($header_value=0;$header_value<count($headers[$header_name]);$header_value++)
if ($header_name == "location") { return load_url($headers[$header_name][$header_value]); }
}
else
if ($header_name == "location") {
$redir = $headers[$header_name];
$regexp = "http(s?)\:\/\/(.*)\/(.*)";
if(preg_match("/$regexp/siU", $redir, $matches)) {
$url = $redir;
return load_url($url);
} else {
if(preg_match("/$regexp/siU", $url, $matches)) {
$url = "http://".$matches[2].str_replace(" ", "%20", $redir);
return load_url($url);
} else {
return "An Error Has Occurred.";
}
}
}
}

for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}

  2. Re: load url with port 1080   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-06-24 22:59:41 - In reply to message 1 from Orion Tiller
Usually you set the HostPort entry of the $arguments array passed to the Open function.

But since you call the GetArguments function first, if you passed it an URL of the form http://www.somehost.com:1080/someurl , it automatically extracts the port number from the URL and sets the HostPort entry of the $arguments array.

  3. Re: load url with port 1080   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2009-06-24 23:12:26 - In reply to message 2 from Manuel Lemos
Thanks. That's weird because I tried it that way initially and it didn't work. I'll try again.