PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/hosts/download/1fichier_com.php

https://gitlab.com/dkiller1/rapidleech
PHP | 127 lines | 94 code | 29 blank | 4 comment | 21 complexity | 9ddc0a145fbd4b8b428bfe4bbdc366c8 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once('index.html');
  4. exit;
  5. }
  6. class d1fichier_com extends DownloadClass {
  7. private $page, $cookie = array('LG' => 'en'), $pA;
  8. public function Download($link) {
  9. $this->LnkRegexp = '@https?://(?:www\.)?((?:1fichier|alterupload|desfichiers|dfichiers|pjointe|tenvoi|dl4free)\.com|(?:cjoint|piecejointe)\.net|mesfichiers\.org|megadl\.fr)/\?([\w\-]+)@i';
  10. $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
  11. $link = parse_url($link);
  12. $link['scheme'] = 'https';
  13. $link = rebuild_url($link);
  14. if (!preg_match($this->LnkRegexp, $link, $fid)) html_error('Invalid link?.');
  15. $this->domain = $fid[1];
  16. $this->link = $Referer = $fid[0];
  17. $this->fid = $fid[2];
  18. $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';
  19. if (empty($_POST['step'])) {
  20. $this->page = $this->GetPage($this->link, $this->cookie);
  21. is_present($this->page, 'The requested file has been deleted because was not downloaded within', 'File was Removed by Inactivity.');
  22. is_present($this->page, 'The requested file has been deleted following an abuse request', 'File was Removed due to Abuse.');
  23. is_present($this->page, 'The requested file could not be found', 'File not Found.');
  24. $this->cookie = GetCookiesArr($this->page, $this->cookie);
  25. 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))));
  26. }
  27. $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  28. if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($GLOBALS['premium_acc']['1fichier_com']['user']) && !empty($GLOBALS['premium_acc']['1fichier_com']['pass']))))) {
  29. $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['1fichier_com']['user']);
  30. $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['1fichier_com']['pass']);
  31. if ($this->pA && !empty($_POST['pA_encrypted'])) {
  32. $user = decrypt(urldecode($user));
  33. $pass = decrypt(urldecode($pass));
  34. unset($_POST['pA_encrypted']);
  35. }
  36. return $this->Login($user, $pass);
  37. } else return $this->FreeDL();
  38. }
  39. private function FreeDL() {
  40. $post = array('submit' => 'Download');
  41. $page = $this->GetPage($this->link, $this->cookie, $post);
  42. is_present($page, 'you can only download one file at a time');
  43. $this->cookie = GetCookiesArr($page, $this->cookie);
  44. 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))));
  45. is_present($page, 'you must wait between downloads', 'You must wait 15 minutes between downloads');
  46. if (!preg_match('@[\s,;]var\s+count\s*=\s*(\d+)\s*;@i', $page, $cD)) html_error('Countdown not found.');
  47. if ($cD[1] > 0) $this->CountDown($cD[1]);
  48. $post = array();
  49. $post['submit'] = cut_str($this->page, 'name="submit" value="', '"');
  50. $post['t'] = cut_str($this->page, 'name="t" value="', '"');
  51. if (empty($post['submit'])) $post['submit'] = 'Show the download link';
  52. if (empty($post['t'])) html_error('Form data not found.');
  53. $page = $this->GetPage($this->link, $this->cookie, $post);
  54. $this->cookie = GetCookiesArr($page, $this->cookie);
  55. if (!preg_match($this->DLRegexp, $page, $dl)) html_error('Download Link Not Found.');
  56. return $this->RedirectDownload($dl[0], (empty($dl[2]) ? 'T8_1f_f1' : urldecode(parse_url($dl[0], PHP_URL_PATH))));
  57. }
  58. private function PremiumDL() {
  59. $page = $this->GetPage($this->link, $this->cookie);
  60. $this->cookie = GetCookiesArr($page, $this->cookie);
  61. is_present($page, 'Premium status should not be used on professional services. Use download credits.'); // IP Ban?
  62. if (!preg_match($this->DLRegexp, $page, $dl)) html_error('Download-Link Not Found.');
  63. return $this->RedirectDownload($dl[0], (empty($dl[2]) ? 'T8_1f_pr' : urldecode(parse_url($dl[0], PHP_URL_PATH))));
  64. }
  65. private function Login($user, $pass) {
  66. $purl = 'https://'.$this->domain.'/';
  67. $post = array();
  68. $post['mail'] = urlencode($user);
  69. $post['pass'] = urlencode($pass);
  70. $post['lt'] = 'on';
  71. $post['restrict'] = 'on';
  72. $post['valider'] = 'Send';
  73. $page = $this->GetPage($purl.'login.pl', $this->cookie, $post, $purl);
  74. $this->cookie = GetCookiesArr($page, $this->cookie);
  75. is_present($page, 'Invalid email address');
  76. is_present($page, 'Invalid username or password', 'Login Failed: Email/Password incorrect.');
  77. $page = $this->GetPage($purl, $this->cookie, 0, $purl.'login.pl');
  78. is_notpresent($page, 'logout.pl">Logout', 'Login Error.');
  79. if (stripos($page, 'https://img.1fichier.com/icons/etoile.png') === false) {
  80. $this->changeMesg(lang(300).'<br /><b>Account isn\\\'t premium</b><br />Using it as member.');
  81. $this->page = $this->GetPage($this->link, $this->cookie);
  82. $this->cookie = GetCookiesArr($this->page, $this->cookie);
  83. return $this->FreeDL();
  84. }
  85. return $this->PremiumDL();
  86. }
  87. // As some users doesn't have support por https downloads, let's switch to http
  88. public function RedirectDownload($link, $FileName, $cookie = 0, $post = 0, $referer = 0, $force_name = 0, $auth = 0, $addon = array()) {
  89. $link = parse_url($link);
  90. $link['scheme'] = 'http';
  91. $link = rebuild_url($link);
  92. return parent::RedirectDownload($link, $FileName, $cookie, $post, $referer, $force_name, $auth, $addon);
  93. }
  94. }
  95. //[08-4-2014] Written by Th3-822.
  96. //[18-4-2014] Fixed Link Regexp. - Th3-822
  97. //[17-12-2014] Un-tested fixes for changes at the site. - Th3-822
  98. ?>