/**
* Analog Landing
* $url Request Address
* $post the data to be post
* $cookie cookies to be taken at the time of landing
* $cookiejar where the cookie is to be stored, such as/tmp/test.cookie
* $referer page address
*
**/
function Vcurl ($url, $post = ', $cookie = ', $cookiejar = ', $referer = ') {
$tmpInfo = ';
A file for storing cookies
Initialize Curl
$curl = Curl_init ();
Set the target URL
curl_setopt ($curl, Curlopt_url, $url);
Use the browser proxy currently in use
curl_setopt ($curl, curlopt_useragent, $_server[' http_user_agent ']);
curl_setopt ($curl, Curlopt_useragent, "mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.0) ");
Sets the Referer header if there is a ref parameter, otherwise automatically sets the Referer header
if ($referer) {
curl_setopt ($curl, Curlopt_referer, $referer);
} else {
curl_setopt ($curl, Curlopt_autoreferer, 1);
}
If there is a post data parameter, the method is post and the data is set, otherwise the get
if ($post) {
Send a regular POST request with the default type: Application/x-www-form-urlencoded,www.111cn.net form submission
curl_setopt ($curl, Curlopt_post, 1);
curl_setopt ($curl, Curlopt_postfields, $post);
}
If there is a cookie parameter, set the
if ($cookie) {
curl_setopt ($curl, Curlopt_cookie, $cookie);
}
If there is a cookie file parameter, set the access cookie file name
if ($cookiejar) {
curl_setopt ($curl, Curlopt_cookiejar, $cookiejar);
curl_setopt ($curl, Curlopt_cookiefile, $cookiejar);
}
If it is 302 transfer, then return the transferred URL and content
curl_setopt ($curl, curlopt_followlocation, 1);
Sets the maximum number of seconds to execute
curl_setopt ($curl, curlopt_timeout, 100);
Returns whether header information is included in the content
curl_setopt ($curl, Curlopt_header, 0);
To have the returned result in a file or variable instead of appearing directly in the browser
curl_setopt ($curl, Curlopt_returntransfer, 1);
Return result after function is executed
$tmpInfo = curl_exec ($curl);
If an error occurs, an error message is displayed
if (Curl_errno ($curl)) {
$tmpInfo = ' <pre><b> error: </b><br/> '. Curl_error ($curl);
}
Close Curl Object
Curl_close ($curl);
return results
return $tmpInfo;
}
|