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

/upload.php

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