改了改TP,自己用
<?php
//自动获取APP_NAME
function get_app_name() {
if(isset($_GET['app'])){
//判断开放的应用列表,进行必要的应用名过滤
$app_name = strtolower(str_replace(array('/','\\'),'',urldecode($_GET['app'])));
}else{
$app_name = 'thinksns';
}
return $app_name;
}
//自动获取APP_PATH
function get_app_path() {
if(APP_NAME=='thinksns'){
$app_path = CORE_PATH.'/thinksns';
}else{
//判断开放的应用列表
$app_path = SITE_PATH.'/apps/'.APP_NAME;
}
return $app_path;
}
//前置缓存 规则待定
//载入核心文件
//记录开始运行时间
$GLOBALS['_beginTime'] = microtime(TRUE);
//路由解析
if(!defined('APP_NAME')) define('APP_NAME' , get_app_name());
if(!defined('APP_PATH')) define('APP_PATH' , get_app_path());
//重新设定编译路径
if(!defined('THINK_PATH')) define('THINK_PATH' , CORE_PATH.'/ThinkPHP');
if(!defined('RUNTIME_PATH')) define('RUNTIME_PATH',SITE_PATH.'/_runtime/~'.APP_NAME.'/');
if(!is_dir(RUNTIME_PATH)) mkdir(RUNTIME_PATH,0777,true);
if(is_file(RUNTIME_PATH.'~allinone.php')) {
// ALLINONE 模式直接载入allinone缓存
$result = require RUNTIME_PATH.'~allinone.php';
C($result);
// 自动设置为运行模式
define('RUNTIME_MODEL',true);
}else{
if(version_compare(PHP_VERSION,'5.0.0','<')) die('require PHP > 5.0 !');
// ThinkPHP系统目录定义
if(is_file(RUNTIME_PATH.'~runtime.php')) {
// 加载框架核心编译缓存
require RUNTIME_PATH.'~runtime.php';
}else{
// 加载编译函数文件
require THINK_PATH."/Common/runtime.php";
// 生成核心编译~runtime缓存
build_runtime();
}
}
// 记录加载文件时间
$GLOBALS['_loadTime'] = microtime(TRUE);
?>