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

/pluginz/download/real_debrid_com.php

http://rapidleech36b.googlecode.com/
PHP | 83 lines | 79 code | 4 blank | 0 comment | 22 complexity | ec60699ff11422c75fa41411167f8294 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once('index.html');
  4. exit();
  5. }
  6. class real_debrid_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. $this->posturl = "http://real-debrid.com/";
  10. if (preg_match("@$this->posturl[?]([^\r\n]+)@i", $link, $ck)) {
  11. $check = $ck[1];
  12. if (stristr($check, "|")) {
  13. $arr = explode('|', $check);
  14. $this->url = urlencode($arr[0]);
  15. $this->password = urlencode($arr[1]);
  16. } else { //no password input
  17. $this->url = urlencode($check);
  18. }
  19. } else {
  20. html_error('Format link unknown, please input like this http://real-debrid.com/?http://www.megaupload.com/?d=VLV1UJ0C');
  21. }
  22. if (($_REQUEST["cookieuse"] == "on" && preg_match("@auth=(\w{114})@i", $_REQUEST["cookie"], $c)) || ($_REQUEST["premium_acc"] == "on" && $premium_acc["real-debrid_com"]["cookie"])) {
  23. $cookie = (empty($c[1]) ? $premium_acc["real-debrid_com"]["cookie"] : $c[1]);
  24. return $this->Premium($cookie);
  25. } elseif (($_REQUEST['premium_acc'] == 'on' && $_REQUEST['premium_acc']['user'] && $_REQUEST['premium_acc']['pass']) || ($_REQUEST['premium_acc'] == 'on' && $premium_acc['real-debrid_com']['user'] && $premium_acc['real-debrid_com']['pass'])) {
  26. return $this->Premium();
  27. } else {
  28. html_error("This plugin need <a href='http://www.real-debrid.com/'><font color='red'>Real-Debrid</font></a> Premium Account");
  29. }
  30. }
  31. private function Premium($cookie = false) {
  32. $cookie = $this->Login($cookie);
  33. $page = $this->GetPage($this->posturl . "ajax/unrestrict.php?link={$this->url}&password={$this->password}&remote=0&time=" . round(microtime(true) * 1000) . "", $cookie, 0, $this->posturl . "downloaders\r\nX-Requested-With: XMLHttpRequest");
  34. if (preg_match('@\{"([^"]+)":(\d+),"([^"]+)":"([^"]+)"\}?(,"([^"]+)":"([^"]+)","([^"]+)":"([^"]+)",)?@', $page, $match)) {
  35. if ($match[2] == '0') {
  36. $dlink = str_replace('\\', '', cut_str($match[9], '|-|', '\r\n'));
  37. $filename = trim($match[4]);
  38. $this->RedirectDownload($dlink, $filename, $cookie, 0, $posturl . "downloaders");
  39. } else {
  40. html_error("$match[1][$match[2]] : $match[4]");
  41. }
  42. } else {
  43. html_error("Error: Unknown Page Response!");
  44. }
  45. }
  46. private function Login($auth = false) {
  47. global $premium_acc;
  48. if (!$auth) {
  49. if (!empty($_REQUEST["premium_user"]) && !empty($_REQUEST["premium_pass"])) {
  50. $user = $_REQUEST["premium_user"];
  51. $pass = $_REQUEST["premium_pass"];
  52. } else {
  53. $user = $premium_acc["real-debrid_com"]['user'];
  54. $pass = $premium_acc["real-debrid_com"]['pass'];
  55. }
  56. if (empty($user) || empty($pass)) html_error("Username or password is empty, you need to insert your login detail!");
  57. $page = $this->GetPage($this->posturl . "ajax/login.php?user=" . urlencode($user) . "&pass=" . urlencode($pass) . "", "lang=en", 0, $this->posturl . "\r\nX-Requested-With: XMLHttpRequest");
  58. $cookie = GetCookies($page) . "; lang=en";
  59. is_present($page, 'Your login informations are incorrect !');
  60. } elseif (strlen($auth) == 114) {
  61. $cookie = "auth=$auth; lang=en";
  62. } else {
  63. html_error("[Cookie] Invalid cookie (" . strlen($auth) . " != 114).");
  64. }
  65. //check account
  66. $page = $this->GetPage($this->posturl . "account", $cookie, 0, $this->posturl);
  67. is_present($page, "<h3>403 - Forbidden</h3>", "Account invalid!");
  68. is_present($page, 'A dedicated server has been detected and your account will not be Premium on this IP address.');
  69. is_present($page, '<strong>Free</strong>', 'Account Free, login not validated!');
  70. return $cookie;
  71. }
  72. }
  73. // real-debrid download plugin by Ruud v.Tony 23-10-2011
  74. ?>