diff --git a/Library/Think/App.php b/Library/Think/App.php
index cfbbc8d6..c5e6fed8 100644
--- a/Library/Think/App.php
+++ b/Library/Think/App.php
@@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
namespace Think;
+use Think\Exception;
/**
* App 应用管理
@@ -22,52 +23,76 @@ class App {
* @access public
* @return void
*/
- static public function run() {
+ static public function run($config) {
// 监听app_init
- Tag::listen('app_init');
- if(Config::get('common_module')){
- define('COMMON_PATH', APP_PATH . Config::get('common_module').'/');
- // 加载全局初始化文件
- if(is_file( COMMON_PATH . 'init' . EXT )) {
- include COMMON_PATH . 'init' . EXT;
- }else{
- // 检测全局配置文件
- if(is_file(COMMON_PATH . 'config' . EXT)) {
- Config::set(include COMMON_PATH . 'config' . EXT);
- }
- // 加载全局别名文件
- if(is_file(COMMON_PATH . 'alias' . EXT)) {
- Loader::addMap(include COMMON_PATH . 'alias' . EXT);
- }
- // 加载全局公共文件
- if(is_file( COMMON_PATH . 'common' . EXT)) {
- include COMMON_PATH . 'common' . EXT;
- }
- if(is_file(COMMON_PATH . 'tags' . EXT)) {
- // 全局行为扩展文件
- Tag::import(include COMMON_PATH . 'tags' . EXT);
- }
- }
- }
+ Hook::listen('app_init');
+
+ define('COMMON_PATH', APP_PATH . $config['common_module'].'/');
+ // 加载全局初始化文件
+ if(is_file( COMMON_PATH . 'init' . EXT )) {
+ include COMMON_PATH . 'init' . EXT;
+ }else{
+ // 检测全局配置文件
+ if(is_file(COMMON_PATH . 'config' . EXT)) {
+ $config = Config::set(include COMMON_PATH . 'config' . EXT);
+ }
+ // 加载全局别名文件
+ if(is_file(COMMON_PATH . 'alias' . EXT)) {
+ Loader::addMap(include COMMON_PATH . 'alias' . EXT);
+ }
+ // 加载全局公共文件
+ if(is_file( COMMON_PATH . 'common' . EXT)) {
+ include COMMON_PATH . 'common' . EXT;
+ }
+ if(is_file(COMMON_PATH . 'tags' . EXT)) {
+ // 全局行为扩展文件
+ Hook::import(include COMMON_PATH . 'tags' . EXT);
+ }
+ }
// 应用URL调度
self::dispatch($config);
// 监听app_run
- Tag::listen('app_run');
+ Hook::listen('app_run');
// 执行操作
- $instance = Loader::controller(CONTROLLER_NAME);
+ if(!preg_match('/^[A-Za-z](\/|\w)*$/',CONTROLLER_NAME)){ // 安全检测
+ $instance = false;
+ }elseif($config['action_bind_class']){
+ // 操作绑定到类:模块\Controller\控制器\操作
+ $layer = $config['controller_layer'];
+ if(is_dir(MODULE_PATH.$layer.'/'.CONTROLLER_NAME)){
+ $namespace = MODULE_NAME.'\\'.$layer.'\\'.CONTROLLER_NAME.'\\';
+ }else{
+ // 空控制器
+ $namespace = MODULE_NAME.'\\'.$layer.'\\_empty\\';
+ }
+ $actionName = strtolower(ACTION_NAME);
+ if(class_exists($namespace.$actionName)){
+ $class = $namespace.$actionName;
+ }elseif(class_exists($namespace.'_empty')){
+ // 空操作
+ $class = $namespace.'_empty';
+ }else{
+ throw new Exception('_ERROR_ACTION_:'.ACTION_NAME);
+ }
+ $instance = new $class;
+ // 操作绑定到类后 固定执行run入口
+ $action = 'run';
+ }else{
+ $instance = Loader::controller(CONTROLLER_NAME);
+ // 获取当前操作名
+ $action = ACTION_NAME . $config['action_suffix'];
+ }
if(!$instance) {
- E('[ ' . MODULE_NAME . '\\Controller\\' . parse_name(CONTROLLER_NAME, 1) . 'Controller ] not exists');
+ throw new Exception('[ ' . MODULE_NAME . '\\Controller\\' . parse_name(CONTROLLER_NAME, 1) . 'Controller ] not exists');
}
- // 获取当前操作名
- $action = ACTION_NAME . $config['action_suffix'];
try{
// 操作方法开始监听
$call = [$instance, $action];
- Tag::listen('action_begin', $call);
+ Hook::listen('action_begin', $call);
if(!preg_match('/^[A-Za-z](\w)*$/', $action)){
// 非法操作
throw new \ReflectionException();
@@ -88,9 +113,12 @@ class App {
$vars = $_GET;
}
$params = $method->getParameters();
+ $paramsBindType = $config['url_parmas_bind_type'];
foreach ($params as $param){
$name = $param->getName();
- if(isset($vars[$name])) {
+ if( 1 == $paramsBindType && !empty($vars) ){
+ $args[] = array_shift($vars);
+ }if(0 == $paramsBindType && isset($vars[$name])) {
$args[] = $vars[$name];
}elseif($param->isDefaultValueAvailable()){
$args[] = $param->getDefaultValue();
@@ -98,12 +126,13 @@ class App {
E('_PARAM_ERROR_:' . $name);
}
}
+ array_walk_recursive($args,'Input::filterExp');
$method->invokeArgs($instance, $args);
}else{
$method->invoke($instance);
}
// 操作方法执行完成监听
- Tag::listen('action_end', $call);
+ Hook::listen('action_end', $call);
}else{
// 操作方法不是Public 抛出异常
throw new \ReflectionException();
@@ -114,11 +143,11 @@ class App {
$method = new \ReflectionMethod($instance, '_empty');
$method->invokeArgs($instance, [$action, '']);
}else{
- E('[ ' . (new \ReflectionClass($instance))->getName() . ':' . $action . ' ] not exists ', 404);
+ throw new Exception('[ ' . (new \ReflectionClass($instance))->getName() . ':' . $action . ' ] not exists ', 404);
}
}
// 监听app_end
- Tag::listen('app_end');
+ Hook::listen('app_end');
return ;
}
@@ -128,25 +157,20 @@ class App {
* @return void
*/
static public function dispatch($config) {
- $var_m = $config['var_module'];
- $var_g = $config['var_group'];
- $var_c = $config['var_controller'];
- $var_a = $config['var_action'];
- $var_p = $config['var_pathinfo'];
- if(isset($_GET[$var_p])) { // 判断URL里面是否有兼容模式参数
- $_SERVER['PATH_INFO'] = $_GET[$var_p];
- unset($_GET[$var_p]);
+ if(isset($_GET[$config['var_pathinfo']])) { // 判断URL里面是否有兼容模式参数
+ $_SERVER['PATH_INFO'] = $_GET[$config['var_pathinfo']];
+ unset($_GET[$config['var_pathinfo']]);
}elseif(IS_CLI){ // CLI模式下 index.php module/controller/action/params/...
$_SERVER['PATH_INFO'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
}
// 检测域名部署
- if(!IS_CLI) {
- Route::checkDomain();
+ if(!IS_CLI && $config['sub_domain_deploy']) {
+ Route::checkDomain($config);
}
// 监听path_info
- Tag::listen('path_info');
+ Hook::listen('path_info');
// 分析PATHINFO信息
if(!isset($_SERVER['PATH_INFO']) && $_SERVER['SCRIPT_NAME'] != $_SERVER['PHP_SELF']) {
$types = explode(',', $config['pathinfo_fetch']);
@@ -162,43 +186,34 @@ class App {
}
}
- // 定位模块
if(empty($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = '';
- }
-
- // URL后缀
- define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'],PATHINFO_EXTENSION)));
- $_SERVER['PATH_INFO'] = trim(preg_replace('/\.(' . trim($config['url_html_suffix'], '.') . ')$/i', '', $_SERVER['PATH_INFO']), '/');
- if($_SERVER['PATH_INFO']) {
- if($config['url_deny_suffix'] && preg_match('/\.('.$config['url_deny_suffix'].')$/i', $_SERVER['PATH_INFO'])){
- exit;
- }
- $paths = explode($config['pathinfo_depr'], $_SERVER['PATH_INFO']);
- // 获取URL中的模块名
- if($config['require_module'] && !isset($_GET[$var_m])) {
- $_GET[$var_m] = array_shift($paths);
- $_SERVER['PATH_INFO'] = implode('/', $paths);
- }
+ define('__INFO__','');
+ define('__EXT__','');
+ }else{
+ define('__INFO__',trim($_SERVER['PATH_INFO'],'/'));
+ // URL后缀
+ define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'],PATHINFO_EXTENSION)));
+ $_SERVER['PATH_INFO'] = __INFO__;
+ if(!defined('BIND_MODULE')){
+ if($config['url_deny_suffix'] && preg_match('/\.('.$config['url_deny_suffix'].')$/i', $_SERVER['PATH_INFO'])){
+ exit;
+ }
+ $paths = explode($config['pathinfo_depr'], $_SERVER['PATH_INFO']);
+ // 获取URL中的模块名
+ if($config['require_module'] && !isset($_GET[$config['var_module']])) {
+ $_GET[$config['var_module']] = array_shift($paths);
+ $_SERVER['PATH_INFO'] = implode('/', $paths);
+ }
+ }
}
// 获取模块名称
- $module = strtolower(isset($_GET[$var_m]) ? $_GET[$var_m] : $config['default_module']);
- if($maps = Config::get('url_module_map')) {
- if(isset($maps[$module])) {
- // 记录当前别名
- define('MODULE_ALIAS',$module);
- // 获取实际的项目名
- $module = $maps[MODULE_ALIAS];
- }elseif(array_search($module,$maps)){
- // 禁止访问原始项目
- $module = '';
- }
- }
- define('MODULE_NAME', ucwords($module));
+ define('MODULE_NAME', defined('BIND_MODULE')? BIND_MODULE : self::getModule($config));
+
// 模块初始化
- if(MODULE_NAME && Config::get('common_module') != MODULE_NAME && is_dir( APP_PATH . MODULE_NAME )) {
- Tag::listen('app_begin');
+ if(MODULE_NAME && $config['common_module'] != MODULE_NAME && is_dir( APP_PATH . MODULE_NAME )) {
+ Hook::listen('app_begin');
define('MODULE_PATH', APP_PATH . MODULE_NAME . '/');
// 加载模块初始化文件
if(is_file( MODULE_PATH . 'init' . EXT )) {
@@ -223,33 +238,39 @@ class App {
}
if(is_file(MODULE_PATH . 'tags' . EXT)) {
// 行为扩展文件
- Tag::import(include MODULE_PATH . 'tags' . EXT);
+ Hook::import(include MODULE_PATH . 'tags' . EXT);
}
}
- $var_g = $config['var_group'];
- $var_c = $config['var_controller'];
- $var_a = $config['var_action'];
}else{
- E('module not exists :' . MODULE_NAME);
+ throw new Exception('module not exists :' . MODULE_NAME);
}
// 路由检测和控制器、操作解析
- Route::check($_SERVER['PATH_INFO']);
-
- // 获取分组名
- if(Config::get('require_group')){
- define('GROUP_NAME', strtolower(isset($_GET[$var_g]) ? $_GET[$var_g] : $config['default_group']));
- }else{
- define('GROUP_NAME', '');
- }
+ Route::check($_SERVER['PATH_INFO'],$config);
// 获取控制器名
- define('CONTROLLER_NAME', strtolower(isset($_GET[$var_c]) ? $_GET[$var_c] : $config['default_controller']));
+ define('CONTROLLER_NAME', strip_tags(strtolower(isset($_GET[$config['var_controller']]) ? $_GET[$config['var_controller']] : $config['default_controller'])));
// 获取操作名
- define('ACTION_NAME', strtolower(isset($_GET[$var_a]) ? $_GET[$var_a] : $config['default_action']));
+ define('ACTION_NAME', strip_tags(strtolower(isset($_GET[$config['var_action']]) ? $_GET[$config['var_action']] : $config['default_action'])));
- unset($_GET[$var_a], $_GET[$var_c], $_GET[$var_m]);
+ unset($_GET[$config['var_action']], $_GET[$config['var_controller']], $_GET[$config['var_module']]);
//保证$_REQUEST正常取值
$_REQUEST = array_merge($_POST, $_GET);
}
+
+ static private function getModule($config){
+ $module = strtolower(isset($_GET[$config['var_module']]) ? $_GET[$config['var_module']] : $config['default_module']);
+ if($maps = $config['url_module_map']) {
+ if(isset($maps[$module])) {
+ // 记录当前别名
+ define('MODULE_ALIAS',$module);
+ // 获取实际的项目名
+ $module = $maps[MODULE_ALIAS];
+ }elseif(array_search($module,$maps)){
+ // 禁止访问原始项目
+ $module = '';
+ }
+ }
+ return strip_tags(ucwords($module));
+ }
}
diff --git a/Library/Think/Behavior/TokenBuild.php b/Library/Think/Behavior/TokenBuild.php
index 11e71993..082e25b3 100644
--- a/Library/Think/Behavior/TokenBuild.php
+++ b/Library/Think/Behavior/TokenBuild.php
@@ -52,7 +52,7 @@ class TokenBuildBehavior extends Behavior {
if(isset($_SESSION[$tokenName][$tokenKey])) {// 相同页面不重复生成session
$tokenValue = $_SESSION[$tokenName][$tokenKey];
}else{
- $tokenValue = $tokenType(microtime(TRUE));
+ $tokenValue = $tokenType(microtime(true));
$_SESSION[$tokenName][$tokenKey] = $tokenValue;
}
$token = '';
diff --git a/Library/Think/Cache.php b/Library/Think/Cache.php
index 885f3800..b49d8312 100644
--- a/Library/Think/Cache.php
+++ b/Library/Think/Cache.php
@@ -27,12 +27,12 @@ class Cache {
*/
static public function connect($options=[]) {
$type = !empty($options['type'])?$options['type']:'File';
- $class = 'Think\\Cache\\Driver\\'.ucwords($type);
+ $class = 'Think\\Cache\\Driver\\'.ucwords($type);
self::$handler = new $class($options);
return self::$handler;
}
- static public function __callStatic($method, $params){
- return call_user_func_array(array(self::$handler, $method), $params);
- }
+ static public function __callStatic($method, $params){
+ return call_user_func_array(array(self::$handler, $method), $params);
+ }
}
diff --git a/Library/Think/Config.php b/Library/Think/Config.php
index 2b428abc..d1ce9e90 100644
--- a/Library/Think/Config.php
+++ b/Library/Think/Config.php
@@ -36,15 +36,16 @@ class Config {
// 检测配置是否存在
static public function has($name,$range=''){
- $range = $range?$range:self::$_range;
- $name = strtolower($name);
- // 优先执行设置获取或赋值
+ $range = $range ? $range : self::$_range;
+ $name = strtolower($name);
+
if (!strpos($name, '.')) {
return isset(self::$_config[$range][$name]);
+ }else{
+ // 二维数组设置和获取支持
+ $name = explode('.', $name);
+ return isset(self::$_config[$range][$name[0]][$name[1]]);
}
- // 二维数组设置和获取支持
- $name = explode('.', $name);
- return isset(self::$_config[$range][$name[0]][$name[1]]);
}
// 获取配置参数 为空则获取所有配置
@@ -55,13 +56,13 @@ class Config {
return self::$_config[$range];
}
$name = strtolower($name);
- // 优先执行设置获取或赋值
if (!strpos($name, '.')) {
return isset(self::$_config[$range][$name]) ? self::$_config[$range][$name] : null;
+ }else{
+ // 二维数组设置和获取支持
+ $name = explode('.', $name);
+ return isset(self::$_config[$range][$name[0]][$name[1]]) ? self::$_config[$range][$name[0]][$name[1]] : null;
}
- // 二维数组设置和获取支持
- $name = explode('.', $name);
- return isset(self::$_config[$range][$name[0]][$name[1]]) ? self::$_config[$range][$name[0]][$name[1]] : null;
}
// 设置配置参数 name为数组则为批量设置
@@ -74,18 +75,18 @@ class Config {
$name = strtolower($name);
if (!strpos($name, '.')) {
self::$_config[$range][$name] = $value;
- return;
+ }else{
+ // 二维数组设置和获取支持
+ $name = explode('.', $name);
+ self::$_config[$range][$name[0]][$name[1]] = $value;
}
- // 二维数组设置和获取支持
- $name = explode('.', $name);
- self::$_config[$range][$name[0]][$name[1]] = $value;
return;
- }
- // 批量设置
- if (is_array($name)){
+ }elseif (is_array($name)){
+ // 批量设置
self::$_config[$range] = array_merge(self::$_config[$range], array_change_key_case($name));
return self::$_config[$range];
+ }else{
+ return null; // 避免非法参数
}
- return null; // 避免非法参数
}
}
diff --git a/Library/Think/Controller.php b/Library/Think/Controller.php
index 87593b67..1611814a 100644
--- a/Library/Think/Controller.php
+++ b/Library/Think/Controller.php
@@ -11,6 +11,7 @@
namespace Think;
use Think\View;
+use Think\Transform;
class Controller {
// 视图类实例
@@ -27,7 +28,7 @@ class Controller {
'cache_path' => RUNTIME_PATH . 'Cache/',
];
$this->view = new View();
- $this->view->engine('think', $config);
+ $this->view->engine(Config::get('template_engine'), $config);
//控制器初始化
if(method_exists($this, '_initialize'))
@@ -80,39 +81,41 @@ class Controller {
* @return void
*/
protected function ajaxReturn($data, $type='') {
- if(empty($type)) $type = C('default_ajax_return');
+ if(empty($type)) $type = Config::get('default_ajax_return');
switch (strtoupper($type)){
case 'JSON':
// 返回JSON数据格式到客户端 包含状态信息
header('Content-Type:application/json; charset=utf-8');
- exit(Think\Transform::jsonEncode($data));
+ $data = Transform::jsonEncode($data);
+ break;
case 'XML':
// 返回xml格式数据
header('Content-Type:text/xml; charset=utf-8');
- exit(Think\Transform::xmlEncode($data));
+ $data = Transform::xmlEncode($data);
+ break;
case 'JSONP':
// 返回JSON数据格式到客户端 包含状态信息
header('Content-Type:application/javascript; charset=utf-8');
$handler = isset($_GET[C('var_jsonp_handler')]) ? $_GET[C('var_jsonp_handler')] : C('default_jsonp_handler');
- exit($handler . '(' . Think\Transform::jsonEncode($data) . ');');
+ $data = $handler . '(' . Transform::jsonEncode($data) . ');';
+ break;
case 'SCRIPT':
// 返回可执行的js脚本
header('Content-Type:application/javascript; charset=utf-8');
- exit($data);
+ break;
case 'HTML':
// 返回html片段
header('Content-Type:text/html; charset=utf-8');
- echo $data;
- exit;
+ break;
case 'TEXT':
// 返回一段纯文本
header('Content-Type:text/plain; charset=utf-8');
- echo $data;
- exit;
+ break;
default:
// 用于扩展其他返回格式数据
- Tag::listen('ajax_return', $data);
+ $data = Hook::listen('ajax_return', $data);
}
+ exit($data);
}
/**
@@ -158,27 +161,35 @@ class Controller {
$data['url'] = $jumpUrl;
$this->ajaxReturn($data);
}
- if(is_int($ajax)) $this->view->assign('waitSecond', $ajax);
- if(!empty($jumpUrl)) $this->view->assign('jumpUrl', $jumpUrl);
+ // 模板变量
+ $data = [];
+ if(is_int($ajax))
+ $data['waitSecond'] = $ajax;
+ if(!empty($jumpUrl))
+ $data['jumpUrl'] = $jumpUrl;
+
// 提示标题
- $this->view->assign('msgTitle', $status ? L('_OPERATION_SUCCESS_') : L('_OPERATION_FAIL_'));
- $this->view->assign('status', $status); // 状态
+ $data['msgTitle'] = $status ? L('_OPERATION_SUCCESS_') : L('_OPERATION_FAIL_');
+ $data['status'] = $status; // 状态
+
//保证输出不受静态缓存影响
- C('HTML_CACHE_ON',false);
+ Config::set('html_cache_on',false);
if($status) { //发送成功信息
- $this->view->assign('message', $message);// 提示信息
+ $data['message'] = $message;// 提示信息
// 成功操作后默认停留1秒
- $this->view->assign('waitSecond', '1');
+ $data['waitSecond'] = '1';
// 默认操作成功自动返回操作前页面
- if(!$jumpUrl) $this->view->assign("jumpUrl", $_SERVER["HTTP_REFERER"]);
- $this->display(C('success_tmpl'));
+ if(!$jumpUrl)
+ $data["jumpUrl"] = $_SERVER["HTTP_REFERER"];
+ $this->display(Config::get('success_tmpl'),$data);
}else{
- $this->view->assign('error', $message);// 提示信息
+ $data['error'] = $message;// 提示信息
//发生错误时候默认停留3秒
- $this->view->assign('waitSecond', '3');
+ $data['waitSecond'] = '3';
// 默认发生错误的话自动返回上页
- if(!$jumpUrl) $this->view->assign('jumpUrl', 'javascript:history.back(-1);');
- $this->display(C('error_tmpl'));
+ if(!$jumpUrl)
+ $data['jumpUrl'] = 'javascript:history.back(-1);';
+ $this->display(Config::get('error_tmpl'),$data);
// 中止执行 避免出错后继续执行
exit ;
}
diff --git a/Library/Think/Cookie.php b/Library/Think/Cookie.php
index 7b679b50..00868771 100644
--- a/Library/Think/Cookie.php
+++ b/Library/Think/Cookie.php
@@ -18,6 +18,8 @@ class Cookie {
'expire' => 0, // cookie 保存时间
'path' => '/', // cookie 保存路径
'domain' => '', // cookie 有效域名
+ 'secure' => false, // cookie 启用安全传输
+ 'httponly' => '', // httponly设置
];
/**
@@ -27,6 +29,9 @@ class Cookie {
*/
static public function init($config=[]){
self::$config = array_merge(self::$config, array_change_key_case($config));
+ if(!empty(self::$config['httponly'])){
+ ini_set('session.cookie_httponly', 1);
+ }
}
/**
@@ -66,7 +71,7 @@ class Cookie {
$value = 'think:'.json_encode(array_map('urlencode',$value));
}
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
- setcookie($name, $value, $expire, $config['path'], $config['domain']);
+ setcookie($name, $value, $expire, $config['path'], $config['domain'],$config['secure'],$config['httponly']);
$_COOKIE[$name] = $value;
}
@@ -77,11 +82,11 @@ class Cookie {
* @return mixed
*/
static public function get($name, $prefix='') {
- $prefix = $prefix?$prefix:self::$config['prefix'];
+ $prefix = $prefix ? $prefix : self::$config['prefix'];
$name = $prefix . $name;
if(isset($_COOKIE[$name])){
$value = $_COOKIE[$name];
- if(0===strpos($value,'think:')){
+ if(0 === strpos($value,'think:')){
$value = substr($value,6);
return array_map('urldecode',json_decode($value,true));
}else{
@@ -99,9 +104,10 @@ class Cookie {
* @return mixed
*/
static public function delete($name, $prefix='') {
- $prefix = $prefix?$prefix:self::$config['prefix'];
- $name = $prefix . $name;
- setcookie($name, '', time() - 3600, self::$config['path'], self::$config['domain']);
+ $config = self::$config;
+ $prefix = $prefix ? $prefix : $config['prefix'];
+ $name = $prefix . $name;
+ setcookie($name, '', time() - 3600, $config['path'], $config['domain'],$config['secure'],$config['httponly']);
unset($_COOKIE[$name]); // 删除指定cookie
}
@@ -115,11 +121,12 @@ class Cookie {
if (empty($_COOKIE))
return;
// 要删除的cookie前缀,不指定则删除config设置的指定前缀
- $prefix = $prefix ? $prefix: self::$config['prefix'];
+ $config = self::$config;
+ $prefix = $prefix ? $prefix: $config['prefix'];
if ($prefix) {// 如果前缀为空字符串将不作处理直接返回
foreach ($_COOKIE as $key => $val) {
if (0 === strpos($key, $prefix)) {
- setcookie($key, '', time() - 3600, self::$config['path'], self::$config['domain']);
+ setcookie($key, '', time() - 3600, $config['path'], $config['domain'],$config['secure'],$config['httponly']);
unset($_COOKIE[$key]);
}
}
diff --git a/Library/Think/Crypt.php b/Library/Think/Crypt.php
deleted file mode 100644
index 393b93e0..00000000
--- a/Library/Think/Crypt.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
-// +----------------------------------------------------------------------
-
-namespace Think;
-
-class Crypt {
- /**
- * 加密字符串
- * @access public
- * @param string $str 字符串
- * @param string $key 加密key
- * @return string
- */
- static public function encrypt($data,$key,$expire=0){
- $key = md5($key);
- $data = base64_encode($data);
- $x = 0;
- $len = strlen($data);
- $l = strlen($key);
- $char = '';
- for ($i = 0; $i< $len; $i++) {
- if ($x == $l) $x = 0;
- $char .=substr($key, $x, 1);
- $x++;
- }
- $str = sprintf('%010d', $expire ? $expire + time() : 0);
- for ($i=0; $i< $len; $i++) {
- $str .= chr(ord(substr($data, $i, 1)) + (ord(substr($char, $i, 1))) % 256);
- }
- return str_replace('=', '', base64_encode($str));
- }
-
- /**
- * 解密字符串
- * @access public
- * @param string $str 字符串
- * @param string $key 加密key
- * @return string
- */
- static public function decrypt($data,$key){
- $key = md5($key);
- $x = 0;
- $data = base64_decode($data);
- $expire = substr($data,0,10);
- $data = substr($data,10);
- if($expire > 0 && $expire