Commit 6893fdea authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Added basic framework for front end

- Working using Slim and Smarty
- Initial templates in place
- Login/logout code working
parent a0cf8bf9
{--* Skynet - Automated "Cloud" Security Scanner *}
{--* Copyright (C) 2014-present Jason Frisvold <friz@godshell.com> *}
{--* *}
{--* This program is free software; you can redistribute it and/or modify *}
{--* it under the terms of the GNU General Public License as published by *}
{--* the Free Software Foundation; either version 2 of the License, or *}
{--* (at your option) any later version. *}
{--* *}
{--* This program is distributed in the hope that it will be useful, *}
{--* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
{--* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
{--* GNU General Public License for more details. *}
{--* *}
{--* You should have received a copy of the GNU General Public License *}
{--* along with this program; if not, write to the Free Software *}
{--* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1' />
<link rel='shortcut icon' type='image/x-icon' href='{$skynet_favicon}'>
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link rel='stylesheet' href='{$skynet_stylesheet}' type='text/css' />
<title>Skynet Automated Security Scanner</title>
</head>
<body>
{assign var=page value='main'}
{include file='header.tpl'}
Main Page
{include file='footer.tpl'}
</body>
</html>
<?php
/* Skynet - Automated "Cloud" Security Scanner *#
#* Copyright (C) 2014-present Jason Frisvold <friz@godshell.com> *#
#* *#
#* This program is free software; you can redistribute it and/or modify *#
#* it under the terms of the GNU General Public License as published by *#
#* the Free Software Foundation; either version 2 of the License, or *#
#* (at your option) any later version. *#
#* *#
#* This program is distributed in the hope that it will be useful, *#
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *#
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *#
#* GNU General Public License for more details. *#
#* *#
#* You should have received a copy of the GNU General Public License *#
#* along with this program; if not, write to the Free Software *#
#* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
// Define skynet (to allow access to files)
define('skynet', 1);
// Define usesmarty (to indicate that config needs to load smarty)
define('usesmarty', 1);
// Load the configuration file
require_once("config.php");
// Connect to the database server
$sqlhdlr = new mysqli($skynet_dbHost, $skynet_dbUser, $skynet_dbPass,
$skynet_dbName);
// Make sure we have a connection
if (mysqli_connect_errno()) {
die( '<p>Unable to connect to the database server at this time: ' .
mysqli_connect_error() . ' </p>' );
}
// Call the logout function
logout();
// Assign a 1 to the logout variable
// This causes a logout message to appear on the web page
$smarty->assign('logout', 1);
// Close the MySQL Handler
$sqlhdlr->close();
// Display the login page once again
$smarty->display('index.tpl');
?>
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim(array(
'view' => new \Slim\Views\Smarty(),
'debug' => true,
'log.enable' => true,
'log.path' => 'logs/',
'log.level' => 4,
'mode' => 'development'
));
$view = $app->view();
$view->parserDirectory = '/Users/XenoPhage/Sites/Smarty/libs';
$view->parserCompileDirectory = '/Users/XenoPhage/Sites/Smarty/skynet/templates_c';
$view->parserCacheDirectory = '/Users/XenoPhage/Sites/Smarty/skynet/cache';
$view->parserExtensions = array(
dirname(__FILE__) . '/libs',
);
// GET route
$app->map('/', function () use ($app) {
$smarty = $app->view()->getInstance();
$smarty->loadFilter("pre", 'whitespace_control');
$data = array(
'skynet_favicon' => '',
'skynet_stylesheet' => 'css/default.css',
'skynet_homepage' => '',
'skynet_version' => '1.0 Beta',
);
$app->render('index.tpl', $data);
})->via('GET', 'POST');
// GET route
$app->map('/about', function () use ($app) {
$smarty = $app->view()->getInstance();
$smarty->loadFilter("pre", 'whitespace_control');
$data = array(
'skynet_favicon' => '',
'skynet_stylesheet' => 'css/default.css',
'skynet_homepage' => '',
'skynet_version' => '1.0 Beta',
'username' => 'guest',
);
$app->render('about.tpl', $data);
})->via('GET', 'POST');
// GET route
$app->get('/another', function () use ($app) {
$app->render('another.tpl');
});
// POST route
$app->post(
'/post',
function () {
echo 'This is a POST route';
}
);
// PUT route
$app->put(
'/put',
function () {
echo 'This is a PUT route';
}
);
// PATCH route
$app->patch('/patch', function () {
echo 'This is a PATCH route';
});
// DELETE route
$app->delete(
'/delete',
function () {
echo 'This is a DELETE route';
}
);
/**
* Step 4: Run the Slim application
*
* This method should be called last. This executes the Slim application
* and returns the HTTP response to the HTTP client.
*/
$app->run();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment