Hi,
I've seen this problem from previous post and it was resolved by using fsockopen below.
function damnProxy($page, $proxyHost, $proxyPort) {
$data = fsockopen($proxyHost, $proxyPort);
if(!$data) {
fclose($result);
echo "Cannot access ".$page;
}
else {
fputs($data,"GET $page HTTP/1.0\n\n");
while(!feof($data)) {
$cont=$cont.fread($data,4096);
}
}
fclose($data);
return substr($cont,strpos($cont,"\r\n\r\n")+4);
}
$slash = damnProxy("http://slashdot.org/slashdot.rdf", "proxy.yourcompany.com", 8080);
if($slash) {
echo $slash;
}
else {
echo "damned proxy";
}
Well, I don't quite understand what the code is doing after fsockopen successfully, but I guess it's writing something. What I need is to open the URL that's all. I just want to check if a URL provided is valid.
1) How can I do it?
2) Is there anyway I can get the proxy host and port number by some $_SERVER or some other super global arrays?
Below is my code:
// check URL format
if (strstr($URL, "http://")===false)
$new_url = "http://".$URL;
// check URL is valid
$proxyHost = $myproxyhost;
$proxyPort = 80;
$OpenInternetConnection = fsockopen($proxyHost, $proxyPort, $errno, $errstr);
echo $errno;
echo $errstr;
echo "<br>";
if (@fopen($URL, "r"))
echo "OK";
else
echo $URL." is not a valid URL.";