PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/pluginz/download/cramit_in.php

http://rapidleech36b.googlecode.com/
PHP | 169 lines | 147 code | 13 blank | 9 comment | 38 complexity | 0abaaf0de08f15dc916dd58d09ad3a66 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit();
  5. }
  6. class cramit_in extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. // check & replace for other cramit domain
  10. if (preg_match('@http:\/\/((cramitin\.eu)|(cramitin\.net)|(cramitin\.us))\/@', $link, $match)) {
  11. $link = str_replace($match[1], "cramit.in", $link);
  12. }
  13. if (!$_REQUEST['step']) {
  14. $this->page = $this->GetPage($link);
  15. is_present($this->page, "File Not Found");
  16. }
  17. if ($_REQUEST['premium_acc'] == 'on' && (($_REQUEST['premium_user'] && $_REQUEST['premium_pass'])|| ($premium_acc['cramit_in']['user'] && $premium_acc['cramit_in']['pass']))) {
  18. return $this->Premium($link);
  19. } elseif ($_REQUEST['step'] == 'password') {
  20. return $this->Premium($link, true);
  21. } else {
  22. return $this->Free($link);
  23. }
  24. }
  25. private function Free($link) {
  26. global $L;
  27. if ($_REQUEST['down_direct'] == '1') {
  28. $post['op'] = $_POST['op'];
  29. $post['id'] = $_POST['id'];
  30. $post['rand'] = $_POST['rand'];
  31. $post['referer'] = $_POST['referer'];
  32. $post['method_free'] = $_POST['method_free'];
  33. $post['method_premium'] = '';
  34. if (!empty($_POST['password'])) {
  35. $post['password'] = $_POST['password'];
  36. }
  37. $post['code'] = $_POST['captcha'];
  38. $link = urldecode($_POST['link']);
  39. $page = $this->GetPage($link, 0, $post, $link);
  40. } else {
  41. $form = cut_str($this->page, '<Form method="POST" action=\'\'>', '</form>');
  42. if (!preg_match_all('@<input type="hidden" name="([^"]+)" value="([^"]+)?">@i', $form, $one) || !preg_match_all('@<input type="submit" name="([^"]+)" value="([^"]+)" alt="([^"]+)">@i', $form, $two)) html_error("Error: Post Data[1] not found!");
  43. $post = array();
  44. $match = array_merge(array_combine($one[1], $one[2]),array_combine($two[1], $two[2]));
  45. foreach ($match as $k => $v) {
  46. $post[$k] = ($v == "") ? 1 : $v;
  47. }
  48. $page = $this->GetPage($link, 0, $post, $link);
  49. }
  50. if (strpos($page, "Enter the code below:") || strpos($page, "Wrong captcha")) {
  51. global $PHP_SELF;
  52. $form = cut_str($page, '<Form name="F1" method="POST"', '</Form>');
  53. if (!preg_match_all('@<input type="hidden" name="([^"]+)" value="([^"]+)?">@i', $form, $match)) html_error("Error: Post Data[2] not found!");
  54. $data = array_merge($this->DefaultParamArr($link), array_combine($match[1], $match[2]));
  55. echo "\n<center><form name='dl' action='$PHP_SELF' method='post' ><br />\n";
  56. foreach ($data as $name => $value) {
  57. echo '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . "\n";
  58. }
  59. if (stristr($form, "Password :") || strpos($page, "Wrong password")) {
  60. echo '<h4>Enter password here: <input type="text" name="password" size="10" /></h4><br />';
  61. }
  62. echo '<h4>' . $L->say['_enter'] . ' <img src="' . cut_str($form, '<img src="', '">') . '" /> ' . $L->say['_here'] . ': <input type="text" name="captcha" id="capcus" size="20" />&nbsp;&nbsp;<br />';
  63. echo "<input type='submit' name='submit' onclick='javascript:return checkc();' value='Download File' />\n";
  64. echo "<script type='text/javascript'>/*<![CDATA[*/\nfunction checkc(){\nvar capt=document.getElementById('capcus');\nif (capt.value == '') { window.alert('You didn\'t enter the image verification code.'); return false; }\nelse { return true; }\n}\n/*]]>*/</script>\n";
  65. echo "</form></center>\n</body>\n</html>";
  66. exit;
  67. }
  68. is_present($page, cut_str($page, '<p class="err">', '<br />'));
  69. if (!preg_match('#http://cramit.in/file_download/[^"]+#i', $page, $rd)) html_error("Error: Redirect Link [FREE] not found!");
  70. $rlink = trim($rd[0]);
  71. $page = $this->GetPage($rlink, 0, 0, $link);
  72. if (!preg_match('@Location: (http:\/\/[^\r\n]+)@i', $page, $dl)) html_error("Error: Download Link [FREE] not found!");
  73. $dlink = trim($dl[1]);
  74. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  75. $this->RedirectDownload($dlink, $filename, 0, 0, $link);
  76. exit();
  77. }
  78. private function Premium($link, $password = false) {
  79. if ($password == true) {
  80. $post['op'] = $_POST['op'];
  81. $post['id'] = $_POST['id'];
  82. $post['rand'] = $_POST['rand'];
  83. $post['referer'] = $_POST['referer'];
  84. $post['method_free'] = '';
  85. $post['method_premium'] = $_POST['method_premium'];
  86. $post['password'] = $_POST['password'];
  87. $post['down_direct'] = $_POST['down_direct'];
  88. $link = urldecode($_POST['link']);
  89. $cookie = decrypt(urldecode($_POST['cookie']));
  90. $this->page = $this->GetPage($link, $cookie, $post, $link);
  91. } else {
  92. $cookie = $this->login();
  93. $this->page = $this->GetPage($link, $cookie, 0, $link);
  94. }
  95. if (!preg_match('@http:\/\/cramit\.in\/file_download\/[^|\r|\n|"?]+@i', $this->page, $rd)) { //non direct download also password link have the same layout...
  96. global $PHP_SELF;
  97. $form = cut_str($this->page, '<Form name="F1" method="POST"', '</Form>');
  98. if (!preg_match_all('@<input type="hidden" name="([^"]+)" value="([^"]+)?">@i', $form, $match)) html_error("Error: Post Data [PREMIUM] not found!");
  99. $match = array_combine($match[1], $match[2]);
  100. if (stristr($form, "Password :") || strpos($this->page, "Wrong password")) {
  101. $data = array_merge($this->DefaultParamArr($link, encrypt($cookie)), $match);
  102. echo "\n<center><form name='dl' action='$PHP_SELF' method='post' ><br />\n";
  103. foreach ($data as $name => $value) {
  104. echo '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . "\n";
  105. }
  106. echo '<input type="hidden" name="step" value="password" />' . "\n";
  107. echo '<h4>Enter password here: <input type="text" name="password" id="filepass" size="10" /></h4><br />';
  108. echo "<input type='submit' name='submit' onclick='javascript:return checkc();' value='Download File' />\n";
  109. echo "<script type='text/javascript'>/*<![CDATA[*/\nfunction checkc(){\nvar capt=document.getElementById('filepass');\nif (capt.value == '') { window.alert('You didn\'t enter the image verification code.'); return false; }\nelse { return true; }\n}\n/*]]>*/</script>\n";
  110. echo "</form></center>\n</body>\n</html>";
  111. exit();
  112. } else {
  113. $post = array();
  114. foreach ($match as $key => $value) {
  115. $post[$key] = $value;
  116. }
  117. $this->page = $this->GetPage($link, $cookie, $post, $link);
  118. if (!preg_match('@http:\/\/cramit\.in\/file_download/[^|\r|\n|"]+@', $this->page, $rd)) html_error("Error: Redirect Link [PREMIUM] not found!");
  119. }
  120. }
  121. $rlink = trim($rd[0]);
  122. $page = $this->GetPage($rlink, $cookie, 0, $link);
  123. if (!preg_match('@Location: (http:\/\/[^\r\n]+)@i', $page, $dl)) html_error("Error: Download Link [PREMIUM] not found!");
  124. $dlink = trim($dl[1]);
  125. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  126. $this->RedirectDownload($dlink, $filename, $cookie, 0, $link);
  127. }
  128. private function login() {
  129. global $premium_acc;
  130. $user = ($_REQUEST["premium_user"] ? trim($_REQUEST["premium_user"]) : $premium_acc ["cramit_in"] ["user"]);
  131. $pass = ($_REQUEST["premium_pass"] ? trim($_REQUEST["premium_pass"]) : $premium_acc ["cramit_in"] ["pass"]);
  132. if (empty($user) || empty($pass)) html_error("Login failed, user [$user] or password [$pass] is empty!");
  133. $Url = 'http://cramit.in/';
  134. $post['op'] = 'login';
  135. $post['redirect'] = '';
  136. $post['login'] = $user;
  137. $post['password'] = $pass;
  138. $page = $this->GetPage($Url, 0, $post, $Url."login.html");
  139. $cookie = GetCookies($page);
  140. is_present($page, cut_str($page, "<b class='err'>","</b>"));
  141. is_notpresent($cookie, 'login=', 'Invalid cookie!');
  142. //check account
  143. $page = $this->GetPage($Url."?op=my_account", $cookie, 0, $Url);
  144. is_notpresent($page, '<TD class=left> Username</TD>', 'Account is not valid!');
  145. is_notpresent($page, '<TD class=left>Premium Account expires on</TD>', 'Account type : FREE');
  146. return $cookie;
  147. }
  148. }
  149. //Cramit.in Free Download Plugin by Ruud v.Tony 2-4-2011
  150. //Updated 11-5-2011 to support password protected files by help vdhdevil
  151. //Fixed for site layout change by Ruud v.Tony 24-06-2011
  152. //Update for the captcha failure n the error message 06-07-2011
  153. //Update again for redirect location in download link 25-07-2011 :hammer:
  154. //Update for including other cramit domain also fix the password form 14/01/2012
  155. //Update to support premium by Ruud v.Tony 01/02/2012
  156. ?>