'); echo(''); echo(''); echo('
' . lang(300) . '
'); } /* * You can use this function to retrieve pages without parsing the link * @param string $link -> The link of the page to retrieve * @param string $cookie -> The cookie value if you need * @param array $post -> Array name=>value of the post data * @param string $referer -> The referer of the page, it might be the value you are missing if you can't get plugin to work * @param string $auth -> Page authentication, unneeded in most circumstances */ public function GetPage($link, $cookie = 0, $post = 0, $referer = 0, $auth = 0, $XMLRequest = 0) { if (!$referer && !empty($GLOBALS['Referer'])) { $referer = $GLOBALS['Referer']; } $cURL = $GLOBALS['options']['use_curl'] && extension_loaded('curl') && function_exists('curl_init') && function_exists('curl_exec') ? true : false; $Url = parse_url(trim($link)); if (strtolower($Url['scheme']) == 'https') { $chttps = false; if ($cURL) { $cV = curl_version(); if (in_array('https', $cV['protocols'], true)) $chttps = true; } if (!extension_loaded('openssl') && !$chttps) html_error('You need to install/enable PHP\'s OpenSSL extension to support HTTPS connections.'); elseif (!$chttps) $cURL = false; } if ($cURL) { if ($XMLRequest) $referer .= "\r\nX-Requested-With: XMLHttpRequest"; $page = cURL($link, $cookie, $post, $referer, $auth); } else { global $pauth; $page = geturl($Url['host'], defport($Url), $Url['path'] . (!empty($Url['query']) ? '?' . $Url['query'] : ''), $referer, $cookie, $post, 0, !empty($_GET['proxy']) ? $_GET['proxy'] : '', $pauth, $auth, $Url['scheme'], 0, $XMLRequest); is_page($page); } return $page; } /* * Use this function instead of insert_location so that we can improve this feature in the future * @param string $link -> The download link of the file * @param string $FileName -> The name of the file * @param string $cookie -> The cookie value * @param array $post -> The post value will be serialized here * @param string $referer -> The page that refered to this link * @param string $auth -> In format username:password * @param array $params -> This parameter allows you to add extra _GET values to be passed on */ public function RedirectDownload($link, $FileName = 0, $cookie = 0, $post = 0, $referer = 0, $force_name = 0, $auth = 0, $addon = array()) { if (!$referer && !empty($GLOBALS['Referer'])) { $referer = $GLOBALS['Referer']; } $url = parse_url($link); $params = $this->DefaultParamArr($link, $cookie, $referer, true); unset($params['premium_acc']); $params['filename'] = urlencode(basename((!empty($FileName) ? $FileName : urldecode(parse_url($link, PHP_URL_PATH))))); if (!empty($force_name)) $params['force_name'] = urlencode(basename($force_name)); $params['host'] = urlencode($url['host']); if (!empty($url['port'])) $params['port'] = urlencode($url['port']); $params['path'] = urlencode($url['path'] . (!empty($url['query']) ? '?' . $url['query'] : '')); if (!empty($post)) $params['post'] = urlencode(encrypt(serialize($post))); if (!empty($auth)) $params['auth'] = ($auth == '1' ? '1' : urlencode(encrypt(base64_encode($auth)))); if (!empty($addon)) { if (!is_array($addon)) html_error('Plugin problem! Please report, error: "The parameter passed must be an array"'); // Some problems with the plugin, quit it foreach ($addon as $name => $value) $params[$name] = (is_array($value) ? urlencode(serialize($value)) : urlencode($value)); } insert_location($params); } /* * Use this function to move your multiples links array to auto downloader * @param array $link_array -> Normal array containing all download links */ public function moveToAutoDownloader($link_array) { if (empty($link_array) || !is_array($link_array) || count($link_array) == 0) html_error('Error getting links from folder.'); if (!is_file('audl.php') || !empty($GLOBALS['options']['auto_download_disable'])) html_error('audl.php not found or you have disable auto download feature!'); $pos = strrpos($_SERVER['SCRIPT_NAME'], '/'); $audlpath = ($pos !== false) ? substr($_SERVER['SCRIPT_NAME'], 0, $pos + 1).'audl.php?GO=GO' : 'audl.php?GO=GO'; $inputs = GetDefaultParams(); $inputs['links'] = implode("\r\n", $link_array); $key_array = array('premium_acc', 'premium_user', 'premium_pass', 'cookieuse', 'cookie'); foreach ($key_array as $v) if (!empty($_GET[$v])) $inputs[$v] = urlencode($_GET[$v]); insert_location($inputs, $audlpath); exit(); } public function CountDown($countDown) { if ($countDown <= 0) return; insert_timer($countDown, 'Waiting link timelock.', '', true); } /* * Use this function to create Captcha display form * @param string $captchaImg -> The link of the captcha image or downloaded captcha image on server * @param array $inputs -> Key Value pairs for html form input elements ( these elements will be hidden form elements ) * @param string $captchaSize -> The size of captcha text box * @param string $sname -> The text of submit button * @param string $sname -> The name of captcha text field */ public function EnterCaptcha($captchaImg, $inputs, $captchaSize = '5', $sname = 'Enter Captcha', $iname = 'captcha') { echo "\n
\n"; foreach ($inputs as $name => $input) echo "\t\n"; echo "\t

" . lang(301) . " CAPTCHA Image " . lang(302) . ":   \n\t\t\n\t

\n\t\n
\n"; include(TEMPLATE_DIR.'footer.php'); exit(); } /* * This function will return an array with the Default Key Value pairs including proxy, method, email, etc. * @param string $link -> Adds the link value to the array url encoded if you need it. * @param string $cookie -> Adds the cookie value to the array url encoded if you need it. * @param string $referer -> Adds the referer value to the array url encoded if you need it. If isn't set, it will load $Referer value. (Set as 0 or false for not add it in the array.) */ public function DefaultParamArr($link = 0, $cookie = 0, $referer = 1, $encrypt = 0) { if ($referer === 1 || $referer === true) { global $Referer; $referer = $Referer; } if (!empty($cookie)) { if (is_array($cookie)) $cookie = CookiesToStr($cookie); if ($encrypt) $cookie = encrypt($cookie); } $DParam = GetDefaultParams(); if (!empty($link)) $DParam['link'] = $link; if (!empty($cookie)) $DParam['cookie'] = urlencode($cookie); if (!empty($referer)) $DParam['referer'] = $referer; return $DParam; } /* Use this function for filehost longer timelock * Param int $secs -> The number of seconds to count down * Param array $post -> Variable array to include as POST so you dont need to start over the process * Param $string $text -> Default text you want to display when counting down */ public function JSCountdown($secs, $post = 0, $text = '', $stop = 1, $onFinish = '') { if (empty($text)) $text = 'Waiting link timelock'; if (empty($onFinish)) $onFinish = (empty($post) ? 'location.reload();' : 'document.forms.js_timer.submit();'); echo "

ERROR: Please enable JavaScript. (Countdown)
Please wait

\n"; echo "
\n"; if (!empty($post) && is_array($post)) foreach ($post as $name => $input) echo "\n"; echo "

"; if ($stop) { include(TEMPLATE_DIR.'footer.php'); exit(); } } public function changeMesg($mesg, $add=false) { echo("\n"); } public function json2array($content, $errorPrefix = 'Error') { if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.'); if (empty($content)) html_error("[$errorPrefix]: No content."); $content = ltrim($content); if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4)); $cb_pos = strpos($content, '{'); $sb_pos = strpos($content, '['); if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found."); $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false; $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1); if (empty($content)) html_error("[$errorPrefix]: No JSON content."); $rply = json_decode($content, true); if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON."); return $rply; } public function reCAPTCHA($publicKey, $inputs, $referer = 0, $sname = 'Download File') { if (empty($publicKey) || preg_match('/[^\w\.\-]/', $publicKey)) html_error('Invalid reCAPTCHA public key.'); if (!is_array($inputs)) html_error('Error parsing captcha post data.'); $cookie = array('PREF' => 'LD=en'); // Check for a global recaptcha key $page = $this->GetPage('http://www.google.com/recaptcha/api/challenge?k=' . $publicKey, $cookie, 0, 'http://fakedomain.tld/fakepath'); if (substr($page, 9, 3) != '200') html_error('Invalid or deleted reCAPTCHA public key.'); $inputs['recaptcha_public_key'] = $publicKey; // This may be needed later. if (strpos($page, 'Invalid referer') === false && strpos($page, 'An internal error occurred') === false) { // Embed captcha echo "\n\n

