Advertisement
terorama

PHP Console

Oct 13th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.31 KB | None | 0 0
  1. <?php
  2. ob_start();
  3.  
  4. $logform =<<<INF
  5.    <form action="{$_SERVER["PHP_SELF"]}" method="post" name="logform"
  6.             enctype="application/www-form-urlencoded">
  7.    <fieldset>
  8.    <legend>input auth code</legend>
  9.    <label for="password">input password</label>
  10.        <input type="text" name="password" />
  11.        <input type="submit" name="submit" value="submit" />
  12.    </fieldset>
  13.    </form>
  14.  
  15. INF;
  16.  
  17. $fname4 = isset($_POST["fname"])?$_POST["fname"]:'test.php';
  18. $phptext4 = isset($_POST["phptext"])?$_POST["phptext"]:'text...';
  19. $load4 = isset($_POST["load"])?"checked":"";
  20.  
  21. function php_inform() {
  22.  
  23.    global $fname4;
  24.    global $phptext4;
  25.    global $load4;
  26.  
  27. $php_inpform = <<<INF
  28.    <script type="text/javascript">
  29.       function checkpos(el) {
  30.  
  31.          var zdiv = document.getElementById("posdiv");
  32.       }
  33.      
  34.    </script>
  35.    <form action="{$_SERVER["REQUEST_URI"]}" method="post" name="phpform"
  36.              enctype="application/www-form-urlencoded" >
  37.    <fieldset>
  38.    <legend>PHP Exec Form</legend>
  39.    <label for="fname">Input file name</label>
  40.    <input type="text" name="fname" value="{$fname4}" />
  41.    <p>Input PHP text</p>
  42.    <textarea name="phptext" rows="40" cols="100">{$phptext4}</textarea>
  43.    <br />
  44.    <input type="submit" name="submit" value="submit" /> Load
  45.    <input type="checkbox" name="load" {$load4} />
  46.    <div id="posdiv"></div>
  47.    </fieldset>
  48.    </form>
  49.  
  50. INF;
  51.  
  52.    return $php_inpform;
  53. }
  54.  
  55.  
  56.    session_start();
  57.  
  58.    if (isset($_GET["reset"])) {
  59.  
  60.       session_destroy();
  61.       ob_clean();
  62.       header('Location: '.$_SERVER["PHP_SELF"]);
  63.    }
  64.  
  65.    if (!isset($_SESSION["logged"]))
  66.       logon();
  67.    else
  68.       php_execform();
  69.  
  70.    //---------------------------------------
  71.    function logon() {
  72.  
  73.       global $logform;
  74.  
  75.       if (isset($_POST["submit"])) {
  76.  
  77.          if (@$_POST["createpass"]==true) {
  78.  
  79.             $fh = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'hash8.txt', 'w');
  80.             fwrite($fh,md5($_POST["password"]));
  81.             fclose($fh);
  82.             echo "password created";
  83.             exit();
  84.          }
  85.  
  86.          $pass=md5($_POST["password"]);
  87.  
  88.          $fh = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'hash.txt','r');
  89.  
  90.          $s=fread($fh, 1024);
  91.  
  92.          fclose($fh);
  93.  
  94.          if ($pass!=$s) {
  95.             echo "invalid password<br/>";
  96.             echo "<a href=\"{$_SERVER["REQUEST_URI"]}\" />back</a>";
  97.            
  98.             }
  99.          else
  100.             {
  101.                $_SESSION["logged"]=true;
  102.                ob_clean();
  103.                header('Location:'.$_SERVER["PHP_SELF"]);
  104.             }
  105.       }
  106.       else {
  107.          echo $logform;
  108.       }
  109.    }
  110.  
  111.    //---------------------------------------
  112.    function php_execform() {
  113.  
  114.  
  115.       $fn=dirname(__FILE__).'/'.(isset($_POST["fname"])?$_POST["fname"]:'test.php');
  116.  
  117.       $fnz = 'http://'.$_SERVER["SERVER_NAME"].
  118.                      substr($_SERVER["SCRIPT_NAME"],0,strrpos($_SERVER["SCRIPT_NAME"],'/')+1).
  119.                      (isset($_POST["fname"])?$_POST["fname"]:'test.php');
  120.  
  121.       if (isset($_POST["submit"]) ) {
  122.  
  123.          if (!isset($_POST["load"])) {
  124.             echo 'write file<br/>';
  125.            
  126.  
  127.             $fh = fopen($fn,'w');
  128.             fwrite($fh, $_POST["phptext"]);
  129.             fclose($fh);
  130.            }
  131.          else
  132.            {
  133.              global $phptext4;
  134.              
  135.              $phptext4=file_get_contents($fn);
  136.              
  137.            }
  138.         }
  139.  
  140.         echo '<div style="float:left;width:900px;">';
  141.         echo php_inform();
  142.         echo '</div><div style="margin-left:900px;background-color:#eee;">';
  143.  
  144.         echo $fnz.'<hr>';
  145.         echo file_get_contents($fnz);
  146.        
  147.      
  148.        
  149.        
  150.      
  151.  
  152.       echo '</div><div style="margin-top=10px;background-color:#ffe;margin-left:900px;">';
  153.       $fh = fopen ($fn, 'r');
  154.       $i=1;
  155.       $strz='';
  156.       while ($row= fgets($fh)) {
  157.          $row=htmlentities($row);
  158.          $strz.= $i.' '.$row;
  159.          $i++;
  160.       }
  161.       echo '<pre>'.$strz.'</pre></div><div style="margin-top=10px;margin-left:900px;">';
  162.      
  163.       $d= opendir('.');
  164.       while ($f=readdir($d)) {
  165.          if (is_file($f)) {
  166.             echo $f.' '.date('d.m.Y H:i:s',filemtime($f)).' '.filesize($f).'<br />';
  167.          }
  168.       }
  169.      
  170.       echo '</div>';
  171.    }
  172.  
  173.  
  174. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement