<?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 = ''; $site = Sites::byId($_REQUEST['id']); //TODO: Detect protocal $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '/runner?id=' . $_REQUEST['id']; $context = stream_context_create(array('http' => array('timeout' => 1))); //file_get_contents($url, 0, $context); if ($site === false) { $error = 'Invalid Site'; } Gorilla3d_Template::load('app/site.php', array('pageTitle' => 'Site | Editor v0.1', 'error' => $error, 'success' => $success, 'site' => $site));
<?php require_once 'library/Gorilla3d/Session.php'; $session = new Gorilla3d_Session(); $session->logout(); header('Location: app'); exit;
<?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));
<?php require_once 'library/Gorilla3d/Session.php'; require_once 'library/Gorilla3d/Template.php'; require_once 'models/Accounts.php'; require_once 'models/Sites.php'; $session = new Gorilla3d_Session(); if ($session->get('accountId') !== null) { header('Location: app'); exit; } $error = false; $password = isset($_POST['password']) ? $_POST['password'] : ''; $username = isset($_POST['username']) ? $_POST['username'] : ''; if (!empty($_POST)) { $newAccount = false; if (!Accounts::exists()) { Accounts::createTable(); Sites::createTable(); $newAccount = true; } $account = false; if ($newAccount) { $account = new Accounts(); $account->setPasswd($password)->setUsername($username); Accounts::insert($account); unset($account); } $account = Accounts::byLogin($username, $password); if ($account === false) { $error = 'Unable to Login';