\n"; foreach ($inputs as $name => $input) echo "\n"; echo "
\n\n
\n"; include(TEMPLATE_DIR.'footer.php'); } else { // Download captcha $page = $this->GetPage('http://www.google.com/recaptcha/api/challenge?k=' . $publicKey, $cookie, 0, $referer); if (strpos($page, 'Invalid referer') !== false) html_error('Error getting reCAPTCHA challenge: Bad referer'); if (strpos($page, 'An internal error occurred') !== false) html_error('Error getting reCAPTCHA challenge: Possible reCAPTCHA v2 or bad referer'); if (!preg_match('@[\{,\s]challenge\s*:\s*[\'\"]([\w\.\-]+)[\'\"]@', $page, $challenge)) html_error('Error getting reCAPTCHA challenge.'); $inputs['recaptcha_challenge_field'] = $challenge = $challenge[1]; list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage('http://www.google.com/recaptcha/api/image?c=' . $challenge, 0, 0, $referer), 2); if (substr($headers, 9, 3) != '200') html_error('Error downloading captcha img.'); $mimetype = (preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/jpeg'); $this->EnterCaptcha("data:$mimetype;base64,".base64_encode($imgBody), $inputs, 20, $sname, 'recaptcha_response_field'); } exit; } public function SolveMedia($publicKey, $data, $referer = 0, $sname = 'Download File') { if (!is_array($data)) html_error('Post needs to be sended in a array.'); if (empty($publicKey) || preg_match('@[^\w\-\.]@', $publicKey)) html_error('[SM] Invalid value for $publicKey'); $page = $this->GetPage("http://api.solvemedia.com/papi/challenge.noscript?k=$publicKey", 0, 0, $referer); is_present($page, 'domain / ckey mismatch', '[SM] Error getting CAPTCHA challenge: Bad referer.'); if (!preg_match('@]*src\s?=\s?\"((https?://[^/\"<>]+)?/papi/media[^\"<>]+)\"@i', $page, $imgurl)) html_error('[SM] CAPTCHA img not found.'); $imgurl = (empty($imgurl[2])) ? 'http://api.solvemedia.com'.$imgurl[1] : $imgurl[1]; if (!preg_match_all('@]*type\s?=\s?\"?hidden\"?[^/<>]*\s?name\s?=\s?\"(\w+)\"[^/<>]*\s?value\s?=\s?\"([^\"<>]+)\"[^/<>]*/?\s*>@i', $page, $forms)) html_error('[SM] CAPTCHA data not found.'); $forms = array_combine($forms[1], $forms[2]); foreach ($forms as $n => $v) $data["_smc[$n]"] = urlencode($v); $data['sm_public_key'] = $publicKey; // Required for verifySolveMedia() //Download captcha img. list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage($imgurl), 2); if (substr($headers, 9, 3) != '200') html_error('[SM] Error downloading CAPTCHA img.'); $mimetype = (preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/gif'); $this->EnterCaptcha("data:$mimetype;base64,".base64_encode($imgBody), $data, 20, $sname, 'adcopy_response'); exit; } public function verifySolveMedia($directOutput = false, $retryMethod = 'retrySolveMedia') { if (empty($_POST['adcopy_response'])) html_error('[SM] You didn\'t enter the image verification code.'); if (empty($_POST['_smc']) || !is_array($_POST['_smc'])) html_error('[SM] CAPTCHA data invalid.'); $post = array(); foreach ($_POST['_smc'] as $n => $v) $post[urlencode($n)] = $v; $post['adcopy_response'] = urlencode($_POST['adcopy_response']); $publicKey = $_POST['sm_public_key']; $link = 'http://api.solvemedia.com/papi/verify.noscript'; $page = $this->GetPage($link, 0, $post, 'http://api.solvemedia.com/papi/challenge.noscript?k=' . urlencode($publicKey)); if (!preg_match('@(https?://[^/\'\"<>\r\n]+)?/papi/verify\.pass\.noscript\?[^/\'\"<>\r\n]+@i', $page, $resp)) { if (stripos($page, '/papi/challenge.noscript') !== false) { $retryCallback = array($this, $retryMethod); if (is_callable($retryCallback)) { echo '[SM] Wrong CAPTCHA entered.

'; return call_user_func($retryCallback); } else html_error('[SM] Wrong CAPTCHA entered.'); } html_error('Error sending CAPTCHA.'); } $resp = (empty($resp[1])) ? 'http://api.solvemedia.com'.$resp[0] : $resp[0]; $page = $this->GetPage($resp, 0, 0, $link); if (!preg_match('@>\s*([^<>\s]+)\s*@i', $page, $gibberish)) html_error('[SM] CAPTCHA response not found.'); if ($directOutput) return urlencode($gibberish[1]); else return array('adcopy_challenge' => urlencode($gibberish[1]), 'adcopy_response' => 'manual_challenge'); } protected $rc2Page = array(); public function reCAPTCHAv2($publicKey, $inputs, $referer = 0, $sname = 'Download File') { if (empty($publicKey) || preg_match('/[^\w\.\-]/', $publicKey)) html_error('Invalid reCAPTCHA2 public key.'); if (!is_array($inputs)) html_error('[RC2] Error parsing captcha post data.'); $blink = 'http://www.google.com/recaptcha'; $link = "$blink/api/fallback?k=" . urlencode($publicKey); $cookie = array('PREF' => 'LD=en'); // Check key if (empty($this->rc2Page[$publicKey])) { $c = '[c] '; $this->rc2Page[$publicKey] = $page = $this->GetPage($link, $cookie, 0, ($referer !== 0 ? $referer : $link)); if (substr($page, 9, 3) != '200') html_error('Invalid or deleted reCAPTCHA2 public key.'); } else { $c = ''; $page = $this->rc2Page[$publicKey]; if (substr($page, 9, 3) != '200') html_error('[RC2] Invalid cached response.'); } $inputs['recaptcha2_public_key'] = $publicKey; // Required for validateReCaptchav2() // Download captcha if (!preg_match('@name="c" value="([\w\.\-]+)"@', $page, $challenge)) html_error("{$c}Error getting reCAPTCHA2 challenge."); $inputs['recaptcha2_challenge_field'] = $challenge = $challenge[1]; list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage("$blink/api2/payload?c=" . urlencode($challenge) . '&k=' . urlencode($publicKey), $cookie, 0, $link), 2); if (substr($headers, 9, 3) != '200') html_error("[RC2] {$c}Error downloading captcha img."); $imgBody = 'data:'.(preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/jpeg').';base64,' . base64_encode($imgBody); // Get Challenge Text/Picture if (!preg_match('@\s*<(?:(div)|label for="response") class="fbc-imageselect-message-(?:text|error)">(?>(.*?))@i', $page, $cMsg)) html_error("[RC2] {$c}Error getting challenge message."); if (empty($cMsg[1])) { if (!preg_match('@@i', $page, $addImage)) html_error("[RC2] {$c}Error getting challenge image."); $addImage = $addImage[1]; } else { $addImage = false; } $cMsg = $cMsg[3]; echo "\n
\n"; foreach ($inputs as $name => $input) echo "\t\n"; echo "
"; if (!empty($addImage)) echo ""; echo "
"; for ($x = 0; $x < 9; $x++) echo "\n"; echo "\n
\n"; include(TEMPLATE_DIR.'footer.php'); exit(); } public function verifyReCaptchav2($directOutput = false, $retryMethod = 'retryReCaptchav2') { if (empty($_POST['recaptcha2_challenge_field']) || empty($_POST['recaptcha2_public_key']) || preg_match('/[^\w\.\-]/', $_POST['recaptcha2_public_key'])) html_error('[RC2] Invalid / Missing reCaptcha2 data.'); if (empty($_POST['recaptcha2_response_field']) || !is_array($_POST['recaptcha2_response_field'])) html_error('[RC2] You didn\'t enter the image verification code.'); $publicKey = $_POST['recaptcha2_public_key']; $post = 'c=' . urlencode($_POST['recaptcha2_challenge_field']) . '&response=' . implode(array_map('urlencode', $_POST['recaptcha2_response_field']), '&response='); $link = 'http://www.google.com/recaptcha/api/fallback?k=' . urlencode($publicKey); $this->rc2Page[$publicKey] = $page = $this->GetPage($link, array('PREF' => 'LD=en'), $post, $link); is_present($page, 'Sorry, an error has occurred', '[RC2] Corrupted o Invalid reCaptcha2 Data.'); if (stripos($page, 'payload?c=') !== false) { $retryCallback = array($this, $retryMethod); if (is_callable($retryCallback)) { echo '[RC2] Wrong CAPTCHA entered.

'; return call_user_func($retryCallback); } else html_error('[RC2] retryMethod not found/callable.'); } if (stripos($page, 'Copy this code') === false) html_error('[RC2] Unknown error after sending captcha.'); if (!preg_match('@>\s*([^<>\s]+)\s*@i', $page, $gibberish)) html_error('[RC2] Validated response not found.'); if ($directOutput) return urlencode($gibberish[1]); else return array('g-recaptcha-response' => urlencode($gibberish[1])); } } /********************************************************** Added support of force_name in RedirectDownload function by Raj Malhotra on 02 May 2010 Fixed EnterCaptcha function ( Re-Write ) by Raj Malhotra on 16 May 2010 Added auto-encryption system (szal) 14 June 2010 Added GetPage support function for https connection by Th3-822 21 April 2011 Added GetPage support function for xml request by vdhdevil 9 July 2011 Tweaked DefaultParamArr code by Th3-822 22 July 2011 Moved JSCountdown function for future use by Th3-822 Add CheckBack function to test correctly download link by vdhdevil Remove declaration of checkback function, it automatically signed in the plugin itself Add new limitation options by Ruud v.Tony **********************************************************/ ?>