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

Commit

Permalink
Added support for password protected links on 1fichier (only FreeDL),…
Browse files Browse the repository at this point in the history
… partially closes #253
  • Loading branch information
Th3-822 committed Aug 31, 2021
1 parent 6e69b9e commit 8b478d3
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions hosts/download/1fichier_com.php
Expand Up @@ -6,19 +6,22 @@
}

class d1fichier_com extends DownloadClass {
private $page, $cookie = array('LG' => 'en'), $pA;
private $lpass, $page, $cookie = array('LG' => 'en'), $pA;
public function Download($link) {
$this->LnkRegexp = '@https?://(?:www\.)?((?:1fichier|alterupload|desfichiers|dfichiers|pjointe|tenvoi|dl4free)\.com|(?:cjoint|piecejointe)\.net|mesfichiers\.org|megadl\.fr)/\?([\w\-]+)@i';

$link = preg_replace('@//([\w\-]{4,})\.((?:1fichier|alterupload|desfichiers|dfichiers|pjointe|tenvoi|dl4free)\.com|(?:cjoint|piecejointe)\.net|mesfichiers\.org|megadl\.fr)/[^\r\n\t\'\"<>]*$@i', '//$2/?$1', $link); // Let's support old links by now
$link = explode('|', str_ireplace('%7C', '|', $link), 2);
if (count($link) > 1) $this->lpass = rawurldecode($link[1]);

$link = preg_replace('@//([\w\-]{4,})\.((?:1fichier|alterupload|desfichiers|dfichiers|pjointe|tenvoi|dl4free)\.com|(?:cjoint|piecejointe)\.net|mesfichiers\.org|megadl\.fr)/[^\r\n\t\'\"<>]*$@i', '//$2/?$1', $link[0]); // Let's support old links by now

$link = parse_url($link);
$link['scheme'] = 'https';
$link = rebuild_url($link);

if (!preg_match($this->LnkRegexp, $link, $fid)) html_error('Invalid link?.');
$this->domain = $fid[1];
$this->link = $Referer = $fid[0];
$this->link = $GLOBALS['Referer'] = $fid[0];
$this->fid = $fid[2];

$this->DLRegexp = '@https?://\w+-\w+\.((?:1fichier|alterupload|desfichiers|dfichiers|pjointe|tenvoi|dl4free)\.com|(?:cjoint|piecejointe)\.net|mesfichiers\.org|megadl\.fr)/(?:\w+'.preg_quote($this->fid).'|\w\d+)(/[^\s\'\"<>]*)?@i';
Expand All @@ -28,6 +31,7 @@ public function Download($link) {
is_present($this->page, 'The requested file has been deleted because was not downloaded within', 'File was Removed by Inactivity.');
is_present($this->page, 'The requested file has been deleted following an abuse request', 'File was Removed due to Abuse.');
is_present($this->page, 'The requested file could not be found', 'File not Found.');
$this->CheckPass($this->page);
$this->cookie = GetCookiesArr($this->page, $this->cookie);

if (preg_match($this->DLRegexp, $this->page, $dl)) return $this->RedirectDownload($dl[0], (empty($dl[2]) ? 'T8_1f_d1' : urldecode(parse_url($dl[0], PHP_URL_PATH))));
Expand All @@ -46,30 +50,27 @@ public function Download($link) {
} else return $this->FreeDL();
}

private function FreeDL() {
$post = array('submit' => 'Download');
private function FreeDL($waited = 0) {
$post = (empty($this->lpass) ? array('submit' => 'Download') : array('pass' => urlencode($this->lpass)));
$post['adz'] = cut_str($this->page, 'name="adz" value="', '"');

$page = $this->GetPage($this->link, $this->cookie, $post);
is_present($page, 'you can only download one file at a time');
$this->cookie = GetCookiesArr($page, $this->cookie);

is_present($page, 'The link your requested is expired','The download link is expired, please try again.');

if (preg_match($this->DLRegexp, $page, $dl)) return $this->RedirectDownload($dl[0], (empty($dl[2]) ? 'T8_1f_f2' : urldecode(parse_url($dl[0], PHP_URL_PATH))));

if (preg_match('@\(\'.clock\'\), (\d+)\*60, { clockFace:@i', $page, $cD)) if ($cD[1] > 0) $this->CountDown(($cD[1]*60));
if (preg_match($this->DLRegexp, $page, $dl)) return $this->RedirectDownload($dl[0], (empty($dl[2]) ? ($waited ? 'T8_1f_f1' : 'T8_1f_f2') : urldecode(parse_url($dl[0], PHP_URL_PATH))));

$post = array();
$post['submit'] = cut_str($this->page, 'name="submit" value="', '"');
$post['adzone'] = cut_str($this->page, 'name="adzone" value="', '"');
if (empty($post['submit'])) $post['submit'] = 'Show the download link';
if (empty($post['adzone'])) html_error('Form data not found.');
if (preg_match('@\(\'\.clock\'\),\s*(\d+)\s*\*\s*60,\s*{\s*clockFace:@i', $page, $cD) && $cD[1] > 0) {
if ($cD[1] > 1) {
$data = $this->DefaultParamArr($this->link . (!empty($this->lpass) ? "|{$this->lpass}" : ''));
return $this->JSCountdown($cD[1] * 60, $data);
} else $this->CountDown($cD[1] * 60);
} else $this->CheckPass($page, true);

$page = $this->GetPage($this->link, $this->cookie, $post);
$this->cookie = GetCookiesArr($page, $this->cookie);

if (!preg_match($this->DLRegexp, $page, $dl)) html_error('Download Link Not Found.');

return $this->RedirectDownload($dl[0], (empty($dl[2]) ? 'T8_1f_f1' : urldecode(parse_url($dl[0], PHP_URL_PATH))));
if ($waited > 1) html_error('Too many countdown retries, check concurrent downloads.');
return $this->FreeDL($waited + 1);
}

private function PremiumDL() {
Expand Down Expand Up @@ -117,10 +118,17 @@ public function RedirectDownload($link, $FileName = 0, $cookie = 0, $post = 0, $
$link = rebuild_url($link);
return parent::RedirectDownload($link, $FileName, $cookie, $post, $referer, $force_name, $auth, $addon);
}

private function CheckPass($page, $dl = false) {
if (stripos($page, 'The owner of this file has chosen to protect access with a password.') !== false || stripos($page, 'warn">Bad password<') !== false) {
if (empty($this->lpass)) html_error('File is password protected, please send the password in this format: link|pass');
else if ($dl) html_error('The link\'s password you have sent is not valid.');
}
}
}

//[08-4-2014] Written by Th3-822.
//[18-4-2014] Fixed Link Regexp. - Th3-822
//[17-12-2014] Un-tested fixes for changes at the site. - Th3-822
//[14-10-2018] fixed countdown and form data. - miyuru
?>
//[31-8-2021] Added link password support (FreeDL only at the moment). - Th3-822

0 comments on commit 8b478d3

Please sign in to comment.