\?]+@i';
private $ignoreApiDLCaptcha = false;
public function Download($link) {
if (!preg_match('@https?://openload\.co/f/([\w-]+)@i', str_ireplace(array('://www.openload.co', '/embed/'), array('://openload.co', '/f/'), $link), $fid)) html_error('Invalid link?.');
$this->link = $GLOBALS['Referer'] = str_ireplace('http://', 'https://', $fid[0]);
$this->elink = str_ireplace('/f/', '/embed/', $this->link);
$this->fid = $fid[1];
if (empty($_POST['step'])) $this->testLink();
else if ($_POST['step'] == '1') return $this->ApiDLPost();
else if ($_POST['step'] == '42') return $this->processAnswer();
$this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($GLOBALS['premium_acc']['openload_co']['user']) && !empty($GLOBALS['premium_acc']['openload_co']['pass']))))) {
$user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['openload_co']['user']);
$pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['openload_co']['pass']);
if ($this->pA && !empty($_POST['pA_encrypted'])) {
$user = decrypt(urldecode($user));
$pass = decrypt(urldecode($pass));
unset($_POST['pA_encrypted']);
}
return $this->Login($user, $pass);
} else return $this->AnonDL();
}
private function testLink() {
$this->page = $this->GetPage($this->link, $this->cookie);
$this->cookie = GetCookiesArr($this->page, $this->cookie);
if (stripos($this->page, 'We can\'t find the file you are looking for.') !== false) {
$this->page = $this->GetPage($this->elink, $this->cookie);
is_present($this->page, 'We can\'t find the file you are looking for.', 'File Not Found.');
$this->cookie = GetCookiesArr($this->page, $this->cookie);
}
}
private function processAnswer() {
if (empty($_POST['streamurl'])) return html_error('Decoded Download-Link Empty');
else if (($DL = $this->testStreamToken($_POST['streamurl']))) return $this->RedirectDownload($DL, urldecode(parse_url($DL, PHP_URL_PATH)));
return html_error('Decoded Download-Link Invalid or Not Found');
}
private function AnonDL() {
// ApiDL
try {
return $this->tryApiDL();
} catch (Exception $e) {
$this->changeMesg(sprintf('
Anon_ApiDL Failed: "%s"', htmlspecialchars($e->getMessage(), ENT_QUOTES)), true);
}
// WebDL
return $this->WebDL();
}
private function tryApiDL($login = 0, $key = 0) {
$query = array('file' => $this->fid);
if (!empty($login) && !empty($key)) {
$query['login'] = $login;
$query['key'] = $key;
}
$ticket = $this->ApiReq('file/dlticket', $query);
if (empty($ticket['ticket'])) throw new Exception('Token not Found');
if (!empty($ticket['wait_time']) && $ticket['wait_time'] > 0) $this->CountDown($ticket['wait_time']);
if (!empty($ticket['captcha_url'])) {
// Got CAPTCHA
if ($this->ignoreApiDLCaptcha) throw new Exception('ignoreApiDLCaptcha is true');
$data = $this->DefaultParamArr($this->link);
$data['step'] = '1';
$data['ticket'] = $ticket['ticket'];
list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage($ticket['captcha_url']), 2);
if (substr($headers, 9, 3) != '200') throw new Exception('Error downloading captcha img');
$mimetype = (preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/png');
return $this->EnterCaptcha("data:$mimetype;base64," . base64_encode($imgBody), $data);
}
// Download
unset($query['login'], $query['key']);
$query['ticket'] = $ticket['ticket'];
$DL = $this->ApiReq('file/dl', $query);
if (empty($DL['url'])) throw new Exception('Download Link not Found');
return $this->RedirectDownload($DL['url'], 'T8_ol_adl');
}
private function ApiDLPost() {
if (empty($_POST['ticket'])) html_error('ApiDLPost: Ticket not Found.');
if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
try {
$DL = $this->ApiReq('file/dl', array('file' => $this->fid, 'ticket' => $_POST['ticket'], 'captcha_response' => $_POST['captcha']));
} catch (Exception $e) {
html_error(sprintf('ApiDLPost Error: "%s"', htmlspecialchars($e->getMessage(), ENT_QUOTES)));
}
if (empty($DL['url'])) html_error('ApiDLPost: Download Link not Found.');
return $this->RedirectDownload($DL['url'], 'T8_ol_adl_c');
}
private function getAAScript($page) {
if (preg_match_all('@゚ω゚ノ.+?\(\'_\'\);@i', $page, $scripts)) {
foreach ($scripts[0] as $script) {
$script = (new AADecoder)->decode($script);
if (stripos($script, 'String.fromCharCode') !== false && stripos($script, '#streamurl') !== false) {
return $script;
}
}
}
return false;
}
private function testStreamToken($token) {
if (!preg_match($this->DLRegexp, $token, $DL)) {
if (!preg_match("@{$this->fid}~\d{10}~(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)~[\w\-]{8}(?:\?|$)@", $token)) return false;
$page = $this->GetPage("https://openload.co/stream/$token?mime=true");
if (!preg_match($this->DLRegexp, $page, $DL)) return html_error('Stream Download-Link Not Found.');
if ($this->fid != 'KDA_8nZ2av4' && strpos($DL[0], '/KDA_8nZ2av4/x.mp4') !== false) return false; // :P
}
return $DL[0];
}
private function WebDL() {
if (!($script = $this->getAAScript($this->page))) html_error('Obsfuscated JS Not Found.');
# if (preg_match('@var\s+secondsdl\s*=\s*(\d+)\s*;@', $this->page, $cD) && $cD[1] > 0) $this->CountDown($cD[1]);
$data = $this->DefaultParamArr($this->link);
$data['step'] = '42';
$data['streamurl'] = '';
$T8 = '';
if (preg_match_all('@\$[\s\t]*\([\s\t]*[\"\']#([a-z][\w\.\-]*)[\"\'][\s\t]*\)@i', $script, $ids) && count($ids[0]) > 1) {
foreach (array_unique($ids[1]) as $id) {
if ($id == 'streamurl') continue;
if (!preg_match("@<([a-z][a-z\d]*)\s*(?:\w+\s*=\s*[\"\'][^\"\'<>]*[\"\']\s*)*(?:\s*id\s*=[\"\']{$id}[\"\']\s*)(?:\w+\s*=\s*[\"\'][^\"\'<>]*[\"\']\s*)*(?:\s*>([!-~]+)\\1>|(/)?\s*>)@i", $this->page, $tag)) break; // If it doesn't found the tag the decode will fail, im not sure if break or continue...
$T8 .= (!empty($tag[2]) ? $tag[0] : (empty($tag[3]) ? $tag[0].''.$tag[1].'>' : $tag[0]));
}
}
$script = preg_replace('@\.text\(\s*(?!\))@', '.val(', str_replace('streamurl', 'T8_streamurl', $script));
echo "\n