$Obj = $s; } else { // Si method non static : init objet and fire Page_ServiceLoad event $Obj = new $s(); \Core\Event::fire("Page_ServiceLoad", $_REQUEST, $Obj); } $Url = $_REQUEST->parse(); $params = array($_REQUEST); // add url params (Custom made Redirect Url) (todo array_merge with order) foreach ($Url["params"] as $p) { $params[] = $p; } $res = \Core\Task::execTask($Obj, $r, $params); $str = \Core\Task::renderTask($res); $eventReturn = \Core\Event::fire("Page_BeforeRender", $_REQUEST, $str); // Apply BeforeRender funciton to change custom output if (is_string($eventReturn)) { echo $eventReturn; } else { // supp eventuel trans si module non chargé $str = preg_replace("!<trans>(.{1,})</trans>!isU", "\$1", $str); echo $str; } \Core\Event::fire("Page_TaskLoad", $_REQUEST, $Obj, $r, $res); } catch (\Core\CException $exception) { \Core\Event::fire("Page_ServiceError", $_REQUEST, $exception); $message = $exception->getMessage(); \Core\Server::sendHeaderStatus(500); die($exception->getMessage()); } \Core\Event::fire("Page_Load", $_REQUEST, $Obj, $res);
<?php date_default_timezone_set("asia/shanghai"); include __DIR__ . '/core/Server.php'; error_reporting(E_ALL ^ E_NOTICE); use core\Server; define('BASEDIR', __DIR__); spl_autoload_register('autoload'); function autoload($classname) { $filename = BASEDIR . '/' . str_replace('\\', '/', $classname) . '.php'; if (file_exists($filename)) { include_once "{$filename}"; } else { echo '文件' . $filename . '不存在' . PHP_EOL; } } $webserver = new Server(); $webserver->run('0.0.0.0', 9501);
/** Init Translation */ public static function initEvent(\Core\Request $params) { global $PROJECT_TRANSLATION; if (empty($PROJECT_TRANSLATION)) { $PROJECT_TRANSLATION = array(); } // Langue de l'utilisateur $aLang = \Core\Server::getLang(); // Si langue en cookie if (isset($_COOKIE["oronlang"])) { $aLang = array($_COOKIE["oronlang"]); } $langFound = false; // Load from Translation modules foreach ($aLang as $lang) { if (file_exists(__DIR__ . "/Translation/{$lang}.php")) { include_once __DIR__ . "/translation/{$lang}.php"; $langFound = true; break; } } $tempLang = $PROJECT_TRANSLATION; // Load from ressource Translation foreach ($aLang as $lang) { if (file_exists(APP_PATH . "resources/Translation/{$lang}.php")) { include_once APP_PATH . "resources/Translation/{$lang}.php"; $langFound = true; break; } } $PROJECT_TRANSLATION = array_merge($tempLang, $PROJECT_TRANSLATION); if ($langFound === false) { \Core\FirePHP::fbLog("error", "Translation error : lang \"" . implode(", ", $aLang) . "\" not found"); } // sanitize Translation key foreach ($PROJECT_TRANSLATION as $key => &$val) { $key = \Core\CString::sanitize($key); $PROJECT_TRANSLATION[$key] = $val; } }