baseUrl = 'https://rapidgator.net/';
$link = parse_url($link);
$link['scheme'] = 'https';
$link['host'] = 'rapidgator.net';
$this->link = $GLOBALS['Referer'] = $link = rebuild_url($link);
$this->cookie = array('lang' => 'en');
$this->DLregexp = '@https?://(?:pr|(s))\d+\.rapidgator\.net/(?(1)download/)[^\s\"\'<>]+@i';
if ((empty($_POST['step']) || !in_array($_POST['step'], array('1', '2', 'L'))) && (empty($_GET['rgredir']) || (stripos($_GET['rgredir'], '/auth/login') === false && stripos($_GET['rgredir'], '/site/ChangeLocation/key/') === false))) {
// Weird RG redirects.
$rdc = 0;
$this->page = false; // False value for starting the loop.
$redir = $this->link;
$this->referer = !empty($GLOBALS['Referer']) ? $GLOBALS['Referer'] : $this->link;
while (($redir = $this->ChkRGRedirs($this->page, $redir)) && $rdc < 15) {
$this->page = cURL($redir, $this->cookie, 0, $this->referer);
$this->cookie = GetCookiesArr($this->page, $this->cookie);
$this->referer = $redir;
$rdc++;
}
// I haven't tested those redirects fine so i will check this too.
if (stripos($redir, 'rapidgator.net/file/') === false) {
$this->page = cURL($this->link, $this->cookie, 0, $this->referer);
$this->cookie = GetCookiesArr($this->page, $this->cookie);
}
is_present($this->page, '>File not found<', 'File not found.');
}
if ($_REQUEST['premium_acc'] == 'on' && ((!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) || (!empty($GLOBALS['premium_acc']['rapidgator_net']['user']) && !empty($GLOBALS['premium_acc']['rapidgator_net']['pass'])))) {
$this->Login();
} else html_error('Login Failed: User or Password is empty.');
}
private function PremiumDL() {
$page = cURL($this->link, $this->cookie);
if (preg_match('@You have reached quota of downloaded information for premium accounts. At the moment, the quota is \d+ [GT]B(?: per \d+ day\(s\))?@i', $page, $err)) html_error($err[0]);
if (!preg_match($this->DLregexp, $page, $dlink)) html_error('Error: Download-link not found.');
$this->RedirectDownload($dlink[0], 'rapidgatorpr');
}
private function Login() {
if (!empty($_REQUEST['pA_encrypted']) && !empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) {
$_REQUEST['premium_user'] = decrypt(urldecode($_REQUEST['premium_user']));
$_REQUEST['premium_pass'] = decrypt(urldecode($_REQUEST['premium_pass']));
unset($_REQUEST['pA_encrypted']);
}
$pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
$user = ($pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['rapidgator_net']['user']);
$pass = ($pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['rapidgator_net']['pass']);
if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty. Please check login data.');
$this->cookie = array('lang' => 'en'); // Account is always showed as free if it comes from a file, as i don't send file's link as referer, lets reset the cookies.
if (($page = $this->cJar_load($user, $pass))) {
// Account loaded from Cookie Storage
is_present($page, '>Free', 'Account isn\'t premium');
return $this->PremiumDL();
}
$post = array();
$post['LoginForm%5Bemail%5D'] = urlencode($user);
$post['LoginForm%5Bpassword%5D'] = urlencode($pass);
$post['LoginForm%5BrememberMe%5D'] = '1';
if (!empty($_POST['step']) && $_POST['step'] == 'L') {
$_POST['step'] = false;
if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
$this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
$post['LoginForm%5BverifyCode%5D'] = urlencode($_POST['captcha']);
}
// There are more of those redirects at login
$rdc = 0;
$page = false; // False value for starting the loop.
$redir = $this->baseUrl . 'auth/login';
$this->referer = !empty($GLOBALS['Referer']) && $GLOBALS['Referer'] != $this->link ? $GLOBALS['Referer'] : $this->baseUrl;
while (($redir = $this->ChkRGRedirs($page, $redir, '(?:/auth/login|/site/ChangeLocation/key/)')) && $rdc < 15) {
$page = cURL($redir, $this->cookie, $post, $this->referer);
$this->cookie = GetCookiesArr($page, $this->cookie);
$this->referer = $redir;
$rdc++;
}
is_present($page, 'Wrong e-mail or password.', 'Login Failed: Email/Password incorrect.');
is_present($page, 'E-mail is not a valid email address.', 'Login Failed: Login isn\'t an email address.');
is_present($page, 'Frequent logins.', 'Too frequent logins, please wait and try again.');
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])) ? $this->baseUrl . substr($imgurl[0], 1) : $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 = $this->DefaultParamArr($this->link, CookiesToStr($this->cookie), 1, 1);
$data['step'] = 'L';
$data['premium_acc'] = 'on'; // I should add 'premium_acc' to DefaultParamArr()
if ($pA) {
$data['pA_encrypted'] = 'true';
$data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
$data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
}
$this->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)');
if (empty($this->cookie['user__'])) html_error("Login Error: Cannot find 'user__' cookie.");
$this->cookie['lang'] = 'en';
$this->cJar_save();
$page = cURL($this->baseUrl, $this->cookie, 0, $this->baseUrl . 'auth/login');
is_present($page, '>Free', 'Account isn\'t premium.');
return $this->PremiumDL();
}
private function ChkRGRedirs($page, $lasturl, $rgpath = '/') {
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, '')) && !($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\n\n\n\n