mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
数组定义用法统一
This commit is contained in:
1
Library/Org/README.md
Normal file
1
Library/Org/README.md
Normal file
@@ -0,0 +1 @@
|
||||
ThinkPHP 扩展类库目录
|
||||
@@ -63,7 +63,7 @@ class App {
|
||||
$action = ACTION_NAME.$config['action_suffix'];
|
||||
try{
|
||||
// 操作方法开始监听
|
||||
$call = array($instance,$action);
|
||||
$call = [$instance,$action];
|
||||
Tag::listen('action_begin',$call);
|
||||
if(!preg_match('/^[A-Za-z](\w)*$/',$action)){
|
||||
// 非法操作
|
||||
@@ -109,7 +109,7 @@ class App {
|
||||
// 操作不存在
|
||||
if(method_exists($instance,'_empty')) {
|
||||
$method = new \ReflectionMethod($instance,'_empty');
|
||||
$method->invokeArgs($instance,array($action,''));
|
||||
$method->invokeArgs($instance,[$action,'']);
|
||||
}else{
|
||||
E('[ '.(new \ReflectionClass($instance))->getName().':'.$action.' ] not exists ',404);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class ContentReplace {
|
||||
define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME);
|
||||
|
||||
// 系统默认的特殊变量替换
|
||||
$replace = array(
|
||||
$replace = [
|
||||
'__ROOT__' => ROOT_URL, // 当前网站地址
|
||||
'__APP__' => MODULE_URL, // 当前项目地址
|
||||
'__CONTROLL__' => CONTROLLER_URL, // 当前操作地址
|
||||
@@ -52,7 +52,7 @@ class ContentReplace {
|
||||
'__ACTION__' => ACTION_URL, // 当前操作地址
|
||||
'__SELF__' => $_SERVER['PHP_SELF'], // 当前页面地址
|
||||
'__PUBLIC__' => ROOT_URL.'/Public',// 站点公共目录
|
||||
);
|
||||
];
|
||||
// 允许用户自定义模板的字符串替换
|
||||
if(is_array(Config::get('tmpl_parse_string')) )
|
||||
$replace = array_merge($replace,Config::get('tmpl_parse_string'));
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
class ReadHtmlCacheBehavior {
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'HTML_CACHE_ON' => false,
|
||||
'HTML_CACHE_TIME' => 60,
|
||||
'HTML_CACHE_RULES' => [],
|
||||
'HTML_FILE_SUFFIX' => '.html',
|
||||
);
|
||||
];
|
||||
|
||||
// 行为扩展的执行入口必须是run
|
||||
public function run(&$params){
|
||||
@@ -72,8 +72,8 @@ class ReadHtmlCacheBehavior {
|
||||
$rule = preg_replace('/{(\w+)}/e',"\$_GET['\\1']",$rule);
|
||||
// 特殊系统变量
|
||||
$rule = str_ireplace(
|
||||
array('{:app}','{:module}','{:action}','{:group}'),
|
||||
array(APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''),
|
||||
['{:app}','{:module}','{:action}','{:group}'],
|
||||
[APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''],
|
||||
$rule);
|
||||
// {|FUN} 单独使用函数
|
||||
$rule = preg_replace('/{|(\w+)}/e',"\\1()",$rule);
|
||||
|
||||
@@ -42,7 +42,7 @@ class ShowPageTrace {
|
||||
}
|
||||
$trace = [];
|
||||
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'],
|
||||
'运行时间' => Debug::getUseTime('START','END',6).'s',
|
||||
'内存开销' => MEMORY_LIMIT_ON?G('START','END','m').'b':'不支持',
|
||||
@@ -50,7 +50,7 @@ class ShowPageTrace {
|
||||
'文件加载' => count($files),
|
||||
'缓存信息' => N('cache_read').' gets '.N('cache_write').' writes ',
|
||||
'配置加载' => count(Config::get()),
|
||||
);
|
||||
];
|
||||
// 读取项目定义的Trace文件
|
||||
$traceFile = MODULE_PATH.'trace.php';
|
||||
if(is_file($traceFile)) {
|
||||
|
||||
@@ -19,12 +19,12 @@ defined('THINK_PATH') or exit();
|
||||
*/
|
||||
class TokenBuildBehavior extends Behavior {
|
||||
// 行为参数定义
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'TOKEN_ON' => false, // 开启令牌验证
|
||||
'TOKEN_NAME' => '__hash__', // 令牌验证的表单隐藏字段名称
|
||||
'TOKEN_TYPE' => 'md5', // 令牌验证哈希规则
|
||||
'TOKEN_RESET' => true, // 令牌错误后是否重置
|
||||
);
|
||||
];
|
||||
|
||||
public function run(&$content){
|
||||
if(C('TOKEN_ON')) {
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Apc {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'expire' => 0,
|
||||
'prefix' => '',
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -23,13 +23,13 @@ namespace Think\Cache\Driver;
|
||||
class Db {
|
||||
|
||||
protected $handler = null;
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'db' => '',
|
||||
'table' => '',
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Eaccelerator {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Think\Cache\Driver;
|
||||
|
||||
/**
|
||||
* 文件类型缓存类
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
class File {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'expire' => 0,
|
||||
'cache_subdir' => false,
|
||||
'path_level' => 1,
|
||||
@@ -23,7 +24,7 @@ class File {
|
||||
'length' => 0,
|
||||
'temp' => '',
|
||||
'data_compress' => false,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Memcache {
|
||||
protected $handler = null;
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'expire' => 0,
|
||||
'timeout' => false,
|
||||
'persistent' => false,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Redis {
|
||||
protected $handler = null;
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'timeout' => false,
|
||||
'expire' => 0,
|
||||
'persistent' => false,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace Think\Cache\Driver;
|
||||
class Secache {
|
||||
|
||||
protected $handler = null;
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'project' => '',
|
||||
'temp' => '',
|
||||
'expire' => 0,
|
||||
'prefix' => '',
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Simple {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'temp' => '',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Sqlite {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'db' => ':memory:',
|
||||
'table' => 'sharedmemory',
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'length' => 0,
|
||||
'persistent' => false,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Wincache {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Think\Cache\Driver;
|
||||
*/
|
||||
class Xcache {
|
||||
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'length' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
|
||||
@@ -15,15 +15,15 @@ class Controller {
|
||||
|
||||
public function __construct(){
|
||||
|
||||
$config['template_options'] = array(
|
||||
$config['template_options'] = [
|
||||
'tpl_path' => MODULE_PATH.'view/',
|
||||
'cache_path' => MODULE_PATH.'cache/',
|
||||
'compile_type' => 'File',
|
||||
'taglib_build_in' => 'cx',
|
||||
'cache_options' => array(
|
||||
'cache_options' => [
|
||||
'temp' => APP_PATH.'runtime/temp/',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$config['http_content_type'] = 'text/html';
|
||||
$config['http_cache_control'] = 'private';
|
||||
$config['http_charset'] = 'utf-8';
|
||||
|
||||
@@ -52,7 +52,7 @@ class Cookie {
|
||||
// 参数设置(会覆盖黙认设置)
|
||||
if (!is_null($option)) {
|
||||
if (is_numeric($option))
|
||||
$option = array('expire' => $option);
|
||||
$option = ['expire' => $option];
|
||||
elseif (is_string($option))
|
||||
parse_str($option, $option);
|
||||
$config = array_merge(self::$config, array_change_key_case($option));
|
||||
|
||||
@@ -29,14 +29,14 @@ class Mysql extends Driver{
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['field']] = array(
|
||||
$info[$val['field']] = [
|
||||
'name' => $val['field'],
|
||||
'type' => $val['type'],
|
||||
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
|
||||
'default' => $val['default'],
|
||||
'primary' => (strtolower($val['key']) == 'pri'),
|
||||
'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
|
||||
@@ -72,14 +72,14 @@ class Oracle extends Driver{
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[strtolower($val['column_name'])] = array(
|
||||
$info[strtolower($val['column_name'])] = [
|
||||
'name' => strtolower($val['column_name']),
|
||||
'type' => strtolower($val['data_type']),
|
||||
'notnull' => $val['notnull'],
|
||||
'default' => $val['data_default'],
|
||||
'primary' => $val['pk'],
|
||||
'autoinc' => $val['pk'],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
|
||||
@@ -29,14 +29,14 @@ class Pgsql extends Driver{
|
||||
$info = [];
|
||||
if($result){
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['field']] = array(
|
||||
$info[$val['field']] = [
|
||||
'name' => $val['field'],
|
||||
'type' => $val['type'],
|
||||
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
|
||||
'default' => $val['default'],
|
||||
'primary' => (strtolower($val['key']) == 'pri'),
|
||||
'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
|
||||
@@ -29,14 +29,14 @@ class Sqlite extends Driver {
|
||||
$info = [];
|
||||
if($result){
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['field']] = array(
|
||||
$info[$val['field']] = [
|
||||
'name' => $val['field'],
|
||||
'type' => $val['type'],
|
||||
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
|
||||
'default' => $val['default'],
|
||||
'primary' => (strtolower($val['dey']) == 'pri'),
|
||||
'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
|
||||
@@ -37,14 +37,14 @@ class Sqlsrv extends Driver{
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['column_name']] = array(
|
||||
$info[$val['column_name']] = [
|
||||
'name' => $val['column_name'],
|
||||
'type' => $val['data_type'],
|
||||
'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes
|
||||
'default' => $val['column_default'],
|
||||
'primary' => false,
|
||||
'autoinc' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
|
||||
@@ -53,7 +53,7 @@ class Debug {
|
||||
if(!isset(self::$_mem['mem'][$end]))
|
||||
self::$_mem['mem'][$end] = memory_get_usage();
|
||||
$size = self::$_mem['mem'][$end]-self::$_mem['mem'][$start];
|
||||
$a = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
$a = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$pos = 0;
|
||||
while ($size >= 1024) {
|
||||
$size /= 1024;
|
||||
@@ -72,7 +72,7 @@ class Debug {
|
||||
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();
|
||||
$size = self::$_mem['peak'][$end]-self::$_mem['peak'][$start];
|
||||
$a = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
$a = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$pos = 0;
|
||||
while ($size >= 1024) {
|
||||
$size /= 1024;
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
namespace Think;
|
||||
class Filter {
|
||||
//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',
|
||||
'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=''){
|
||||
return filter_var($data,is_int($filter)?$filter:filter_id($filter),$option);
|
||||
@@ -48,7 +48,7 @@ class Filter {
|
||||
* @return string
|
||||
*/
|
||||
static public function forSearch($string) {
|
||||
return str_replace( array('%','_'), array('\%','\_'), $string );
|
||||
return str_replace( ['%','_'], ['\%','\_'], $string );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class Filter {
|
||||
* @return string
|
||||
*/
|
||||
static public function forTarea($string) {
|
||||
return str_ireplace(array('<textarea>','</textarea>'), array('<textarea>','</textarea>'), $string);
|
||||
return str_ireplace(['<textarea>','</textarea>'], ['<textarea>','</textarea>'], $string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class Filter {
|
||||
* @return string
|
||||
*/
|
||||
static public function forTag($string) {
|
||||
return str_replace(array('"',"'"), array('"','''), $string);
|
||||
return str_replace(['"',"'"], ['"','''], $string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ class Filter {
|
||||
* @return string
|
||||
*/
|
||||
static function hsc($string) {
|
||||
return preg_replace(array("/&/i", "/ /i"), array('&', '&nbsp;'), htmlspecialchars($string, ENT_QUOTES));
|
||||
return preg_replace(["/&/i", "/ /i"], ['&', '&nbsp;'], htmlspecialchars($string, ENT_QUOTES));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ class Filter {
|
||||
* @return string
|
||||
*/
|
||||
static function undoHsc($text) {
|
||||
return preg_replace(array("/>/i", "/</i", "/"/i", "/'/i", '/&nbsp;/i'), array(">", "<", "\"", "'", " "), $text);
|
||||
return preg_replace(["/>/i", "/</i", "/"/i", "/'/i", '/&nbsp;/i'], [">", "<", "\"", "'", " "], $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,12 @@ class Gd{
|
||||
}
|
||||
|
||||
//设置图像信息
|
||||
$this->info = array(
|
||||
$this->info = [
|
||||
'width' => $info[0],
|
||||
'height' => $info[1],
|
||||
'type' => image_type_to_extension($info[2], false),
|
||||
'mime' => $info['mime'],
|
||||
);
|
||||
];
|
||||
|
||||
//销毁已存在的图像
|
||||
empty($this->im) || imagedestroy($this->im);
|
||||
@@ -146,7 +146,7 @@ class Gd{
|
||||
*/
|
||||
public function size(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
return array($this->info['width'], $this->info['height']);
|
||||
return [$this->info['width'], $this->info['height']];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,12 @@ class Imagick{
|
||||
$this->im = new \Imagick(realpath($imgname));
|
||||
|
||||
//设置图像信息
|
||||
$this->info = array(
|
||||
$this->info = [
|
||||
'width' => $this->im->getImageWidth(),
|
||||
'height' => $this->im->getImageHeight(),
|
||||
'type' => strtolower($this->im->getImageFormat()),
|
||||
'mime' => $this->im->getImageMimeType(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class Imagick{
|
||||
*/
|
||||
public function size(){
|
||||
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));
|
||||
$info = array($water->getImageWidth(), $water->getImageHeight());
|
||||
$info = [$water->getImageWidth(), $water->getImageHeight()];
|
||||
|
||||
/* 设定水印位置 */
|
||||
switch ($locate) {
|
||||
|
||||
@@ -82,7 +82,7 @@ class Input {
|
||||
|
||||
// 过滤表单中的表达式
|
||||
static private function filter_exp(&$value){
|
||||
if (in_array(strtolower($value),array('exp','or'))){
|
||||
if (in_array(strtolower($value),['exp','or'])){
|
||||
$value .= ' ';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class Loader {
|
||||
}elseif (in_array($class_strut[0], ['Org','Com'])) {
|
||||
// org 第三方公共类库 com 企业公共类库
|
||||
$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;
|
||||
}else { // 加载其他项目应用类库
|
||||
$class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1);
|
||||
@@ -206,7 +206,7 @@ class Loader {
|
||||
if(is_string($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{
|
||||
return false;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ class Loader {
|
||||
if(class_exists($class)){
|
||||
$o = new $class();
|
||||
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
|
||||
$_instance[$identify] = $o;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,15 @@
|
||||
// $Id$
|
||||
|
||||
namespace Think;
|
||||
|
||||
class Model {
|
||||
//use Think\Model\Traits\ActiveRecord;
|
||||
// 操作状态
|
||||
const MODEL_INSERT = 1; // 插入模型数据
|
||||
const MODEL_UPDATE = 2; // 更新模型数据
|
||||
const MODEL_BOTH = 3; // 包含上面两种方式
|
||||
|
||||
|
||||
// 当前使用的扩展模型
|
||||
private $_extModel = null;
|
||||
// 当前数据库操作对象
|
||||
|
||||
@@ -169,7 +169,7 @@ class Validate {
|
||||
* @return boolean
|
||||
*/
|
||||
public function regex($value,$rule) {
|
||||
$validate = array(
|
||||
$validate = [
|
||||
'require' => '/.+/',
|
||||
'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
|
||||
'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/',
|
||||
@@ -179,7 +179,7 @@ class Validate {
|
||||
'integer' => '/^[-\+]?\d+$/',
|
||||
'double' => '/^[-\+]?\d+(\.\d+)?$/',
|
||||
'english' => '/^[A-Za-z]+$/',
|
||||
);
|
||||
];
|
||||
// 检查是否有内置的正则表达式
|
||||
if(isset($validate[strtolower($rule)]))
|
||||
$rule = $validate[strtolower($rule)];
|
||||
|
||||
@@ -18,10 +18,10 @@ body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16p
|
||||
<div class="system-message">
|
||||
<present name="message">
|
||||
<h1>:)</h1>
|
||||
<p class="success"><?php echo($message); ?></p>
|
||||
<p class="success"><?php echo(strip_tags($message)); ?></p>
|
||||
<else/>
|
||||
<h1>:(</h1>
|
||||
<p class="error"><?php echo($error); ?></p>
|
||||
<p class="error"><?php echo(strip_tags($error)); ?></p>
|
||||
</present>
|
||||
<p class="detail"></p>
|
||||
<p class="jump">
|
||||
|
||||
2
base.php
2
base.php
@@ -19,7 +19,7 @@ define('THINK_VERSION', '4.0beta');
|
||||
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');
|
||||
defined('CORE_PATH') or define('CORE_PATH', THINK_PATH.'Think/');
|
||||
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('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'Data/');
|
||||
defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH.'Log/');
|
||||
|
||||
11
start.php
11
start.php
@@ -16,7 +16,7 @@ namespace Think;
|
||||
//--------------------------
|
||||
|
||||
// 加载基础文件
|
||||
require dirname(__FILE__).'/base.php';
|
||||
require __DIR__.'/base.php';
|
||||
require CORE_PATH.'Loader.php';
|
||||
|
||||
// 注册自动加载
|
||||
@@ -36,17 +36,14 @@ set_exception_handler(['Think\Error','appException']);
|
||||
// 导入系统惯例
|
||||
Config::load(THINK_PATH.'convention.php');
|
||||
|
||||
// 初始化操作可以在应用的公共文件中处理 下面只是示例
|
||||
//---------------------------------------------------
|
||||
// 日志初始化
|
||||
Log::init(['type'=>Config::get('log_type'),'log_path'=> Config::get('log_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
|
||||
if(!IS_CLI) {
|
||||
|
||||
Reference in New Issue
Block a user