PHP Classes

File: console.example1.php

Recommend this page to a friend!
  Classes of Matthew Knowlton   PHP Web Console   console.example1.php   Download  
File: console.example1.php
Role: Example script
Content type: text/plain
Description: Example of a PHP console setup
Class: PHP Web Console
Execute PHP commands on a console Web page
Author: By
Last change: Modified ajax to point at correct file.
Date: 9 years ago
Size: 995 bytes
 

Contents

Class file image Download
<?php
require_once('PHPConsole.class.php');

if(isset(
$_POST['command']) && $_POST['command'] != ''){
   
PHPConsole::run($_POST['command']);
    exit();
}
?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
setTimeout(function(){
    $('#submit').click(function(){
        if($('#command').val() == '') return;
        $.post('console.example1.php',{'command': $('#command').val()},function(r){
            $('#command').val('');
        });
    });
   
    $('#stop').click(function(){
        $.post('console.example1.php',{'command': 'exit();'},function(r){
            $('#command, #submit, #stop').hide();
            $('#restart').show();
           
        });
    });
   
    $('#restart').click(function(){
        top.location.reload();
    });
},1000);
</script>

<div>
    <input id="command" name="command"/>
    <button id="submit">Submit</button>
    <button id="stop">Stop</button>
    <button id="restart" style="display:none;">Start</button>
    <br/>
</div>

<?php
PHPConsole
::printDisplay();
?>