PageRenderTime 32ms CodeModel.GetById 45ms RepoModel.GetById 1ms app.codeStats 0ms

/index.php

http://rapidleech36b.googlecode.com/
PHP | 381 lines | 296 code | 42 blank | 43 comment | 127 complexity | ed1e619434c50fe9927ad787fab46055 MD5 | raw file
  1. <?php
  2. /*****************************************************
  3. * Rapidleech 36B Rv.8
  4. *
  5. * $Id: index.php - 05apr2010-Idx $
  6. *****************************************************/
  7. define('RAPIDLEECH', 'yes');
  8. require_once "./global.php";
  9. //PROTECTED AREA, REMOVING THIS YOU'RE DEAD MAN!
  10. define('BUILD', '23082007');
  11. define('CREDITS', '<a href="http://www.rapidleech.com/" style="text-decoration:none"><b>RL</b></a>&nbsp;<b class="footer1">PlugMod rev. ' . $rev_num . '</b> <span class="footer2">' . $dev_name . '</span><br /><small class="footer2">Credits to Pramode &amp; Checkmate &amp; Kloon. Mod by: MsNeil &amp; Idoenk<br />In memoriam our beloving brother, husband and father, Ruud v.Tony(15/03/1978 - 21/07/2009)</small>');
  12. define('VERSION', '<small class="footer3"><span>[ olc | ccpb | kaskus ]</span><br />[ Shout: Viant77, Jujuan, Huka, Limpy ]</small>');
  13. //END OF PROTECTED AREA
  14. //************************
  15. // MAIN ...
  16. //************************
  17. $_REQUEST['premium_acc'] = $_POST['premium_acc'] = isset($_REQUEST['premium_acc']) && $_REQUEST['premium_acc'] == 'on' ? 'on' : false;
  18. foreach ($_POST as $key => $value) {
  19. $_GET[$key] = $value;
  20. }
  21. if (!$_COOKIE) {
  22. if (strstr($_SERVER["HTTP_COOKIE"], ";")) {
  23. foreach (explode("; ", $_SERVER["HTTP_COOKIE"]) as $key => $value) {
  24. list($var, $val) = explode("=", $value);
  25. $_COOKIE[$var] = $val;
  26. }
  27. } else if (!empty($_SERVER ["HTTP_COOKIE"])) {
  28. list ($var, $val) = @explode("=", $_SERVER ["HTTP_COOKIE"]);
  29. $_COOKIE [$var] = $val;
  30. }
  31. }
  32. require_once(CLASS_DIR . "cookie.php");
  33. if (!@file_exists(HOST_DIR . "download/hosts.php")) {
  34. create_hosts_file(HOST_DIR . "download/hosts.php");
  35. }
  36. require_once (HOST_DIR . "download/hosts.php");
  37. if (!empty($_GET["image"])) {
  38. require_once(CLASS_DIR . "http.php");
  39. require_once(CLASS_DIR . "image.php");
  40. exit();
  41. }
  42. if (isset($_GET["useproxy"]) && (!$_GET["proxy"] || !strstr($_GET["proxy"], ":"))) {
  43. html_error($L->say['wrong_proxy']);
  44. } else {
  45. if (!empty($_GET["pauth"])) {
  46. $pauth = $_GET["pauth"];
  47. } else {
  48. $pauth = (!empty($_GET ["proxyuser"]) && !empty($_GET ["proxypass"])) ? base64_encode($_GET ["proxyuser"] . ":" . $_GET ["proxypass"]) : "";
  49. }
  50. }
  51. if (empty($_GET ["path"]) || $options['download_dir_is_changeable'] == false) {
  52. if (empty($_GET ["host"])) {
  53. $_GET["path"] = (substr($options["download_dir"], 0, 6) != "ftp://") ? realpath(DOWNLOAD_DIR) : $options["download_dir"];
  54. } else {
  55. $_GET["saveto"] = (substr($options["download_dir"], 0, 6) != "ftp://") ? realpath(DOWNLOAD_DIR) : $options["download_dir"];
  56. }
  57. }
  58. if (empty($_GET ["filename"]) || empty($_GET ["host"]) || empty($_GET ["path"])) {
  59. if (!isset($_POST["link"])) {
  60. if (isset($_GET["idx"])) {
  61. // link was sent from audl
  62. $LINK = (isset($_GET["link"]) ? utf8_strrev(base64_decode($_GET["link"])) : "");
  63. } else {
  64. $LINK = (isset($_GET["link"]) ? $_GET["link"] : "");
  65. }
  66. } else {
  67. $LINK = $_POST["link"];
  68. }
  69. // urldecode, trim, strip * in link
  70. $LINK = urlcleaner(trim(urldecode($LINK)));
  71. if (!$LINK) {
  72. _create_list();
  73. require_once(CLASS_DIR . "main.php");
  74. exit();
  75. } elseif ($limitation_alert === true) {
  76. html_error('Limitation alerted, can not use RL! ' . $msg, 1);
  77. }
  78. check_referer();
  79. // Detect if it doesn't have a protocol assigned
  80. if (substr($LINK, 0, 7) != "http://" && substr($LINK, 0, 6) != "ftp://" && substr($LINK, 0, 6) != "ssl://" && substr($LINK, 0, 8) != "https://" && !stristr($LINK, '://')) {
  81. // Automatically assign http://
  82. $LINK = "http://" . $LINK;
  83. }
  84. if (!empty($_GET["saveto"]) && !$_GET["path"]) {
  85. html_error($L->say['path_not_defined']);
  86. }
  87. if (empty($_GET["useproxy"])) {
  88. $_GET["proxy"] = "";
  89. }
  90. if (!empty($_GET["domail"]) && !checkmail($_GET["email"])) {
  91. html_error($L->say['didnt_enter_mail']);
  92. if (!empty($_GET ["split"]) && !is_numeric($_GET ["partSize"])) {
  93. html_error($L->say['size_not_true']);
  94. }
  95. }
  96. $Url = parse_url($LINK);
  97. $Url['path'] = str_replace('%2F', '/', rawurlencode(urldecode($Url['path'])));
  98. $LINK = rebuild_url($Url);
  99. if (empty($_GET ["referer"])) {
  100. $Referer = $Url;
  101. // Remove login from Referer
  102. unset($Referer['user'], $Referer['pass']);
  103. $Referer = rebuild_url($Referer);
  104. } else {
  105. $Referer = trim(urldecode($_GET ["referer"]));
  106. }
  107. if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') {
  108. $LINK = urlcleaner(utf8_strrev(base64_decode($LINK)));
  109. $Url = parse_url($LINK);
  110. if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') {
  111. html_error($L->say['url_unknown']);
  112. }
  113. }
  114. if (empty($Url['user']) xor empty($Url['pass'])) {
  115. unset($Url['user'], $Url['pass']);
  116. $LINK = rebuild_url($Url);
  117. }
  118. if (isset($_GET['user_pass']) && $_GET['user_pass'] == "on" && !empty($_GET['iuser']) && !empty($_GET['ipass'])) {
  119. $Url['user'] = $_GET['iuser'];
  120. $Url['pass'] = $_GET['ipass'];
  121. // Rebuild url
  122. $LINK = rebuild_url($Url);
  123. }
  124. // If Url has user & pass, use them as premium login for plugins and set $auth for direct download.
  125. if (!empty($Url['user']) && !empty($Url['pass'])) {
  126. if (!$_REQUEST['premium_acc']) $_GET['premium_acc'] = $_POST['premium_acc'] = $_REQUEST['premium_acc'] = 'on';
  127. $_GET['premium_user'] = $_POST['premium_user'] = $_REQUEST['premium_user'] = $Url['user'];
  128. $_GET['premium_pass'] = $_POST['premium_pass'] = $_REQUEST['premium_pass'] = $Url['pass'];
  129. $auth = "&auth=" . urlencode(encrypt(base64_encode(rawurlencode($Url ["user"]) . ":" . rawurlencode($Url ["pass"]))));
  130. // We have premium_acc and $auth setted, delete User and Pass from link.
  131. unset($Url['user'], $Url['pass']);
  132. $LINK = rebuild_url($Url);
  133. } else {
  134. $auth = "";
  135. }
  136. $litehead = 1;
  137. if (!isset($_GET['dis_plug']) || $_GET ['dis_plug'] != "on") {
  138. //check Domain-Host
  139. if (isset($_GET["vBulletin_plug"])) {
  140. $page_title = $L->say['downloading'];
  141. include(TEMPLATE_DIR . 'header.php');
  142. require_once(CLASS_DIR . "http.php");
  143. require_once(HOST_DIR . "download/vBulletin_plug.php");
  144. exit();
  145. } else {
  146. foreach ($host as $site => $file) {
  147. if (preg_match("/^(.+\.)?" . str_replace('.', '\.', $site) . "$/i", $Url ["host"])) {
  148. $page_title = $L->say['prep_dl'] . " " . $LINK;
  149. $shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
  150. include(TEMPLATE_DIR . 'header.php');
  151. require_once(CLASS_DIR . "http.php");
  152. require_once (HOST_DIR . "DownloadClass.php");
  153. require_once(HOST_DIR . 'download/' . $file);
  154. $class = substr($file, 0, -4);
  155. $firstchar = substr($file, 0, 1);
  156. if ($firstchar > 0) {
  157. $class = "d" . $class;
  158. }
  159. if (class_exists($class)) {
  160. $hostClass = new $class();
  161. $hostClass->Download($LINK);
  162. }
  163. exit();
  164. }
  165. }
  166. }
  167. }
  168. $page_title = $L->say['leeching'];
  169. $shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
  170. include(TEMPLATE_DIR . 'header.php');
  171. $Url = parse_url($LINK);
  172. $FileName = isset($Url ["path"]) ? basename($Url ["path"]) : '';
  173. $mydomain = $_SERVER['SERVER_NAME'];
  174. $myip = $_SERVER['SERVER_ADDR'];
  175. if ($options['bw_save'] && preg_match("/($mydomain|$myip)/i", $Url["host"])) {
  176. html_error($L->sprintf($L->say['leech_not_allowed'], $mydomain, $myip));
  177. }
  178. if (isset($_GET ['cookieuse'])) {
  179. if (strlen($_GET ['cookie'] > 0)) {
  180. $_GET ['cookie'] .= ';' . $_POST ['cookie'];
  181. } else {
  182. $_GET ['cookie'] = $_POST ['cookie'];
  183. }
  184. }
  185. insert_location("$PHP_SELF?filename=" . urlencode($FileName) . "&host=" . $Url ["host"] . "&port=" . (isset($Url ["port"]) ? $Url ["port"] : '') . "&path=" . (!empty($Url ["path"]) ? urlencode($Url ["path"]) : '') . (!empty($Url ["query"]) ? urlencode("?" . $Url ["query"]) : "") . "&referer=" . urlencode($Referer) . "&email=" . (!empty($_GET ["domail"]) ? $_GET ["email"] : "") . "&partSize=" . (!empty($_GET ["split"]) ? $_GET ["partSize"] : "") . "&method=" . (!empty($_GET ["method"]) ? $_GET ["method"] : '') . (!empty($_GET ["proxy"]) ? "&useproxy=on&proxy=" . $_GET ["proxy"] : "") . "&saveto=" . $_GET ["path"] . "&link=" . urlencode($LINK) . (isset($_GET ["add_comment"]) && $_GET ["add_comment"] == "on" && !empty($_GET ["comment"]) ? "&comment=" . urlencode($_GET ["comment"]) : "") . $auth . ($pauth ? "&pauth=$pauth" : "") . (isset($_GET["idx"]) ? "&idx=" . $_GET["idx"] : "") . "&cookie=" . (!empty($_GET ["cookie"]) ? urlencode(encrypt($_GET ['cookie'])) : '' . "&dis_plug=on"));
  186. } else {
  187. $page_title = 'nYedoTz...';
  188. $shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
  189. $litehead = 1;
  190. include(TEMPLATE_DIR . 'header.php');
  191. check_referer();
  192. echo('<div align="center">');
  193. /* Deprecated of useless and unworth feature for some cases might fail this status.
  194. if ($options['MaxServerJob'] > 0) {
  195. if ($options['MaxServerJob'] <= ongoingGet()) {
  196. html_error($L->sprintf($L->say['maxjob_limited'], $options['MaxServerJob']));
  197. }
  198. } */
  199. if ($options["limitbyip"]) {
  200. if ($ada_acc) {
  201. $trheute = $heute + 1;
  202. if ($trheute > $options['maximum_free_downloads']) {
  203. html_error($msgNya);
  204. }
  205. }
  206. }
  207. /* Deprecated of useless and unworth feature for some cases might fail this status.
  208. ongoingAdd(); */
  209. do {
  210. $_GET ["filename"] = urldecode(trim($_GET ["filename"]));
  211. if (strstr($_GET ["filename"], '?') !== false) list ($_GET ["filename"], $tmp) = explode('?', $_GET ["filename"], 2);
  212. $_GET["saveto"] = urldecode(trim($_GET["saveto"]));
  213. $_GET["host"] = urldecode(trim($_GET["host"]));
  214. $_GET["path"] = urldecode(trim($_GET["path"]));
  215. $_GET ["port"] = !empty($_GET ["port"]) ? urldecode(trim($_GET ["port"])) : 80;
  216. $_GET ["referer"] = !empty($_GET ["referer"]) ? urldecode(trim($_GET ["referer"])) : 0;
  217. $_GET["link"] = urldecode(trim($_GET["link"]));
  218. $_GET ["post"] = !empty($_GET ["post"]) ? unserialize(stripslashes(urldecode(trim($_GET ["post"])))) : 0;
  219. $_GET ["cookie"] = !empty($_GET ["cookie"]) ? decrypt(urldecode(trim($_GET["cookie"]))) : "";
  220. $_GET ["proxy"] = !empty($_GET ["proxy"]) ? $_GET ["proxy"] : "";
  221. $redirectto = "";
  222. $pauth = !empty($_GET ["pauth"]) ? urldecode(trim($_GET ["pauth"])) : '';
  223. $_GET['auth'] = isset($_GET['auth']) ? trim($_GET['auth']) : '';
  224. if ($_GET['auth'] == "1") {
  225. if (!preg_match("|^(?:.+\.)?(.+\..+)$|i", $_GET ["host"], $hostmatch)) html_error('No valid hostname found for authorisation!');
  226. $hostmatch = str_replace('.', '_', $hostmatch[1]);
  227. if ($premium_acc ["$hostmatch"] && $premium_acc ["$hostmatch"] ["user"] && $premium_acc ["$hostmatch"] ["pass"]) {
  228. $auth = base64_encode($premium_acc ["$hostmatch"] ["user"] . ":" . $premium_acc ["$hostmatch"] ["pass"]);
  229. } else {
  230. html_error('No useable premium account found for this download - please set one in accounts.php');
  231. }
  232. } elseif (!empty($_GET['auth'])) {
  233. $auth = decrypt(urldecode($_GET['auth']));
  234. $AUTH ["use"] = true;
  235. $AUTH ["str"] = $auth;
  236. } else {
  237. $auth = $AUTH = false;
  238. }
  239. $pathWithName = $_GET["saveto"] . PATH_SPLITTER . $_GET["filename"];
  240. while (stristr($pathWithName, "\\\\")) {
  241. $pathWithName = str_replace("\\\\", "\\", $pathWithName);
  242. }
  243. if (strstr($pathWithName, '?') !== false) list ($pathWithName, $tmp) = explode('?', $pathWithName, 2);
  244. $ftp = parse_url($_GET["link"]);
  245. if ($ftp ["scheme"] == "ftp" && !$_GET ["proxy"]) {
  246. $AUTH ["ftp"] = array("login" => !empty($ftp ["user"]) ? $ftp ["user"] : "anonymous", "password" => !empty($ftp ["pass"]) ? $ftp ["pass"] : "anonymous@leechget.com");
  247. require_once (CLASS_DIR . "ftp.php");
  248. $file = getftpurl($_GET ["host"], !empty($ftp ["port"]) ? $ftp ["port"] : 21, $_GET ["path"], $pathWithName);
  249. } else {
  250. require_once (CLASS_DIR . "http.php");
  251. !empty($_GET ["force_name"]) ? $force_name = urldecode($_GET ["force_name"]) : '';
  252. $file = geturl($_GET ["host"], $_GET ["port"], $_GET ["path"], $_GET ["referer"], $_GET ["cookie"], $_GET ["post"], $pathWithName, $_GET ["proxy"], $pauth, $auth, $ftp ["scheme"]);
  253. }
  254. if ($options['redir'] && $lastError && stristr($lastError, $L->say['_error'] . " " . $L->say['_redirect_to'] . " [")) {
  255. $redirectto = trim(cut_str($lastError, $L->say['_error'] . " " . $L->say['_redirect_to'] . " [", "]"));
  256. print $L->say['_redirecting_to'] . " <b>$redirectto</b> ... <br />$nn";
  257. $_GET ["referer"] = $_GET ["link"];
  258. $_GET["link"] = $redirectto;
  259. $purl = parse_url($redirectto);
  260. if (strstr(basename($redirectto), '?') !== false) list ($_GET ["filename"], $tmp) = explode('?', basename($redirectto));
  261. else $_GET ["filename"] = basename($redirectto);
  262. // In case the redirect didn't include the host
  263. $_GET ["host"] = ($purl ["host"]) ? $purl ["host"] : $_GET ["host"];
  264. $_GET ["path"] = $purl ["path"] . ($purl ["query"] ? "?" . $purl ["query"] : "");
  265. $_GET ['port'] = $purl ['port'] ? $purl ['port'] : 80;
  266. $_GET ['cookie'] = !empty($_GET ["cookie"]) ? urlencode(encrypt($_GET["cookie"])) : "";
  267. $lastError = "";
  268. }
  269. } while ($redirectto && !$lastError);
  270. /* Deprecated of useless and unworth feature for some cases might fail this status.
  271. ongoingRemove(); */
  272. if ($lastError) {
  273. html_error($lastError, 0);
  274. } elseif ($file["bytesReceived"] == $file["bytesTotal"] || $file["size"] == "Unknown") {
  275. list($final_link, $current_time) = link_for_file(dirname($pathWithName) . "/" . basename($file["file"]), false, true);
  276. echo "<script type=\"text/javascript\">pr(100, '" . $file["size"] . "', '" . $file["speed"] . "')</script>";
  277. echo $L->sprintf($L->say['_filesaved'], $final_link, $file ["size"], $file ["time"], $file ["speed"]);
  278. $file["date"] = getNowzone($current_time);
  279. $tosave = array("name" => $file["file"], "size" => str_replace(" ", "&nbsp;", $file["size"]), "date" => $file["date"], "age" => $L->say['less_a_minute'], "link" => $_GET["link"], "comment" => str_replace("\n", "\\n", str_replace("\r", "\\r", $_GET["comment"])), "ip" => $ipmu);
  280. //print_r($tosave);
  281. $result = write_file(FILES_LST, serialize($tosave) . "\r\n", 0);
  282. $result2 = write_file(IP_L33CH_L0G, serialize(array("name" => $file["file"], "date" => $file["date"], "ip" => $ipmu)) . "\r\n", 0);
  283. if (!$result || !$result2) {
  284. echo $L->say['error_upd_list'] . "<br />";
  285. }
  286. if ($options["limitbytraffic"]) {
  287. if ($options["max_trafic"] > 0) {
  288. if (!is_numeric($traffic->total)) $traffic->total = 0;
  289. $traffic->total += $file["bytesReceived"];
  290. $traffic->updTraffic();
  291. }
  292. }
  293. if (!empty($_GET ["email"])) {
  294. require_once(CLASS_DIR . "mail.php");
  295. $_GET ["partSize"] = (isset($_GET ["partSize"]) && is_numeric($_GET ["partSize"]) ? $_GET ["partSize"] * 1024 * 1024 : false);
  296. if (xmail($fromaddr, $_GET ["email"], "File " . basename($file ["file"]), "File: " . basename($file ["file"]) . "\r\n" . "Link: " . $_GET ["link"] . (!empty($_GET ["comment"]) ? "\r\n" . "Comments: " . str_replace("\\r\\n", "\r\n", $_GET ["comment"]) : ""), $pathWithName, $_GET ["partSize"], ($_GET ["partSize"] && !empty($_GET ["method"]) ? $_GET ["method"] : ''))) {
  297. print $L->sprintf($L->say['mail_file_sent'], $_GET['email'], basename($file['file']));
  298. } else {
  299. print "<div class='acthistory_result'>" . $L->say['mail_error_send'] . "</div>";
  300. }
  301. }
  302. if ($options['new_window']) {
  303. print '<br /><a href="javascript:window.close();">' . $L->say['closewin'] . '</a>';
  304. } else {
  305. /* if ($options['pointboost'] > 0 && empty($_GET["idx"])) {
  306. // i'd rather not delete current downloaded file
  307. if(!defined("DOWNLOADED_FILE")){define('DOWNLOADED_FILE', DOWNLOAD_DIR.basename($file["file"]));}
  308. @write_file(DOWNLOADED_FILE, " ");
  309. if($numidx < $options["pointboost"]-1)
  310. {
  311. // generate reload form (link, secondcounterdown, auth, indexnumber)
  312. echo genReload($_GET["link"], 3, $auth, $numidx);
  313. }
  314. } */
  315. $rnd = rand(11, 99);
  316. // generate delete link
  317. echo $L->sprintf($L->say['_del_link'], 'del.php?d=' . str_replace("=", "", rotN(base64_encode($file["date"] . ':' . '4puZ'), $rnd)) . "-" . $rnd, date("M-d, Y - H:i:s", $file["date"]));
  318. print "<br /><a id='tdone' href=\"" . $PHP_SELF . "\">[&nbsp;<b><span id='txtdone'>" . $L->say['back_main'] . "&nbsp;]</b></span></a><br />";
  319. }
  320. } else {
  321. @unlink($pathWithName);
  322. print $L->say['con_lost'] . "<br /><a href=\"javascript:location.reload();\">" . $L->say['_reload'] . "</a>";
  323. print '<script type="text/javascript">setTimeout("location.reload()",1000);</script>';
  324. }
  325. //check whether this index called from audl.php
  326. $audlparam = (isset($_GET["idx"])) ? $_GET["idx"] : '';
  327. if ($audlparam != '') {
  328. $audlparam = explode('|', $audlparam);
  329. $audlparam[0] = ($audlparam[0] != '' ? true : false);
  330. if ($audlparam[1] == '') {
  331. $audlparam[1] = 'none';
  332. }
  333. echo autoNext($audlparam[0], true, $audlparam[1]);
  334. }
  335. echo('</div>');
  336. echo('</body>');
  337. echo('</html>');
  338. }
  339. ?>