PHP Classes

File: sample-kmd-shell.php

Recommend this page to a friend!
  Classes of François NEUMANN-RYSTOW   PHP Command Line Shell   sample-kmd-shell.php   Download  
File: sample-kmd-shell.php
Role: Example script
Content type: text/plain
Description: wrapping linux console for education or joke purpose.
Class: PHP Command Line Shell
Use ncurses to get key inputs and write shell text
Author: By
Last change:
Date: 10 years ago
Size: 495 bytes
 

Contents

Class file image Download
<?php

require 'kmd.php';

class
kmd_shell extends kmd {
    function
inv($host) {
        return
$host . ':' . getcwd() . '# ';
    }
    function
ret($line) {
       
$line = trim($line);
        if (
substr($line, 0, 2) == 'cd') {
           
chdir(substr($line, 3));
            return
"\n";
        }
        elseif (
$line == 'exit') return false;
        else return
shell_exec($line);
    }
}

$kmd_shell = new kmd_shell(get_current_user() . '@' . php_uname('n'));
$kmd_shell->run();

?>