Esempio n. 1
0
 public function testCase1()
 {
     $str = "";
     // turn reverse video on
     $str .= "aaaaaaaaaaaaaaaaaa";
     $str .= "";
     // move cursor left 10 lines
     $str .= "";
     // reset everything
     $str .= "bbb";
     $ansi = new ANSI();
     $ansi->appendString($str);
     $expected = '<pre width="80" style="color: white; background: black">';
     $expected .= '<span style="color: black"><span style="background: white">aaaaaaaa</span></span>';
     $expected .= 'bbb';
     $expected .= '<span style="color: black"><span style="background: white">aaaaaaa</span></span>';
     $expected .= '</pre>';
     $this->assertSame($ansi->getScreen(), $expected);
 }
Esempio n. 2
0
<?php

include 'vendor/autoload.php';
use phpseclib\Net\SSH2;
use phpseclib\File\ANSI;
$ansi = new ANSI();
echo <<<HTML
\t<form action="ssh.php" method="POST">
\t\t<label for="host">Host</label>
\t\t<input name="host">
\t\t<label for="user">Username</label>
\t\t<input name="user">
\t\t<label for="pass">Password</label>
\t\t<input name="pass" type="password">
\t\t<label for="port">Port</label>
\t\t<input name="port" value="22">
\t\t<input type="submit">
\t</form>
HTML;
extract($_POST);
if (isset($host, $user, $pass)) {
    $ssh = new SSH2($host, $port);
    if (!$ssh->login($user, $pass)) {
        exit('Login Failed');
    }
    $ansi->appendString($ssh->read('username@username:~$'));
    $ansi->appendString($ssh->read());
    echo $ansi->getScreen();
}