Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function yarzCurl($url, $fields=false, $cookie=false, $httpheader=false, $proxy=false, $encoding=false, $timeout=false)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- if($fields !== false)
- {
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
- }
- if($encoding !== false)
- {
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
- }
- if($cookie !== false)
- {
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
- }
- if($httpheader !== false)
- {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
- }
- if($proxy !== false)
- {
- curl_setopt($ch, CURLOPT_PROXY, $proxy);
- curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- }
- if($timeout !== false)
- {
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 6); //timeout in seconds
- }
- $response = curl_exec($ch);
- $header = substr($response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
- $body = substr($response, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
- curl_close($ch);
- return array($header, $body);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement