final class Engine { static private $sRootDir; static private $sLibDir; static private $sAppDir; private function __construct(){} /** * E1 Main autoloader (core) * @param string $class_name */ static private function AutoLoader($class_name) { $class_path = str_replace('_', DIRECTORY_SEPARATOR, $class_name, $count); // Attention $sFile required!!! if (0 == $count) { $sFile = self::$sLibDir . 'E1' . DIRECTORY_SEPARATOR . $class_name . '.php'; } else { $sFile = self::$sAppDir . $class_path . '.php'; } $sLoadFilename=null; //Engine Library or External Library if (file_exists($sFile)) { $sLoadFilename = $sFile; } else { $sLibFile = self::$sLibDir . $class_name . DIRECTORY_SEPARATOR . $class_name .'.php'; if (file_exists($sLibFile)) {$sLoadFilename = $sLibFile;} } if (!$sLoadFilename) {return null;} require_once($sLoadFilename); } /** * Use in Config instance * @return string - name of config-file */ public static function GetConfigFile() { return self::$sRootDir . 'config.php'; } /** * * @return string - path to SiteRoot */ public static function GetRootDir() { return self::$sRootDir; } /** * Main Init system routine */ public static function Init() { self::$sRootDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; self::$sLibDir = self::$sRootDir . 'Library' . DIRECTORY_SEPARATOR; self::$sAppDir = self::$sRootDir . 'Application' . DIRECTORY_SEPARATOR; spl_autoload_register('self::AutoLoader'); $c = new Comportable(); //TODO: Правильно проверять в инсталлере и ставить флаг Router::getInstance()->Exec(); } } function e1(){ $aMsg = ''; foreach( func_get_args() as $param ){ if( is_string($param) ){ $aMsg .= $param; }else{ $aMsg .= var_export($param, true); } } file_put_contents('server.log', date('D, d M Y H:i:s',time())." - $aMsg \r\n", FILE_APPEND); } // Magic quotes Disable if( get_magic_quotes_gpc() ){ $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while( list($key, $val)=each($process) ){ foreach( $val as $k=>$v ){ unset($process[$key][$k]); if( is_array($v) ){ $process[$key][stripslashes($k)] = $v; $process[] = &$process[$key][stripslashes($k)]; }else{ $process[$key][stripslashes($k)] = stripslashes($v); } } } unset($process); } //Developer profile error_reporting(E_ALL); ini_set('display_errors', 1); //Secure issue //ini_set("session.use_only_cookies", true); //ini_set('display_errors', 0); //ini_set('log_errors', 1); //ini_set('error_log', './server.log'); //E1 Go Engine::Init();