You’ll note I’ve defined my ports as an array, so that I may loop through them when attempting to connect thus:
<?php
foreach ($Ports as $Port){
$fp = fsockopen($IP, $Port, $errno, $errstr, $Timeout);
?>
If we don’t get an error straight away, we send our request. You’ll note that some of the headers are slightly different to your standard HTTP request, in that first of all we include the full URL and not just the file path in the GET and add Host and Proxy-Connection headers to the request.
<?php
if ($errno == 0 ) {
$FPut = "GET http://".$URL."/ HTTP/1.0rn";
$FPut .= "Proxy-Connection: Keep-Alivern";
$FPut .= "Pragma: no-cachern";
$FPut .= "Host: ".$URL."rn";
$FPut .= "User-Agent: Proxy-Validatorrn";
$FPut .= "rn";
fputs($fp, $FPut);
$HTTP_Response = fgets($fp, 128);
if(strlen(stristr($HTTP_Response, "200")) > 0){
$bOpenProxy = true;
}
fclose($fp);
}
?>