All pastes #519613 Raw Edit

Untitled

public php v1 · immutable
#519613 ·published 2007-05-29 18:32 UTC
rendered paste body
<?php/** * SpotSec WebConsole * * LICENSE * * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * @category SpotSec_WebConsole * @package WebConsole * @copyright Copyright (c) 2006 SpotSec Networks * @license GNU Public License * @link http://www.spotsec.com *//** * WARNING: ENTER AT YOUR OWN RISK, SOURCE CODE AHEAD MAY WIELD HACKS *//** * Development/Debugging external file stuff * * This file is not committed to source control, but instead it is * here to allow developers an extra hook for their development setup. */if (file_exists('../application/configs/Devel.php')) {	include_once('../application/configs/Devel.php');}/** * SpotSec_Controller_Plugin_NoRoute */require_once('SpotSec/Controller/Plugin/NoRoute.php');/** * SpotSec_Error_Handler */require_once('SpotSec/Error/Handler.php');/** * SpotSec_Exception_Handler */require_once('SpotSec/Exception/Handler.php');/** * Zend_Loader */require_once('Zend/Loader.php');/*require_once('SpotSec/Config/Framework.php');require_once('Zend/Controller/Action/HelperBroker.php');require_once('SpotSec/Folder.php');require_once('SpotSec/View.php');require_once('Zend/Acl.php');require_once('Zend/Session.php');require_once('Frontend/Controller/Plugin/Acl/Adapter/Frontend.php');require_once('SpotSec/Controller/Plugin/Acl.php');*//** * SpotSec Framework Bootstrap */spl_autoload_register(array('Zend_Loader', 'autoload'));set_error_handler(array(new SpotSec_Error_Handler(), 'globalErrorHandler'));set_exception_handler(array(new SpotSec_Exception_Handler(), 'globalExceptionHandler'));SpotSec_Config_Framework::getInstance()->loadConfig('../application/configs/SpotSec.xml', 'staging');date_default_timezone_set('UTC');/** * Zend Framework Bootstrap *//** * Get basic configuration */$basicConfig = new Zend_Config_Xml('../application/configs/config.xml', 'staging');Zend_Registry::set('conf', $basicConfig);/** * Start Session */if (!Zend_Session::isStarted()) {	$sessionConfig = new Zend_Config_Xml('../application/configs/session.xml', 'staging');	Zend_Session::start($sessionConfig->toArray());	if (Zend_Session::sessionExists()) {		/**		 * Regenerate id		 */		Zend_Session::regenerateId();	}}/** * Instantiate View object */$view = new Zend_View();$view->setScriptPath(array(	$basicConfig->paths->templates . '/' . $basicConfig->template->name, // todo: validate template exists and is valid	$basicConfig->paths->views));/** * Action helpers */Zend_Controller_Action_HelperBroker::addPrefix('Frontend_Controller_Action_Helper');$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();$viewRenderer->setView($view)			 ->setViewBasePathSpec($basicConfig->paths->views .'/views/:module')			 ->setViewScriptPathSpec(':controller/:action.:suffix')			 ->setViewScriptPathNoControllerSpec(':action.:suffix');Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);/** * Generate list of modules and controllers */try {	/**	 * Get controller paths and file suffixes	 */	$controllers = array();	$controllersPath = $basicConfig->paths->controllers;	$controllersSuffix = $basicConfig->controllers->fileSuffix;	$controllersFolder = new SpotSec_Folder($controllersPath);	/**	 * Default controller dir	 */	$controllers['default'] = $controllersPath;	/**	 * Push controllers into array	 */	foreach ($controllersFolder->getListing() as $controllerFolderItem) {		/**		 * Make sure folder item is a folder and does not start with a '.'		 */		if (substr($controllerFolderItem, -14) != $controllersSuffix && $controllerFolderItem{0} != '.') {			$controllers[str_replace($controllersSuffix, '', $controllerFolderItem)] = $controllersPath . '/' . $controllerFolderItem;		}	}} catch (Exception $e) {	/**	 * Note: Exception is thrown later at the front controller	 */}/** * Acls */if ($backendConf->acl instanceof Zend_Acl) {	// Get stored acl object	$acl = $backendConf->acl;} else {	$acl = new Zend_Acl();	// Default acls	$acl->add(new Zend_Acl_Resource('Auth_Login'));	$roleGuest = new Zend_Acl_Role('guest');	$roleAdmin = new Zend_Acl_Role('admin');	$acl->addRole($roleGuest)		->addRole($roleAdmin);	$acl->allow($roleGuest, 'Auth_Login');	$acl->allow($roleAdmin);	$backendConf->acl = $acl;}Zend_Registry::set('acl', $acl);$aclPlugin = new Frontend_Controller_Plugin_Acl_Adapter_Frontend(array(	'module' => 'Auth',	'controller' => 'Login',	'action' => 'index'));/** * Set up front controller */$frontController = Zend_Controller_Front::getInstance();$frontController->setControllerDirectory($controllers)				->addModuleDirectory($controllersPath)				->registerPlugin(new SpotSec_Controller_Plugin_Acl($acl, $aclPlugin))				->registerPlugin(new SpotSec_Controller_Plugin_NoRoute('', 'httperror', 'code404'))				->throwExceptions(true);/** * Pass on parameters */$frontController->setParam('useDefaultControllerAlways', false)				->setParam('config', $basicConfig);/** * Dispatch front controller */$frontController->dispatch();/** * Get response object */$response = $frontController->getResponse();/** * Check for uncaught exceptions caught by the response object */if ($response->isException()) {	foreach ($response->getException() as $e) {		/**		 * Redirect to a 'pretty' error page		 */		throw $e;	}}/** * Check for uncaught errors (and dump them on the user) *//*$errorQueue = SpotSec_Error_Queue::getInstance();if ($errorQueue->getAllMessages(false)) {	echo "<br />\n";	foreach ($errorQueue->getAllMessages() as $message) {		echo $message . "<br />\n";	}}*/