<?php// This script is released into the public domain, see http://creativecommons.org/licenses/publicdomain/function curl_func($url,$timeout=15){$curl=curl_init($url);curl_setopt($curl, CURLOPT_TIMEOUT,$timeout);curl_setopt($curl, CURLOPT_CONNECTTIMEOUT,$timeout);curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);$page=curl_exec($curl);curl_close($curl);return$page;}$cache='proxylist.txt';$maxage=432000;// If the script was called remotely we need to return the proxy list.if($_SERVER['REMOTE_ADDR']){// Send the proper headers so the browser can cache this page.if($mtime=@filemtime($cache)){if($_SERVER['HTTP_IF_MODIFIED_SINCE']&&$_SERVER['HTTP_IF_MODIFIED_SINCE']==gmdate('D, d M Y H:i:s',$mtime).' GMT'){header('HTTP/1.1 304 Not Modified');exit();}header('Last-Modified: '.gmdate('D, d M Y H:i:s',$mtime).' GMT');header('ETag: "'.md5($mtime.$_SERVER['SCRIPT_FILENAME']).'"');header('Expires: '.gmdate('D, d M Y H:i:s',$mtime+$maxage).' GMT');}header('Content-Type: text/plain');if($mtime<time()-$maxage){// We're re-caching the proxy list. Update the file modification time to play nice with multiple instances of this script.if(file_exists($cache)){touch($cache);}else{@file_put_contents($cache,null) or exit("Cannot write to $cache");}// Launch a separate process to re-cache the proxy list.exec("php {$_SERVER['SCRIPT_FILENAME']} > /dev/null &");}exit(file_get_contents($cache));}// If the script was called locally we need to update the cache. Get all the anonymous proxy list pages.$pnum=0;while($pnum<=$maxpnum){$page.= curl_func("http://www.xroxy.com/proxylist.php?type=Anonymous&pnum=$pnum");preg_match_all('/pnum=(\d+)/',$page,$matches);$link=array_pop($matches[1]);$maxpnum>=$link or $maxpnum=$link;$pnum++;}// Match the IP and port.preg_match_all('/&host=((?:[0-9]{1,3}\.){3}[0-9]{1,3})&port=(\d+)/',$page,$matches, PREG_SET_ORDER);// Check if the proxy is accepting connections and if so, add it to the listforeach($matchesas$row){if($fp=@fsockopen($row[1],$row[2],$errno,$errstr,5)){fclose($fp);$text.="{$row[1]}:{$row[2]}\n";}}file_put_contents($cache,$text);?>