PageRenderTime 141ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

http://rapidleech.googlecode.com/
PHP | 324 lines | 259 code | 50 blank | 15 comment | 135 complexity | ca0fefb8f662bdb9bc664058d899f3d6 MD5 | raw file
  1. <?php
  2. // ini_set('display_errors', 0);
  3. @set_time_limit(0);
  4. ini_alter('memory_limit', '1024M');
  5. if (ob_get_level()) ob_end_clean();
  6. ob_implicit_flush(true);
  7. ignore_user_abort(true);
  8. clearstatcache();
  9. error_reporting(6135);
  10. $nn = "\r\n";
  11. $fromaddr = 'RapidLeech';
  12. $dev_name = 'Development Stage';
  13. $rev_num = '43';
  14. $plusrar_v = '4.1';
  15. $PHP_SELF = $_SERVER['SCRIPT_NAME'];
  16. define('RAPIDLEECH', 'yes');
  17. define('ROOT_DIR', realpath ('./'));
  18. define('PATH_SPLITTER', ((strpos(ROOT_DIR, "\\") !== false) ? "\\" : '/'));
  19. define('HOST_DIR', 'hosts/');
  20. define('CLASS_DIR', 'classes/');
  21. define('CONFIG_DIR', 'configs/');
  22. define('BUILD', '30May2011');
  23. define('CREDITS', '<a href="http://www.rapidleech.com/" class="rl-link"><b>RapidLeech</b></a>&nbsp;<b class="rev-dev">PlugMod (eqbal) rev. ' . $rev_num . '</b> <span class="rev-dev">' . $dev_name . '</span><br><small class="small-credits">Credits to Pramode &amp; Checkmate &amp; Kloon</small><br /><p class="rapidleechhost"><a href="http://www.rapidleechhost.com/aff.php?aff=001" target="_blank">RapidleechHost Offical Hosting</a></p>');
  24. require_once(CONFIG_DIR . 'setup.php');
  25. // $options['download_dir'] should always end with a '/'
  26. if (substr($options['download_dir'], - 1) != '/') $options['download_dir'] .= '/';
  27. define('DOWNLOAD_DIR', (substr ($options['download_dir'], 0, 6) == 'ftp://' ? '' : $options['download_dir']));
  28. define('TEMPLATE_DIR', 'templates/' . $options['template_used'] . '/');
  29. define('IMAGE_DIR', TEMPLATE_DIR . 'images/');
  30. if ($options['no_cache']) {
  31. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  32. header('Last-Modified: ' . gmdate ("D, d M Y H:i:s") . 'GMT');
  33. header('Cache-Control: no-cache, must-revalidate');
  34. header('Pragma: no-cache');
  35. }
  36. if (!defined('CRLF')) define ('CRLF', "\r\n");
  37. if (!defined('FTP_AUTOASCII')) define('FTP_AUTOASCII', -1);
  38. if (!defined('FTP_BINARY')) define('FTP_BINARY', 1);
  39. if (!defined('FTP_ASCII')) define('FTP_ASCII', 0);
  40. if (!defined('FTP_FORCE')) define('FTP_FORCE', true);
  41. define('FTP_OS_Unix', 'u');
  42. define('FTP_OS_Windows', 'w');
  43. define('FTP_OS_Mac', 'm');
  44. require_once(CLASS_DIR . 'other.php');
  45. require_once(TEMPLATE_DIR . 'functions.php');
  46. // If configs/files.lst is not writable, give a warning
  47. if (!is__writable(CONFIG_DIR . 'files.lst')) html_error(lang(304));
  48. // If the download path is not writable, show error
  49. if (!is__writable (DOWNLOAD_DIR)) html_error(DOWNLOAD_DIR . lang(305));
  50. purge_files($options['delete_delay']);
  51. register_shutdown_function('pause_download');
  52. login_check();
  53. $_REQUEST['premium_acc'] = $_POST['premium_acc'] = isset($_REQUEST['premium_acc']) && $_REQUEST['premium_acc'] == 'on' ? 'on' : false;
  54. $_REQUEST['cookieuse'] = $_POST['cookieuse'] = isset($_REQUEST['cookieuse']) && $_REQUEST['cookieuse'] == 'on' ? 'on' : false;
  55. foreach($_POST as $key => $value) $_GET[$key] = $value;
  56. if (!$_COOKIE) {
  57. if (isset($_SERVER['HTTP_COOKIE']) && strpos ($_SERVER['HTTP_COOKIE'], ';') !== false) {
  58. foreach(explode('; ', $_SERVER['HTTP_COOKIE']) as $key => $value) {
  59. list ($var, $val) = explode('=', $value);
  60. $_COOKIE[$var] = $val;
  61. }
  62. }
  63. else if (!empty($_SERVER['HTTP_COOKIE'])) {
  64. list($var, $val) = @explode('=', $_SERVER['HTTP_COOKIE']);
  65. $_COOKIE[$var] = $val;
  66. }
  67. }
  68. require_once(CLASS_DIR . 'cookie.php');
  69. if (!@file_exists(HOST_DIR . 'download/hosts.php')) html_error(lang(127));
  70. // require "hosts.php";
  71. require_once(HOST_DIR . 'download/hosts.php');
  72. if (!empty ($_GET['image'])) {
  73. require_once(CLASS_DIR . 'http.php');
  74. require_once(CLASS_DIR . 'image.php');
  75. exit();
  76. }
  77. if (isset($_GET['useproxy']) && (empty($_GET['proxy']) || strpos($_GET['proxy'], ':') === false)) {
  78. html_error(lang(324));
  79. } else {
  80. if (!empty($_GET['pauth'])) $pauth = decrypt(urldecode(trim($_GET['pauth'])));
  81. else $pauth = (!empty($_GET['proxyuser']) && !empty($_GET['proxypass'])) ? base64_encode($_GET['proxyuser'] . ':' . $_GET['proxypass']) : '';
  82. }
  83. if (empty($_GET['path']) || $options['download_dir_is_changeable'] == false) {
  84. if (empty($_GET['host'])) $_GET['path'] = (substr($options['download_dir'], 0, 6) != 'ftp://') ? realpath(DOWNLOAD_DIR) : $options['download_dir'];
  85. else $_GET['saveto'] = (substr($options['download_dir'], 0, 6) != 'ftp://') ? realpath(DOWNLOAD_DIR) : $options['download_dir'];
  86. }
  87. if (empty($_GET['filename']) || empty($_GET['host']) || empty($_GET['path'])) {
  88. $LINK = !empty($_GET['link']) ? trim(rawurldecode($_GET['link'])) : false;
  89. if (!$LINK) {
  90. require_once(CLASS_DIR . 'main.php');
  91. exit();
  92. }
  93. check_referer();
  94. // Detect if it doesn't have a protocol assigned
  95. if (stripos($LINK, '://') === false || (substr($LINK, 0, 7) != 'http://' && substr($LINK, 0, 6) != 'ftp://' && substr($LINK, 0, 6) != 'ssl://' && substr($LINK, 0, 8) != 'https://')) {
  96. // Automatically assign http://
  97. $LINK = 'http://' . $LINK;
  98. }
  99. if (!empty($_GET['saveto']) && empty($_GET['path'])) html_error(lang(6));
  100. if (empty($_GET['useproxy'])) $_GET['proxy'] = '';
  101. if (!empty($_GET['domail']) && !checkmail($_GET['email'])) {
  102. html_error(lang(3));
  103. if (!empty($_GET['split']) && !is_numeric($_GET['partSize'])) html_error(lang(4)); // T-8: Check this.
  104. }
  105. $Url = parse_url($LINK);
  106. $Url['path'] = (empty($Url['path'])) ? '/' :str_replace('%2F', '/', rawurlencode(rawurldecode($Url['path'])));
  107. $LINK = rebuild_url($Url);
  108. if (empty($_GET['referer'])) {
  109. $Referer = $Url;
  110. // Remove login from Referer
  111. unset($Referer['user'], $Referer['pass']);
  112. $Referer = rebuild_url($Referer);
  113. } else $Referer = trim(rawurldecode($_GET['referer']));
  114. if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') html_error(lang(5));
  115. if (empty($Url['user']) xor empty($Url['pass'])) {
  116. unset($Url['user'], $Url['pass']);
  117. $LINK = rebuild_url($Url);
  118. }
  119. if (isset($_GET['user_pass']) && $_GET['user_pass'] == 'on' && !empty($_GET['iuser']) && !empty($_GET['ipass'])) {
  120. $Url['user'] = $_GET['iuser'];
  121. $Url['pass'] = $_GET['ipass'];
  122. // Rebuild url
  123. $LINK = rebuild_url($Url);
  124. }
  125. // If Url has user & pass, use them as premium login for plugins and set $auth for direct download.
  126. if (!empty($Url['user']) && !empty($Url['pass'])) {
  127. if (empty($_REQUEST['premium_acc'])) $_GET['premium_acc'] = $_POST['premium_acc'] = $_REQUEST['premium_acc'] = 'on';
  128. $_GET['premium_user'] = $_POST['premium_user'] = $_REQUEST['premium_user'] = $Url['user'];
  129. $_GET['premium_pass'] = $_POST['premium_pass'] = $_REQUEST['premium_pass'] = $Url['pass'];
  130. $auth = urlencode(encrypt(base64_encode(rawurlencode($Url['user']) . ':' . rawurlencode($Url['pass']))));
  131. // Lets delete User and Pass from link because isn't needed now.
  132. unset($Url['user'], $Url['pass']);
  133. $LINK = rebuild_url($Url);
  134. } else $auth = '';
  135. if (empty($_GET['dis_plug']) || $_GET ['dis_plug'] != 'on') {
  136. // check Domain-Host
  137. foreach ($host as $site => $file) {
  138. if (host_matchs($site, $Url['host'])) {
  139. include(TEMPLATE_DIR . '/header.php');
  140. require_once (CLASS_DIR . 'http.php');
  141. require_once (HOST_DIR . 'DownloadClass.php');
  142. require_once (HOST_DIR . 'download/' . $file);
  143. $class = substr($file, 0, -4);
  144. $firstchar = substr($file, 0, 1);
  145. if ($firstchar > 0) $class = "d$class";
  146. if (class_exists($class)) {
  147. $hostClass = new $class();
  148. $hostClass->Download($LINK);
  149. }
  150. exit();
  151. }
  152. }
  153. }
  154. // print "<html>$nn<head>$nn<title>Downloading $LINK</title>$nn<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />$nn</head>$nn<body>$nn";
  155. include(TEMPLATE_DIR . '/header.php');
  156. $FileName = isset($Url['path']) ? basename($Url['path']) : '';
  157. $mydomain = ($pos = strpos($_SERVER['HTTP_HOST'], ':')) !== false ? substr($_SERVER['HTTP_HOST'], 0, $pos) : $_SERVER['HTTP_HOST'];
  158. if ($options['bw_save'] && ($Url['host'] == $_SERVER['SERVER_ADDR'] || host_matchs($mydomain, $Url['host']))) html_error(sprintf(lang(7), $mydomain, $_SERVER['SERVER_ADDR']));
  159. $redir = GetDefaultParams();
  160. $redir['dis_plug'] = 'on';
  161. $redir['filename'] = urlencode($FileName);
  162. $redir['host'] = urlencode($Url['host']);
  163. if (!empty($Url['port'])) $redir['port'] = urlencode($Url['port']);
  164. $redir['path'] = urlencode($Url['path'] . (!empty($Url['query']) ? '?' . $Url['query'] : ''));
  165. if (!empty($Referer)) $redir['referer'] = urlencode($Referer);
  166. $redir['link'] = urlencode($LINK);
  167. if (!empty($_GET['cookie'])) $redir['cookie'] = urlencode(encrypt($_GET['cookie']));
  168. if (!empty($auth)) $redir['auth'] = $auth;
  169. insert_location($redir);
  170. } else {
  171. include(TEMPLATE_DIR . '/header.php');
  172. check_referer();
  173. echo('<div align="center">');
  174. do {
  175. $_GET['filename'] = urldecode(trim($_GET['filename']));
  176. if (strpos($_GET['filename'], '?') !== false) $_GET['filename'] = substr($_GET['filename'], 0, strpos($_GET['filename'], '?'));
  177. $_GET['saveto'] = urldecode(trim($_GET['saveto']));
  178. $_GET['host'] = urldecode(trim($_GET['host']));
  179. $_GET['path'] = urldecode(trim($_GET['path']));
  180. $_GET['port'] = !empty($_GET['port']) ? urldecode(trim($_GET['port'])) : 80;
  181. $_GET['referer'] = !empty($_GET['referer']) ? urldecode(trim($_GET['referer'])) : 0;
  182. $_GET['link'] = urldecode(trim($_GET['link']));
  183. $_GET['post'] = !empty($_GET['post']) ? unserialize(decrypt(urldecode(trim($_GET['post'])))) : 0;
  184. $_GET['cookie'] = !empty($_GET['cookie']) ? decrypt(urldecode(trim($_GET['cookie']))) : '';
  185. $_GET['proxy'] = !empty($_GET['proxy']) ? trim(urldecode($_GET['proxy'])) : '';
  186. // $resume_from = $_GET["resume"] ? intval(urldecode(trim($_GET["resume"]))) : 0;
  187. // if ($_GET["resume"]) {unset($_GET["resume"]);}
  188. $redirectto = '';
  189. $pauth = !empty($_GET['pauth']) ? decrypt(urldecode(trim($_GET['pauth']))) : '';
  190. $_GET['auth'] = !empty($_GET['auth']) ? trim($_GET['auth']) : '';
  191. if ($_GET['auth'] == '1') {
  192. if (!preg_match('|^(?:.+\.)?(.+\..+)$|i', $_GET['host'], $hostmatch)) html_error('No valid hostname found for authorisation!');
  193. $hostmatch = str_replace('.', '_', $hostmatch[1]);
  194. if (isset($premium_acc["$hostmatch"]) && is_array($premium_acc["$hostmatch"]) && !empty($premium_acc["$hostmatch"]['user']) && !empty($premium_acc["$hostmatch"]['pass'])) {
  195. $auth = base64_encode($premium_acc["$hostmatch"]['user'] . ":" . $premium_acc["$hostmatch"]['pass']);
  196. } else html_error('No usable premium account found for this download - please set one in accounts.php');
  197. } elseif (!empty($_GET['auth'])) {
  198. $auth = decrypt(urldecode($_GET['auth']));
  199. $AUTH['use'] = true;
  200. $AUTH['str'] = $auth;
  201. } else $auth = $AUTH = false;
  202. $pathWithName = $_GET['saveto'] . PATH_SPLITTER . $_GET['filename'];
  203. while (stripos($pathWithName, "\\\\") !== false) {
  204. $pathWithName = str_replace("\\\\", "\\", $pathWithName);
  205. }
  206. if (strpos($pathWithName, '?') !== false) $pathWithName = substr($pathWithName, 0, strpos($pathWithName, '?'));
  207. $url = parse_url($_GET['link']);
  208. if (isset($url['scheme']) && $url['scheme'] == 'ftp' && empty($_GET['proxy'])) {
  209. $AUTH['ftp'] = array('login' => !empty($url['user']) ? $url['user'] : 'anonymous', 'password' => !empty($url['pass']) ? $url['pass'] : 'anonymous@leechget.com');
  210. require_once(CLASS_DIR . 'ftp.php');
  211. $file = getftpurl($_GET['host'], !empty($url['port']) ? $url['port'] : 21, $_GET['path'], $pathWithName);
  212. } else {
  213. require_once(CLASS_DIR . 'http.php');
  214. !empty($_GET['force_name']) ? $force_name = urldecode($_GET['force_name']) : '';
  215. $file = geturl($_GET['host'], $_GET['port'], $_GET['path'], $_GET['referer'], $_GET['cookie'], $_GET['post'], $pathWithName, $_GET['proxy'], $pauth, $auth, $url['scheme']);
  216. }
  217. if ($options['redir'] && $lastError && strpos($lastError, substr(lang(95), 0, strpos(lang(95), '%1$s'))) !== false) {
  218. $redirectto = trim(cut_str($lastError, substr(lang(95), 0, strpos(lang(95), '%1$s')), ']'));
  219. print lang(8) . " <b>$redirectto</b> ... <br />$nn";
  220. $_GET['referer'] = urlencode($_GET['link']);
  221. if (strpos($redirectto, '://') === false) { // If redirect doesn't have the host
  222. $ref = parse_url(urldecode($_GET['referer']));
  223. unset($ref['user'], $ref['pass'], $ref['query'], $ref['fragment']);
  224. if (substr($redirectto, 0, 1) != '/') $redirectto = "/$redirectto";
  225. $purl = array_merge($ref, parse_url($redirectto));
  226. } else $purl = parse_url($redirectto);
  227. $_GET['link'] = urlencode(rebuild_url($purl));
  228. $_GET['filename'] = urlencode(basename($purl['path']));
  229. $_GET['host'] = urlencode($purl['host']);
  230. $_GET['path'] = urlencode($purl['path'] . (!empty($purl['query']) ? '?' . $purl['query'] : ''));
  231. $_GET['port'] = !empty($purl['port']) ? $purl['port'] : 80;
  232. $_GET['cookie'] = !empty($_GET['cookie']) ? urlencode(encrypt($_GET['cookie'])) : '';
  233. if (is_array($_GET['post'])) $_GET['post'] = urlencode(encrypt(serialize($_GET['post'])));
  234. if (!empty($_GET['proxy'])) {
  235. $_GET['proxy'] = urlencode($_GET['proxy']);
  236. if (!empty($pauth)) $_GET['pauth'] = urlencode(encrypt($pauth));
  237. }
  238. $lastError = $_GET['auth'] = ''; // With $_GET['auth'] empty it will still using the $auth
  239. unset($ref, $purl);
  240. }
  241. } while ($redirectto && !$lastError);
  242. if ($lastError) html_error($lastError, 0);
  243. elseif ($file['bytesReceived'] == $file['bytesTotal'] || $file['size'] == 'Unknown') {
  244. echo '<script type="text/javascript">' . "pr(100, '" . $file['size'] . "', '" . $file['speed'] . "')</script>\r\n";
  245. echo sprintf(lang(10), link_for_file(dirname($pathWithName) . '/' . basename($file['file'])), $file['size'], $file['time'], $file['speed']);
  246. $file['date'] = time();
  247. if (!write_file(CONFIG_DIR . 'files.lst', serialize(array('name' => $file['file'], 'size' => $file['size'], 'date' => $file['date'], 'link' => $_GET['link'], 'comment' => (!empty($_GET['comment']) ? str_replace(array("\r", "\n"), array('\r', '\n'), $_GET['comment']) : ''))) . "\r\n", 0)) echo lang(9) . '<br />';
  248. if (!empty($_GET['email']) && !$options['disable_email']) {
  249. require_once(CLASS_DIR . 'mail.php');
  250. $_GET['partSize'] = (isset($_GET['partSize']) && is_numeric($_GET['partSize']) ? $_GET['partSize'] * 1024 * 1024 : false);
  251. 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 (array('\r', '\n'), array("\r", "\n"), $_GET['comment']) : ''), $pathWithName, $_GET['partSize'], ($_GET['partSize'] && !empty($_GET['method']) ? $_GET['method'] : ''))) {
  252. printf(lang(11), $_GET['email'], basename($file['file']));
  253. } else echo lang(12) . '<br />';
  254. }
  255. echo "\n<form method='POST' name='flist' action='$PHP_SELF'>\n";
  256. echo "\t<input type='hidden' name='files[]' value='{$file['date']}' /><br />\n";
  257. echo "\t<div style='text-align:center;'>\n";
  258. echo renderActions();
  259. echo "\t</div>\n";
  260. echo "</form>\n";
  261. if ($options['new_window']) echo '<br /><a href="javascript:window.close();">' . lang(378) . '</a>';
  262. else echo "<br /><a href='$PHP_SELF'>" . lang(13) . "</a>";
  263. if (!empty($_GET['audl'])) echo $nn . '<script type="text/javascript">parent.nextlink();</script>';
  264. } else {
  265. unlink($pathWithName);
  266. print lang(14) . '<br /><a href="javascript:location.reload();">' . lang(15) . '</a>';
  267. if (!empty($_GET['audl'])) {
  268. echo $nn . '<script type="text/javascript">parent.nextlink();</script>';
  269. }
  270. echo '<script type="text/javascript">location.reload();</script>';
  271. }
  272. echo "\n</div>\n</body>\n</html>";
  273. }
  274. ?>