private static function _VLoadHostRules($sHost) { $confFile = Ko_Web_Config::SGetRewriteConf($sHost); if (is_file($confFile)) { $cacheFile = Ko_Web_Config::SGetRewriteCache($sHost); if ('' === $cacheFile) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); } else { $cacheDir = dirname($cacheFile); if (!is_dir($cacheDir)) { mkdir($cacheDir, 0777, true); if (!is_dir($cacheDir)) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); return; } } if (!is_file($cacheFile) || filemtime($confFile) > filemtime($cacheFile)) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); $script = "<?php\nKo_Web_Rewrite::VLoadRules(" . Ko_Tool_Stringify::SConvArray(self::$s_aRules) . ");\n"; file_put_contents($cacheFile, $script); } else { require_once $cacheFile; } } } }
private static function _VLoadHostRules($sHost, &$sUri) { $srcUri = $sUri; $confFile = Ko_Web_Config::SGetValue('rewriteconf', $sHost, $sUri); if (is_file($confFile)) { $cacheFile = Ko_Web_Config::SGetValue('rewritecache', $sHost, $srcUri); if ('' === $cacheFile) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); } else { $cacheDir = dirname($cacheFile); if (!is_dir($cacheDir)) { mkdir($cacheDir, 0777, true); if (!is_dir($cacheDir)) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); return; } } if (!is_file($cacheFile) || filemtime($confFile) > filemtime($cacheFile)) { self::$s_aRules = Ko_Web_RewriteParser::AProcess(file_get_contents($confFile)); $script = "<?php\nKo_Web_Rewrite::VLoadRules(" . var_export(self::$s_aRules, true) . ");\n"; file_put_contents($cacheFile, $script); } else { require_once $cacheFile; } } } }
public static function VLoadConfig($aConfig) { self::$s_aConfig = $aConfig; }
$loginuid = $loginApi->iGetLoginUid(); if (empty($loginuid)) { Ko_Web_Response::VSetRedirect('http://' . PASSPORT_DOMAIN . '/user/login'); Ko_Web_Response::VSend(); exit; } } } $hooks = COMMON_CLASS_PATH . 'hooks/' . $appname . '.php'; if (is_file($hooks)) { require_once $hooks; } }); Ko_Web_Event::On('ko.error', '500', function ($errno, $errstr, $errfile, $errline, $errcontext) { Ko_Web_Error::V500($errno, $errstr, $errfile, $errline, $errcontext); exit; }); Ko_Web_Event::On('ko.dispatch', 'before', function () { Ko_Tool_Adapter::VOn('user_baseinfo', array('KUser_baseinfoApi', 'AAdapter')); Ko_Tool_Adapter::VOn('image_baseinfo', array('KStorage_Api', 'AAdapter')); $uri = Ko_Web_Request::SRequestUri(); $appname = Ko_Web_Config::SGetAppName(); if ('zc' === $appname) { $_GET['uid'] = 20; } }); Ko_Web_Event::On('ko.dispatch', '404', function () { Ko_Web_Route::V404(); exit; }); require_once KO_DIR . 'web/Bootstrap.php';
<?php Ko_Web_Config::VLoadConfig(array('global' => array('operation.imfw.cn:8080' => 'operation', 'operation.main.imfw.cn' => 'operation'), 'app_default' => array('documentroot' => '/usr/share/php/apps/www/default', 'rewriteconf' => '/usr/share/php/apps/conf/rewrite/default.txt', 'rewritecache' => '/usr/share/php/apps/rundata/rewrite/default.php'), 'app_passport' => array('documentroot' => '/usr/share/php/apps/www/passport', 'rewriteconf' => '/usr/share/php/apps/conf/rewrite/passport.txt', 'rewritecache' => '/usr/share/php/apps/rundata/rewrite/passport.php'), 'app_xhprof' => array('documentroot' => '/usr/share/php/xhprof/'), 'app_operation' => array('documentroot' => '/srv/htdocs/apps/www/operation', 'rewriteconf' => '/srv/htdocs/apps/conf/rewrite/operation.txt', 'rewritecache' => '/srv/htdocs/apps/rundata/rewrite/operation.php')));
<?php /** * Bootstrap * * @package ko/Web * @author zhangchu */ if (!defined('KO_WEB_BOOTSTRAP')) { define('KO_WEB_BOOTSTRAP', 1); Ko_Tool_Xhprof::VStart(); Ko_Web_Event::Trigger('ko.bootstrap', 'before'); Ko_Web_Config::VLoad(); Ko_Web_Event::Trigger('ko.config', 'after'); Ko_Web_Error::VHandle(); Ko_Web_Rewrite::VHandle(); Ko_Web_Event::Trigger('ko.dispatch', 'before'); if (Ko_Web_Route::IDispatch($phpFilename)) { Ko_Web_Event::Trigger('ko.dispatch', '404'); } else { if ('' !== $phpFilename) { $cwd = getcwd(); chdir(dirname($phpFilename)); require_once $phpFilename; chdir($cwd); } } }
public static function SDocumentRoot() { $dr = Ko_Web_Config::SGetDocumentRoot(); if ('' === $dr) { $dr = self::_VServer('DOCUMENT_ROOT'); } return $dr; }