setTitle('Terminal'); $display->setNavElement('dev'); // create a history session var if one doesn't exist if ( !isset( $_SESSION['history'] ) ) { $_SESSION['history'] = array(); } // if a command has been entered, run it. if ( isset( $_POST['newCmd'] ) ) { try { $res = $shell->exec( $_POST['newCmd'] ); array_push( $_SESSION['history'], array( $_POST['newCmd'], $res, false ) ); } catch ( Exception $e ) { array_push( $_SESSION['history'], array( $_POST['newCmd'], $e->getMessage(), true ) ); } } // and add it to the history $display->add('
'); // fill in history $display->add(''); // create a text box for a new command $display->add(''); $display->add(''); $display->add('
'); foreach ( $_SESSION['history'] as $cmd ) { $line = $cmd[0] . '

'; $display->add( $line ); } $display->add('
'); $display->add(''); $display->printHtml();