Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit 2cd0823

Browse files
committed
Fixed FileFactory DL
Forced cURL to use HTTP/1.1 to avoid unforeseen consequences (λ)
1 parent 937187f commit 2cd0823

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

classes/http.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveT
131131
if (!empty($referer)) $request['referer'] = $referer;
132132
if (!empty($cookies)) $request['cookie'] = $cookies;
133133
$request['cache-control'] = $request['pragma'] = 'no-cache';
134-
// if ($Resume['use'] === TRUE) $request['range'] = 'bytes=' . $Resume['from'] . '-';
134+
// if (!empty($Resume['use']) && $Resume['use'] === TRUE) $request['range'] = 'bytes=' . $Resume['from'] . '-';
135135
if (!empty($auth)) $request['authorization'] = "Basic $auth";
136136
if (!empty($pauth) && !$scheme) $request['proxy-authorization'] = "Basic $pauth";
137137
if ($method == 'POST') {
@@ -297,7 +297,7 @@ function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveT
297297
return FALSE;
298298
}
299299
//$ContentType = trim (cut_str($header, "\nContent-Type:", "\n")); // Unused
300-
if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") === false) {
300+
if (!empty($Resume['use']) && $Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") === false) {
301301
$lastError = (stripos($header, '503 Limit Exceeded') !== false) ? lang(97) : lang(98);
302302
return FALSE;
303303
}
@@ -331,19 +331,19 @@ function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveT
331331

332332
$saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
333333

