コード例 #1
0
ファイル: console.php プロジェクト: DINKIN/rokket
<div class="panel">
	<div class="content">
        <div id="terminal">
            <?php 
$SSH = rp::get('SSH');
$host = $SSH['ip'];
$user = $SSH['user'];
$pass = $SSH['password'];
unset($SSH);
$ssh = new ssh($host, $user, $pass);
if (ajax::is()) {
    $test = 1;
} else {
    echo nl2br($ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX));
    $ssh->write("screen -r test123 \n\r");
    $ssh->setTimeout(4);
    $ssh->write("ping google.de \n\r");
}
if (ajax::is()) {
    #$ssh->setTimeout(1);
    #$ssh->write("ping google.de \n\r");
    $ssh->setTimeout(4);
    $ssh->exec("screen -r test123");
    #$return = nl2br($ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX));
    ajax::addReturn($return);
}
?>
        </div>
    </div>
</div>
コード例 #2
0
ファイル: server.php プロジェクト: kyroskoh/rokket
 protected function control($type)
 {
     $id = $this->id;
     $SSH = rp::get('SSH');
     $host = $SSH['ip'];
     $user = $SSH['user'];
     $pass = $SSH['password'];
     unset($SSH);
     $ssh = new ssh($host, $user, $pass);
     $sql = new sql();
     $sql->setTable('server');
     $sql->setWhere('id=' . $id);
     #$ssh->read('[prompt]');
     switch ($type) {
         case 'install':
             $ssh->exec("cd {$id}; ./control.sh auto-install  > /dev/null &");
             $sql->addPost('status', 0);
             break;
         case 'start':
             $ssh->exec("cd {$id}; ./control.sh start >> /dev/null 2>&1 & /n");
             $sql->addPost('status', 1);
             break;
         case 'stop':
             $ssh->exec("cd {$id}; ./control.sh stop >> /dev/null 2>&1 & /n");
             $sql->addPost('status', 0);
             break;
         case 'restart':
             $ssh->exec("cd {$id}; ./control.sh restart >> /dev/null 2>&1 & /n");
             $sql->addPost('status', 1);
             break;
     }
     $sql->update();
 }
コード例 #3
0
ファイル: files.php プロジェクト: sgchris/grunssh
 /**
  * @brief create new folder
  * @method POST
  * 	 * grep -r -i -B 2 -A 1 "n Search" --include \*php /var/www/grunssh
  * @return  
  */
 public function search()
 {
     $params = $this->input->post();
     if (empty($params) || !isset($params['id']) || empty($params['id']) || !isset($params['term']) || empty($params['term']) || !isset($params['host']) || empty($params['host']) || !isset($params['login']) || empty($params['login']) || !isset($params['password']) || empty($params['password'])) {
         echo json_encode(array('result' => 'error', 'error' => 'missing parameters'));
         return;
     }
     $fileNamesOnly = isset($params['onlyFiles']) && $params['onlyFiles'] == 1;
     // connect to remote host
     $ssh = new ssh($params['host'], $params['login'], $params['password']);
     $folderPath = str_replace('_SEP_', '/', $params['id']);
     $term = $params['term'];
     $commandParams = '';
     if ($fileNamesOnly) {
         $commandParams .= ' -l ';
     }
     $result = $ssh->exec('grep -r ' . $commandParams . ' ' . escapeshellarg($term) . ' ' . escapeshellarg($folderPath));
     $totalResults = substr_count($result, "\n");
     if ($result === false) {
         echo json_encode(array('result' => 'error', 'error' => 'cannot create folder'));
         return;
     }
     // get list of results
     $results = explode("\n", $result);
     // clear empty lines
     $results = array_filter($results, 'strlen');
     // keep files with path (starting with "/")
     $results = array_filter($results, function ($el) {
         return preg_match('%^/%', $el);
     });
     // rearrange the array
     $results = array_values($results);
     echo json_encode(array('result' => 'success', 'occurrences' => $results));
 }