= 5.4 required, aborting'); if(php_sapi_name() == "cli" || defined('STDIN')) /** * Defined if PHP is run from the command line. */ define('_CLI_', true); if(file_exists(_BASEPATH_ . DIRECTORY_SEPARATOR . 'pathconfig.php')) include_once (_BASEPATH_ . DIRECTORY_SEPARATOR . 'pathconfig.php'); if(!defined('_SELF_')) define('_SELF_', $_SERVER['SCRIPT_NAME']); if(!defined('_PHPEXT_')) { $nextpos = -1; $found = 0; while(($nextpos = strpos(_SELF_, '.', $nextpos + 1)) !== false) $found = $nextpos; /** * The used PHP file extension on this server, which could be php, php5 or something * linke that. */ define('_PHPEXT_', substr(_SELF_, $found + 1)); unset($nextpos, $found); } if(!defined('_SELF_SERVICE_')) /** * Contrant which links to the service address. */ define('_SELF_SERVICE_', _BASEURL_ . '/' . (defined('_ADMIN_') ? 'adminservice' : 'service') . '.' . _PHPEXT_); if(!defined('_SELF_DEFAULT_')) /** * Contrant which links to the default output address. */ define('_SELF_DEFAULT_', _BASEURL_ . '/' . (defined('_ADMIN_') ? 'admin' : 'index') . '.' . _PHPEXT_); if(!defined('_SELF_FRONTEND_')) /** * Contrant which links to the frontend script. */ define('_SELF_FRONTEND_', _BASEURL_ . '/index.' . _PHPEXT_); if(!defined('_SELF_BACKEND_')) /** * Contrant which links to the backend script. */ define('_SELF_BACKEND_', _BASEURL_ . '/admin.' . _PHPEXT_); $DS = DIRECTORY_SEPARATOR; // shorthand and speedup, cause php handles constants slower than variables // define paths which aren't defined if(!defined('_CFGPATH_')) define('_CFGPATH_', _BASEPATH_ . $DS . 'cfg'); if(!defined('_LIBPATH_')) // system libary path define('_LIBPATH_', _BASEPATH_ . $DS . 'lib'); if(!defined('_LIBPATHX_')) // custom libary path define('_LIBPATHX_', _BASEPATH_ . $DS . 'libx'); if(!defined('_DATAPATH_')) // system data path define('_DATAPATH_', _BASEPATH_ . $DS . 'data'); if(!defined('_DATAURL_')) // system data url base define('_DATAURL_', _BASEURL_ . '/data'); if(!defined('_DATAPATHX_')) // custom data path define('_DATAPATHX_', _BASEPATH_ . $DS . 'datax'); if(!defined('_DATAURLX_')) // extended data url base define('_DATAURLX_', _BASEURL_ . '/datax'); if(!defined('_PLUGINPATH_')) // system plugin path define('_PLUGINPATH_', _BASEPATH_ . $DS . 'plugin'); if(!defined('_PLUGINURL_')) // system plugin path define('_PLUGINURL_', _BASEURL_ . '/plugin'); if(!defined('_PLUGINPATHX_')) // custom plugin path define('_PLUGINPATHX_', _BASEPATH_ . $DS . 'pluginx'); if(!defined('_PLUGINURLX_')) // custom plugin path define('_PLUGINURLX_', _BASEURL_ . '/pluginx'); if(!defined('_COMPATH_')) // system component path define('_COMPATH_', _BASEPATH_ . $DS . 'component'); if(!defined('_COMURL_')) // system component url base define('_COMURL_', _BASEURL_ . '/component'); if(!defined('_COMPATHX_')) // custom component path define('_COMPATHX_', _BASEPATH_ . $DS . 'componentx'); if(!defined('_COMURLX_')) // system component url base define('_COMURLX_', _BASEURL_ . '/componentx'); if(!defined('_MODPATH_')) // system module path define('_MODPATH_', _BASEPATH_ . $DS . 'module'); if(!defined('_MODURL_')) // system module url base define('_MODURL_', _BASEURL_ . '/module'); if(!defined('_MODPATHX_')) // custom module path define('_MODPATHX_', _BASEPATH_ . $DS . 'modulex'); if(!defined('_MODURLX_')) // custom module url base define('_MODURLX_', _BASEURL_ . '/modulex'); if(!defined('_JSPATH_')) // system javascript path define('_JSPATH_', _BASEPATH_ . $DS . 'jscript'); if(!defined('_JSURL_')) // system module url base define('_JSURL_', _BASEURL_ . '/jscript'); if(!defined('_JSPATHX_')) // custom javascript path define('_JSPATHX_', _BASEPATH_ . $DS . 'jscriptx'); if(!defined('_JSURLX_')) // system module url base define('_JSURLX_', _BASEURL_ . '/jscriptx'); if(!defined('_LAYOUTPATH_')) // system plugin path define('_LAYOUTPATH_', _BASEPATH_ . $DS . 'layout'); if(!defined('_LAYOUTURL_')) // system plugin path define('_LAYOUTURL_', _BASEURL_ . '/layout'); if(!defined('_LAYOUTPATHX_')) // custom plugin path define('_LAYOUTPATHX_', _BASEPATH_ . $DS . 'layoutx'); if(!defined('_LAYOUTURLX_')) // custom plugin path define('_LAYOUTURLX_', _BASEURL_ . '/layoutx'); unset($DS); // update include path $inc_path = get_include_path(); $inc_path .= PATH_SEPARATOR . _LIBPATH_; $inc_path .= PATH_SEPARATOR . _LIBPATHX_; set_include_path($inc_path); unset($inc_path); define('USE_MCMS', true); // load system libary require_once ('MCMS' . DIRECTORY_SEPARATOR . 'lib.system.php'); require_once ('Mammut' . DIRECTORY_SEPARATOR . 'lib.mammut.php'); if(include_exists(_CFGPATH_ . __DS__ . 'defines.php')) require_once (_CFGPATH_ . __DS__ . 'defines.php'); if(defined('DEBUG')) { // enable debug output error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', 1); } else ini_set('display_errors', 0); use \Mammut\Profiler\Profiler as Profiler; if(defined('PROFILE')) { Profiler::init(); } defined('PROFILE') && Profiler::start('sys::load'); if(!defined('RUNNER')) define('RUNNER', '\\MCMS\\Runner'); if(!defined('SYSTEM')) define('SYSTEM', '\\MCMS\\System'); $classes = array(); $lastdot = false; foreach(array('system' => SYSTEM,'runner' => RUNNER) as $type=>$classpath) { $classpath = str_replace('.', '\\', $classpath); // legacy support if(!class_exists($classpath, true)) die('class does not exist: ' . $classpath . ' for ' . $type); $classes[$type] = $classpath; } unset($lastdot, $classpath, $type); defined('PROFILE') && Profiler::stopAndStart('sys::load', 'sys::init'); call_user_func(array($classes['system'],'init')); // initalize the system class $system = call_user_func(array($classes['system'],'getInstance')); // get the system instance if(!$system->getRequest()->isValid()) { call_user_func(array($classes['system'],'shutdown')); die('invalid request'); } // create the runner, check if the MMiRunner interface is implemented, and run the methods one by one $runner = new $classes['runner'](); unset($classes); $doProfile = defined('PROFILE'); // variables have better performance than const calls $doProfile && Profiler::stop('sys::init'); if($runner instanceof \MCMS\Interfaces\iRunner) { try { $doProfile && Profiler::start('runner::doLoadConfig'); $runner->doLoadConfig(); $doProfile && Profiler::stopAndStart('runner::doLoadConfig', 'runner::doInit'); $runner->doInit(); $doProfile && Profiler::stop('runner::doInit'); if(defined('_CLI_')) { $runner->doRunCLI(); } else { $doProfile && Profiler::start('runner::doRoute'); $runner->doRoute(); $doProfile && Profiler::stopAndStart('runner::doRoute', 'runner::doBeforeRun'); $runner->doBeforeRun(); $doProfile && Profiler::stopAndStart('runner::doBeforeRun', 'runner::doRun'); $runner->doRun(); $doProfile && Profiler::stopAndStart('runner::doRun', 'runner::doAfterRun'); $runner->doAfterRun(); $doProfile && Profiler::stopAndStart('runner::doAfterRun', 'runner::doOutput'); $runner->doOutput(); $doProfile && Profiler::stop('runner::doOutput'); } $doProfile && Profiler::start('runner::doCleanup'); $runner->doCleanup(); $doProfile && Profiler::stop('runner::doCleanup'); } catch(Exception $e) { $runner->onException($e); } } else die('Runnerclass does not implement iRunner'); $doProfile && defined('DEBUG') && Profiler::printResult();