334-
if (@file_exists($saveToFile) && $Resume['use'] !== TRUE) {
334+
if (!empty($Resume['use']) && $Resume['use'] !== TRUE && @file_exists($saveToFile)) {
335335
if ($options['bw_save']) return html_error(lang(99) . ': ' . link_for_file($saveToFile));
336336
$FileName = time() . '_' . $FileName;
337337
$saveToFile = dirname($saveToFile) . PATH_SPLITTER . $FileName;
338338
}
339-
$fs = @fopen($saveToFile, ($Resume['use'] === TRUE ? 'ab' : 'wb'));
339+
$fs = @fopen($saveToFile, ((!empty($Resume['use']) && $Resume['use'] === TRUE) ? 'ab' : 'wb'));
340340
if (!$fs) {
341341
$lastError = sprintf(lang(101), $FileName, dirname($saveToFile)) . '<br />' . lang(102) . '<br /><a href="javascript:location.reload();">' . lang(103) . '</a>';
342342
return FALSE;
343343
}
344344

345345
flock($fs, LOCK_EX);
346-
if ($Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") !== false) {
346+
if (!empty($Resume['use']) && $Resume['use'] === TRUE && stripos($header, "\nContent-Range: ") !== false) {
347347
list($temp, $Resume['range']) = explode(' ', trim(cut_str($header, "\nContent-Range: ", "\n")));
348348
list($Resume['range'], $fileSize) = explode('/', $Resume['range']);
349349
$fileSize = bytesToKbOrMbOrGb($fileSize);
@@ -353,13 +353,13 @@ function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveT
353353

354354
//$scriptStarted = false;
355355
require_once(TEMPLATE_DIR . '/transloadui.php');
356-
if ($Resume['use'] === TRUE) {
356+
if (!empty($Resume['use']) && $Resume['use'] === TRUE) {
357357
$received = bytesToKbOrMbOrGb(filesize($saveToFile));
358358
$percent = round($Resume['from'] / ($bytesTotal + $Resume['from']) * 100, 2);
359359
echo "<script type='text/javascript'>pr('$percent', '$received', '0');</script>";
360360
//$scriptStarted = true;
361361
flush();
362-
}
362+
} else $Resume = array('use' => false, 'from' => 0, 'range' => 0);
363363

364364
$time = $last = $lastChunkTime = 0;
365365
do {
@@ -444,6 +444,7 @@ function cURL($link, $cookie = 0, $post = 0, $referer = 0, $auth = 0, $opts = 0)
444444
CURLOPT_FORBID_REUSE => 0, CURLOPT_FRESH_CONNECT => 0,
445445
CURLINFO_HEADER_OUT => 1, CURLOPT_URL => $link,
446446
CURLOPT_SSLVERSION => (defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1),
447+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
447448
CURLOPT_ENCODING => 'gzip, deflate', CURLOPT_USERAGENT => rl_UserAgent);
448449

449450
// Fixes "Unknown cipher in list: TLSv1" on cURL with NSS

hosts/download/filefactory_com.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
if (!defined('RAPIDLEECH')) {
3-
require_once ("index.html");
3+
require_once('index.html');
44
exit();
55
}
66

@@ -16,7 +16,7 @@ public function Download($link) {
1616
}
1717
unset($arr);
1818

19-
$this->link = $GLOBALS['Referer'] = str_ireplace('://filefactory.com/', '://www.filefactory.com/', $link);
19+
$this->link = $GLOBALS['Referer'] = str_ireplace(array('http://', '://filefactory.com/'), array('https://', '://www.filefactory.com/'), $link);
2020

2121
$post = empty($this->lpass) ? 0 : array('password' => urlencode($this->lpass), 'Submit' => 'Continue');
2222
$this->page = $this->GetPage($this->link, $this->cookie, $post);
@@ -26,15 +26,15 @@ public function Download($link) {
2626

2727
$X = 0;
2828
while ($X < 3 && preg_match('@\nLocation: .*(/(?:file|preview)/[^\r\n]+)@i', $this->page, $RD)) {
29-
$this->link = 'http://www.filefactory.com' . $RD[1];
29+
$this->link = 'https://www.filefactory.com' . $RD[1];
3030
$this->page = $this->GetPage($this->link, $this->cookie);
3131
$this->cookie = GetCookiesArr($this->page, $this->cookie);
3232
$X++;
3333
}
3434

3535
if (preg_match('@/error\.php\?code=(\d+)@i', $this->page, $this->redir) && !in_array($this->redir[1], array('257', '258')) /*Forcing PPS is not fair...*/) {
3636
if ($this->redir[1] == '160') html_error('IP banned by FF.');
37-
$page = $this->GetPage('http://www.filefactory.com'.$this->redir[0], $this->cookie);
37+
$page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
3838
if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $page, $err)) html_error("[FF:{$this->redir[1]}] ".htmlspecialchars($err[1]));
3939
html_error("Link is not available [{$this->redir[1]}]");
4040
}
@@ -57,13 +57,13 @@ private function CheckTS() {
5757
private function CheckPass() {
5858
if (stripos($this->page, 'This File has been password protected by the uploader.') !== false || stripos($this->page, '>Please enter the password</') !== false) {
5959
if (empty($this->lpass)) html_error('File is password protected, please send the password in this format: link|pass');
60-
else html_error('The link\'s password you have sended is not valid.');
60+
else html_error('The link\'s password you have sent is not valid.');
6161
}
6262
}
6363

6464
private function FreeDL() {
6565
if (!empty($this->redir)) {
66-
$page = $this->GetPage('http://www.filefactory.com'.$this->redir[0], $this->cookie);
66+
$page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
6767
if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $page, $err)) html_error("[FF:{$this->redir[1]}] ".htmlspecialchars($err[1]));
6868
html_error("Link is not available [{$this->redir[1]}]");
6969
}
@@ -85,14 +85,14 @@ private function PremiumDL() {
8585

8686
$X = 0;
8787
while ($X < 3 && preg_match('@\nLocation: .*(/(?:file|preview)/[^\r\n]+)@i', $this->page, $RD)) {
88-
$this->link = 'http://www.filefactory.com' . $RD[1];
88+
$this->link = 'https://www.filefactory.com' . $RD[1];
8989
$this->page = $this->GetPage($this->link, $this->cookie);
9090
$this->cookie = GetCookiesArr($this->page, $this->cookie);
9191
$X++;
9292
}
9393

9494
if (preg_match('@/error\.php\?code=(\d+)@i', $this->page, $this->redir)) {
95-
$this->page = $this->GetPage('http://www.filefactory.com'.$this->redir[0], $this->cookie);
95+
$this->page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
9696
if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $this->page, $err)) html_error("[FF:{$this->redir[1]}]-".htmlspecialchars($err[1]));
9797
html_error("Link is not available. [{$this->redir[1]}]");
9898
}
@@ -112,7 +112,7 @@ private function Login() {
112112

113113
if (empty($email) || empty($password)) html_error('Login Failed: Email or Password is empty. Please check login data.');
114114

115-
$postURL = 'http://www.filefactory.com/member/signin.php';
115+
$postURL = 'https://www.filefactory.com/member/signin.php';
116116
$post = array();
117117
$post['loginEmail'] = urlencode($email);
118118
$post['loginPassword'] = urlencode($password);
@@ -124,7 +124,7 @@ private function Login() {
124124
$this->cookie = GetCookiesArr($page, $this->cookie);
125125
if (empty($this->cookie['auth'])) html_error('Login Failed, auth cookie not found.');
126126

127-
$page = $this->GetPage('http://www.filefactory.com/account/', $this->cookie, 0, $postURL);
127+
$page = $this->GetPage('https://www.filefactory.com/account/', $this->cookie, 0, $postURL);
128128
is_present($page, "\nLocation: /member/settos.php", 'TOS have changed and need to be approved at the site.');
129129
is_present($page, "\nLocation: /member/setpwd.php", 'Your password has expired, please change it.');
130130
if (stripos($page, '>Free Member<') !== false) {
@@ -151,5 +151,4 @@ private function Login() {
151151
//[24-Oct-2013] Added a error at login & fixed redirect on premium download. - Th3-822
152152
//[18-Nov-2013] Fixed premium-dl error msgs. - Th3-822
153153
//[02-Dec-2016] Fixed login error msgs. - Th3-822
154-
155-
?>
154+
//[14-May-2021] Switched links to https. - Th3-822

0 commit comments

Comments
 (0)