Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- $logform =<<<INF
- <form action="{$_SERVER["PHP_SELF"]}" method="post" name="logform"
- enctype="application/www-form-urlencoded">
- <fieldset>
- <legend>input auth code</legend>
- <label for="password">input password</label>
- <input type="text" name="password" />
- <input type="submit" name="submit" value="submit" />
- </fieldset>
- </form>
- INF;
- function php_inform() {
- ob_start();
- ?>
- <script type="text/javascript" src="jquery.min.js"></script>
- <script type="text/javascript">
- function checkpos(el) {
- var zdiv = document.getElementById("posdiv");
- }
- function onSuccess(inf) {
- if (inf['reztype']=='load') {
- document.forms.phpform.phptext.value = inf['rez'];
- $('#sourcediv').html('<pre>'+inf['source']+'</pre>');
- if (window.infblock)
- infblock.html('document loaded');
- }
- else {
- if (!window.infblock) {
- $('form[name=phpform] textarea').before($('<div/>',{id:'infblock'}).html('status'));
- infblock = $('#infblock').css('color','green');
- }
- infblock.html(inf.rez);
- }
- }
- function ajax_go(action, fname, content) {
- if (!content)
- content = '';
- if (window.infblock)
- infblock.html('Waiting...');
- $.ajax ( {
- type: 'POST',
- url: '<?=$_SERVER["PHP_SELF"]?>',
- data: {
- ajax:'',action:action, fname:fname, content: content
- },
- dataType: 'json',
- success: onSuccess
- }
- )
- }
- function load_file(el) {
- var fname = el.form.fname.value;
- ajax_go('load', fname);
- }
- function save_file(el) {
- var fname = el.form.fname.value;
- var content = el.form.phptext.value;
- ajax_go('save', fname, content);
- }
- function launch_file(el) {
- var fname = el.form.fname.value;
- window.open(fname);
- }
- </script>
- <?php
- $php_header = ob_get_clean();
- $php_inpform = <<<INF
- <form name="phpform"
- enctype="application/www-form-urlencoded" >
- <fieldset>
- <legend>PHP Exec Form</legend>
- <label for="fname">Input file name</label>
- <input type="text" name="fname" value="" />
- <input type="button" onclick="load_file(this)" value="load" />
- <input type="button" onclick="save_file(this)" value="save" />
- <input type="button" onclick="launch_file(this)" value="launch" />
- <p>Input PHP text</p>
- <textarea name="phptext" rows="40" cols="100"></textarea>
- <br />
- <div id="posdiv"></div>
- </fieldset>
- </form>
- INF;
- return $php_header."\r\n".$php_inpform;
- }
- session_start();
- if (isset($_GET["reset"])) {
- session_destroy();
- ob_clean();
- header('Location: '.$_SERVER["PHP_SELF"]);
- }
- if (!isset($_SESSION["logged"]))
- logon();
- else
- php_execform();
- //---------------------------------------
- function logon() {
- global $logform;
- if (isset($_POST["submit"])) {
- if (@$_POST["createpass"]==true) {
- $fh = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'hash8.txt', 'w');
- fwrite($fh,md5($_POST["password"]));
- fclose($fh);
- echo "password created";
- exit();
- }
- $pass=md5($_POST["password"]);
- $fh = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR.'hash.txt','r');
- $s=fread($fh, 1024);
- fclose($fh);
- if ($pass!=$s) {
- echo "invalid password<br/>";
- echo "<a href=\"{$_SERVER["REQUEST_URI"]}\" />back</a>";
- }
- else
- {
- $_SESSION["logged"]=true;
- ob_clean();
- header('Location:'.$_SERVER["PHP_SELF"]);
- }
- }
- else {
- echo $logform;
- }
- }
- //---------------------------------------
- function php_execform() {
- if (isset($_POST["ajax"])) {
- $source = '';
- if ($_POST["action"]=='load') {
- $reztype = 'load';
- $rez =file_get_contents(dirname(__FILE__).'/'.$_POST['fname']);
- $fn=dirname(__FILE__).'/'.(isset($_POST["fname"])?$_POST["fname"]:'test.php');
- $fh = fopen ($fn, 'r');
- $i=1;
- $strz='';
- while ($row= fgets($fh)) {
- $row=htmlentities($row);
- $strz.= $i.' '.$row;
- $i++;
- }
- $source = $strz;
- } else {
- $reztype = 'save';
- file_put_contents(dirname(__FILE__).'/'.$_POST['fname'], $_POST['content']);
- $rez = "document ".$_POST["fname"].' saved';
- }
- echo json_encode(Array('reztype'=>$reztype, 'rez'=>$rez, 'source'=>$source));
- return;
- }
- //-------------------------------------------
- echo '<div style="float:left;width:900px;">';
- echo php_inform();
- echo '</div>';
- echo '<div id= "sourcediv" style="margin-top=10px;background-color:#ffe;margin-left:900px;">';
- echo '<pre></pre></div><div style="margin-top=10px;margin-left:900px;">';
- $d= opendir('.');
- while ($f=readdir($d)) {
- if (is_file($f)) {
- echo $f.' '.date('d.m.Y H:i:s',filemtime($f)).' '.filesize($f).'<br />';
- }
- }
- echo '</div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement