Using Default Login.
\n"; } else $default_acc = false; if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'FORM') { echo "\n"; echo "\n"; echo "\n"; echo "
 Email* 
 Password* 

*You can set it as default in ".basename(__FILE__)."
\n\n"; } else { $not_done = $login = false; $domain = 'rapidgator.net'; $referer = "http://$domain/"; // Login echo "\n
\n
Login to $domain
\n"; $cookie = array('lang' => 'en'); if (!empty($_REQUEST['up_login']) && !empty($_REQUEST['up_pass'])) { // Decrypt login if it was encrypted if (!empty($_REQUEST['A_encrypted'])) { $_REQUEST['up_login'] = decrypt(urldecode($_REQUEST['up_login'])); $_REQUEST['up_pass'] = decrypt(urldecode($_REQUEST['up_pass'])); unset($_REQUEST['A_encrypted']); } $post = array(); $post['LoginForm%5Bemail%5D'] = urlencode($_REQUEST['up_login']); $post['LoginForm%5Bpassword%5D'] = urlencode($_REQUEST['up_pass']); $post['LoginForm%5BrememberMe%5D'] = 1; if (!empty($_POST['step']) && $_POST['step'] == '1') { $_POST['step'] = false; if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.'); $cookie = StrToCookies(decrypt(urldecode($_POST['cookie']))); $post['LoginForm%5BverifyCode%5D'] = urlencode($_POST['captcha']); } //Redirects $rdc = 0; $page = false; // False value for starting the loop. $redir = "http://$domain/auth/login"; if (!empty($_POST['referer'])) $referer = $_POST['referer']; while (($redir = ChkRGRedirs($page, $redir, '(?:/auth/login|/site/ChangeLocation/key/)', $default_acc)) && $rdc < 15) { $page = cURL($redir, $cookie, $post, $referer); $cookie = GetCookiesArr($page, $cookie); $referer = $redir; $rdc++; } is_present($page, 'Wrong e-mail or password.', 'Login Failed: Invalid Email or Password.'); is_present($page, 'E-mail is not a valid email address.', 'Login Failed: Login isn\'t an email address.'); is_present($page, 'We discovered that you try to access your account from unusual location.', 'Login Failed: Login Blocked By IP, Check Account Email And Follow The Steps To Add IP to Whitelist.'); if (stripos($page, 'The code from a picture does not coincide') !== false) { if (!empty($post['LoginForm%5BverifyCode%5D'])) html_error('Login Failed: Incorrect CAPTCHA response.'); if (!preg_match('@(https?://(?:[^\./\r\n\'\"\t\:]+\.)?rapidgator\.net(?:\:\d+)?)?/auth/captcha/\w+/\w+@i', $page, $imgurl)) html_error('Error: CAPTCHA not found.'); $imgurl = (empty($imgurl[1])) ? 'http://rapidgator.net'.$imgurl[0] : $imgurl[0]; //Download captcha img. $captcha = explode("\r\n\r\n", cURL($imgurl, $this->cookie), 2); if (substr($captcha[0], 9, 3) != '200') html_error('Error downloading captcha img.'); $mimetype = (preg_match('@image/[\w+]+@', $captcha[0], $mimetype) ? $mimetype[0] : 'image/png'); $data = array(); $data['step'] = '1'; $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie))); $data['action'] = 'FORM'; // I should add 'premium_acc' to DefaultParamArr() if (!$default_acc) { $data['A_encrypted'] = 'true'; $data['up_login'] = urlencode(encrypt($_REQUEST['up_login'])); // encrypt() will keep this safe. $data['up_pass'] = urlencode(encrypt($_REQUEST['up_pass'])); // And this too. } EnterCaptcha("data:$mimetype;base64,".base64_encode($captcha[1]), $data, 5, 'Login'); exit; } //is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)'); is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)'); if (empty($cookie['user__'])) html_error("Login Error: Cannot find 'user__' cookie."); $cookie['lang'] = 'en'; $login = true; } else html_error('Login failed: User/Password empty.'); // Retrive upload ID echo "\n
Retrive upload ID
\n"; //Redirects $rdc = 0; $page = false; // False value for starting the loop. $redir = "http://$domain/"; while (($redir = ChkRGRedirs($page, $redir)) && $rdc < 15) { $page = cURL($redir, $cookie, 0, $referer); $cookie = GetCookiesArr($page, $cookie); $referer = $redir; $rdc++; } if (!preg_match('@var\s+form_url\s*=\s*"(https?://[^/|\"]+/[^\"]+)"\s*;@i', $page, $form_url) || !preg_match('@var\s+progress_url_web\s*=\s*"(https?://[^/|\"]+/[^\"]+)"\s*;@i', $page, $prog_url)) { is_present($page, 'Your storage space is full. Delete some files or upgrade to the new', 'Your storage space is full'); html_error('Error: Cannot find upload url.'); } $starttime = time(); $uuid = ''; $hexchars = str_split('0123456789abcdef'); for ($i = 0; $i < 32; $i++) $uuid .= $hexchars[array_rand($hexchars)]; $up_url = $form_url[1]."$uuid&folder_id=0"; // Uploading echo "\n"; $url = parse_url($up_url); $upfiles = upfile($url['host'], defport($url), $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), $referer, $cookie, array(), $lfile, $lname, 'file', '', $_GET['proxy'], $pauth, 0, $url['scheme']); // Upload Finished echo ""; is_page($upfiles); // Pool Upload echo "
Checking Finished Upload : Try 0
\n"; $x = 1; do { echo "\n"; sleep($x + 5); // A little wait //Redirects $rdc = 0; $page = false; // False value for starting the loop. $redir = $prog_url[1]."&data%5B0%5D%5Buuid%5D=$uuid&data%5B0%5D%5Bstart_time%5D=$starttime"; while (($redir = ChkRGRedirs($page, $redir)) && $rdc < 15) { $page = cURL($redir, $cookie, 0, $referer); $cookie = GetCookiesArr($page, $cookie); $referer = $redir; $rdc++; } $resp = json2array($page, "Cannot get upload status $x"); } while ($x++ < 5 && $resp[0]['state'] == 'processing'); if (!empty($resp[0]['download_url'])) { $download_link = $resp[0]['download_url']; if (!empty($resp[0]['remove_url'])) $delete_link = $resp[0]['remove_url']; } else html_error("Download link not found ({$resp[0]['state']})."); } function json2array($content, $errorPrefix = 'Error') { if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.'); if (empty($content)) return NULL; $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; } // Edited For upload.php usage. 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"; } function ChkRGRedirs($page, $lasturl, $rgpath = '/', $default_login = false) { // Edited for upload plugin usage. if (!is_array($lasturl)) $lasturl = parse_url($lasturl); if ($page === false) return rebuild_url($lasturl); $hpos = strpos($page, "\r\n\r\n"); $headers = empty($hpos) ? $page : substr($page, 0, $hpos); if (stripos($headers, "\nLocation: ") === false && stripos($headers, "\nSet-Cookie: ") === false && stripos($headers, '', ''))) { if (empty($_REQUEST['rgredir'])) { if (!($body = cut_str($page, '', ''))) $body = $page; if (stripos($body, ' 'FORM', 'referer' => rebuild_url($lasturl), 'rgredir' => ''); if (!$default_login) { $data['A_encrypted'] = 'true'; $data['up_login'] = urlencode(encrypt($_REQUEST['up_login'])); $data['up_pass'] = urlencode(encrypt($_REQUEST['up_pass'])); } if (!($js = cut_str($body, '')) && !($js = cut_str($body, ''))) html_error('Cannot get the redirect code.'); $js = str_ireplace(array('window.location.href','document.location.href'), 'document.getElementById("rgredir").value', $js); if (strpos($js, 'document.body.onmousemove') !== false) { // New redirect code $js = preg_replace('@^[\s\t]*\w+\([^\;]+;@i', '', $js); $js = preg_replace('@document\.body\.onmousemove[\s\t]*=[\s\t]*function[\s\t]*\(\)[\s\t]*\{@i', '', $js); $js = preg_replace('@document\.body\.onmousemove[\s\t]*=[\s\t]*\'\';?\};[\s\t]*window\.setTimeout\([\s\t]*((\"[^\"]+\")|(\'[^\']+\'))[^\;]+;[\s\t\r\n]*$@i', '', $js); } elseif (($funcPos = stripos($js, 'function WriteA(')) !== false) { // JS + aaaaaaaaaaaaaaaaaaaaaaaaa $links = array(); if (preg_match_all('@]*\shref="((?:https?://(?:www\.)?rapidgator\.net)?/[^\"]+)"[^>]*\sid="([A-Za-z][\w\.\-]*)"@i', $body, $a)) $links = array_merge($links, array_combine($a[2], $a[1])); if (preg_match_all('@]*\sid="([A-Za-z][\w\.\-]*)"[^>]*\shref="((?:https?://(?:www\.)?rapidgator\.net)?/[^\"]+)"@i', $body, $a)) $links = array_merge($links, array_combine($a[1], $a[2])); if (empty($links)) html_error('Cannot get the redirect fields'); unset($a); $jsLinks = ''; foreach ($links as $key => $link) { if (strpos($link, '://') === false) $link = (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net' . $link; $jsLinks .= "$key: '".addslashes($link)."', "; } unset($links, $key, $link); $jsLinks = '{' . substr($jsLinks, 0, -2) . '}'; $func = substr($js, $funcPos); if (!preg_match('@\.getElementById\(([\$_A-Za-z][\$\w]*)\)@i', $func, $linkVar)) html_error('Cannot edit redirect JS'); $linkVar = $linkVar[1]; unset($func); $js = substr($js, 0, $funcPos)."\nvar T8RGLinks = $jsLinks;\nif ($linkVar in T8RGLinks) document.getElementById('rgredir').value = T8RGLinks[$linkVar];"; unset($jsLinks, $funcPos, $linkVar); } echo "\n

\n"; foreach ($data as $name => $input) echo "\n"; echo "
\n\n\n\n\n\n"; exit; } else { $_REQUEST['rgredir'] = rawurldecode($_REQUEST['rgredir']); if (strpos($_REQUEST['rgredir'], '://')) $_REQUEST['rgredir'] = parse_url($_REQUEST['rgredir'], PHP_URL_PATH); if (empty($_REQUEST['rgredir']) || substr($_REQUEST['rgredir'], 0, 1) != '/') html_error('Invalid redirect value.'); $redir = (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net'.$_REQUEST['rgredir']; unset($_REQUEST['rgredir']); } } elseif (preg_match('@Location: ((https?://(?:[^/\r\n]+\.)?rapidgator\.net)?'.$rgpath.'[^\r\n]*)@i', $headers, $redir)) $redir = (empty($redir[2])) ? (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net'.$redir[1] : $redir[1]; return (empty($redir) ? false : $redir); } // [09-9-2012] Written by Th3-822. // [02-10-2012] Fixed for new weird redirect code. - Th3-822 // [31-10-2012] Fixed for https on login/redirects. - Th3-822 // [28-1-2013] Added Login captcha support. - Th3-822 // [14-6-2013] Removed https from first login try, for avoid block. - Th3-822 // [10-8-2013] Fixed redirects (again). - Th3-822 // [05-10-2013] Removed anon user support. - Th3-822 // [25-11-2013] Fixed redirects function (aagain :D ). - Th3-822 // [16-12-2015][WIP] Fixing Blocks, Redirect Handling & Forcing Plugin To Use cURL. - Th3-822 // [27-11-2016] Added wait and retries to get download_link. - Th3-822 ?>