/** * 加载页面文件 * * @access public * @param $file 页面文件 */ public function load($file) { if (file_exists($file = PAGE_PATH . '/' . strtolower(lb_convert_quote_to_path($file)) . '.html')) { include $file; } }
/** * 载入指定文件 * * @param string $prefix 路径前缀 * @param string $file 文件位置 * @param int $force 强制标记 * @global array $_loaded_files 已载入文件 * @return int $require 返回状态 */ function lb_require_file($prefix, $file, $force = 0) { // 全局数组用于防止重复载入 global $_loaded_files; if (!$force && in_array($prefix . ' ' . $file, (array) $_loaded_files)) { return 1; } // 如果文件存在则载入并记录 if (file_exists($file_path = $prefix . '/' . strtolower(lb_convert_quote_to_path($file)) . '.php')) { $_loaded_files[] = $prefix . ' ' . $file; return require $file_path; } return 0; }
/** * 加载样式文件 * * @param string $name 配置索引 * @param array $files 样式文件 */ function lb_load_style($name, $files) { // 负载均衡配置 $static_conf = lb_read_static($name); preg_match('/\\.balance$/', $name) && ($static_conf = $static_conf[rand(0, count($static_conf) - 1)]); // 输出样式标签及文件版本 foreach ((array) $files as $style) { $file_path = strtolower(lb_convert_quote_to_path($style)) . '.css?version=' . $static_conf['time']; echo '<link rel="stylesheet" href="' . $static_conf['domain'] . $file_path . '" />'; echo "\n"; } }