1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <?php
function ip_file(){ if(($fp=fopen("ip.txt","r"))==false){ echo "打开ip.txt失败!"; }else{
$counter = get_ip(); $fp=fopen("ip.txt","w"); fputs($fp,$counter); fclose($fp); } }
function read_ip(){ $fp=fopen("ip.txt","r"); $ip=fgets($fp,1024); fclose($fp); return $ip; } function get_ip() { $url = 'https://proxy.357.im/api/proxies/stable?protocol=http&anonymity=high_anonymous'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); $response = curl_exec($curl); $httpCode = curl_getinfo($curl,CURLINFO_HTTP_CODE); curl_close($curl); if($httpCode==200){ $json = json_decode($response); $json2 = $json->data; $json3 = json_to_array($json2); $str = $json3['protocol']."://".$json3['ip'].":".$json3['port']; } return $str; } function json_to_array($web){ $arr = array(); foreach($web as $k=>$w){ if(is_object($w)) $arr[$k]=$this->json_to_array($w); else $arr[$k]=$w; } return $arr; }
function isType(){ $ch = curl_init("http://www.xulirun.com"); $proxy = read_ip(); curl_setopt ($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); $result = curl_exec($ch); $httpCode = curl_getinfo($curl,CURLINFO_HTTP_CODE); curl_close($ch); curl_close($curl); if($httpCode==200){ return true; }else{ return false; } } ip_file();
|