From 6a7a72341794cced17529b790a495d4291006baf Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 3 Jan 2013 09:49:56 +0800 Subject: [PATCH 01/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=9A=84=E4=B8=80=E5=A4=84js=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Tpl/dispatch_jump.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThinkPHP/Tpl/dispatch_jump.tpl b/ThinkPHP/Tpl/dispatch_jump.tpl index 2fe05a940..585efa59f 100644 --- a/ThinkPHP/Tpl/dispatch_jump.tpl +++ b/ThinkPHP/Tpl/dispatch_jump.tpl @@ -33,7 +33,7 @@ body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16p var wait = document.getElementById('wait'),href = document.getElementById('href').href; var interval = setInterval(function(){ var time = --wait.innerHTML; - if(time == 0) { + if(time <= 0) { location.href = href; clearInterval(interval); }; From 532e673a1506a000c1aac0263100ae404f81dc31 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 3 Jan 2013 11:21:15 +0800 Subject: [PATCH 02/33] =?UTF-8?q?A=E6=96=B9=E6=B3=95=E5=92=8CD=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=9C=A8=E7=8B=AC=E7=AB=8B=E5=88=86=E7=BB=84=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E8=B7=A8=E5=88=86=E7=BB=84?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/common.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ThinkPHP/Common/common.php b/ThinkPHP/Common/common.php index fd0207430..63a53cfcd 100644 --- a/ThinkPHP/Common/common.php +++ b/ThinkPHP/Common/common.php @@ -264,7 +264,13 @@ function D($name='',$layer='') { $name = C('DEFAULT_APP').'/'.$layer.'/'.$name; } if(isset($_model[$name])) return $_model[$name]; - import($name.$layer); + $path = explode('/',$name); + if(count($path)>3 && 1 == C('APP_GROUP_MODE')) { // 独立分组 + $baseUrl = $path[0]== '@' ? dirname(BASE_LIB_PATH) : APP_PATH.'../'.$path[0].'/'.C('APP_GROUP_PATH').'/'; + import($path[2].'/'.$path[1].'/'.$path[3].$layer,$baseUrl); + }else{ + import($name.$layer); + } $class = basename($name.$layer); if(class_exists($class)) { $model = new $class(basename($name)); @@ -311,15 +317,19 @@ function A($name,$layer='',$common=false) { $name = '@/'.$layer.'/'.$name; } if(isset($_action[$name])) return $_action[$name]; - if($common){ // 独立分组情况下 加载公共目录类库 + $path = explode('/',$name); + if(count($path)>3 && 1 == C('APP_GROUP_MODE')) { // 独立分组 + $baseUrl = $path[0]== '@' ? dirname(BASE_LIB_PATH) : APP_PATH.'../'.$path[0].'/'.C('APP_GROUP_PATH').'/'; + import($path[2].'/'.$path[1].'/'.$path[3].$layer,$baseUrl); + }elseif($common) { // 加载公共类库目录 import(str_replace('@/','',$name).$layer,LIB_PATH); }else{ - import($name.$layer); - } + import($name.$layer); + } $class = basename($name.$layer); if(class_exists($class,false)) { - $action = new $class(); - $_action[$name] = $action; + $action = new $class(); + $_action[$name] = $action; return $action; }else { return false; From b05e8fdd02eef3a07680c580a14dfa019ea00ee8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 3 Jan 2013 11:47:09 +0800 Subject: [PATCH 03/33] =?UTF-8?q?=E5=88=86=E7=BB=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E6=89=A9=E5=B1=95=E5=AE=9A=E4=B9=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Dispatcher.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Lib/Core/Dispatcher.class.php b/ThinkPHP/Lib/Core/Dispatcher.class.php index a3134dbc5..3997e7bbf 100644 --- a/ThinkPHP/Lib/Core/Dispatcher.class.php +++ b/ThinkPHP/Lib/Core/Dispatcher.class.php @@ -150,7 +150,10 @@ static public function dispatch() { C(include $config_path.'config.php'); // 加载分组别名定义 if(is_file($config_path.'alias.php')) - alias_import(include $config_path.'alias.php'); + alias_import(include $config_path.'alias.php'); + // 加载分组tags文件定义 + if(is_file($config_path.'tags.php')) + C('tags', include $config_path.'tags.php'); // 加载分组函数文件 if(is_file($common_path.'function.php')) include $common_path.'function.php'; From 36e2b5fa1e863798eaf5c66626c0698a4de1d64e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 6 Jan 2013 10:23:36 +0800 Subject: [PATCH 04/33] =?UTF-8?q?=E5=85=A5=E5=8F=A3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E5=BC=95=E6=93=8E=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=9A=84=E8=BD=BD=E5=85=A5=E6=94=AF=E6=8C=81=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=BC=95=E6=93=8E=E6=89=A9=E5=B1=95=E6=97=A0=E9=9C=80?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E5=85=A5=E5=8F=A3=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E5=8F=AA=E9=9C=80=E8=A6=81=E5=9C=A8=E5=85=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E5=AE=9A=E4=B9=89=20ENGINE=5FNAME=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Dispatcher.class.php | 1 - ThinkPHP/ThinkPHP.php | 24 ++++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ThinkPHP/Lib/Core/Dispatcher.class.php b/ThinkPHP/Lib/Core/Dispatcher.class.php index 3997e7bbf..ea37af130 100644 --- a/ThinkPHP/Lib/Core/Dispatcher.class.php +++ b/ThinkPHP/Lib/Core/Dispatcher.class.php @@ -157,7 +157,6 @@ static public function dispatch() { // 加载分组函数文件 if(is_file($common_path.'function.php')) include $common_path.'function.php'; - } define('MODULE_NAME',self::getModule(C('VAR_MODULE'))); define('ACTION_NAME',self::getAction(C('VAR_ACTION'))); diff --git a/ThinkPHP/ThinkPHP.php b/ThinkPHP/ThinkPHP.php index 9128a00f4..2563de65e 100644 --- a/ThinkPHP/ThinkPHP.php +++ b/ThinkPHP/ThinkPHP.php @@ -10,22 +10,26 @@ // +---------------------------------------------------------------------- // ThinkPHP 入口文件 -//记录开始运行时间 +// 记录开始运行时间 $GLOBALS['_beginTime'] = microtime(TRUE); // 记录内存初始使用 define('MEMORY_LIMIT_ON',function_exists('memory_get_usage')); if(MEMORY_LIMIT_ON) $GLOBALS['_startUseMems'] = memory_get_usage(); +// 系统目录定义 +defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/'); defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); defined('RUNTIME_PATH') or define('RUNTIME_PATH',APP_PATH.'Runtime/'); defined('APP_DEBUG') or define('APP_DEBUG',false); // 是否调试模式 -$runtime = defined('MODE_NAME')?'~'.strtolower(MODE_NAME).'_runtime.php':'~runtime.php'; -defined('RUNTIME_FILE') or define('RUNTIME_FILE',RUNTIME_PATH.$runtime); -if(!APP_DEBUG && is_file(RUNTIME_FILE)) { - // 部署模式直接载入运行缓存 - require RUNTIME_FILE; +if(defined('ENGINE_NAME')) { + require THINK_PATH.'Extend/'.strtolower(ENGINE_NAME).'.php'; }else{ - // 系统目录定义 - defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/'); - // 加载运行时文件 - require THINK_PATH.'Common/runtime.php'; + $runtime = defined('MODE_NAME')?'~'.strtolower(MODE_NAME).'_runtime.php':'~runtime.php'; + defined('RUNTIME_FILE') or define('RUNTIME_FILE',RUNTIME_PATH.$runtime); + if(!APP_DEBUG && is_file(RUNTIME_FILE)) { + // 部署模式直接载入运行缓存 + require RUNTIME_FILE; + }else{ + // 加载运行时文件 + require THINK_PATH.'Common/runtime.php'; + } } \ No newline at end of file From 1715d2d8f7cb087564b5fca87ce9b9dff81f2ea0 Mon Sep 17 00:00:00 2001 From: luofei614 Date: Wed, 9 Jan 2013 10:41:18 +0800 Subject: [PATCH 05/33] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0ENGIN=5FPATH?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/ThinkPHP.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/ThinkPHP.php b/ThinkPHP/ThinkPHP.php index 2563de65e..940b48dd9 100644 --- a/ThinkPHP/ThinkPHP.php +++ b/ThinkPHP/ThinkPHP.php @@ -21,7 +21,8 @@ defined('RUNTIME_PATH') or define('RUNTIME_PATH',APP_PATH.'Runtime/'); defined('APP_DEBUG') or define('APP_DEBUG',false); // 是否调试模式 if(defined('ENGINE_NAME')) { - require THINK_PATH.'Extend/'.strtolower(ENGINE_NAME).'.php'; + defined('ENGINE_PATH') or define('ENGINE_PATH',THINK_PATH.'Extend/Engine/'); + require ENGINE_PATH.strtolower(ENGINE_NAME).'.php'; }else{ $runtime = defined('MODE_NAME')?'~'.strtolower(MODE_NAME).'_runtime.php':'~runtime.php'; defined('RUNTIME_FILE') or define('RUNTIME_FILE',RUNTIME_PATH.$runtime); @@ -32,4 +33,4 @@ // 加载运行时文件 require THINK_PATH.'Common/runtime.php'; } -} \ No newline at end of file +} From 3ff790e29baa3e6a266032029e1909db39a8d45c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 17 Jan 2013 21:38:51 +0800 Subject: [PATCH 06/33] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81sql=E5=87=BD=E6=95=B0=EF=BC=8C=E4=BE=8B?= =?UTF-8?q?=E5=A6=82=EF=BC=9A=20$map['YEAR(schedu=5Ftime)']=20=3D=20$year;?= =?UTF-8?q?=20$map['MONTH(schedu=5Ftime)']=20=3D=20$month;=20$Model->where?= =?UTF-8?q?($map)->select();?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Model.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Lib/Core/Model.class.php b/ThinkPHP/Lib/Core/Model.class.php index 177707da4..0b0db02eb 100644 --- a/ThinkPHP/Lib/Core/Model.class.php +++ b/ThinkPHP/Lib/Core/Model.class.php @@ -521,7 +521,7 @@ public function buildSql($options=array()) { /** * 分析表达式 - * @access proteced + * @access protected * @param array $options 表达式参数 * @return array */ @@ -554,7 +554,7 @@ protected function _parseOptions($options=array()) { if(is_scalar($val)) { $this->_parseType($options['where'],$key); } - }elseif('_' != substr($key,0,1) && false === strpos($key,'.') && false === strpos($key,'|') && false === strpos($key,'&')){ + }elseif('_' != substr($key,0,1) && false === strpos($key,'.') && false === strpos($key,'(') && false === strpos($key,'|') && false === strpos($key,'&')){ unset($options['where'][$key]); } } From 6ad62d9474177b9e9ff2dc3e48bc7c27dbd164c4 Mon Sep 17 00:00:00 2001 From: Aoiujz Date: Thu, 24 Jan 2013 21:25:45 +0800 Subject: [PATCH 07/33] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=20xml=5Fencode=20=E5=92=8C=20data=5Fto=5Fxml=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E4=B8=8D=E4=BB=85=E5=8F=AF=E4=BB=A5=E7=94=A8?= =?UTF-8?q?=E4=BA=8EajaxReturn=E8=BF=98=E5=8F=AF=E4=BB=A5=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E5=85=B6=E4=BB=96xml=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 8fc982de6..6c15a13e3 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -483,31 +483,47 @@ function to_guid_string($mix) { /** * XML编码 * @param mixed $data 数据 - * @param string $encoding 数据编码 * @param string $root 根节点名 + * @param string $item 数字索引的子节点名 + * @param string $attr 根节点属性 + * @param string $id 数字索引子节点key转换的属性名 + * @param string $encoding 数据编码 * @return string */ -function xml_encode($data, $encoding='utf-8', $root='think') { - $xml = ''; - $xml .= '<' . $root . '>'; - $xml .= data_to_xml($data); - $xml .= ''; +function xml_encode($data, $root='think', $item='item', $attr='', $id='id', $encoding='utf-8') { + if(is_array($attr)){ + $_attr = array(); + foreach ($attr as $key => $value) { + $_attr[] = "{$key}={$value}"; + } + $attr = implode(' ', $_attr); + } + $attr = trim($attr); + $attr = empty($attr) ? " {$attr}" : ''; + $xml = ""; + $xml .= "<{$root}{$attr}>"; + $xml .= data_to_xml($data, $item, $id); + $xml .= ""; return $xml; } /** * 数据XML编码 - * @param mixed $data 数据 + * @param mixed $data 数据 + * @param string $item 数字索引时的节点名称 + * @param string $id 数字索引key转换为的属性名 * @return string */ -function data_to_xml($data) { - $xml = ''; +function data_to_xml($data, $item='item', $id='id') { + $xml = $attr = ''; foreach ($data as $key => $val) { - is_numeric($key) && $key = "item id=\"$key\""; - $xml .= "<$key>"; - $xml .= ( is_array($val) || is_object($val)) ? data_to_xml($val) : $val; - list($key, ) = explode(' ', $key); - $xml .= ""; + if(is_numeric($key)){ + $id && $attr = " {$id}=\"{$key}\""; + $key = $item; + } + $xml .= "<{$key}{$attr}>"; + $xml .= (is_array($val) || is_object($val)) ? data_to_xml($val, $item, $id) : $val; + $xml .= ""; } return $xml; } From dcf464f176bf68f2129b3695cd63aa4c2bae98d2 Mon Sep 17 00:00:00 2001 From: Aoiujz Date: Fri, 25 Jan 2013 11:22:15 +0800 Subject: [PATCH 08/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9xml=5Fencode=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=80=E5=A4=84=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 6c15a13e3..bcf045718 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -494,12 +494,12 @@ function xml_encode($data, $root='think', $item='item', $attr='', $id='id', $enc if(is_array($attr)){ $_attr = array(); foreach ($attr as $key => $value) { - $_attr[] = "{$key}={$value}"; + $_attr[] = "{$key}=\"{$value}\""; } $attr = implode(' ', $_attr); } $attr = trim($attr); - $attr = empty($attr) ? " {$attr}" : ''; + $attr = empty($attr) ? '' : " {$attr}"; $xml = ""; $xml .= "<{$root}{$attr}>"; $xml .= data_to_xml($data, $item, $id); From 7de01c89c869328224a945fcb2646d58c1706a52 Mon Sep 17 00:00:00 2001 From: luofei614 Date: Wed, 13 Feb 2013 11:13:49 +0800 Subject: [PATCH 09/33] =?UTF-8?q?trace=E4=BF=A1=E6=81=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=90=9E=E5=90=90=E7=8E=87=E6=98=BE=E7=A4=BA=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=83=BD=E6=9B=B4=E7=9B=B4=E8=A7=82=E7=9C=8B=E8=A7=81?= =?UTF-8?q?=E5=AF=B9=E7=A8=8B=E5=BA=8F=E7=9A=84=E4=BC=98=E5=8C=96=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Behavior/ShowPageTraceBehavior.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Lib/Behavior/ShowPageTraceBehavior.class.php b/ThinkPHP/Lib/Behavior/ShowPageTraceBehavior.class.php index dc0f8380f..760d5b9a9 100644 --- a/ThinkPHP/Lib/Behavior/ShowPageTraceBehavior.class.php +++ b/ThinkPHP/Lib/Behavior/ShowPageTraceBehavior.class.php @@ -47,6 +47,7 @@ private function showTrace() { $base = array( '请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.__SELF__, '运行时间' => $this->showTime(), + '吞吐率' => number_format(1/G('beginTime','viewEndTime'),2).'req/s', '内存开销' => MEMORY_LIMIT_ON?number_format((memory_get_usage() - $GLOBALS['_startUseMems'])/1024,2).' kb':'不支持', '查询信息' => N('db_query').' queries '.N('db_write').' writes ', '文件加载' => count(get_included_files()), @@ -124,4 +125,4 @@ private function showTime() { // 显示详细运行时间 return G('beginTime','viewEndTime').'s ( Load:'.G('beginTime','loadTime').'s Init:'.G('loadTime','initTime').'s Exec:'.G('initTime','viewStartTime').'s Template:'.G('viewStartTime','viewEndTime').'s )'; } -} \ No newline at end of file +} From 91059fa548d2701f7ca64e637ef54dae690932af Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 26 Feb 2013 12:07:50 +0800 Subject: [PATCH 10/33] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=5FparseOptions=E6=96=B9=E6=B3=95=E5=AF=B9join=E7=9A=84?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Model.class.php | 33 +++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Lib/Core/Model.class.php b/ThinkPHP/Lib/Core/Model.class.php index 0b0db02eb..9cfccdaf8 100644 --- a/ThinkPHP/Lib/Core/Model.class.php +++ b/ThinkPHP/Lib/Core/Model.class.php @@ -546,7 +546,7 @@ protected function _parseOptions($options=array()) { $options['model'] = $this->name; // 字段类型验证 - if(isset($options['where']) && is_array($options['where']) && !empty($fields)) { + if(isset($options['where']) && is_array($options['where']) && !empty($fields) && !isset($options['join'])) { // 对数组查询条件进行字段类型检查 foreach ($options['where'] as $key=>$val){ $key = trim($key); @@ -610,11 +610,28 @@ public function find($options=array()) { } $this->data = $resultSet[0]; $this->_after_find($this->data,$options); - return $this->data; + return $this->returnResult($this->data); } // 查询成功的回调方法 protected function _after_find(&$result,$options) {} + protected function returnResult($data,$type=''){ + $type = $type?$type:$this->options['result']; + if ($type){ + if(is_array($type)){ + $handler = $type[1]; + return $handler($data); + } + switch (strtolower($type)){ + case 'json': + return json_encode($data); + case 'xml': + return xml_encode($data); + } + } + return $data; + } + /** * 处理字段映射 * @access public @@ -1497,6 +1514,18 @@ public function page($page,$listRows=null){ return $this; } + /** + * 指定返回结果类型 + * @access public + * @param string $result 类型 + * @param string $handler 类型处理方法 + * @return Model + */ + public function result($result,$handler=null){ + $this->options['result'] = is_null($handler)?$result:array($result,$handler); + return $this; + } + /** * 查询注释 * @access public From b60e330f6a041b1eb3e7dfba59d3356d08efb472 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 26 Feb 2013 12:08:59 +0800 Subject: [PATCH 11/33] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=AF=B9=5F=5FINFO=5F?= =?UTF-8?q?=5F=20=E5=B8=B8=E9=87=8F=E7=9A=84=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Dispatcher.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ThinkPHP/Lib/Core/Dispatcher.class.php b/ThinkPHP/Lib/Core/Dispatcher.class.php index ea37af130..b5c0f84e4 100644 --- a/ThinkPHP/Lib/Core/Dispatcher.class.php +++ b/ThinkPHP/Lib/Core/Dispatcher.class.php @@ -121,6 +121,8 @@ static public function dispatch() { $_GET = array_merge($var,$_GET); } define('__INFO__',$_SERVER['PATH_INFO']); + }else{ + define('__INFO__',''); } // URL常量 From 4063a9ab14719a74d9f5a6112cfd4ab0d17dd717 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 26 Feb 2013 12:12:04 +0800 Subject: [PATCH 12/33] =?UTF-8?q?W=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0path?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81=E5=AE=9A=E4=B9=89?= =?UTF-8?q?Widget=E7=B1=BB=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index bcf045718..3cefe66d7 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -295,10 +295,12 @@ function U($url='',$vars='',$suffix=true,$redirect=false,$domain=false) { * @param string $name Widget名称 * @param array $data 传人的参数 * @param boolean $return 是否返回内容 + * @param string $path Widget所在路径 * @return void */ -function W($name, $data=array(), $return=false) { +function W($name, $data=array(), $return=false,$path='') { $class = $name . 'Widget'; + $path = empty($path) ? BASE_LIB_PATH : $path; require_cache(BASE_LIB_PATH . 'Widget/' . $class . '.class.php'); if (!class_exists($class)) throw_exception(L('_CLASS_NOT_EXIST_') . ':' . $class); From c359d4a3b5694947cef069ed873663c3a75d907d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 1 Mar 2013 16:13:19 +0800 Subject: [PATCH 13/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3CacheFile=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E7=9A=84clear=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=AD=A3m?= =?UTF-8?q?ysql=E9=A9=B1=E5=8A=A8=E7=9A=84=E5=AD=98=E5=82=A8=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E6=9F=A5=E8=AF=A2=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Driver/Cache/CacheFile.class.php | 13 ++++++++----- ThinkPHP/Lib/Driver/Db/DbMysql.class.php | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php b/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php index 3150e7270..86fc91007 100644 --- a/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php +++ b/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php @@ -174,14 +174,17 @@ public function rm($name) { */ public function clear() { $path = $this->options['temp']; - if ( $dir = opendir( $path ) ) { - while ( $file = readdir( $dir ) ) { - $check = is_dir( $file ); - if ( !$check ) + $files = scandir($path); + if($files){ + foreach($files as $file){ + if ($file != '.' && $file != '..' && is_dir($path.$file) ){ + array_map( 'unlink', glob( $path.$file.'/*.*' ) ); + }elseif(is_file($path.$file)){ unlink( $path . $file ); + } } - closedir( $dir ); return true; } + return false; } } \ No newline at end of file diff --git a/ThinkPHP/Lib/Driver/Db/DbMysql.class.php b/ThinkPHP/Lib/Driver/Db/DbMysql.class.php index 3a4f860d6..b047ac4f6 100644 --- a/ThinkPHP/Lib/Driver/Db/DbMysql.class.php +++ b/ThinkPHP/Lib/Driver/Db/DbMysql.class.php @@ -90,6 +90,7 @@ public function free() { public function query($str) { if(0===stripos($str, 'call')){ // 存储过程查询支持 $this->close(); + $this->connected = false; } $this->initConnect(false); if ( !$this->_linkID ) return false; @@ -217,7 +218,7 @@ public function getFields($tableName) { $info[$val['Field']] = array( 'name' => $val['Field'], 'type' => $val['Type'], - 'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes + 'notnull' => (bool) (strtoupper($val['Null']) === 'NO'), // not null is empty, null is yes 'default' => $val['Default'], 'primary' => (strtolower($val['Key']) == 'pri'), 'autoinc' => (strtolower($val['Extra']) == 'auto_increment'), From 1670588a10e6c231d60f1f1fc0afd68fe9c715b2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 1 Mar 2013 21:53:40 +0800 Subject: [PATCH 14/33] =?UTF-8?q?=E6=94=B9=E8=BF=9Baction=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=BB=91=E5=AE=9A=E7=9A=84=E6=94=AF=E6=8C=81=20?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=90=8C=E6=97=B6=E6=94=AF=E6=8C=81get?= =?UTF-8?q?=E5=92=8Cpost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/App.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThinkPHP/Lib/Core/App.class.php b/ThinkPHP/Lib/Core/App.class.php index 88934b7cb..32bde31ab 100644 --- a/ThinkPHP/Lib/Core/App.class.php +++ b/ThinkPHP/Lib/Core/App.class.php @@ -147,7 +147,7 @@ static public function exec() { if(C('URL_PARAMS_BIND') && $method->getNumberOfParameters()>0){ switch($_SERVER['REQUEST_METHOD']) { case 'POST': - $vars = $_POST; + $vars = array_merge($_GET,$_POST); break; case 'PUT': parse_str(file_get_contents('php://input'), $vars); From 8ec349b47a36d448c3b6e07bbd2deff90961002d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 1 Mar 2013 22:39:14 +0800 Subject: [PATCH 15/33] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=B1=BB=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Driver/Cache/CacheFile.class.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php b/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php index 86fc91007..8f5c30132 100644 --- a/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php +++ b/ThinkPHP/Lib/Driver/Cache/CacheFile.class.php @@ -41,15 +41,9 @@ public function __construct($options=array()) { * @return boolen */ private function init() { - $stat = stat($this->options['temp']); - $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. - $file_perms = $dir_perms & 0000666; // Remove execute bits for files. - // 创建项目缓存目录 if (!is_dir($this->options['temp'])) { - if (! mkdir($this->options['temp'])) - return false; - chmod($this->options['temp'], $dir_perms); + mkdir($this->options['temp']); } } From 52e8d1ecf12294e339ea099d25bfd006b25c0300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Tue, 5 Mar 2013 13:50:35 +0800 Subject: [PATCH 16/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9RUNTIME=5FPATH=E7=9A=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=BC=BA=E5=88=B6=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E8=A7=A3=E5=86=B3exit=E9=80=80=E5=87=BA=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=86=99=E6=97=A5=E5=BF=97=E7=9A=84BUG=E3=80=82=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E8=87=AA=E5=AE=9A=E4=B9=89ThinkPHP=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=B8=B8=E9=87=8F=E6=97=B6=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BB=9D=E5=BA=A6=E8=B7=AF=E5=BE=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/ThinkPHP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThinkPHP/ThinkPHP.php b/ThinkPHP/ThinkPHP.php index 940b48dd9..050992285 100644 --- a/ThinkPHP/ThinkPHP.php +++ b/ThinkPHP/ThinkPHP.php @@ -18,7 +18,7 @@ // 系统目录定义 defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/'); defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); -defined('RUNTIME_PATH') or define('RUNTIME_PATH',APP_PATH.'Runtime/'); +defined('RUNTIME_PATH') or define('RUNTIME_PATH',realpath(APP_PATH).'/Runtime/'); defined('APP_DEBUG') or define('APP_DEBUG',false); // 是否调试模式 if(defined('ENGINE_NAME')) { defined('ENGINE_PATH') or define('ENGINE_PATH',THINK_PATH.'Extend/Engine/'); From 9e4e8eac0387542532aa1e47e36cd5bdc18c3d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Mon, 11 Mar 2013 16:18:49 +0800 Subject: [PATCH 17/33] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E8=BE=93=E5=87=BA=EF=BC=8C=E6=9B=B4=E5=8F=8B=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=B3=BB=E7=BB=9F=E5=BC=82=E5=B8=B8=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Think.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Lib/Core/Think.class.php b/ThinkPHP/Lib/Core/Think.class.php index 4ced81495..c2035e6f8 100644 --- a/ThinkPHP/Lib/Core/Think.class.php +++ b/ThinkPHP/Lib/Core/Think.class.php @@ -245,7 +245,23 @@ static public function instance($class,$method='') { * @param mixed $e 异常对象 */ static public function appException($e) { - halt($e->__toString()); + $error = array(); + $trace = $e->getTrace(); + $error['message'] = $e->getMessage(); + $error['file'] = $e->getFile(); + $error['class'] = isset($trace[0]['class'])?$trace[0]['class']:''; + $error['function'] = isset($trace[0]['function'])?$trace[0]['function']:''; + $error['line'] = $e->getLine(); + $error['trace'] = ''; + $time = date('y-m-d H:i:m'); + foreach ($trace as $t) { + $error['trace'] .= '[' . $time . '] ' . $t['file'] . ' (' . $t['line'] . ') '; + $error['trace'] .= $t['class'] . $t['type'] . $t['function'] . '('; + $error['trace'] .= implode(', ', $t['args']); + $error['trace'] .=')
'; + } + + halt($error); } /** From a6419ce0a2363d57a5ef97c949da5f70ad371383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Mon, 11 Mar 2013 22:36:25 +0800 Subject: [PATCH 18/33] =?UTF-8?q?=E6=9B=B4=E6=94=B9README=E4=B8=BA=20markd?= =?UTF-8?q?own=20=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ README.txt | 36 ------------------------------------ 2 files changed, 38 insertions(+), 36 deletions(-) create mode 100644 README.md delete mode 100644 README.txt diff --git a/README.md b/README.md new file mode 100644 index 000000000..97390798f --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +## 简介 + +ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。 + +## 全面的WEB开发特性支持 + +最新的ThinkPHP为WEB应用开发提供了强有力的支持,这些支持包括: + +* MVC支持-基于模型(M)、视图(V)、控制器(C)的设计模式 +* ORM支持-提供了全功能和高性能的ORM支持,支持大部分数据库 +* 模板引擎支持-内置了高性能的基于标签库和XML标签的编译型模板引擎 +* RESTFul支持-REST模式提供了RESTFul支持,为你打造全新的URL设计和访问体验 +* SAE支持-提供了新浪SAE平台的强力支持,具备“横跨性”和“平滑性”,支持本地化开发和调试以及部署切换,打造全新的SAE开发体验 +* CLI支持-支持基于命令行的应用开发 +* AMF支持-支持Flex开发和Flash通讯,打造互联网富应用 +* PHPRPC支持-提供基于PHPRpc的WEBService解决方案 +* MongoDb支持-提供NoSQL的支持 +* 缓存支持-提供了包括文件、数据库、Memcache、Xcache、Redis等多种类型的缓存支持 + +## 大道至简的开发理念 + +ThinkPHP从诞生以来一直秉承大道至简的开发理念,无论从底层实现还是应用开发,我们都倡导用最少的代码完成相同的功能,正是由于对简单的执着和代码的修炼,让我们长期保持出色的性能和极速的开发体验。在主流PHP开发框架的评测数据中表现卓越,简单和快速开发是我们不变的宗旨。 + +## 安全性 + +框架在系统层面提供了众多的安全特性,确保你的网站和产品安全无忧。这些特性包括: + +* XSS安全防护 +* 表单自动验证 +* 强制数据类型转换 +* 输入数据过滤 +* 表单令牌验证 +* 防SQL注入 +* 图像上传检测 + +## 商业友好的开源协议 + +ThinkPHP遵循Apache2开源协议发布。Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,同样允许代码修改,再作为开源或商业软件发布。 \ No newline at end of file diff --git a/README.txt b/README.txt deleted file mode 100644 index 200b27d71..000000000 --- a/README.txt +++ /dev/null @@ -1,36 +0,0 @@ -ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。 - -[ 全面的WEB开发特性支持 ] - -最新的ThinkPHP为WEB应用开发提供了强有力的支持,这些支持包括: - MVC支持-基于模型(M)、视图(V)、控制器(C)的设计模式 - ORM支持-提供了全功能和高性能的ORM支持,支持大部分数据库 - 模板引擎支持-内置了高性能的基于标签库和XML标签的编译型模板引擎 - RESTFul支持-REST模式提供了RESTFul支持,为你打造全新的URL设计和访问体验 - SAE支持-提供了新浪SAE平台的强力支持,具备“横跨性”和“平滑性”,支持本地化开发和调试以及部署切换,打造全新的SAE开发体验 - CLI支持-支持基于命令行的应用开发 - AMF支持-支持Flex开发和Flash通讯,打造互联网富应用 - PHPRPC支持-提供基于PHPRpc的WEBService解决方案 - MongoDb支持-提供NoSQL的支持 - 缓存支持-提供了包括文件、数据库、Memcache、Xcache、Redis等多种类型的缓存支持 - -[ 大道至简的开发理念 ] - -ThinkPHP从诞生以来一直秉承大道至简的开发理念,无论从底层实现还是应用开发,我们都倡导用最少的代码完成相同的功能,正是由于对简单的执着和代码的修炼,让我们长期保持出色的性能和极速的开发体验。在主流PHP开发框架的评测数据中表现卓越,简单和快速开发是我们不变的宗旨。 - - -[ 安全性 ] - -框架在系统层面提供了众多的安全特性,确保你的网站和产品安全无忧。这些特性包括: - - XSS安全防护 - 表单自动验证 - 强制数据类型转换 - 输入数据过滤 - 表单令牌验证 - 防SQL注入 - 图像上传检测 - -[ 商业友好的开源协议 ] - -ThinkPHP遵循Apache2开源协议发布。Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,同样允许代码修改,再作为开源或商业软件发布。 \ No newline at end of file From 7ffc6fd7ba25bb0f6fef4d5ad49fc864a86135ae Mon Sep 17 00:00:00 2001 From: EagleWu Date: Wed, 13 Mar 2013 15:42:23 +0800 Subject: [PATCH 19/33] Update functions.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复“查询缓存”无法设置过期时间问题 --- ThinkPHP/Common/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 3cefe66d7..9bc95abf1 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -380,19 +380,21 @@ function S($name,$value='',$options=null) { // 缓存操作的同时初始化 $type = isset($options['type'])?$options['type']:''; $cache = Cache::getInstance($type,$options); + $expire = is_numeric($options['expire'])?$options['expire']:NULL; //修复查询缓存无法设置过期时间 }elseif(is_array($name)) { // 缓存初始化 $type = isset($name['type'])?$name['type']:''; $cache = Cache::getInstance($type,$name); return $cache; }elseif(empty($cache)) { // 自动初始化 $cache = Cache::getInstance(); + $expire = is_numeric($options)?$options:NULL; //默认快捷缓存设置过期时间 } if(''=== $value){ // 获取缓存 return $cache->get($name); }elseif(is_null($value)) { // 删除缓存 return $cache->rm($name); }else { // 缓存数据 - $expire = is_numeric($options)?$options:NULL; + //$expire = is_numeric($options)?$options:NULL; //原始语句 return $cache->set($name, $value, $expire); } } @@ -768,4 +770,4 @@ function filter_exp(&$value){ if (in_array(strtolower($value),array('exp','or'))){ $value .= ' '; } -} \ No newline at end of file +} From e75e29d08127689d41327ec92bdfdf0f73d4666b Mon Sep 17 00:00:00 2001 From: Eslizn Date: Thu, 14 Mar 2013 14:45:52 +0800 Subject: [PATCH 20/33] Update App.class.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 建议ob头在最前输出,因为load_ext_file()所加载的方法中可能会导致ob输出异常 --- ThinkPHP/Lib/Core/App.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ThinkPHP/Lib/Core/App.class.php b/ThinkPHP/Lib/Core/App.class.php index 32bde31ab..5ab97e9de 100644 --- a/ThinkPHP/Lib/Core/App.class.php +++ b/ThinkPHP/Lib/Core/App.class.php @@ -25,6 +25,11 @@ class App { * @return void */ static public function init() { + // 页面压缩输出支持 + if(C('OUTPUT_ENCODE')){ + $zlib = ini_get('zlib.output_compression'); + if(empty($zlib)) ob_start('ob_gzhandler'); + } // 设置系统时区 date_default_timezone_set(C('DEFAULT_TIMEZONE')); // 加载动态项目公共文件和配置 @@ -43,11 +48,6 @@ static public function init() { // URL调度结束标签 tag('url_dispatch'); - // 页面压缩输出支持 - if(C('OUTPUT_ENCODE')){ - $zlib = ini_get('zlib.output_compression'); - if(empty($zlib)) ob_start('ob_gzhandler'); - } // 系统变量安全过滤 if(C('VAR_FILTERS')) { $filters = explode(',',C('VAR_FILTERS')); @@ -215,4 +215,4 @@ static public function run() { static public function logo(){ return 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjVERDVENkZGQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjVERDVENzAwQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9Inh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ncHIAAAAASUVORK5CYII='; } -} \ No newline at end of file +} From 4b1eae8c063518709d48c4aff1d771322610af74 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 17 Mar 2013 20:06:09 +0800 Subject: [PATCH 21/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3W=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 3cefe66d7..a1b625df4 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -301,7 +301,7 @@ function U($url='',$vars='',$suffix=true,$redirect=false,$domain=false) { function W($name, $data=array(), $return=false,$path='') { $class = $name . 'Widget'; $path = empty($path) ? BASE_LIB_PATH : $path; - require_cache(BASE_LIB_PATH . 'Widget/' . $class . '.class.php'); + require_cache($path . 'Widget/' . $class . '.class.php'); if (!class_exists($class)) throw_exception(L('_CLASS_NOT_EXIST_') . ':' . $class); $widget = Think::instance($class); From ea61b13ffe60e2a23e76a7a12973875e684ba718 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 19 Mar 2013 09:55:59 +0800 Subject: [PATCH 22/33] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E7=9A=84error=E6=96=B9=E6=B3=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E9=94=99=E8=AF=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Driver/Db/DbMysql.class.php | 2 +- ThinkPHP/Lib/Driver/Db/DbMysqli.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Lib/Driver/Db/DbMysql.class.php b/ThinkPHP/Lib/Driver/Db/DbMysql.class.php index b047ac4f6..4d3a7835f 100644 --- a/ThinkPHP/Lib/Driver/Db/DbMysql.class.php +++ b/ThinkPHP/Lib/Driver/Db/DbMysql.class.php @@ -312,7 +312,7 @@ public function close() { * @return string */ public function error() { - $this->error = mysql_error($this->_linkID); + $this->error = mysql_errno().':'.mysql_error($this->_linkID); if('' != $this->queryStr){ $this->error .= "\n [ SQL语句 ] : ".$this->queryStr; } diff --git a/ThinkPHP/Lib/Driver/Db/DbMysqli.class.php b/ThinkPHP/Lib/Driver/Db/DbMysqli.class.php index 5c738d9a0..a79606313 100644 --- a/ThinkPHP/Lib/Driver/Db/DbMysqli.class.php +++ b/ThinkPHP/Lib/Driver/Db/DbMysqli.class.php @@ -306,7 +306,7 @@ public function close() { * @return string */ public function error() { - $this->error = $this->_linkID->error; + $this->error = $this->_linkID->errno.':'.$this->_linkID->error; if('' != $this->queryStr){ $this->error .= "\n [ SQL语句 ] : ".$this->queryStr; } From 8ed0e3db135cc31f4725990bf120f5bafb4fe68d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 22 Mar 2013 11:01:14 +0800 Subject: [PATCH 23/33] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index bd90150f4..fd500c4a1 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -394,7 +394,6 @@ function S($name,$value='',$options=null) { }elseif(is_null($value)) { // 删除缓存 return $cache->rm($name); }else { // 缓存数据 - //$expire = is_numeric($options)?$options:NULL; //原始语句 return $cache->set($name, $value, $expire); } } From d271ad88e55cbae044f77a5de8adb8e2b883a67b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 25 Mar 2013 17:52:05 +0800 Subject: [PATCH 24/33] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84result=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=94=B9=E8=BF=9B=20=E6=94=AF=E6=8C=81callback?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BE=8B=E5=A6=82=EF=BC=9A=20$model?= =?UTF-8?q?->result(array('myclas','test'))->find();?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Model.class.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/ThinkPHP/Lib/Core/Model.class.php b/ThinkPHP/Lib/Core/Model.class.php index 9cfccdaf8..f1364e76a 100644 --- a/ThinkPHP/Lib/Core/Model.class.php +++ b/ThinkPHP/Lib/Core/Model.class.php @@ -60,7 +60,7 @@ class Model { // 是否批处理验证 protected $patchValidate = false; // 链操作方法列表 - protected $methods = array('table','order','alias','having','group','lock','distinct','auto','filter','validate'); + protected $methods = array('table','order','alias','having','group','lock','distinct','auto','filter','validate','result'); /** * 架构函数 @@ -610,17 +610,18 @@ public function find($options=array()) { } $this->data = $resultSet[0]; $this->_after_find($this->data,$options); - return $this->returnResult($this->data); + if(!empty($this->options['result'])) { + return $this->returnResult($this->data,$this->options['result']); + } + return $this->data; } // 查询成功的回调方法 protected function _after_find(&$result,$options) {} protected function returnResult($data,$type=''){ - $type = $type?$type:$this->options['result']; if ($type){ - if(is_array($type)){ - $handler = $type[1]; - return $handler($data); + if(is_callable($type)){ + return call_user_func($type,$data); } switch (strtolower($type)){ case 'json': @@ -1514,18 +1515,6 @@ public function page($page,$listRows=null){ return $this; } - /** - * 指定返回结果类型 - * @access public - * @param string $result 类型 - * @param string $handler 类型处理方法 - * @return Model - */ - public function result($result,$handler=null){ - $this->options['result'] = is_null($handler)?$result:array($result,$handler); - return $this; - } - /** * 查询注释 * @access public From 8466ca9ea17cf9941ff2c31341479e8424449320 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Mar 2013 09:47:35 +0800 Subject: [PATCH 25/33] =?UTF-8?q?=E5=A2=9E=E5=8A=A0I=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=AE=89=E5=85=A8=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8F=98=E9=87=8F=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=92=8C=E9=BB=98=E8=AE=A4=E5=80=BC=E3=80=82?= =?UTF-8?q?=20=E7=94=A8=E4=BA=8E=E6=9B=BF=E4=BB=A3Action=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E9=87=8C=E9=9D=A2=E7=9A=84=5Fget=20=5Fpost=E7=AD=89=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E4=BE=BF=E4=BA=8E=E5=85=A8=E5=B1=80=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/common.php | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/ThinkPHP/Common/common.php b/ThinkPHP/Common/common.php index 63a53cfcd..89aecf85d 100644 --- a/ThinkPHP/Common/common.php +++ b/ThinkPHP/Common/common.php @@ -16,6 +16,79 @@ * @author liu21st */ +/** + * 获取输入参数 支持过滤和默认值 + * 使用方法: + * + * I('id',0); 获取id参数 自动判断get或者post + * I('post.name','','htmlspecialchars'); 获取$_POST['name'] + * I('get.'); 获取$_GET + * + * @param string $name 变量的名称 支持指定类型 + * @param mixed $default 不存在的时候默认值 + * @param mixed $filter 参数过滤方法 + * @return mixed + */ +function I($name,$default='',$filter='') { + if(strpos($name,'.')) { // 指定参数来源 + list($method,$name) = explode('.',$name); + }else{ // 默认为自动判断 + $method = 'param'; + } + switch(strtolower($method)) { + case 'get' : $input =& $_GET;break; + case 'post' : $input =& $_POST;break; + case 'put' : parse_str(file_get_contents('php://input'), $input);break; + case 'param' : + switch($_SERVER['REQUEST_METHOD']) { + case 'POST': + $input = $_POST; + break; + case 'PUT': + parse_str(file_get_contents('php://input'), $input); + break; + default: + $input = $_GET; + } + if(C('VAR_URL_PARAMS')){ + $params = $_GET[C('VAR_URL_PARAMS')]; + $input = array_merge($input,$params); + } + break; + case 'request' : $input =& $_REQUEST; break; + case 'session' : $input =& $_SESSION; break; + case 'cookie' : $input =& $_COOKIE; break; + case 'server' : $input =& $_SERVER; break; + case 'globals' : $input =& $GLOBALS; break; + default: + return NULL; + } + if(C('VAR_FILTERS')) { + $filters = explode(',',C('VAR_FILTERS')); + foreach($filters as $filter){ + // 全局参数过滤 + array_walk_recursive($input,$filter); + } + } + if(empty($name)) { // 获取全部变量 + $data = $input; + }elseif(isset($input[$name])) { // 取值操作 + $data = $input[$name]; + $filters = isset($filter)?$filter:C('DEFAULT_FILTER'); + if($filters) { + $filters = explode(',',$filters); + foreach($filters as $filter){ + if(function_exists($filter)) { + $data = is_array($data)?array_map($filter,$data):$filter($data); // 参数过滤 + } + } + } + }else{ // 变量默认值 + $data = isset($default)?$default:NULL; + } + return $data; +} + /** * 记录和统计时间(微秒)和内存使用情况 * 使用方法: From 1232272267c22939184a557b9971570d1b667f09 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Mar 2013 09:49:57 +0800 Subject: [PATCH 26/33] =?UTF-8?q?=E6=94=B9=E8=BF=9BI=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ThinkPHP/Common/common.php b/ThinkPHP/Common/common.php index 89aecf85d..b25432d2a 100644 --- a/ThinkPHP/Common/common.php +++ b/ThinkPHP/Common/common.php @@ -64,10 +64,10 @@ function I($name,$default='',$filter='') { return NULL; } if(C('VAR_FILTERS')) { - $filters = explode(',',C('VAR_FILTERS')); - foreach($filters as $filter){ + $_filters = explode(',',C('VAR_FILTERS')); + foreach($_filters as $_filter){ // 全局参数过滤 - array_walk_recursive($input,$filter); + array_walk_recursive($input,$_filter); } } if(empty($name)) { // 获取全部变量 From c6b5c59c9b7334b5c23ff2a40d7883f34ab34ff5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Mar 2013 11:45:35 +0800 Subject: [PATCH 27/33] =?UTF-8?q?I=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81PHP?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E7=9A=84=E8=BF=87=E6=BB=A4=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E4=BE=8B=E5=A6=82=EF=BC=9A=20I('get.url','',FILTER=5F?= =?UTF-8?q?VALIDATE=5FURL);=20=E6=94=AF=E6=8C=81=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E8=BF=87=E6=BB=A4=20I('get.url','','url');?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/common.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ThinkPHP/Common/common.php b/ThinkPHP/Common/common.php index b25432d2a..c2312ac61 100644 --- a/ThinkPHP/Common/common.php +++ b/ThinkPHP/Common/common.php @@ -80,6 +80,11 @@ function I($name,$default='',$filter='') { foreach($filters as $filter){ if(function_exists($filter)) { $data = is_array($data)?array_map($filter,$data):$filter($data); // 参数过滤 + }else{ + $data = filter_var($data,is_int($filter)?$filter:filter_id($filter)); + if(false === $data) { + return isset($args[2])?$args[2]:NULL; + } } } } From 0c50ecec2d4aaff88e58af91cbbc72e552445b1c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Mar 2013 21:40:29 +0800 Subject: [PATCH 28/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3I=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E5=A4=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/common.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Common/common.php b/ThinkPHP/Common/common.php index c2312ac61..015852b99 100644 --- a/ThinkPHP/Common/common.php +++ b/ThinkPHP/Common/common.php @@ -63,6 +63,8 @@ function I($name,$default='',$filter='') { default: return NULL; } + // 全局过滤 + // array_walk_recursive($input,'filter_exp'); if(C('VAR_FILTERS')) { $_filters = explode(',',C('VAR_FILTERS')); foreach($_filters as $_filter){ @@ -83,7 +85,7 @@ function I($name,$default='',$filter='') { }else{ $data = filter_var($data,is_int($filter)?$filter:filter_id($filter)); if(false === $data) { - return isset($args[2])?$args[2]:NULL; + return isset($default)?$default:NULL; } } } From 716a82dbc60d975d2c075558741a4d1904519475 Mon Sep 17 00:00:00 2001 From: luofei614 Date: Thu, 28 Mar 2013 11:45:05 +0800 Subject: [PATCH 29/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3notbetween=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Driver/TagLib/TagLibCx.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Lib/Driver/TagLib/TagLibCx.class.php b/ThinkPHP/Lib/Driver/TagLib/TagLibCx.class.php index 2e633dbbb..7f8c2a0b1 100644 --- a/ThinkPHP/Lib/Driver/TagLib/TagLibCx.class.php +++ b/ThinkPHP/Lib/Driver/TagLib/TagLibCx.class.php @@ -360,7 +360,7 @@ public function _range($attr,$content,$type='in') { if($type=='between') { $parseStr = '= $_RANGE_VAR_[0] && '.$name.'<= $_RANGE_VAR_[1]):?>'.$content.''; }elseif($type=='notbetween'){ - $parseStr = '$_RANGE_VAR_[1]):?>'.$content.''; + $parseStr = '$_RANGE_VAR_[1]):?>'.$content.''; }else{ $fun = ($type == 'in')? 'in_array' : '!in_array'; $parseStr = ''.$content.''; @@ -639,4 +639,4 @@ public function _for($attr, $content){ return $parseStr; } - } \ No newline at end of file + } From 7fa02cce09ad4f7f90ae6a948c51ac96447248c6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 1 Apr 2013 16:50:13 +0800 Subject: [PATCH 30/33] =?UTF-8?q?=E6=94=B9=E8=BF=9BThink=E7=B1=BB=E7=9A=84?= =?UTF-8?q?appException=E6=96=B9=E6=B3=95=20=E7=AE=80=E5=8C=96=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Think.class.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/ThinkPHP/Lib/Core/Think.class.php b/ThinkPHP/Lib/Core/Think.class.php index c2035e6f8..eec15ca39 100644 --- a/ThinkPHP/Lib/Core/Think.class.php +++ b/ThinkPHP/Lib/Core/Think.class.php @@ -246,21 +246,11 @@ static public function instance($class,$method='') { */ static public function appException($e) { $error = array(); - $trace = $e->getTrace(); $error['message'] = $e->getMessage(); $error['file'] = $e->getFile(); - $error['class'] = isset($trace[0]['class'])?$trace[0]['class']:''; - $error['function'] = isset($trace[0]['function'])?$trace[0]['function']:''; $error['line'] = $e->getLine(); - $error['trace'] = ''; - $time = date('y-m-d H:i:m'); - foreach ($trace as $t) { - $error['trace'] .= '[' . $time . '] ' . $t['file'] . ' (' . $t['line'] . ') '; - $error['trace'] .= $t['class'] . $t['type'] . $t['function'] . '('; - $error['trace'] .= implode(', ', $t['args']); - $error['trace'] .=')
'; - } - + $error['trace'] = $e->getTraceAsString(); + Log::record($error['message'],Log::ERR); halt($error); } @@ -302,6 +292,7 @@ function_exists('halt')?halt($errorStr):exit('ERROR:'.$errorStr); // 致命错误捕获 static public function fatalError() { + Log::save(); if ($e = error_get_last()) { Think::appError($e['type'],$e['message'],$e['file'],$e['line']); } From fab517b13a5dad666970a04e4b71c863817812a0 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 1 Apr 2013 17:09:26 +0800 Subject: [PATCH 31/33] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E8=87=B4=E5=91=BD?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 16 ++---- ThinkPHP/Lib/Core/Think.class.php | 3 +- ThinkPHP/Lib/Core/ThinkException.class.php | 67 ---------------------- 3 files changed, 6 insertions(+), 80 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index fd500c4a1..9c44debd5 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -29,18 +29,10 @@ function halt($error) { $trace = debug_backtrace(); $e['message'] = $error; $e['file'] = $trace[0]['file']; - $e['class'] = isset($trace[0]['class'])?$trace[0]['class']:''; - $e['function'] = isset($trace[0]['function'])?$trace[0]['function']:''; $e['line'] = $trace[0]['line']; - $traceInfo = ''; - $time = date('y-m-d H:i:m'); - foreach ($trace as $t) { - $traceInfo .= '[' . $time . '] ' . $t['file'] . ' (' . $t['line'] . ') '; - $traceInfo .= $t['class'] . $t['type'] . $t['function'] . '('; - $traceInfo .= implode(', ', $t['args']); - $traceInfo .=')
'; - } - $e['trace'] = $traceInfo; + ob_start(); + debug_print_backtrace(); + $e['trace'] = ob_get_clean(); } else { $e = $error; } @@ -70,7 +62,7 @@ function halt($error) { */ function throw_exception($msg, $type='ThinkException', $code=0) { if (class_exists($type, false)) - throw new $type($msg, $code, true); + throw new $type($msg, $code); else halt($msg); // 异常类型不存在则输出错误信息字串 } diff --git a/ThinkPHP/Lib/Core/Think.class.php b/ThinkPHP/Lib/Core/Think.class.php index eec15ca39..7ff612551 100644 --- a/ThinkPHP/Lib/Core/Think.class.php +++ b/ThinkPHP/Lib/Core/Think.class.php @@ -294,7 +294,8 @@ function_exists('halt')?halt($errorStr):exit('ERROR:'.$errorStr); static public function fatalError() { Log::save(); if ($e = error_get_last()) { - Think::appError($e['type'],$e['message'],$e['file'],$e['line']); + ob_end_clean(); + function_exists('halt')?halt($e):exit('ERROR:'.$e['message']); } } diff --git a/ThinkPHP/Lib/Core/ThinkException.class.php b/ThinkPHP/Lib/Core/ThinkException.class.php index d3a234a9b..64dd38070 100644 --- a/ThinkPHP/Lib/Core/ThinkException.class.php +++ b/ThinkPHP/Lib/Core/ThinkException.class.php @@ -17,71 +17,4 @@ * @author liu21st */ class ThinkException extends Exception { - - /** - * 异常类型 - * @var string - * @access private - */ - private $type; - - // 是否存在多余调试信息 - private $extra; - - /** - * 架构函数 - * @access public - * @param string $message 异常信息 - */ - public function __construct($message,$code=0,$extra=false) { - parent::__construct($message,$code); - $this->type = get_class($this); - $this->extra = $extra; - } - - /** - * 异常输出 所有异常处理类均通过__toString方法输出错误 - * 每次异常都会写入系统日志 - * 该方法可以被子类重载 - * @access public - * @return array - */ - public function __toString() { - $trace = $this->getTrace(); - if($this->extra) - // 通过throw_exception抛出的异常要去掉多余的调试信息 - array_shift($trace); - $this->class = isset($trace[0]['class'])?$trace[0]['class']:''; - $this->function = isset($trace[0]['function'])?$trace[0]['function']:''; - $this->file = $trace[0]['file']; - $this->line = $trace[0]['line']; - $file = file($this->file); - $traceInfo = ''; - $time = date('y-m-d H:i:m'); - foreach($trace as $t) { - $traceInfo .= '['.$time.'] '.$t['file'].' ('.$t['line'].') '; - $traceInfo .= $t['class'].$t['type'].$t['function'].'('; - $traceInfo .= implode(', ', $t['args']); - $traceInfo .=")\n"; - } - $error['message'] = $this->message; - $error['type'] = $this->type; - $error['detail'] = L('_MODULE_').'['.MODULE_NAME.'] '.L('_ACTION_').'['.ACTION_NAME.']'."\n"; - $error['detail'] .= ($this->line-2).': '.$file[$this->line-3]; - $error['detail'] .= ($this->line-1).': '.$file[$this->line-2]; - $error['detail'] .= ''.($this->line).': '.$file[$this->line-1].''; - $error['detail'] .= ($this->line+1).': '.$file[$this->line]; - $error['detail'] .= ($this->line+2).': '.$file[$this->line+1]; - $error['class'] = $this->class; - $error['function'] = $this->function; - $error['file'] = $this->file; - $error['line'] = $this->line; - $error['trace'] = $traceInfo; - - // 记录 Exception 日志 - if(C('LOG_EXCEPTION_RECORD')) { - Log::Write('('.$this->type.') '.$this->message); - } - return $error ; - } } \ No newline at end of file From d6513a09b8b6fe8bbbeaa4b4d4424f50cdaf652c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 2 Apr 2013 09:10:37 +0800 Subject: [PATCH 32/33] =?UTF-8?q?=E6=94=B9=E8=BF=9BS=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=A4=84=E8=AD=A6=E5=91=8A=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Common/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 9c44debd5..ae79f9f13 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -372,20 +372,23 @@ function S($name,$value='',$options=null) { // 缓存操作的同时初始化 $type = isset($options['type'])?$options['type']:''; $cache = Cache::getInstance($type,$options); - $expire = is_numeric($options['expire'])?$options['expire']:NULL; //修复查询缓存无法设置过期时间 }elseif(is_array($name)) { // 缓存初始化 $type = isset($name['type'])?$name['type']:''; $cache = Cache::getInstance($type,$name); return $cache; }elseif(empty($cache)) { // 自动初始化 $cache = Cache::getInstance(); - $expire = is_numeric($options)?$options:NULL; //默认快捷缓存设置过期时间 } if(''=== $value){ // 获取缓存 return $cache->get($name); }elseif(is_null($value)) { // 删除缓存 return $cache->rm($name); }else { // 缓存数据 + if(is_array($options)) { + $expire = isset($options['expire'])?$options['expire']:NULL; + }else{ + $expire = is_numeric($options)?$options:NULL; + } return $cache->set($name, $value, $expire); } } From 3d862bf06557936edf5b7d93e55497bbd6fc1e26 Mon Sep 17 00:00:00 2001 From: luofei614 Date: Tue, 2 Apr 2013 10:48:39 +0800 Subject: [PATCH 33/33] =?UTF-8?q?=E4=BF=AE=E6=AD=A3pathinfo=E7=9A=84?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThinkPHP/Lib/Core/Dispatcher.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ThinkPHP/Lib/Core/Dispatcher.class.php b/ThinkPHP/Lib/Core/Dispatcher.class.php index b5c0f84e4..2525eaeff 100644 --- a/ThinkPHP/Lib/Core/Dispatcher.class.php +++ b/ThinkPHP/Lib/Core/Dispatcher.class.php @@ -26,7 +26,7 @@ class Dispatcher { */ static public function dispatch() { $urlMode = C('URL_MODEL'); - if(!empty($_GET[C('VAR_PATHINFO')])) { // 判断URL里面是否有兼容模式参数 + if(isset($_GET[C('VAR_PATHINFO')])) { // 判断URL里面是否有兼容模式参数 $_SERVER['PATH_INFO'] = $_GET[C('VAR_PATHINFO')]; unset($_GET[C('VAR_PATHINFO')]); } @@ -75,7 +75,7 @@ static public function dispatch() { } } // 分析PATHINFO信息 - if(empty($_SERVER['PATH_INFO'])) { + if(!isset($_SERVER['PATH_INFO'])) { $types = explode(',',C('URL_PATHINFO_FETCH')); foreach ($types as $type){ if(0===strpos($type,':')) {// 支持函数判断 @@ -253,4 +253,4 @@ static private function getGroup($var) { return strip_tags(C('URL_CASE_INSENSITIVE') ?ucfirst(strtolower($group)):$group); } -} \ No newline at end of file +}