Commit 51f2d44e authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- New templates for the CSS and Javascript handling

- Updated composer to only add framework pieces
- Started converting over to illuminate database ORM
parent 0b51632e
{
"require": {
"slim/slim": "*",
"slim/views": "*",
"illuminate/database": "*"
"slim/slim": "2.4.3",
"slim/views": "0.1.2",
"smarty/smarty": "3.1.21",
"illuminate/database": "4.2.9"
}
}
......@@ -25,24 +25,54 @@
// Load the configuration file
require_once("config.php");
// Load ORM
use Illuminate\Database\Capsule\Manager as Capsule;
// Initiate ORM instance
$sqlhdlr = new Capsule;
$sqlhdlr->addConnection([
'driver' => 'mysql',
'host' => $skynet_dbHost,
'database' => $skynet_dbName,
'username' => $skynet_dbUser,
'password' => $skynet_dbPass,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$sqlhdlr->setEventDispatcher(new Dispatcher(new Container));
// Make this Capsule instance available globally via static methods... (optional)
$sqlhdlr->setAsGlobal();
// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$sqlhdlr->bootEloquent();
// Global array for Smarty data
$data = array(
$smarty_data = array(
'skynet_favicon' => $skynet_favicon,
'skynet_stylesheet' => $skynet_stylesheet,
'skynet_homepage' => $skynet_homepage,
'skynet_version' => $skynet_version,
'skynet_useCDN' => $skynet_useCDN,
'skynet_bootstrap_root' => $skynet_bootstrap_root,
);
// Connect to the database server
$sqlhdlr = new mysqli($skynet_dbHost, $skynet_dbUser, $skynet_dbPass,
$skynet_dbName);
//// Connect to the database server
//$sqlhdlr = new mysqli($skynet_dbHost, $skynet_dbUser, $skynet_dbPass,
// $skynet_dbName);
// Make sure we have a connection
// TODO : This should be slimified (whatever that means)
if (mysqli_connect_errno()) {
die( '<p>Unable to connect to the database server at this time: ' .
mysqli_connect_error() . ' </p>' );
}
//// Make sure we have a connection
//// TODO : This should be slimified (whatever that means)
//if (mysqli_connect_errno()) {
// die( '<p>Unable to connect to the database server at this time: ' .
// mysqli_connect_error() . ' </p>' );
//}
// Instantiate a slim instance
$app = new \Slim\Slim(array(
......@@ -57,7 +87,7 @@
// We want to use Smarty for templates, this sets up the necessary Smarty
// configuration within Slim
$view = $app->view();
$view->parserDirectory = $skynet_smarty_dir;
//$view->parserDirectory = $skynet_smarty_dir;
$view->parserCompileDirectory = "$skynet_work_dir/templates_c";
$view->parserCacheDirectory = "$skynet_work_dir/cache";
$view->parserExtensions = array(
......@@ -72,42 +102,50 @@
return function() use ( $role ) {
// Globalize the phptodo variables needed
global $skynet_dbHost, $skynet_dbUser, $skynet_dbPass, $skynet_dbName,
$skynet_sessTime, $skynet_serveruri, $sqlhdlr, $data;
$skynet_sessTime, $skynet_serveruri, $sqlhdlr, $smarty_data;
// Try and get the id, last time, and user id from the sessions
// database
$query = sprintf('SELECT id, last, user_id FROM sessions WHERE ' .
'phpsessid = "%s"', session_id());
if ($result = $sqlhdlr->query($query)) {
list($id, $last, $user_id) = $result->fetch_array();
$result->close();
} else {
die( 'Error: ' . $sqlhdlr->error );
}
$result = $sqlhdlr->table('sessions')->select('id', 'last', 'user_id')->where('phpsessid', '=', session_id())->first();
$id = $result['id'];
$last = $result['last'];
$user_id = $result['user_id'];
//$query = sprintf('SELECT id, last, user_id FROM sessions WHERE ' .
// 'phpsessid = "%s"', session_id());
//
//if ($result = $sqlhdlr->select($query)) {
// list($id, $last, $user_id) = $result->fetch_array();
// $result->close();
//} else {
// die( 'Error: ' . $sqlhdlr->error );
//}
// Check to see if an id was set, and if the time is valid
if ((isset($id)) && (($last + $skynet_sessTime) >= time())) {
// Good session, update the timestamp
$query = sprintf("UPDATE sessions SET last = %d WHERE id = %d",
time(), $id);
$sqlhdlr->query($query) or die( 'Error: ' . $sqlhdlr->error );
$sqlhdlr->table('sessions')->where('id', '=', $id)->update(array('last' => time()));
//$query = sprintf("UPDATE sessions SET last = %d WHERE id = %d",
// time(), $id);
//
//$sqlhdlr->query($query) or die( 'Error: ' . $sqlhdlr->error );
// Create the user object
$user_obj = new skynetUser($skynet_dbHost, $skynet_dbUser,
$skynet_dbPass, $skynet_dbName,
$user_id);
// Assign the appropriate data to the smarty $data array
$data['username'] = $user_obj->username();
$data['adminflag'] = $user_obj->adminflag();
// Assign the appropriate data to the smarty $smarty_data array
$smarty_data['username'] = $user_obj->username();
$smarty_data['adminflag'] = $user_obj->adminflag();
if (get_magic_quotes_gpc()) {
$data['fullname'] = stripslashes(htmlentities($user_obj->fullname(),
$smarty_data['fullname'] = stripslashes(htmlentities($user_obj->fullname(),
ENT_QUOTES));
} else {
$data['fullname'] = htmlentities($user_obj->fullname(),
$smarty_data['fullname'] = htmlentities($user_obj->fullname(),
ENT_QUOTES);
}
......@@ -115,7 +153,7 @@
} else {
// If a guest role, then bypass the login redirect
if ($role == 'guest') {
$data['username'] = 'guest';
$smarty_data['username'] = 'guest';
return;
}
......@@ -134,20 +172,20 @@
// GET route
$app->get('/', $isauthenticated(), function () use ($app) {
global $data;
global $smarty_data;
prep_smarty($app);
$app->render('main.tpl', $data);
$app->render('main.tpl', $smarty_data);
});
// Login routine
// TODO: Add a redirect here for users already logged in
$app->get('/login', function () use ($app) {
global $data;
global $smarty_data;
prep_smarty($app);
$app->render('login.tpl', $data);
$app->render('login.tpl', $smarty_data);
});
......@@ -205,11 +243,11 @@
// GET route
$app->get('/about', $isauthenticated('guest'), function () use ($app) {
global $data;
global $smarty_data;
prep_smarty($app);
$app->render('about.tpl', $data);
$app->render('about.tpl', $smarty_data);
});
......
......@@ -20,9 +20,7 @@
<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' />
{include file='head-css.tpl'}
<title>Skynet Automated Security Scanner</title>
</head>
<body>
......
{--* 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*}
{if isset($skynet_useCDN) && ($skynet_useCDN eq true)}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css" rel="stylesheet">
{else}
<link href="{$skynet_bootstrap_root}/css/bootstrap.min.css" rel="stylesheet">
<link href="{$skynet_bootstrap_root}/css/bootstrap-theme.min.css" rel="stylesheet">
{/if}
<link rel='stylesheet' href='{$skynet_stylesheet}' type='text/css' />
{--* 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*}
{if isset($skynet_useCDN) && ($skynet_useCDN == true)}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
{else}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
{/if}
\ No newline at end of file
......@@ -21,9 +21,7 @@
<meta name='robots' content='noindex, nofollow' />
<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' />
{include file='head-css.tpl'}
<title>Skynet Automated Security Scanner</title>
</head>
<body>
......
......@@ -20,9 +20,7 @@
<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' />
{include file='head-css.tpl'}
<title>Skynet Automated Security Scanner</title>
</head>
<body>
......
Markdown is supported
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