Copy Code code as follows:
/********************************************
*
* Function Name: curl_string ($url, $proxy)
* Role: Detection agent IP Address
* Author: Plum Lin
* Date: 2011-11-09
*
********************************************/
function curl_string ($url, $proxy)
{
$user _agent = "mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.9.0.5) gecko/2008120122 firefox/3.0.5 firephp/0.2.1 ";
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_proxy, $proxy);
curl_setopt ($ch, Curlopt_url, $url);/Set IP to access
curl_setopt ($ch, curlopt_useragent, $user _agent);//simulate the browser used by the user
@curl_setopt ($ch, curlopt_followlocation, 1); Use automatic jump
curl_setopt ($ch, Curlopt_timeout, 120); Set timeout time
curl_setopt ($ch, Curlopt_autoreferer, 1); Automatically set Referer
curl_setopt ($ch, Curlopt_cookiejar, ' c:\cookie.txt ');
curl_setopt ($ch, Curlopt_header, 1);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_followlocation, 1);
curl_setopt ($ch, Curlopt_timeout, 10);
$result = curl_exec ($ch);
Check If any error occured
if ($result = = False)
{
Error_log (Date ("H:i:s"). ' Curl failed: '. Curl_error ($ch). "--". $proxy. " \ n ", 3, Mymedia." /log/'. Date (' y-m-d '). ' _err.log ');
}else{
Error_log (Date ("H:i:s"). ' Curl success: '. $proxy. " \ n ", 3, Mymedia." /log/'. Date (' y-m-d '). ' _ok.log ');
}
Curl_close ($ch);
return $result;
}