= 5.4 required, aborting'); /** * Defined if PHP is run from the command line. */ if(php_sapi_name() == "cli" || defined('STDIN')) define('_CLI_', true); // define all the default constants used by the system require_once(__DIR__.DIRECTORY_SEPARATOR.'inc.defconst.php'); // 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 library require_once ('MCMS' . __DS__ . 'lib.system.php'); require_once ('Mammut' . __DS__ . 'lib.mammut.php'); if (defined('_CLI_') && in_array('-V', $argv)) { echo 'MCMS v.'.MCMS."\n"; echo 'Mammut v.'.MAMMUT."\n"; die(); } if (defined('_CLI_') && in_array('-v', $argv)) \Mammut\Log\Logger::getInstance()->addAppender(new \Mammut\Log\ConsoleAppender()); // import system flag constants 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'); $weaving = array_from_file(defined('WEAVINGCFG') ? constant('WEAVINGCFG') : __DIR__.__DS__.'inc.weaving.php' , 'weaving'); if (!is_array($weaving)) die('Invalid weaving configuration'); if (!class_exists($weaving['common']['system'])) die("Could not find system class '{$weaving['common']['system']}'"); if (!class_exists($weaving['common']['runner'])) die("Could not find runner class '{$weaving['common']['runner']}'"); // if(!defined('RUNNER')) // define('RUNNER', '\\MCMS\\Runner'); // if(!defined('SYSTEM')) // define('SYSTEM', '\\MCMS\\System'); call_user_func(array($weaving['common']['system'],'init'),['weaving' => $weaving]); // $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 $weaving['common']['runner'](); $runner->setWeaving($weaving); // unset($classes); // $doProfile = defined('PROFILE'); // variables have better performance than const calls // $doProfile && Profiler::stop('sys::init'); if($runner instanceof \MCMS\Interfaces\iRunner) { try { $runner->run(); } catch(Exception $e) { $runner->onException($e); } } else die('Runnerclass does not implement iRunner'); defined('PROFILE') && Profiler::finalize(); $p = defined('PROFILE') ? constant('PROFILE') : false; if ($p !== false) { if (is_string($p)) Profiler::printResult(Profiler::DISPLAY_TEXT, $p); else Profiler::printResult(); }