*# #* *# #* 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); // Load framework require '../app/vendor/autoload.php'; // Load the configuration file require_once('../app/config.php'); // Load ORM use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Events\Dispatcher; use Illuminate\Container\Container; // Global array for Smarty data $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, ); // Instantiate a slim instance $app = new \Slim\Slim(array( 'view' => new \Slim\Views\Smarty(), 'debug' => true, 'log.enable' => true, 'log.path' => 'logs/', 'log.level' => 4, 'mode' => 'development', 'templates.path' => '../app/templates' )); // We want to use Smarty for templates, this sets up the necessary Smarty // configuration within Slim $view = $app->view(); $view->parserCompileDirectory = "$skynet_work_dir/templates_c"; $view->parserCacheDirectory = "$skynet_work_dir/cache"; $view->parserExtensions = array( '../app/libs', ); $app->hook('slim.before', function () use ($app) { $app->view()->appendData(array('baseUrl' => '/index.php/')); }); // Register the DB handler as a framework singleton $app->container->singleton('db', function () use ($app) { global $skynet_dbHost, $skynet_dbName, $skynet_dbUser, $skynet_dbPass; // 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... $sqlhdlr->setEventDispatcher(new Dispatcher(new Container)); // Make this Capsule instance available globally via static methods... $sqlhdlr->setAsGlobal(); // Setup the Eloquent ORM... $sqlhdlr->bootEloquent(); return $sqlhdlr; }); // Load the authentication routes include('../app/authentication.php'); // Load the report routes include('../app/reports.php'); // Home Page Route $app->get('/', $isauthenticated(), function () use ($app) { global $smarty_data; $smarty_data['total_servers'] = $app->db->table('cloud') ->where('disabled', 0) ->count(); $smarty_data['total_scanners'] = $app->db->table('spawn') ->where('disabled', 0) ->count(); $smarty_data['total_targets'] = $app->db->table('target') ->where('disabled', 0) ->count(); $smarty_data['total_timers'] = $app->db->table('timers') ->where('disabled', 0) ->count(); $smarty_data['total_results'] = $app->db->table('results') ->count(); prep_smarty($app); $app->render('main.tpl', $smarty_data); }); // About Page $app->get('/about', $isauthenticated('guest'), function () use ($app) { global $smarty_data; prep_smarty($app); $app->render('about.tpl', $smarty_data); }); $app->run(); // Loads the whitespace_control filter for handling comments within the // Smarty templates function prep_smarty($app) { global $skynet_debug; $smarty = $app->view()->getInstance(); $smarty->loadFilter("pre", 'whitespace_control'); $smarty->debugging = $skynet_debug; } ?>