* @copyright Copyright (C) 2006, Moritz Bechler * @license http://www.gnu.org/licenses/lgpl.html */ /** * HTTP Request interface. * * Basically calls our loader and starts the requested application. */ // Change to local directory for cli define('ORIG_PWD', getcwd()); chdir(dirname(__FILE__)); require dirname(__FILE__) . '/config.php'; if(!defined('SAT_LOCAL')) { define('SAT_LOCAL', dirname(__FILE__)); } set_include_path(get_include_path() . PATH_SEPARATOR . SAT_INCLUDEDIR); define('SAT_WEBROOT', dirname(__FILE__)); chdir(SAT_LOCAL); include('loader.php'); try { $appname = RequestManager::getRequestObject()->getPrimaryHandler()->getApp(); } catch (RequestException $error) { $appname = ConfigGlobal::getInstance()->getVar('application.default'); } $appdir = realpath(sprintf('%s/%s', SAT_LOCAL , basename($appname))); if(!$appdir || !is_dir($appdir)) { throw new ApplicationException('The specified application does not exist.'); } try { chdir($appdir); ApplicationController::initialize($appdir); } catch (Exception $error) { if(defined('DEBUG')) { throw $error; } throw new ApplicationException('The specified application does not exist.'); } ApplicationController::getInstance()->run(); ?>