PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/upload.php

http://rapidleech.googlecode.com/
PHP | 264 lines | 231 code | 14 blank | 19 comment | 36 complexity | 551c56c40f1c40483fdf27d026411a97 MD5 | raw file
  1. <?php
  2. define('RAPIDLEECH', 'yes');
  3. define('CONFIG_DIR', 'configs/');
  4. define('HOST_DIR', 'hosts/');
  5. error_reporting(0);
  6. set_time_limit(0);
  7. @ini_alter("memory_limit", "1024M");
  8. @ob_end_clean();
  9. ob_implicit_flush(TRUE);
  10. ignore_user_abort(1);
  11. clearstatcache();
  12. error_reporting(6135);
  13. $nn = "\r\n";
  14. require_once(CONFIG_DIR.'setup.php');
  15. require_once("classes/other.php");
  16. define ( 'TEMPLATE_DIR', 'templates/'.$options['template_used'].'/' );
  17. define('IMAGE_DIR', TEMPLATE_DIR . 'images/');
  18. login_check();
  19. include("classes/http.php");
  20. if(!defined('CRLF')) define('CRLF',"\r\n");
  21. $_REQUEST['filename']=base64_decode($_REQUEST['filename']);
  22. // Check if requested upload file is within our $options['download_dir']
  23. // We put basename() because we are quite sure that no one is able to upload things besides the download directory normally
  24. // htmlentities() prevents XSS attacks
  25. $_REQUEST['filename'] = htmlentities($options['download_dir'].basename($_REQUEST['filename']));
  26. $_REQUEST['uploaded'] = htmlentities($_REQUEST['uploaded']);
  27. // We want to check if the selected upload service is a valid ones
  28. $d = opendir ( HOST_DIR . "upload/" );
  29. while ( false !== ($modules = readdir ( $d )) ) {
  30. if ($modules != "." && $modules != "..") {
  31. if (is_file ( HOST_DIR . "upload/" . $modules )) {
  32. if (strpos ( $modules, ".index.php" ))
  33. include_once (HOST_DIR . "upload/" . $modules);
  34. }
  35. }
  36. }
  37. if (!in_array($_REQUEST['uploaded'],$upload_services) || !$_REQUEST['uploaded'] || !$_REQUEST['filename']) {
  38. html_error(lang(46));
  39. }
  40. $page_title = sprintf(lang(63),basename($_REQUEST['filename']),$_REQUEST['uploaded']);
  41. require(TEMPLATE_DIR.'/header.php');
  42. ?>
  43. <?php
  44. if (!file_exists($_REQUEST['filename']))
  45. {
  46. html_error(sprintf(lang(64),$filename));
  47. }
  48. if (is_readable($_REQUEST['filename']))
  49. {
  50. $lfile=$_REQUEST['filename'];
  51. $lname=basename($lfile);
  52. }
  53. else
  54. {
  55. html_error(sprintf(lang(65),$filename));
  56. }
  57. if (isset ( $_REQUEST ["useuproxy"] ) && (! $_REQUEST ["uproxy"] || ! strstr ( $_REQUEST ["uproxy"], ":" )))
  58. {
  59. html_error ( lang(324) );
  60. }
  61. else
  62. {
  63. $proxy = $_REQUEST ["uproxy"];
  64. }
  65. if ($_REQUEST ["upauth"])
  66. {
  67. $pauth = $_REQUEST ["upauth"];
  68. }
  69. else
  70. {
  71. $pauth = ($_REQUEST ["uproxyuser"] && $_REQUEST ["uproxypass"]) ? base64_encode ( $_REQUEST ["uproxyuser"] . ":" . $_REQUEST ["uproxypass"] ) : "";
  72. }
  73. $fsize = getSize($lfile);
  74. echo '<script type="text/javascript">var orlink="' . basename($_REQUEST['filename']) . ' to ' . $_REQUEST['uploaded'] . '";</script>';
  75. if (file_exists("hosts/upload/".$_REQUEST['uploaded'].".php")){
  76. include_once("hosts/upload/".$_REQUEST['uploaded'].".index.php");
  77. if ($max_file_size[$_REQUEST['uploaded']]!=false)
  78. if ($fsize > $max_file_size[$_REQUEST['uploaded']]*1024*1024)
  79. html_error(lang(66));
  80. include_once("hosts/upload/".$page_upload[$_REQUEST['uploaded']]);
  81. }
  82. else html_error(lang(67));
  83. if ($download_link || $delete_link || $stat_link || $adm_link)
  84. {
  85. //Protect down link with http://lix.in/
  86. /*
  87. if ($_REQUEST['protect']==1){
  88. unset($post);
  89. $post['url'] =$download_link;
  90. $post['button'] = 'Protect+Link';
  91. $post['op'] = 'crypt_single';
  92. $post['reset']='Clear';
  93. $page = geturl("lix.in",80,"/index.php","http://lix.in/",0,$post);
  94. $tmp = cut_str($page,"http://lix.in/","'");
  95. if (!empty($tmp)) $protect = "http://lix.in/".$tmp;
  96. }
  97. */
  98. echo "\n<table width=100% border=0>";
  99. echo ($download_link ? '<tr><td width="100" nowrap="nowrap" align="right"><b>'.lang(68).':</b><td width="80%"><input value="'.$download_link.'" class="upstyles-dllink" readonly="readonly" /></tr>' : '');
  100. echo ($delete_link ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(69).':<td width="80%"><input value="'.$delete_link.'" class="upstyles-dellink" readonly="readonly" /></tr>' : '');
  101. echo ($stat_link ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(70).':<td width="80%"><input value="'.$stat_link.'" class="upstyles-statlink" readonly="readonly" /></tr>' : '');
  102. echo ($adm_link ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(71).':<td width="80%"><input value="'.$adm_link.'" class="upstyles-admlink" readonly="readonly" /></tr>': '');
  103. echo ($user_id ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(72).':<td width="80%"><input value="'.$user_id.'" class="upstyles-userid" readonly="readonly" /></tr>': '');
  104. echo ($ftp_uplink ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(73).':<td width="80%"><input value="'.$ftp_uplink.'" class="upstyles-ftpuplink" readonly="readonly" /></tr>': '');
  105. echo ($access_pass ? '<tr><td width="100" nowrap="nowrap" align="right">'.lang(74).':<td width="80%"><input value="'.$access_pass.'" class="upstyles-accesspass" readonly="readonly" /></tr>': '');
  106. /*echo ($protect ? '<tr><td width="100" nowrap="nowrap" align="right">Protect link:<td width="80%"><input value="'.$protect.'" style="width:470px; border: 1px solid #55AAFF; background-color: #FFFFFF; padding:3px" readonly /></tr>': '');*/
  107. echo "</table>\n";
  108. if(!file_exists(trim($lfile).".upload.html") && !isset($_GET['auul']) && !$options['upload_html_disable'])
  109. {
  110. $html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  111. <html xmlns="http://www.w3.org/1999/xhtml">
  112. <head>
  113. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  114. <title>'.lang(75).'</title>
  115. <style type="text/css">
  116. body {
  117. font-family: tahoma, arial, "times New Roman", georgia, verdana, sans-serif;
  118. font-size: 11px;
  119. color: #333333;
  120. background-color: #EFF0F4;
  121. margin: 0px;
  122. padding: 0px;
  123. }
  124. .linktitle {
  125. width: 576px;
  126. background-color: #C291F9;
  127. text-align: center;
  128. padding:3px;
  129. margin-top: 25px;
  130. margin-right: auto;
  131. margin-bottom: 0;
  132. margin-left: auto;
  133. border-top-width: 1px;
  134. border-right-width: 1px;
  135. border-bottom-width: 0px;
  136. border-left-width: 1px;
  137. border-top-style: solid;
  138. border-right-style: solid;
  139. border-bottom-style: solid;
  140. border-left-style: solid;
  141. border-top-color: #C7C4FB;
  142. border-right-color: #C7C4FB;
  143. border-bottom-color: #C7C4FB;
  144. border-left-color: #C7C4FB;
  145. }
  146. .bluefont {
  147. color: #0E078F;
  148. font-family: tahoma, arial, "times New Roman", georgia, verdana, sans-serif;
  149. font-size: 11px;
  150. }
  151. hr {
  152. border-top-width: 0px;
  153. border-right-width: 0px;
  154. border-bottom-width: 0px;
  155. border-left-width: 0px;
  156. border-top-style: solid;
  157. height: 1px;
  158. background-color: #046FC6;
  159. color: #046FC6;
  160. border-right-style: solid;
  161. border-bottom-style: solid;
  162. border-left-style: solid;
  163. width: 90%;
  164. }
  165. .host .links {
  166. width: 95%;
  167. margin:0 auto;
  168. text-align:left;
  169. padding:3px 0 3px 10px;
  170. border: 1px dashed #666666;
  171. background-color: #F2F1FE;
  172. }
  173. .host {
  174. width: 600px;
  175. margin: 10px auto 10px;
  176. }
  177. .host .links a {
  178. text-decoration:none;
  179. color: #666666;
  180. font-size: 11px;
  181. }
  182. .host .links a:hover {
  183. text-decoration:none;
  184. color:#E8740B
  185. }
  186. .host .title {
  187. width: 95%;
  188. margin:0 auto;
  189. text-align:left;
  190. padding:3px 0 3px 10px;
  191. background-color: #C7C4FB;
  192. color: #000000;
  193. border-top-width: 1px;
  194. border-right-width: 1px;
  195. border-bottom-width: 0px;
  196. border-left-width: 1px;
  197. border-top-style: dashed;
  198. border-right-style: dashed;
  199. border-bottom-style: dashed;
  200. border-left-style: dashed;
  201. border-top-color: #333333;
  202. border-right-color: #333333;
  203. border-bottom-color: #333333;
  204. border-left-color: #333333;
  205. font-size: 12px;
  206. font-family: Georgia, "Times New Roman", Times, serif;
  207. }
  208. </style>
  209. </head>
  210. <body>
  211. ';
  212. write_file(trim($lfile).".upload.html", $html_header.sprintf(lang(76),$lname,bytesToKbOrMb($fsize)), 0);
  213. if (!$options['upload_html_disable']) {
  214. $html_content = '<div class="host"><div class="title"><strong>'.$_REQUEST['uploaded'].'</strong> - <span class="bluefont">'.date("Y-m-d H:i:s").'</span></div>
  215. <div class="links">'.
  216. ($download_link ? '<strong>'.lang(68).': <a href="'.$download_link.'" target="_blank">'.$download_link.' </a></strong>' : '').
  217. ($delete_link ? '<br />'.lang(69).': <a href="'.$delete_link.'" target="_blank">'.$delete_link.' </a>' : '').
  218. ($stat_link ? '<br />'.lang(70).': <a href="'.$stat_link.'" target="_blank">'.$stat_link.' </a>' : '').
  219. ($adm_link ? '<br />'.lang(71).': <a href="'.$adm_link.'" target="_blank">'.$adm_link.' </a>' : '').
  220. ($user_id ? '<br />'.lang(72).': <a href="'.$user_id.'" target="_blank">'.$user_id.' </a>' : '').
  221. ($access_pass ? '<br />'.lang(74).': <a href="'.$access_pass.'" target="_blank">'.$access_pass.' </a>' : '').
  222. ($ftp_uplink ? '<br />'.lang(73).': <a href="'.$ftp_uplink.'" target="_blank">'.$ftp_uplink.' </a>' : '').
  223. '</div></div>';
  224. write_file(trim($lfile).".upload.html", $html_content, 0);
  225. }
  226. }
  227. }
  228. echo $not_done ? "" : '<p><center><b><a href="javascript:window.close();">'.lang(77).'</a></b></center>';
  229. ?>
  230. </body>
  231. </html>
  232. <?php
  233. if (isset($_GET['auul'])) {
  234. ?><script type="text/javascript">parent.nextlink<?php echo $_GET['auul']; ?>();</script><?php
  235. // Write links to a file
  236. $file = $options['download_dir']."myuploads.txt"; // Obviously it was a mistake not making it a variable earlier
  237. if (!$options['myuploads_disable']) {
  238. if (!$_GET['save_style'] && $_GET['save_style'] !== lang(51)) {
  239. $dash = "";
  240. for ($i=0;$i<=80;$i++) $dash.="=";
  241. write_file($file, $lname."\r\n".$dash."\r\n".$download_link."\r\n\r\n", 0);
  242. } else {
  243. $save_style = base64_decode($_GET['save_style']);
  244. $save_style = str_replace('{link}',$download_link,$save_style);
  245. $save_style = str_replace('{name}',$lname,$save_style);
  246. write_file($file, $save_style."\r\n", 0);
  247. }
  248. }
  249. }
  250. ?>