Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#9 Add clear button

open
nobody
5
2006-04-30
2006-04-30
Martin Geisler
No

The button should clear the screen. Having 'clear' as
a new built-in command for this would also be nice.

Discussion

  • krelvinaz
    krelvinaz
    2008-06-29

    Logged In: YES
    user_id=1358733
    Originator: NO

    Adding a clear history command was easy....

    Add a Clear History button and have the code check if it isset and clear the session info it looks for...

    The diff for it is below. I made other changes so the line numbers might be off a bit.

    363,370c364,366
    < // Added Look for CLEAR to clear screen
    < if(isset($_POST['CLEAR'])) {
    < $_SESSION['output'] = "";
    < } else {
    < $lines = substr_count($_SESSION['output'], "\n");
    < $padding = str_repeat("\n", max(0, $rows+1 - $lines));
    < echo rtrim($padding . $_SESSION['output']);
    < }
    ---
    > $lines = substr_count($_SESSION['output'], "\n");
    > $padding = str_repeat("\n", max(0, $rows+1 - $lines));
    > echo rtrim($padding . $_SESSION['output']);
    385,389c381,382
    < <input type="submit" value="Execute Command">
    < <input type="submit" name="CLEAR" value="Clear History">
    < <input type="submit" name="logout" value="Logout">
    <
    <
    ---
    > <input type="submit" value="Execute Command">
    > <input type="submit" name="logout" value="Logout">

     
  • ArcyQwerty
    ArcyQwerty
    2009-05-11

    I also made a clear command for UNIX 'clear' and windows 'cls'

    if (($command == "cls") || ($command == "cls\n") || ($command == "clear") || ($command == "clear\n")) $_SESSION['output'] = "";

    insert right before this

    $p = proc_open($command,
    array(1 => array('pipe', 'w'),
    2 => array('pipe', 'w')),
    $io);