数组定义用法统一

This commit is contained in:
thinkphp
2013-04-11 14:49:39 +08:00
parent bbe3ebedcf
commit 00ee80e943
35 changed files with 83 additions and 81 deletions

1
Library/Org/README.md Normal file
View File

@@ -0,0 +1 @@
ThinkPHP 扩展类库目录

View File

@@ -63,7 +63,7 @@ class App {
$action = ACTION_NAME.$config['action_suffix']; $action = ACTION_NAME.$config['action_suffix'];
try{ try{
// 操作方法开始监听 // 操作方法开始监听
$call = array($instance,$action); $call = [$instance,$action];
Tag::listen('action_begin',$call); Tag::listen('action_begin',$call);
if(!preg_match('/^[A-Za-z](\w)*$/',$action)){ if(!preg_match('/^[A-Za-z](\w)*$/',$action)){
// 非法操作 // 非法操作
@@ -109,7 +109,7 @@ class App {
// 操作不存在 // 操作不存在
if(method_exists($instance,'_empty')) { if(method_exists($instance,'_empty')) {
$method = new \ReflectionMethod($instance,'_empty'); $method = new \ReflectionMethod($instance,'_empty');
$method->invokeArgs($instance,array($action,'')); $method->invokeArgs($instance,[$action,'']);
}else{ }else{
E('[ '.(new \ReflectionClass($instance))->getName().':'.$action.' ] not exists ',404); E('[ '.(new \ReflectionClass($instance))->getName().':'.$action.' ] not exists ',404);
} }

View File

@@ -44,7 +44,7 @@ class ContentReplace {
define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME); define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME);
// 系统默认的特殊变量替换 // 系统默认的特殊变量替换
$replace = array( $replace = [
'__ROOT__' => ROOT_URL, // 当前网站地址 '__ROOT__' => ROOT_URL, // 当前网站地址
'__APP__' => MODULE_URL, // 当前项目地址 '__APP__' => MODULE_URL, // 当前项目地址
'__CONTROLL__' => CONTROLLER_URL, // 当前操作地址 '__CONTROLL__' => CONTROLLER_URL, // 当前操作地址
@@ -52,7 +52,7 @@ class ContentReplace {
'__ACTION__' => ACTION_URL, // 当前操作地址 '__ACTION__' => ACTION_URL, // 当前操作地址
'__SELF__' => $_SERVER['PHP_SELF'], // 当前页面地址 '__SELF__' => $_SERVER['PHP_SELF'], // 当前页面地址
'__PUBLIC__' => ROOT_URL.'/Public',// 站点公共目录 '__PUBLIC__' => ROOT_URL.'/Public',// 站点公共目录
); ];
// 允许用户自定义模板的字符串替换 // 允许用户自定义模板的字符串替换
if(is_array(Config::get('tmpl_parse_string')) ) if(is_array(Config::get('tmpl_parse_string')) )
$replace = array_merge($replace,Config::get('tmpl_parse_string')); $replace = array_merge($replace,Config::get('tmpl_parse_string'));

View File

@@ -17,12 +17,12 @@
* @author liu21st <liu21st@gmail.com> * @author liu21st <liu21st@gmail.com>
*/ */
class ReadHtmlCacheBehavior { class ReadHtmlCacheBehavior {
protected $options = array( protected $options = [
'HTML_CACHE_ON' => false, 'HTML_CACHE_ON' => false,
'HTML_CACHE_TIME' => 60, 'HTML_CACHE_TIME' => 60,
'HTML_CACHE_RULES' => [], 'HTML_CACHE_RULES' => [],
'HTML_FILE_SUFFIX' => '.html', 'HTML_FILE_SUFFIX' => '.html',
); ];
// 行为扩展的执行入口必须是run // 行为扩展的执行入口必须是run
public function run(&$params){ public function run(&$params){
@@ -72,8 +72,8 @@ class ReadHtmlCacheBehavior {
$rule = preg_replace('/{(\w+)}/e',"\$_GET['\\1']",$rule); $rule = preg_replace('/{(\w+)}/e',"\$_GET['\\1']",$rule);
// 特殊系统变量 // 特殊系统变量
$rule = str_ireplace( $rule = str_ireplace(
array('{:app}','{:module}','{:action}','{:group}'), ['{:app}','{:module}','{:action}','{:group}'],
array(APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''), [APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''],
$rule); $rule);
// {|FUN} 单独使用函数 // {|FUN} 单独使用函数
$rule = preg_replace('/{|(\w+)}/e',"\\1()",$rule); $rule = preg_replace('/{|(\w+)}/e',"\\1()",$rule);

View File

@@ -42,7 +42,7 @@ class ShowPageTrace {
} }
$trace = []; $trace = [];
Debug::remark('START',$GLOBALS['startTime']); Debug::remark('START',$GLOBALS['startTime']);
$base = array( $base = [
'请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'], '请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'],
'运行时间' => Debug::getUseTime('START','END',6).'s', '运行时间' => Debug::getUseTime('START','END',6).'s',
'内存开销' => MEMORY_LIMIT_ON?G('START','END','m').'b':'不支持', '内存开销' => MEMORY_LIMIT_ON?G('START','END','m').'b':'不支持',
@@ -50,7 +50,7 @@ class ShowPageTrace {
'文件加载' => count($files), '文件加载' => count($files),
'缓存信息' => N('cache_read').' gets '.N('cache_write').' writes ', '缓存信息' => N('cache_read').' gets '.N('cache_write').' writes ',
'配置加载' => count(Config::get()), '配置加载' => count(Config::get()),
); ];
// 读取项目定义的Trace文件 // 读取项目定义的Trace文件
$traceFile = MODULE_PATH.'trace.php'; $traceFile = MODULE_PATH.'trace.php';
if(is_file($traceFile)) { if(is_file($traceFile)) {

View File

@@ -19,12 +19,12 @@ defined('THINK_PATH') or exit();
*/ */
class TokenBuildBehavior extends Behavior { class TokenBuildBehavior extends Behavior {
// 行为参数定义 // 行为参数定义
protected $options = array( protected $options = [
'TOKEN_ON' => false, // 开启令牌验证 'TOKEN_ON' => false, // 开启令牌验证
'TOKEN_NAME' => '__hash__', // 令牌验证的表单隐藏字段名称 'TOKEN_NAME' => '__hash__', // 令牌验证的表单隐藏字段名称
'TOKEN_TYPE' => 'md5', // 令牌验证哈希规则 'TOKEN_TYPE' => 'md5', // 令牌验证哈希规则
'TOKEN_RESET' => true, // 令牌错误后是否重置 'TOKEN_RESET' => true, // 令牌错误后是否重置
); ];
public function run(&$content){ public function run(&$content){
if(C('TOKEN_ON')) { if(C('TOKEN_ON')) {

View File

@@ -17,11 +17,11 @@ namespace Think\Cache\Driver;
*/ */
class Apc { class Apc {
protected $options = array( protected $options = [
'expire' => 0, 'expire' => 0,
'prefix' => '', 'prefix' => '',
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -23,13 +23,13 @@ namespace Think\Cache\Driver;
class Db { class Db {
protected $handler = null; protected $handler = null;
protected $options = array( protected $options = [
'db' => '', 'db' => '',
'table' => '', 'table' => '',
'prefix' => '', 'prefix' => '',
'expire' => 0, 'expire' => 0,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
*/ */
class Eaccelerator { class Eaccelerator {
protected $options = array( protected $options = [
'prefix' => '', 'prefix' => '',
'expire' => 0, 'expire' => 0,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -9,13 +9,14 @@
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace Think\Cache\Driver; namespace Think\Cache\Driver;
/** /**
* 文件类型缓存类 * 文件类型缓存类
* @author liu21st <liu21st@gmail.com> * @author liu21st <liu21st@gmail.com>
*/ */
class File { class File {
protected $options = array( protected $options = [
'expire' => 0, 'expire' => 0,
'cache_subdir' => false, 'cache_subdir' => false,
'path_level' => 1, 'path_level' => 1,
@@ -23,7 +24,7 @@ class File {
'length' => 0, 'length' => 0,
'temp' => '', 'temp' => '',
'data_compress' => false, 'data_compress' => false,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,14 +15,14 @@ namespace Think\Cache\Driver;
*/ */
class Memcache { class Memcache {
protected $handler = null; protected $handler = null;
protected $options = array( protected $options = [
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'port' => 11211, 'port' => 11211,
'expire' => 0, 'expire' => 0,
'timeout' => false, 'timeout' => false,
'persistent' => false, 'persistent' => false,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -16,14 +16,14 @@ namespace Think\Cache\Driver;
*/ */
class Redis { class Redis {
protected $handler = null; protected $handler = null;
protected $options = array( protected $options = [
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'port' => 6379, 'port' => 6379,
'timeout' => false, 'timeout' => false,
'expire' => 0, 'expire' => 0,
'persistent' => false, 'persistent' => false,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -16,13 +16,13 @@ namespace Think\Cache\Driver;
class Secache { class Secache {
protected $handler = null; protected $handler = null;
protected $options = array( protected $options = [
'project' => '', 'project' => '',
'temp' => '', 'temp' => '',
'expire' => 0, 'expire' => 0,
'prefix' => '', 'prefix' => '',
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,10 +15,10 @@ namespace Think\Cache\Driver;
*/ */
class Simple { class Simple {
protected $options = array( protected $options = [
'prefix' => '', 'prefix' => '',
'temp' => '', 'temp' => '',
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,14 +15,14 @@ namespace Think\Cache\Driver;
*/ */
class Sqlite { class Sqlite {
protected $options = array( protected $options = [
'db' => ':memory:', 'db' => ':memory:',
'table' => 'sharedmemory', 'table' => 'sharedmemory',
'prefix' => '', 'prefix' => '',
'expire' => 0, 'expire' => 0,
'length' => 0, 'length' => 0,
'persistent' => false, 'persistent' => false,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
*/ */
class Wincache { class Wincache {
protected $options = array( protected $options = [
'prefix' => '', 'prefix' => '',
'expire' => 0, 'expire' => 0,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
*/ */
class Xcache { class Xcache {
protected $options = array( protected $options = [
'prefix' => '', 'prefix' => '',
'expire' => 0, 'expire' => 0,
'length' => 0, 'length' => 0,
); ];
/** /**
* 架构函数 * 架构函数

View File

@@ -15,15 +15,15 @@ class Controller {
public function __construct(){ public function __construct(){
$config['template_options'] = array( $config['template_options'] = [
'tpl_path' => MODULE_PATH.'view/', 'tpl_path' => MODULE_PATH.'view/',
'cache_path' => MODULE_PATH.'cache/', 'cache_path' => MODULE_PATH.'cache/',
'compile_type' => 'File', 'compile_type' => 'File',
'taglib_build_in' => 'cx', 'taglib_build_in' => 'cx',
'cache_options' => array( 'cache_options' => [
'temp' => APP_PATH.'runtime/temp/', 'temp' => APP_PATH.'runtime/temp/',
), ],
); ];
$config['http_content_type'] = 'text/html'; $config['http_content_type'] = 'text/html';
$config['http_cache_control'] = 'private'; $config['http_cache_control'] = 'private';
$config['http_charset'] = 'utf-8'; $config['http_charset'] = 'utf-8';

View File

@@ -52,7 +52,7 @@ class Cookie {
// 参数设置(会覆盖黙认设置) // 参数设置(会覆盖黙认设置)
if (!is_null($option)) { if (!is_null($option)) {
if (is_numeric($option)) if (is_numeric($option))
$option = array('expire' => $option); $option = ['expire' => $option];
elseif (is_string($option)) elseif (is_string($option))
parse_str($option, $option); parse_str($option, $option);
$config = array_merge(self::$config, array_change_key_case($option)); $config = array_merge(self::$config, array_change_key_case($option));

View File

@@ -29,14 +29,14 @@ class Mysql extends Driver{
$info = []; $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['field']] = array( $info[$val['field']] = [
'name' => $val['field'], 'name' => $val['field'],
'type' => $val['type'], 'type' => $val['type'],
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
'default' => $val['default'], 'default' => $val['default'],
'primary' => (strtolower($val['key']) == 'pri'), 'primary' => (strtolower($val['key']) == 'pri'),
'autoinc' => (strtolower($val['extra']) == 'auto_increment'), 'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
); ];
} }
} }
return $info; return $info;

View File

@@ -72,14 +72,14 @@ class Oracle extends Driver{
$info = []; $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[strtolower($val['column_name'])] = array( $info[strtolower($val['column_name'])] = [
'name' => strtolower($val['column_name']), 'name' => strtolower($val['column_name']),
'type' => strtolower($val['data_type']), 'type' => strtolower($val['data_type']),
'notnull' => $val['notnull'], 'notnull' => $val['notnull'],
'default' => $val['data_default'], 'default' => $val['data_default'],
'primary' => $val['pk'], 'primary' => $val['pk'],
'autoinc' => $val['pk'], 'autoinc' => $val['pk'],
); ];
} }
} }
return $info; return $info;

View File

@@ -29,14 +29,14 @@ class Pgsql extends Driver{
$info = []; $info = [];
if($result){ if($result){
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['field']] = array( $info[$val['field']] = [
'name' => $val['field'], 'name' => $val['field'],
'type' => $val['type'], 'type' => $val['type'],
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
'default' => $val['default'], 'default' => $val['default'],
'primary' => (strtolower($val['key']) == 'pri'), 'primary' => (strtolower($val['key']) == 'pri'),
'autoinc' => (strtolower($val['extra']) == 'auto_increment'), 'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
); ];
} }
} }
return $info; return $info;

View File

@@ -29,14 +29,14 @@ class Sqlite extends Driver {
$info = []; $info = [];
if($result){ if($result){
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['field']] = array( $info[$val['field']] = [
'name' => $val['field'], 'name' => $val['field'],
'type' => $val['type'], 'type' => $val['type'],
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
'default' => $val['default'], 'default' => $val['default'],
'primary' => (strtolower($val['dey']) == 'pri'), 'primary' => (strtolower($val['dey']) == 'pri'),
'autoinc' => (strtolower($val['extra']) == 'auto_increment'), 'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
); ];
} }
} }
return $info; return $info;

View File

@@ -37,14 +37,14 @@ class Sqlsrv extends Driver{
$info = []; $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['column_name']] = array( $info[$val['column_name']] = [
'name' => $val['column_name'], 'name' => $val['column_name'],
'type' => $val['data_type'], 'type' => $val['data_type'],
'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes 'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes
'default' => $val['column_default'], 'default' => $val['column_default'],
'primary' => false, 'primary' => false,
'autoinc' => false, 'autoinc' => false,
); ];
} }
} }
return $info; return $info;

View File

@@ -53,7 +53,7 @@ class Debug {
if(!isset(self::$_mem['mem'][$end])) if(!isset(self::$_mem['mem'][$end]))
self::$_mem['mem'][$end] = memory_get_usage(); self::$_mem['mem'][$end] = memory_get_usage();
$size = self::$_mem['mem'][$end]-self::$_mem['mem'][$start]; $size = self::$_mem['mem'][$end]-self::$_mem['mem'][$start];
$a = array('B', 'KB', 'MB', 'GB', 'TB'); $a = ['B', 'KB', 'MB', 'GB', 'TB'];
$pos = 0; $pos = 0;
while ($size >= 1024) { while ($size >= 1024) {
$size /= 1024; $size /= 1024;
@@ -72,7 +72,7 @@ class Debug {
static public function getMemPeak($start,$end,$dec=2) { static public function getMemPeak($start,$end,$dec=2) {
if(!isset(self::$_mem['peak'][$end])) self::$_mem['peak'][$end] = function_exists('memory_get_peak_usage')?memory_get_peak_usage():memory_get_usage(); if(!isset(self::$_mem['peak'][$end])) self::$_mem['peak'][$end] = function_exists('memory_get_peak_usage')?memory_get_peak_usage():memory_get_usage();
$size = self::$_mem['peak'][$end]-self::$_mem['peak'][$start]; $size = self::$_mem['peak'][$end]-self::$_mem['peak'][$start];
$a = array('B', 'KB', 'MB', 'GB', 'TB'); $a = ['B', 'KB', 'MB', 'GB', 'TB'];
$pos = 0; $pos = 0;
while ($size >= 1024) { while ($size >= 1024) {
$size /= 1024; $size /= 1024;

View File

@@ -12,10 +12,10 @@
namespace Think; namespace Think;
class Filter { class Filter {
//html标签设置 //html标签设置
static public $htmlTags = array( static public $htmlTags = [
'allow' => 'table|td|th|tr|i|b|u|strong|img|p|br|div|strong|em|ul|ol|li|dl|dd|dt|a', 'allow' => 'table|td|th|tr|i|b|u|strong|img|p|br|div|strong|em|ul|ol|li|dl|dd|dt|a',
'ban' => 'html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml', 'ban' => 'html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml',
); ];
static public function filter($data,$filter,$option=''){ static public function filter($data,$filter,$option=''){
return filter_var($data,is_int($filter)?$filter:filter_id($filter),$option); return filter_var($data,is_int($filter)?$filter:filter_id($filter),$option);
@@ -48,7 +48,7 @@ class Filter {
* @return string * @return string
*/ */
static public function forSearch($string) { static public function forSearch($string) {
return str_replace( array('%','_'), array('\%','\_'), $string ); return str_replace( ['%','_'], ['\%','\_'], $string );
} }
/** /**
@@ -67,7 +67,7 @@ class Filter {
* @return string * @return string
*/ */
static public function forTarea($string) { static public function forTarea($string) {
return str_ireplace(array('<textarea>','</textarea>'), array('&lt;textarea>','&lt;/textarea>'), $string); return str_ireplace(['<textarea>','</textarea>'], ['&lt;textarea>','&lt;/textarea>'], $string);
} }
/** /**
@@ -77,7 +77,7 @@ class Filter {
* @return string * @return string
*/ */
static public function forTag($string) { static public function forTag($string) {
return str_replace(array('"',"'"), array('&quot;','&#039;'), $string); return str_replace(['"',"'"], ['&quot;','&#039;'], $string);
} }
/** /**
@@ -107,7 +107,7 @@ class Filter {
* @return string * @return string
*/ */
static function hsc($string) { static function hsc($string) {
return preg_replace(array("/&amp;/i", "/&nbsp;/i"), array('&', '&amp;nbsp;'), htmlspecialchars($string, ENT_QUOTES)); return preg_replace(["/&amp;/i", "/&nbsp;/i"], ['&', '&amp;nbsp;'], htmlspecialchars($string, ENT_QUOTES));
} }
/** /**
@@ -117,7 +117,7 @@ class Filter {
* @return string * @return string
*/ */
static function undoHsc($text) { static function undoHsc($text) {
return preg_replace(array("/&gt;/i", "/&lt;/i", "/&quot;/i", "/&#039;/i", '/&amp;nbsp;/i'), array(">", "<", "\"", "'", "&nbsp;"), $text); return preg_replace(["/&gt;/i", "/&lt;/i", "/&quot;/i", "/&#039;/i", '/&amp;nbsp;/i'], [">", "<", "\"", "'", "&nbsp;"], $text);
} }
/** /**

View File

@@ -50,12 +50,12 @@ class Gd{
} }
//设置图像信息 //设置图像信息
$this->info = array( $this->info = [
'width' => $info[0], 'width' => $info[0],
'height' => $info[1], 'height' => $info[1],
'type' => image_type_to_extension($info[2], false), 'type' => image_type_to_extension($info[2], false),
'mime' => $info['mime'], 'mime' => $info['mime'],
); ];
//销毁已存在的图像 //销毁已存在的图像
empty($this->im) || imagedestroy($this->im); empty($this->im) || imagedestroy($this->im);
@@ -146,7 +146,7 @@ class Gd{
*/ */
public function size(){ public function size(){
if(empty($this->im)) throw new Exception('没有指定图像资源'); if(empty($this->im)) throw new Exception('没有指定图像资源');
return array($this->info['width'], $this->info['height']); return [$this->info['width'], $this->info['height']];
} }
/** /**

View File

@@ -50,12 +50,12 @@ class Imagick{
$this->im = new \Imagick(realpath($imgname)); $this->im = new \Imagick(realpath($imgname));
//设置图像信息 //设置图像信息
$this->info = array( $this->info = [
'width' => $this->im->getImageWidth(), 'width' => $this->im->getImageWidth(),
'height' => $this->im->getImageHeight(), 'height' => $this->im->getImageHeight(),
'type' => strtolower($this->im->getImageFormat()), 'type' => strtolower($this->im->getImageFormat()),
'mime' => $this->im->getImageMimeType(), 'mime' => $this->im->getImageMimeType(),
); ];
} }
/** /**
@@ -134,7 +134,7 @@ class Imagick{
*/ */
public function size(){ public function size(){
if(empty($this->im)) throw new Exception('没有指定图像资源'); if(empty($this->im)) throw new Exception('没有指定图像资源');
return array($this->info['width'], $this->info['height']); return [$this->info['width'], $this->info['height']];
} }
/** /**
@@ -353,7 +353,7 @@ class Imagick{
//创建水印图像资源 //创建水印图像资源
$water = new Imagick(realpath($source)); $water = new Imagick(realpath($source));
$info = array($water->getImageWidth(), $water->getImageHeight()); $info = [$water->getImageWidth(), $water->getImageHeight()];
/* 设定水印位置 */ /* 设定水印位置 */
switch ($locate) { switch ($locate) {

View File

@@ -82,7 +82,7 @@ class Input {
// 过滤表单中的表达式 // 过滤表单中的表达式
static private function filter_exp(&$value){ static private function filter_exp(&$value){
if (in_array(strtolower($value),array('exp','or'))){ if (in_array(strtolower($value),['exp','or'])){
$value .= ' '; $value .= ' ';
} }
} }

View File

@@ -89,7 +89,7 @@ class Loader {
}elseif (in_array($class_strut[0], ['Org','Com'])) { }elseif (in_array($class_strut[0], ['Org','Com'])) {
// org 第三方公共类库 com 企业公共类库 // org 第三方公共类库 com 企业公共类库
$baseUrl = LIB_PATH; $baseUrl = LIB_PATH;
}elseif(in_array($class_strut[0], ['Think','Vendor','Traits'])){ }elseif(in_array($class_strut[0], ['Think','Vendor','Library','Traits'])){
$baseUrl = THINK_PATH; $baseUrl = THINK_PATH;
}else { // 加载其他项目应用类库 }else { // 加载其他项目应用类库
$class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1); $class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1);
@@ -206,7 +206,7 @@ class Loader {
if(is_string($vars)) { if(is_string($vars)) {
parse_str($vars,$vars); parse_str($vars,$vars);
} }
return call_user_func_array(array(&$class,$action.Config::get('action_suffix')),$vars); return call_user_func_array([&$class,$action.Config::get('action_suffix')],$vars);
}else{ }else{
return false; return false;
} }
@@ -225,7 +225,7 @@ class Loader {
if(class_exists($class)){ if(class_exists($class)){
$o = new $class(); $o = new $class();
if(!empty($method) && method_exists($o,$method)) if(!empty($method) && method_exists($o,$method))
$_instance[$identify] = call_user_func_array(array(&$o, $method)); $_instance[$identify] = call_user_func_array([&$o, $method]);
else else
$_instance[$identify] = $o; $_instance[$identify] = $o;
} }

View File

@@ -11,12 +11,15 @@
// $Id$ // $Id$
namespace Think; namespace Think;
class Model { class Model {
//use Think\Model\Traits\ActiveRecord;
// 操作状态 // 操作状态
const MODEL_INSERT = 1; // 插入模型数据 const MODEL_INSERT = 1; // 插入模型数据
const MODEL_UPDATE = 2; // 更新模型数据 const MODEL_UPDATE = 2; // 更新模型数据
const MODEL_BOTH = 3; // 包含上面两种方式 const MODEL_BOTH = 3; // 包含上面两种方式
// 当前使用的扩展模型 // 当前使用的扩展模型
private $_extModel = null; private $_extModel = null;
// 当前数据库操作对象 // 当前数据库操作对象

View File

@@ -169,7 +169,7 @@ class Validate {
* @return boolean * @return boolean
*/ */
public function regex($value,$rule) { public function regex($value,$rule) {
$validate = array( $validate = [
'require' => '/.+/', 'require' => '/.+/',
'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/', 'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/',
@@ -179,7 +179,7 @@ class Validate {
'integer' => '/^[-\+]?\d+$/', 'integer' => '/^[-\+]?\d+$/',
'double' => '/^[-\+]?\d+(\.\d+)?$/', 'double' => '/^[-\+]?\d+(\.\d+)?$/',
'english' => '/^[A-Za-z]+$/', 'english' => '/^[A-Za-z]+$/',
); ];
// 检查是否有内置的正则表达式 // 检查是否有内置的正则表达式
if(isset($validate[strtolower($rule)])) if(isset($validate[strtolower($rule)]))
$rule = $validate[strtolower($rule)]; $rule = $validate[strtolower($rule)];

View File

@@ -18,10 +18,10 @@ body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16p
<div class="system-message"> <div class="system-message">
<present name="message"> <present name="message">
<h1>:)</h1> <h1>:)</h1>
<p class="success"><?php echo($message); ?></p> <p class="success"><?php echo(strip_tags($message)); ?></p>
<else/> <else/>
<h1>:(</h1> <h1>:(</h1>
<p class="error"><?php echo($error); ?></p> <p class="error"><?php echo(strip_tags($error)); ?></p>
</present> </present>
<p class="detail"></p> <p class="detail"></p>
<p class="jump"> <p class="jump">

View File

@@ -19,7 +19,7 @@ define('THINK_VERSION', '4.0beta');
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/'); defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');
defined('CORE_PATH') or define('CORE_PATH', THINK_PATH.'Think/'); defined('CORE_PATH') or define('CORE_PATH', THINK_PATH.'Think/');
defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
defined('LIB_PATH') or define('LIB_PATH', APP_PATH.'Library/'); defined('LIB_PATH') or define('LIB_PATH', THINK_PATH.'Library/');
defined('RUNTIME_PATH') or define('RUNTIME_PATH', realpath(APP_PATH).'/Runtime/'); defined('RUNTIME_PATH') or define('RUNTIME_PATH', realpath(APP_PATH).'/Runtime/');
defined('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'Data/'); defined('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'Data/');
defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH.'Log/'); defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH.'Log/');

View File

@@ -16,7 +16,7 @@ namespace Think;
//-------------------------- //--------------------------
// 加载基础文件 // 加载基础文件
require dirname(__FILE__).'/base.php'; require __DIR__.'/base.php';
require CORE_PATH.'Loader.php'; require CORE_PATH.'Loader.php';
// 注册自动加载 // 注册自动加载
@@ -36,17 +36,14 @@ set_exception_handler(['Think\Error','appException']);
// 导入系统惯例 // 导入系统惯例
Config::load(THINK_PATH.'convention.php'); Config::load(THINK_PATH.'convention.php');
// 初始化操作可以在应用的公共文件中处理 下面只是示例
//---------------------------------------------------
// 日志初始化 // 日志初始化
Log::init(['type'=>Config::get('log_type'),'log_path'=> Config::get('log_path')]); Log::init(['type'=>Config::get('log_type'),'log_path'=> Config::get('log_path')]);
// 缓存初始化 // 缓存初始化
Cache::connect(['type'=>'File','temp'=> CACHE_PATH]); Cache::connect(['type'=>'File','temp'=> CACHE_PATH]);
//------------------------------------------------------
// 注册行为扩展
//Tag::add('content_filter','ContentReplace','Think');
//Tag::add('app_end','ShowPageTrace','Think');
Tag::add('view_template','LocationTemplate','Think');
// 启动session // 启动session
if(!IS_CLI) { if(!IS_CLI) {