예제 #1
0
<?php

require_once 'library/Gorilla3d/Session.php';
require_once 'library/Gorilla3d/Template.php';
require_once 'models/Sites.php';
$session = new Gorilla3d_Session();
if ($session->get('accountId') === null) {
    header('Location: ../login');
    exit;
}
$error = false;
$success = false;
$password = isset($_POST['password']) ? $_POST['password'] : '';
$host = isset($_POST['host']) ? $_POST['host'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
if (isset($_POST['host'])) {
    include_once 'library/Gorilla3d/Ssh.php';
    $ssh = new Gorilla3d_Ssh($_POST['host'], $_POST['username'], $_POST['password']);
    if (!$ssh->isConnected()) {
        $error = 'Unable to connect';
    } else {
        $success = true;
        $site = new Sites();
        $site->setHost($host)->setPort(22)->setUsername($username)->setPasswd($password)->setAccountId($session->get('accountId'));
        Sites::insert($site);
        $siteId = $site->lastInsertId();
        header('Location: ../app?success=site');
        exit;
    }
}
Gorilla3d_Template::load('app/sites/edit.php', array('pageTitle' => 'Add/Edit Site | Editor v0.1', 'error' => $error, 'success' => $success, 'username' => $username, 'password' => $password, 'host' => $host));
예제 #2
0
ignore_user_abort(true);
require_once 'library/Gorilla3d/Ssh.php';
require_once 'library/Gorilla3d/Ssh/Inode.php';
require_once 'library/Gorilla3d/Session.php';
require_once 'library/Gorilla3d/Template.php';
require_once 'models/Sites.php';
$session = new Gorilla3d_Session();
if ($session->get('accountId') === null) {
    header('Location: ../login');
    exit;
}
$site = Sites::byId($_REQUEST['id']);
if ($site === null) {
}
$ssh = new Gorilla3d_Ssh($site->host, $site->username, $site->passwd);
file_put_contents('data/log.txt', "\n" . 'started: ' . date('F j, Y H:i:s a'), FILE_APPEND);
echo '
    Connected...
    <script type="text/javascript">
    window.stop(); document.execCommand(\'Stop\');
    </script>
    <pre><!-- ' . str_repeat(" ", 1024 * 8) . ' --></pre>
';
flush();
while (1) {
    try {
        if (!$ssh->isConnected()) {
            echo 'unable to connect';
            break;
        }