· 9 years ago · Jun 25, 2016, 09:18 PM
1<?php
2
3if (!defined('RAPIDLEECH')) {
4 require_once('index.html');
5 exit();
6}
7
8if (!file_exists(HOST_DIR . 'download/GenericXFS_DL.php')) html_error('Cannot load "'.htmlentities(HOST_DIR).'download/GenericXFS_DL.php" (File doesn\'t exists)');
9require_once(HOST_DIR . 'download/GenericXFS_DL.php');
10
11class filejoker_net extends GenericXFS_DL {
12 public $pluginVer = 14;
13 public function Download($link) {
14 $this->wwwDomain = false; // Switch to true if filehost forces it's domain with www.
15 $this->cname = 'xfss'; // Session cookie name
16 $this->sslLogin = false; // Force https on login.
17 $this->embedDL = false; // Try to unpack player's js for finding download link. (Only hosts with video player)
18 $this->unescaper = false; // Enable JS unescape decoder.
19
20 // Custom Download Regexp
21 $this->DLregexp = '@https?://(?:[\w\-]+\.)+[\w\-]+(?:\:\d+)?/\w{72}/[^\t\r\n<>\'\"\?\&]+@i';
22
23 $this->Start($link);
24 }
25
26 protected function sendLogin($post) {
27 $page = $this->GetPage($this->purl . '/login', $this->cookie, $post, $this->purl . "\r\nX-Requested-With: XMLHttpRequest");
28 return $page;
29 }
30
31 protected function Login() {
32 $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
33 $pkey = str_ireplace(array('www.', '.'), array('', '_'), $this->domain);
34 if (($_REQUEST['premium_acc'] != 'on' || (!$this->pA && (empty($GLOBALS['premium_acc'][$pkey]['user']) || empty($GLOBALS['premium_acc'][$pkey]['pass']))))) return $this->FreeDL();
35
36 $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc'][$pkey]['user']);
37 $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc'][$pkey]['pass']);
38 if ($this->pA && !empty($_POST['pA_encrypted'])) {
39 $user = decrypt(urldecode($user));
40 $pass = decrypt(urldecode($pass));
41 unset($_POST['pA_encrypted']);
42 }
43 if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty. Please check login data.');
44
45 if (!($page = $this->CookieLogin($user, $pass))) {
46 $is_step = (!empty($_POST['step']) && $_POST['step'] == 'L');
47 if ($is_step) {
48 $_POST['step'] = false;
49 if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
50 }
51
52 $post = array();
53 $post['op'] = 'login';
54 $post['redirect'] = '';
55 $post['email'] = urlencode($user);
56 $post['password'] = urlencode($pass);
57 $post['recaptcha_response_field'] = !empty($_POST['recaptcha_response_field']) ? urlencode($_POST['recaptcha_response_field']) : '';
58 $post['recaptcha_challenge_field'] = !empty($_POST['recaptcha_challenge_field']) ? urlencode($_POST['recaptcha_challenge_field']) : '';
59 $post['rand'] = '';
60
61 $page = $this->sendLogin($post);
62
63 if (stripos($page, 'data-captcha="yes"') !== false) {
64 if ($is_step) html_error('Wrong Captcha Entered.');
65 $data = $this->DefaultParamArr($this->link, $this->cookie, 1, 1);
66 $data['step'] = 'L';
67 if ($this->pA) {
68 $data['pA_encrypted'] = 'true';
69 $data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
70 $data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
71 }
72 $this->reCAPTCHA('6LetAu0SAAAAACCJkqZLvjNS4L7eSL8fGxr-Jzy2', $data); // Hardcoded reCAPTCHA id.
73 exit();
74 }
75
76 if (!$this->checkLogin($page)) html_error('Login Error: checkLogin() returned false.');
77
78 $this->cookie = GetCookiesArr($page);
79 if (empty($this->cookie[(!empty($this->cname) ? $this->cname : 'xfss')])) html_error('Login Error: Cannot find session cookie.');
80 $this->cookie['lang'] = 'english';
81
82 $page = $this->isLoggedIn();
83 if (!$page) html_error('Login Error: isLoggedIn() returned false.');
84 }
85
86 return $this->checkAccount($page);
87 }
88
89 protected function isLoggedIn() {
90 $page = $this->GetPage($this->purl.'profile', $this->cookie, 0, $this->purl.'login');
91 if (stripos($page, '>Logout</a>') === false) return false;
92 return $page;
93 }
94
95 private function IWillNameItLater($cookie, $decrypt=true) {
96 if (!is_array($cookie)) {
97 if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
98 return '';
99 }
100 if (count($cookie) < 1) return $cookie;
101 $keys = array_keys($cookie);
102 $values = array_values($cookie);
103 $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
104 $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
105 return array_combine($keys, $values);
106 }
107
108 // Edited
109 private function CookieLogin($user, $pass, $filename = 'filejoker_dl.php') {
110 global $secretkey;
111 if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty.');
112
113 $filename = DOWNLOAD_DIR . basename($filename);
114 if (!file_exists($filename)) return false;
115
116 $file = file($filename);
117 $savedcookies = unserialize($file[1]);
118 unset($file);
119
120 $hash = hash('crc32b', $user.':'.$pass);
121 if (array_key_exists($hash, $savedcookies)) {
122 $_secretkey = $secretkey;
123 $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user);
124 $testCookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
125 $secretkey = $_secretkey;
126 if (empty($testCookie) || (is_array($testCookie) && count($testCookie) < 1)) return false;
127
128 $oCookie = $this->cookie;
129 $this->cookie = $testCookie;
130 if ($page = $this->isLoggedIn()) {
131 $this->cookie['lang'] = 'english';
132 $this->SaveCookies($user, $pass); // Update cookies file
133 return $page;
134 }
135 $this->cookie = $oCookie;
136 }
137 return false;
138 }
139
140 private function SaveCookies($user, $pass, $filename = 'filejoker_dl.php') {
141 global $secretkey;
142 $maxdays = 31; // Max days to keep cookies saved
143 $filename = DOWNLOAD_DIR . basename($filename);
144 if (file_exists($filename)) {
145 $file = file($filename);
146 $savedcookies = unserialize($file[1]);
147 unset($file);
148
149 // Remove old cookies
150 foreach ($savedcookies as $k => $v) if (time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
151 } else $savedcookies = array();
152 $hash = hash('crc32b', $user.':'.$pass);
153 $_secretkey = $secretkey;
154 $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user);
155 $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
156 $secretkey = $_secretkey;
157
158 file_put_contents($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies), LOCK_EX);
159 }
160}
161
162// Written by Th3-822.
163
164?>