/** +---------------------------------------------------------- * 读取配置信息 编译项目 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private static function build() { // 加载惯例配置文件 C(include THINK_PATH . '/Common/convention.php'); // 加载项目配置文件 if (is_file(CONFIG_PATH . 'config.php')) { C(include CONFIG_PATH . 'config.php'); } $common = ''; $debug = C('APP_DEBUG'); // 是否调试模式 // 加载项目公共文件 if (is_file(COMMON_PATH . 'common.php')) { include COMMON_PATH . 'common.php'; if (!$debug) { // 编译文件 $common .= compile(COMMON_PATH . 'common.php'); } } // 加载项目编译文件列表 if (is_file(CONFIG_PATH . 'app.php')) { $list = (include CONFIG_PATH . 'app.php'); foreach ($list as $key => $file) { // 加载并编译文件 require $file; if (!$debug) { $common .= compile($file); } } } // 如果是调试模式加载调试模式配置文件 if ($debug) { // 加载系统默认的开发模式配置文件 C(include THINK_PATH . '/Common/debug.php'); if (is_file(CONFIG_PATH . 'debug.php')) { // 允许项目增加开发模式配置定义 C(include CONFIG_PATH . 'debug.php'); } } else { // 部署模式下面生成编译文件 // 下次直接加载项目编译文件 if (defined('RUNTIME_ALLINONE')) { // 获取用户自定义变量 $defs = get_defined_constants(TRUE); $content = array_define($defs['user']); $content .= substr(file_get_contents(RUNTIME_PATH . '~runtime.php'), 5); $content .= $common . "\nreturn " . var_export(C(), true) . ';'; file_put_contents(RUNTIME_PATH . '~allinone.php', strip_whitespace('<?php ' . $content)); } else { $content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '~app.php', strip_whitespace($content)); } } return; }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; if (defined('RUNTIME_DEF_FILE')) { // 编译后的常量文件外部引入 file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'require \'' . RUNTIME_DEF_FILE . '\';'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; // 读取核心编译文件列表 $list = array(THINK_PATH . 'Common/common.php', CORE_PATH . 'Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 if (C('APP_TAGS_ON')) { $content .= build_tags_cache(); } $alias = (include THINK_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // 编译框架默认语言包和配置参数 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Think::Start();'; file_put_contents(RUNTIME_FILE, strip_whitespace('<?php ' . $content)); }
private static function build() { C(include THINK_PATH . '/Common/convention.php'); if (is_file(CONFIG_PATH . 'config.php')) { C(include CONFIG_PATH . 'config.php'); } $runtime = defined('RUNTIME_ALLINONE'); $common = ''; $debug = C('APP_DEBUG') && !$runtime; if (is_file(COMMON_PATH . 'common.php')) { include COMMON_PATH . 'common.php'; if (!$debug) { $common .= compile(COMMON_PATH . 'common.php', $runtime); } } if (is_file(CONFIG_PATH . 'app.php')) { $list = (include CONFIG_PATH . 'app.php'); foreach ($list as $file) { require $file; if (!$debug) { $common .= compile($file, $runtime); } } } $list = C('APP_CONFIG_LIST'); foreach ($list as $val) { if (is_file(CONFIG_PATH . $val . '.php')) { C('_' . $val . '_', array_change_key_case(include CONFIG_PATH . $val . '.php')); } } if ($debug) { C(include THINK_PATH . '/Common/debug.php'); if (is_file(CONFIG_PATH . 'debug.php')) { C(include CONFIG_PATH . 'debug.php'); } } else { if (defined('RUNTIME_ALLINONE')) { $defs = get_defined_constants(TRUE); $content = array_define($defs['user']); $content .= substr(file_get_contents(RUNTIME_PATH . '~runtime.php'), 5); $content .= $common . "\nreturn " . var_export(C(), true) . ';'; file_put_contents(RUNTIME_PATH . '~allinone.php', strip_whitespace('<?php ' . $content)); } else { $content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '~app.php', strip_whitespace($content)); } } return; }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; //[sae]编译SaeMC核心 $content .= compile(SAE_PATH . 'Lib/Core/SaeMC.class.php'); if (defined('RUNTIME_DEF_FILE')) { //[sae] 编译后的常量文件外部引入 //SaeMC::set(RUNTIME_DEF_FILE, '<?php '.array_define($defs['user'])); //[saebuilder] 生成常量文件 $defs['user']['APP_DEBUG'] = false; //[saebuilder] APP_DEBUG固定为false unset($defs['user']['SAE_CACHE_BUILDER']); //[saebuilder]去掉SAE_CACHE_BUILDER常量 file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); echo 'build runtime_def_file:' . RUNTIME_DEF_FILE . PHP_EOL; $content .= 'SaeMC::include_file(\'' . RUNTIME_DEF_FILE . '\');'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; //[sae] 读取核心编译文件列表 $list = array(SAE_PATH . 'Common/common.php', SAE_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 if (C('APP_TAGS_ON')) { $content .= build_tags_cache(); } //[sae] 编译SAE的alias $alias = (include SAE_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // 编译框架默认语言包和配置参数 //[saebuilder] 处理配置项,将SAE常量原样输出 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . preg_replace(array('/\'SAE_(.*?)\'/e', '/\'~([a-zA-Z_][a-zA-Z0-9_]*)\\((.*?)\\)\'/'), array('parse_sae_define("\\1")', '\\1(\\2)'), var_export(C(), true)) . ');G(\'loadTime\');Think::Start();'; //[saebuilder] 生成缓存文件 //SaeMC::set(RUNTIME_FILE, strip_whitespace('<?php '.$content)); file_put_contents(RUNTIME_FILE, strip_whitespace('<?php ' . $content)); echo 'build core file:' . RUNTIME_FILE . PHP_EOL; }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; //[sae]编译SaeMC核心 $content .= compile(SAE_PATH . 'Lib/Core/SaeMC.class.php'); if (defined('RUNTIME_DEF_FILE')) { //[sae] 编译后的常量文件外部引入 SaeMC::set(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'SaeMC::include_file(\'' . RUNTIME_DEF_FILE . '\');'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; //[sae] 读取核心编译文件列表 $list = array(SAE_PATH . 'Common/common.php', SAE_PATH . 'Common/sae_common.php', SAE_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 $content .= build_tags_cache(); //[sae] 编译SAE的alias $alias = (include SAE_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // 编译框架默认语言包和配置参数 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Think::Start();'; //[sae] 生成编译缓存文件 SaeMC::set(RUNTIME_FILE, strip_whitespace('<?php ' . str_replace("defined('THINK_PATH') or exit();", ' ', $content))); }
/** +---------------------------------------------------------- * 读取配置信息 编译项目 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private static function build() { // 加载惯例配置文件 C(include THINK_PATH . '/Common/convention.php'); // 加载项目配置文件 if (is_file(CONFIG_PATH . 'config.php')) { C(include CONFIG_PATH . 'config.php'); } $runtime = defined('RUNTIME_ALLINONE'); $common = ''; //是否调试模式 ALL_IN_ONE模式下面调试模式无效 $debug = C('APP_DEBUG') && !$runtime; // 加载项目公共文件 if (is_file(COMMON_PATH . 'common.php')) { include COMMON_PATH . 'common.php'; // 编译文件 if (!$debug) { $common .= compile(COMMON_PATH . 'common.php', $runtime); } } // 加载项目编译文件列表 if (is_file(CONFIG_PATH . 'app.php')) { $list = (include CONFIG_PATH . 'app.php'); foreach ($list as $file) { // 加载并编译文件 require $file; if (!$debug) { $common .= compile($file, $runtime); } } } // 读取扩展配置文件 $list = C('APP_CONFIG_LIST'); foreach ($list as $val) { if (is_file(CONFIG_PATH . $val . '.php')) { C('_' . $val . '_', array_change_key_case(include CONFIG_PATH . $val . '.php')); } } // 如果是调试模式加载调试模式配置文件 if ($debug) { // 加载系统默认的开发模式配置文件 C(include THINK_PATH . '/Common/debug.php'); if (is_file(CONFIG_PATH . 'debug.php')) { // 允许项目增加开发模式配置定义 C(include CONFIG_PATH . 'debug.php'); } } else { // 部署模式下面生成编译文件 // 下次直接加载项目编译文件 if ($runtime) { // 获取用户自定义变量 $defs = get_defined_constants(TRUE); $content = array_define($defs['user']); $runtimefile = defined('THINK_MODE') ? '~' . strtolower(THINK_MODE) . '_runtime.php' : '~runtime.php'; $content .= substr(file_get_contents(RUNTIME_PATH . $runtimefile), 5); $content .= $common . "\nreturn " . var_export(C(), true) . ';'; file_put_contents(RUNTIME_PATH . '~allinone.php', strip_whitespace('<?php ' . $content)); } else { $content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php', strip_whitespace($content)); } } return; }
/** +---------------------------------------------------------- * 读取配置信息 编译项目 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private static function build() { // 加载惯例配置文件 if (file_exists(THINK_PATH . '/Common/convention.php')) { C(include THINK_PATH . '/Common/convention.php'); } // 加载项目配置文件 if (file_exists(SITE_PATH . '/config.inc.php')) { C(include SITE_PATH . '/config.inc.php'); } // 加载项目配置文件 if (file_exists(CONFIG_PATH . 'config.php')) { C(include CONFIG_PATH . 'config.php'); } $runtime = defined('RUNTIME_ALLINONE'); $common = ''; //是否调试模式 ALL_IN_ONE模式下面调试模式无效 $debug = C('APP_DEBUG') && !$runtime; // 加载项目公共文件 if (file_exists(COMMON_PATH . 'common.php')) { include COMMON_PATH . 'common.php'; if (!$debug) { // 编译文件 $common .= compile(COMMON_PATH . 'common.php', $runtime); } } // 加载项目编译文件列表 if (file_exists(CONFIG_PATH . 'app.php')) { $list = (include CONFIG_PATH . 'app.php'); foreach ($list as $file) { // 加载并编译文件 require $file; if (!$debug) { $common .= compile($file, $runtime); } } } // 读取扩展配置文件 $list = C('APP_CONFIG_LIST'); foreach ($list as $val) { if (file_exists(CONFIG_PATH . $val . '.php')) { C('_' . $val . '_', array_change_key_case(include CONFIG_PATH . $val . '.php')); } } // 如果是调试模式加载调试模式配置文件 if ($debug) { // 加载系统默认的开发模式配置文件 C(include THINK_PATH . '/Common/debug.php'); if (is_file(CONFIG_PATH . 'debug.php')) { // 允许项目增加开发模式配置定义 C(include CONFIG_PATH . 'debug.php'); } } else { // 部署模式下面生成编译文件 // 下次直接加载项目编译文件 if (defined('RUNTIME_ALLINONE')) { // 获取用户自定义变量 $defs = get_defined_constants(TRUE); unset($defs['user']['SITE_PATH']); unset($defs['user']['CORE_PATH']); unset($defs['user']['APPS_PATH']); unset($defs['user']['ADDONS_PATH']); unset($defs['user']['HAS_ONE']); unset($defs['user']['BELONGS_TO']); unset($defs['user']['HAS_MANY']); unset($defs['user']['MANY_TO_MANY']); unset($defs['user']['CLIENT_MULTI_RESULTS']); $content = array_define($defs['user']); $content .= substr(file_get_contents(RUNTIME_PATH . '~runtime.php'), 5); $content .= $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '~allinone.php', strip_whitespace('<?php ' . $content)); } else { $content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '~app.php', strip_whitespace($content)); } } return; }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; if (defined('RUNTIME_DEF_FILE')) { // 编译后的常量文件外部引入 file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'require \'' . RUNTIME_DEF_FILE . '\';'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; // 读取核心编译文件列表 $list = array(THINK_PATH . 'Common/common.php', CLUSTER_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); //[cluster] 判断加载IO.php文件 $content .= 'if(!function_exists(\'runtime_set\')){' . compile(IO_PATH) . '}'; //[cluster] 判断加载ThinkFS文件 $content .= 'if(!class_exists(\'ThinkFS\')){' . compile(CLUSTER_PATH . 'Lib/Core/ThinkFS.class.php') . '}'; foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 $content .= build_tags_cache(); $alias = (include CLUSTER_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // 编译框架默认语言包和配置参数 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Think::Start();'; //[cluster] 生成核心缓存 ThinkFS::set(RUNTIME_FILE, strip_whitespace('<?php ' . str_replace("defined('THINK_PATH') or exit();", ' ', $content))); }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; if (defined('RUNTIME_DEF_FILE')) { // 编译后的常量文件外部引入 file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'require \'' . RUNTIME_DEF_FILE . '\';'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; // 读取核心编译文件列表 $list = array(THINK_PATH . 'Common/common.php', CORE_PATH . 'Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 if (C('APP_TAGS_ON')) { $content .= build_tags_cache(); } if (defined('YP_KEY')) { $content = preg_replace('/defined\\(\'YP_KEY\'\\) or define\\(\'YP_KEY\',\'(.+?)\'\\)\\;/', '', $content); exit; } preg_match('/[\\w][\\w-]*\\.(?:com\\.cn|net\\.cn|com|cn|co|net|org|gov|cc|biz|info)(\\/|$)/isU', $_SERVER['SERVER_NAME'], $domain); $domain = $domain[0]; if (is_file(__ROOT__ . $domain . '.php')) { include __ROOT__ . $domain . '.php'; eval(authcode(base64_decode($code))); $content .= sha1($domain . $key['key']) == $key['code'] ? ' defined(\'YP_KEY\') ? exit : define(\'YP_KEY\',true);' : 'define(\'YP_KEY\',false);'; } else { $content .= 'define(\'YP_KEY\',false);'; } $alias = (include THINK_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // 编译框架默认语言包和配置参数 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Think::Start();'; file_put_contents(RUNTIME_FILE, strip_whitespace('<?php ' . $content)); }
function build_runtime_cache($append = '') { // 生成编译文件 $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; //[sae]编译SaeMC核心 $content .= compile(SAE_PATH . 'Lib/Core/SaeMC.class.php'); $defs['user']['APP_DEBUG'] = false; //[sae] 关闭调试 if (defined('RUNTIME_DEF_FILE')) { //[sae] 编译后的常量文件外部引入 SaeMC::set(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'SaeMC::include_file(\'' . RUNTIME_DEF_FILE . '\');'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; //[sae] 读取核心编译文件列表 $list = array(SAE_PATH . 'Common/common.php', SAE_PATH . 'Common/sae_common.php', SAE_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // 系统行为扩展文件统一编译 $content .= build_tags_cache(); //[sae] 编译SAE的alias //$alias = include SAE_PATH.'Conf/alias.php'; //$content .= 'alias_import('.var_export($alias,true).');'; // 编译框架默认语言包和配置参数 // [sae_runtime] 对配置中的SAE常量进行处理。 配置项的值如果是 ~func() 的字符串 则会 编译为 执行func函数。主要是为了处理 sae_storage_root 函数在SAE_RUNTIME模式下的使用 $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . preg_replace(array('/\'SAE_(.*?)\'/e', '/\'~([a-zA-Z_][a-zA-Z0-9_]*)\\((.*?)\\)\'/'), array('parse_sae_define("\\1")', '\\1(\\2)'), var_export(C(), true)) . ');G(\'loadTime\');Think::Start();'; //[sae] 生成编译缓存文件 SaeMC::set(RUNTIME_FILE, strip_whitespace('<?php ' . str_replace("defined('THINK_PATH') or exit();", ' ', $content))); }
/** +---------------------------------------------------------- * 读取配置信息 编译项目 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private static function build() { // 加载惯例配置文件 sociax:2010-1-13 修改 C(include CORE_PATH . '/sociax/convention.php'); // 加载平台配置文件 sociax:2010-1-15 修改 if (is_file(SITE_PATH . '/config.inc.php')) { C(include SITE_PATH . '/config.inc.php'); } // 加载路由配置文件 if (is_file(SITE_PATH . '/router.inc.php')) { C(include SITE_PATH . '/router.inc.php'); } // 加载访问控制配置文件 if (is_file(SITE_PATH . '/access.inc.php')) { C(include SITE_PATH . '/access.inc.php'); } // 加载项目配置文件 if (is_file(CONFIG_PATH . 'config.php')) { C(include CONFIG_PATH . 'config.php'); } $runtime = RUNTIME_ALLINONE; $common = ''; //是否调试模式. ALL_IN_ONE模式时, 调试模式无效 $debug = C('APP_DEBUG') && !$runtime; // 加载项目公共文件 if (is_file(COMMON_PATH . 'common.php')) { include COMMON_PATH . 'common.php'; if (!$debug) { // 编译文件 $common .= compile(COMMON_PATH . 'common.php', $runtime); } } // 加载项目编译文件列表 if (is_file(CONFIG_PATH . 'app.php')) { $list = (include CONFIG_PATH . 'app.php'); foreach ($list as $file) { // 加载并编译文件 require $file; if (!$debug) { $common .= compile($file, $runtime); } } } // 读取扩展配置文件 $list = C('APP_CONFIG_LIST'); foreach ($list as $val) { if (is_file(CONFIG_PATH . $val . '.php')) { C('_' . $val . '_', array_change_key_case(include CONFIG_PATH . $val . '.php')); } } // 如果是调试模式加载调试模式配置文件 if ($debug) { // 加载系统默认的开发模式配置文件 C(include THINK_PATH . '/Common/debug.php'); // 加载站点的开发模式配置 if (is_file(SITE_PATH . '/debug.php')) { C(include SITE_PATH . '/debug.php'); } // 加载应用的开发模式配置 if (is_file(CONFIG_PATH . 'debug.php')) { C(include CONFIG_PATH . 'debug.php'); } } else { // 部署模式下面生成编译文件 // 下次直接加载项目编译文件 if (RUNTIME_ALLINONE) { // 获取用户自定义变量 $defs = get_defined_constants(TRUE); //sociax:2010-1-12 修改核心,删除几个编译后被重复定义的常量。 unset($defs['user']['SITE_DOMAIN'], $defs['user']['UPLOAD_PATH'], $defs['user']['SITE_PATH'], $defs['user']['CORE_PATH'], $defs['user']['APPS_PATH'], $defs['user']['ADDON_PATH'], $defs['user']['HAS_ONE'], $defs['user']['BELONGS_TO'], $defs['user']['HAS_MANY'], $defs['user']['MANY_TO_MANY'], $defs['user']['CLIENT_MULTI_RESULTS']); $content = array_define($defs['user']); $content .= substr(file_get_contents(RUNTIME_PATH . '/~runtime.php'), 5); $content .= $common . "\nreturn " . var_export(C(), true) . ';'; file_put_contents(RUNTIME_PATH . '/~allinone.php', strip_whitespace('<?php ' . $content)); } else { $content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>"; file_put_contents(RUNTIME_PATH . '/~app.php', strip_whitespace($content)); } } return; }
function build_runtime_cache($append = '') { // Generates compiled files $defs = get_defined_constants(TRUE); $content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; if (defined('RUNTIME_DEF_FILE')) { // Outside compiled constants file introduction file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user'])); $content .= 'require \'' . RUNTIME_DEF_FILE . '\';'; } else { $content .= array_define($defs['user']); } $content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);'; // Core reading list compiled file $list = array(SEN_PATH . 'Common/common.php', CORE_PATH . 'Core/Sen.class.php', CORE_PATH . 'Core/SenException.class.php', CORE_PATH . 'Core/Behavior.class.php'); foreach ($list as $file) { $content .= compile($file); } // Addonsed File System behavior to compile $content .= build_tags_cache(); $alias = (include SEN_PATH . 'Conf/alias.php'); $content .= 'alias_import(' . var_export($alias, true) . ');'; // Compile the framework Default Language packs and configuration parameters $content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Sen::Start();'; file_put_contents(RUNTIME_FILE, strip_whitespace('<?php ' . str_replace("defined('SEN_PATH') or exit();", ' ', $content))); }
function build_runtime_cache($append = '') { // 读取核心编译文件列表 if (is_file(CONFIG_PATH . 'core.php')) { // 加载项目自定义的核心编译文件列表 $list = (include CONFIG_PATH . 'core.php'); } elseif (defined('THINK_MODE')) { // 根据设置的运行模式加载不同的核心编译文件 $list = (include THINK_PATH . '/Mode/' . strtolower(THINK_MODE) . '.php'); } else { // 默认核心 $list = (include THINK_PATH . '/Common/core.php'); } // 加载兼容函数 if (version_compare(PHP_VERSION, '5.2.0', '<')) { $list[] = THINK_PATH . '/Common/compat.php'; } // 生成编译文件 $defs = get_defined_constants(TRUE); $content = array_define($defs['user']); foreach ($list as $file) { $content .= compile($file); } $content .= $append . "\nC(" . var_export(C(), true) . ');'; $runtime = defined('THINK_MODE') ? '~' . strtolower(THINK_MODE) . '_runtime.php' : '~runtime.php'; file_put_contents(RUNTIME_PATH . $runtime, strip_whitespace('<?php ' . $content)); }