function cURL($link, $cookie = 0, $post = 0, $referer = 0, $auth = 0, $opts = 0) { global $pauth; static $ch, $lastProxy; if (empty($link) || !is_string($link)) { html_error(lang(24)); } if (!extension_loaded('curl') || !function_exists('curl_init') || !function_exists('curl_exec')) { html_error('cURL isn\'t enabled or cURL\'s functions are disabled'); } $arr = explode("\r\n", $referer); $header = array(); if (count($arr) > 1) { $referer = $arr[0]; unset($arr[0]); $header = array_filter(array_map('trim', $arr)); } $link = str_replace(array(' ', "\r", "\n"), array('%20'), $link); $opt = array(CURLOPT_HEADER => 1, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 0, CURLOPT_FAILONERROR => 0, CURLOPT_FORBID_REUSE => 0, CURLOPT_FRESH_CONNECT => 0, CURLINFO_HEADER_OUT => 1, CURLOPT_URL => $link, CURLOPT_SSLVERSION => defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1, CURLOPT_USERAGENT => rl_UserAgent); // Fixes "Unknown cipher in list: TLSv1" on cURL with NSS $cV = curl_version(); if (!empty($cV['ssl_version']) && strtoupper(substr($cV['ssl_version'], 0, 4)) != 'NSS/') { $opt[CURLOPT_SSL_CIPHER_LIST] = 'TLSv1'; } // Uncomment next line if do you have IPv6 problems // $opt[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; $opt[CURLOPT_REFERER] = !empty($referer) ? $referer : false; $opt[CURLOPT_COOKIE] = !empty($cookie) ? is_array($cookie) ? CookiesToStr($cookie) : trim($cookie) : false; if (isset($_GET['useproxy']) && !empty($_GET['proxy'])) { $opt[CURLOPT_HTTPPROXYTUNNEL] = strtolower(parse_url($link, PHP_URL_SCHEME) == 'https') ? true : false; // cURL https proxy support... Experimental. // $opt[CURLOPT_HTTPPROXYTUNNEL] = false; // Uncomment this line for disable https proxy over curl. $opt[CURLOPT_PROXY] = $_GET['proxy']; $opt[CURLOPT_PROXYUSERPWD] = !empty($pauth) ? base64_decode($pauth) : false; } else { $opt[CURLOPT_PROXY] = false; } // Send more headers... $headers = array('Accept-Language: en-US,en;q=0.9', 'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7', 'Pragma: no-cache', 'Cache-Control: no-cache', 'Connection: Keep-Alive'); if (empty($opt[CURLOPT_REFERER])) { $headers[] = 'Referer:'; } if (empty($opt[CURLOPT_COOKIE])) { $headers[] = 'Cookie:'; } if (!empty($opt[CURLOPT_PROXY]) && empty($opt[CURLOPT_PROXYUSERPWD])) { $headers[] = 'Proxy-Authorization:'; } if (count($header) > 0) { $headers = array_merge($headers, $header); } $opt[CURLOPT_HTTPHEADER] = $headers; if ($post != '0') { $opt[CURLOPT_POST] = 1; $opt[CURLOPT_POSTFIELDS] = is_array($post) ? formpostdata($post) : $post; } else { $opt[CURLOPT_HTTPGET] = 1; } if ($auth) { $opt[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; $opt[CURLOPT_USERPWD] = base64_decode($auth); } else { $opt[CURLOPT_HTTPAUTH] = false; } $opt[CURLOPT_CONNECTTIMEOUT] = $opt[CURLOPT_TIMEOUT] = 120; if (is_array($opts) && count($opts) > 0) { foreach ($opts as $O => $V) { $opt[$O] = $V; } } if (!isset($lastProxy)) { $lastProxy = $opt[CURLOPT_PROXY]; } if (!isset($ch)) { $ch = curl_init(); } elseif ($lastProxy != $opt[CURLOPT_PROXY]) { // cURL seems that doesn't like switching proxies on a active resource, there is a bug about that @ https://bugs.php.net/bug.php?id=68211 curl_close($ch); $ch = curl_init(); $lastProxy = $opt[CURLOPT_PROXY]; } foreach ($opt as $O => $V) { curl_setopt($ch, $O, $V); } // Using this instead of 'curl_setopt_array' $page = curl_exec($ch); $info = curl_getinfo($ch); $errz = curl_errno($ch); $errz2 = curl_error($ch); // curl_close($ch); if (substr($page, 9, 3) == '100' || !empty($opt[CURLOPT_PROXY])) { $page = preg_replace("@^HTTP/1\\.[01] \\d{3}(?:\\s[^\r\n]+)?\r\n\r\n(HTTP/1\\.[01] \\d+ [^\r\n]+)@i", "\$1", $page, 1); } // The "100 Continue" or "200 Connection established" can break some functions in plugins, lets remove it... if ($errz != 0) { html_error("[cURL:{$errz}] {$errz2}"); } return $page; }
function ssl_curl($link, $post = 0, $cookie = 0, $refer = 0) { $mm = !empty($post) ? 1 : 0; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $link); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U;Windows NT 5.1; de;rv:1.8.0.1)\\r\\nGecko/20060111\\r\\nFirefox/1.5.0.1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if ($mm == 1) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, formpostdata($post)); } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $contents .= curl_exec($ch); curl_close($ch); return $contents; }
function cURL($link, $cookie = 0, $post = 0, $referer = 0, $auth = 0, $opts = 0) { global $pauth; if (empty($link) || !is_string($link)) { html_error(lang(24)); } if (!extension_loaded('curl') || !function_exists('curl_init') || !function_exists('curl_exec')) { html_error('cURL isn\'t enabled or cURL\'s functions are disabled'); } $arr = explode("\r\n", $referer); $header = array(); if (count($arr) > 1) { $referer = $arr[0]; unset($arr[0]); $header = array_filter(array_map('trim', $arr)); } $opt = array(CURLOPT_HEADER => 1, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 0, CURLOPT_FAILONERROR => 0, CURLOPT_FORBID_REUSE => 1, CURLOPT_FRESH_CONNECT => 1, CURLINFO_HEADER_OUT => 1, CURLOPT_USERAGENT => 'Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.12'); if (!empty($referer)) { $opt[CURLOPT_REFERER] = $referer; } if (!empty($cookie)) { $opt[CURLOPT_COOKIE] = is_array($cookie) ? CookiesToStr($cookie) : trim($cookie); } // Send more headers... $headers = array('Accept-Language: en-US;q=0.7,en;q=0.3', 'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7', 'Pragma: no-cache', 'Cache-Control: no-cache', 'Connection: Close'); if (count($header) > 0) { $headers = array_merge($headers, $header); } $opt[CURLOPT_HTTPHEADER] = $headers; if ($post != '0') { $opt[CURLOPT_POST] = 1; $opt[CURLOPT_POSTFIELDS] = is_array($post) ? formpostdata($post) : $post; } if ($auth) { $opt[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; $opt[CURLOPT_USERPWD] = base64_decode($auth); } if (isset($_GET['useproxy']) && !empty($_GET['proxy'])) { $opt[CURLOPT_HTTPPROXYTUNNEL] = false; $opt[CURLOPT_PROXY] = $_GET['proxy']; if ($pauth) { $opt[CURLOPT_PROXYUSERPWD] = base64_decode($pauth); } } $opt[CURLOPT_CONNECTTIMEOUT] = $opt[CURLOPT_TIMEOUT] = 120; if (is_array($opts) && count($opts) > 0) { foreach ($opts as $O => $V) { $opt[$O] = $V; } } $link = str_replace(array(' ', "\r", "\n"), array('%20'), $link); $ch = curl_init($link); foreach ($opt as $O => $V) { curl_setopt($ch, $O, $V); } // Using this instead of 'curl_setopt_array' $page = curl_exec($ch); $info = curl_getinfo($ch); $errz = curl_errno($ch); $errz2 = curl_error($ch); curl_close($ch); if (substr($page, 9, 3) == '100') { $page = preg_replace("@^HTTP/1\\.1 100 Continue\r\n\r\n(HTTP/1\\.1 \\d+ [^\r|\n]+)@i", "\$1", $page, 1); } // The "100 Continue" can break some functions in plugins, lets remove it... if ($errz != 0) { html_error("[cURL:{$errz}] {$errz2}"); } return $page; }
function IF_cURL($link, $post) { // Yes, it's from the youtube plugin. $opt = array(CURLOPT_HEADER => 1, CURLOPT_REFERER => $link, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2"); $opt[CURLOPT_POST] = 1; $opt[CURLOPT_POSTFIELDS] = formpostdata($post); $ch = curl_init($link); foreach ($opt as $O => $V) { // Using this instead of 'curl_setopt_array' curl_setopt($ch, $O, $V); } $page = curl_exec($ch); $errz = curl_errno($ch); $errz2 = curl_error($ch); curl_close($ch); if ($errz != 0) { html_error("IF:[cURL:{$errz}] {$errz2}"); } return $page; }