mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
注释和规范化调整及完善
注释和规范化调整及完善,以及部分代码优化
This commit is contained in:
@@ -41,8 +41,8 @@ class ContentReplace
|
||||
$script_name = rtrim($_SERVER['SCRIPT_NAME'],'/');
|
||||
}
|
||||
define('ROOT_URL', rtrim(dirname(str_replace("\\","\/",$script_name)),'/'));
|
||||
define('MODULE_URL', ROOT_URL.'/'.(defined('MODULE_ALIAS')?MODULE_ALIAS:MODULE_NAME);
|
||||
define('CONTROLLER_URL', MODULE_URL.'/'.CONTROLLER_NAME;
|
||||
define('MODULE_URL', ROOT_URL.'/'.(defined('MODULE_ALIAS')?MODULE_ALIAS:MODULE_NAME));
|
||||
define('CONTROLLER_URL', MODULE_URL.'/'.CONTROLLER_NAME);
|
||||
define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME);
|
||||
|
||||
// 系统默认的特殊变量替换
|
||||
|
||||
@@ -27,9 +27,12 @@ class LocationTemplate
|
||||
|
||||
/**
|
||||
* 自动定位模板文件
|
||||
* @access private
|
||||
* @param string $templateFile 文件名
|
||||
* @access private
|
||||
*
|
||||
* @param $template
|
||||
*
|
||||
* @return string
|
||||
* @internal param string $templateFile 文件名
|
||||
*/
|
||||
private function parseTemplateFile($template)
|
||||
{
|
||||
@@ -39,8 +42,6 @@ class LocationTemplate
|
||||
$template = CONTROLLER_NAME . '/' . ACTION_NAME;
|
||||
} elseif (false === strpos($template, '/')) {
|
||||
$template = CONTROLLER_NAME . '/' . $template;
|
||||
} elseif (false === strpos($template, '.')) {
|
||||
$template = $template;
|
||||
}
|
||||
$templateFile = MODULE_PATH . 'view/' . $template . '.html';
|
||||
return $templateFile;
|
||||
|
||||
@@ -104,7 +104,7 @@ class ReadHtmlCache
|
||||
* @access public
|
||||
* @param string $cacheFile 静态文件名
|
||||
* @param integer $cacheTime 缓存有效期
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkHTMLCache($cacheFile = '', $cacheTime = '')
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\behavior;
|
||||
use think\Behavior;
|
||||
|
||||
/**
|
||||
* 系统行为扩展:表单令牌生成
|
||||
|
||||
@@ -15,10 +15,14 @@ class Crypt
|
||||
{
|
||||
/**
|
||||
* 加密字符串
|
||||
* @access public
|
||||
* @param string $str 字符串
|
||||
* @access public
|
||||
*
|
||||
* @param $data
|
||||
* @param string $key 加密key
|
||||
* @param int $expire
|
||||
*
|
||||
* @return string
|
||||
* @internal param string $str 字符串
|
||||
*/
|
||||
public static function encrypt($data, $key, $expire = 0)
|
||||
{
|
||||
@@ -45,10 +49,13 @@ class Crypt
|
||||
|
||||
/**
|
||||
* 解密字符串
|
||||
* @access public
|
||||
* @param string $str 字符串
|
||||
* @access public
|
||||
*
|
||||
* @param $data
|
||||
* @param string $key 加密key
|
||||
*
|
||||
* @return string
|
||||
* @internal param string $str 字符串
|
||||
*/
|
||||
public static function decrypt($data, $key)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,11 @@ class Image
|
||||
|
||||
/**
|
||||
* 初始化方法,用于实例化一个图片处理对象
|
||||
*
|
||||
* @param string $type 要使用的类库,默认使用GD库
|
||||
* @param null $imgname
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public static function init($type = 'Gd', $imgname = null)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace think\image\driver;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Gd
|
||||
{
|
||||
/**
|
||||
@@ -18,6 +20,9 @@ class Gd
|
||||
* @var resource
|
||||
*/
|
||||
private $im;
|
||||
/**
|
||||
* @var $git \think\image\driver\Gif
|
||||
*/
|
||||
private $gif;
|
||||
/**
|
||||
* 图像信息,包括width,height,type,mime,size
|
||||
@@ -36,7 +41,11 @@ class Gd
|
||||
|
||||
/**
|
||||
* 打开一张图像
|
||||
*
|
||||
* @param string $imgname 图像路径
|
||||
*
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function open($imgname)
|
||||
{
|
||||
@@ -50,7 +59,7 @@ class Gd
|
||||
|
||||
//检测图像合法性
|
||||
if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) {
|
||||
throw new \Exception('非法图像文件');
|
||||
throw new Exception('非法图像文件');
|
||||
}
|
||||
|
||||
//设置图像信息
|
||||
@@ -78,14 +87,18 @@ class Gd
|
||||
|
||||
/**
|
||||
* 保存图像
|
||||
*
|
||||
* @param string $imgname 图像保存名称
|
||||
* @param string $type 图像类型
|
||||
* @param boolean $interlace 是否对JPEG类型图像设置隔行扫描
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($imgname, $type = null, $interlace = true)
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有可以被保存的图像资源');
|
||||
throw new Exception('没有可以被保存的图像资源');
|
||||
}
|
||||
|
||||
//自动获取图像类型
|
||||
@@ -113,12 +126,13 @@ class Gd
|
||||
|
||||
/**
|
||||
* 返回图像宽度
|
||||
* @return integer 图像宽度
|
||||
* @return int 图像宽度
|
||||
* @throws Exception
|
||||
*/
|
||||
public function width()
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有指定图像资源');
|
||||
throw new Exception('没有指定图像资源');
|
||||
}
|
||||
|
||||
return $this->info['width'];
|
||||
@@ -126,12 +140,13 @@ class Gd
|
||||
|
||||
/**
|
||||
* 返回图像高度
|
||||
* @return integer 图像高度
|
||||
* @return int 图像高度
|
||||
* @throws Exception
|
||||
*/
|
||||
public function height()
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有指定图像资源');
|
||||
throw new Exception('没有指定图像资源');
|
||||
}
|
||||
|
||||
return $this->info['height'];
|
||||
@@ -140,11 +155,12 @@ class Gd
|
||||
/**
|
||||
* 返回图像类型
|
||||
* @return string 图像类型
|
||||
* @throws Exception
|
||||
*/
|
||||
public function type()
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有指定图像资源');
|
||||
throw new Exception('没有指定图像资源');
|
||||
}
|
||||
|
||||
return $this->info['type'];
|
||||
@@ -153,11 +169,12 @@ class Gd
|
||||
/**
|
||||
* 返回图像MIME类型
|
||||
* @return string 图像MIME类型
|
||||
* @throws Exception
|
||||
*/
|
||||
public function mime()
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有指定图像资源');
|
||||
throw new Exception('没有指定图像资源');
|
||||
}
|
||||
|
||||
return $this->info['mime'];
|
||||
@@ -166,11 +183,12 @@ class Gd
|
||||
/**
|
||||
* 返回图像尺寸数组 0 - 图像宽度,1 - 图像高度
|
||||
* @return array 图像尺寸
|
||||
* @throws Exception
|
||||
*/
|
||||
public function size()
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有指定图像资源');
|
||||
throw new Exception('没有指定图像资源');
|
||||
}
|
||||
|
||||
return [$this->info['width'], $this->info['height']];
|
||||
@@ -178,17 +196,21 @@ class Gd
|
||||
|
||||
/**
|
||||
* 裁剪图像
|
||||
*
|
||||
* @param integer $w 裁剪区域宽度
|
||||
* @param integer $h 裁剪区域高度
|
||||
* @param integer $x 裁剪区域x坐标
|
||||
* @param integer $y 裁剪区域y坐标
|
||||
* @param integer $width 图像保存宽度
|
||||
* @param integer $height 图像保存高度
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function crop($w, $h, $x = 0, $y = 0, $width = null, $height = null)
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有可以被裁剪的图像资源');
|
||||
throw new Exception('没有可以被裁剪的图像资源');
|
||||
}
|
||||
|
||||
//设置保存尺寸
|
||||
@@ -217,14 +239,18 @@ class Gd
|
||||
|
||||
/**
|
||||
* 生成缩略图
|
||||
*
|
||||
* @param integer $width 缩略图最大宽度
|
||||
* @param integer $height 缩略图最大高度
|
||||
* @param integer $type 缩略图裁剪类型
|
||||
* @param int $type 缩略图裁剪类型
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function thumb($width, $height, $type = THINKIMAGE_THUMB_SCALE)
|
||||
public function thumb($width, $height, $type = THINKIMAGE_THUMB_SCALING)
|
||||
{
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有可以被缩略的图像资源');
|
||||
throw new Exception('没有可以被缩略的图像资源');
|
||||
}
|
||||
|
||||
//原图宽度和高度
|
||||
@@ -237,7 +263,7 @@ class Gd
|
||||
case THINKIMAGE_THUMB_SCALING:
|
||||
//原图尺寸小于缩略图尺寸则不进行缩略
|
||||
if ($w < $width && $h < $height) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//计算缩放比例
|
||||
@@ -296,6 +322,8 @@ class Gd
|
||||
//设置缩略图的坐标及宽度和高度
|
||||
$neww = $w * $scale;
|
||||
$newh = $h * $scale;
|
||||
$x = $this->info['width'] - $w;
|
||||
$y = $this->info['height'] - $h;
|
||||
$posx = ($width - $w * $scale) / 2;
|
||||
$posy = ($height - $h * $scale) / 2;
|
||||
|
||||
@@ -322,7 +350,7 @@ class Gd
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception('不支持的缩略图裁剪类型');
|
||||
throw new Exception('不支持的缩略图裁剪类型');
|
||||
}
|
||||
|
||||
/* 裁剪图像 */
|
||||
@@ -332,25 +360,29 @@ class Gd
|
||||
|
||||
/**
|
||||
* 添加水印
|
||||
* @param string $source 水印图片路径
|
||||
* @param integer $locate 水印位置
|
||||
* @param integer $alpha 水印透明度
|
||||
*
|
||||
* @param string $source 水印图片路径
|
||||
* @param int $locate 水印位置
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
* @internal param int $alpha 水印透明度
|
||||
*/
|
||||
public function water($source, $locate = THINKIMAGE_WATER_SOUTHEAST)
|
||||
{
|
||||
//资源检测
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有可以被添加水印的图像资源');
|
||||
throw new Exception('没有可以被添加水印的图像资源');
|
||||
}
|
||||
|
||||
if (!is_file($source)) {
|
||||
throw new \Exception('水印图像不存在');
|
||||
throw new Exception('水印图像不存在');
|
||||
}
|
||||
|
||||
//获取水印图像信息
|
||||
$info = getimagesize($source);
|
||||
if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) {
|
||||
throw new \Exception('非法水印文件');
|
||||
throw new Exception('非法水印文件');
|
||||
}
|
||||
|
||||
//创建水印图像资源
|
||||
@@ -420,7 +452,7 @@ class Gd
|
||||
if (is_array($locate)) {
|
||||
list($x, $y) = $locate;
|
||||
} else {
|
||||
throw new \Exception('不支持的水印位置类型');
|
||||
throw new Exception('不支持的水印位置类型');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,23 +478,27 @@ class Gd
|
||||
|
||||
/**
|
||||
* 图像添加文字
|
||||
*
|
||||
* @param string $text 添加的文字
|
||||
* @param string $font 字体路径
|
||||
* @param integer $size 字号
|
||||
* @param string $color 文字颜色
|
||||
* @param integer $locate 文字写入位置
|
||||
* @param int $locate 文字写入位置
|
||||
* @param integer $offset 文字相对当前位置的偏移量
|
||||
* @param integer $angle 文字倾斜角度
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function text($text, $font, $size, $color = '#00000000',
|
||||
$locate = THINKIMAGE_WATER_SOUTHEAST, $offset = 0, $angle = 0) {
|
||||
//资源检测
|
||||
if (empty($this->im)) {
|
||||
throw new \Exception('没有可以被写入文字的图像资源');
|
||||
throw new Exception('没有可以被写入文字的图像资源');
|
||||
}
|
||||
|
||||
if (!is_file($font)) {
|
||||
throw new \Exception("不存在的字体文件:{$font}");
|
||||
throw new Exception("不存在的字体文件:{$font}");
|
||||
}
|
||||
|
||||
//获取文字信息
|
||||
@@ -536,7 +572,7 @@ class Gd
|
||||
$x += $posx;
|
||||
$y += $posy;
|
||||
} else {
|
||||
throw new \Exception('不支持的文字位置类型');
|
||||
throw new Exception('不支持的文字位置类型');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,7 +593,7 @@ class Gd
|
||||
$color[3] = 0;
|
||||
}
|
||||
} elseif (!is_array($color)) {
|
||||
throw new \Exception('错误的颜色值');
|
||||
throw new Exception('错误的颜色值');
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\image\driver;
|
||||
|
||||
use think\image\driver\GIFDecoder as GIFDecoder;
|
||||
use think\image\driver\GIFEncoder as GIFEncoder;
|
||||
class Gif
|
||||
{
|
||||
/**
|
||||
@@ -44,7 +41,7 @@ class Gif
|
||||
$de = new GIFDecoder($src);
|
||||
$this->frames = $de->GIFGetFrames();
|
||||
$this->delays = $de->GIFGetDelays();
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("解码GIF图片出错");
|
||||
}
|
||||
}
|
||||
@@ -53,7 +50,7 @@ class Gif
|
||||
/**
|
||||
* 设置或获取当前帧的数据
|
||||
* @param string $stream 二进制数据流
|
||||
* @return boolean 获取到的数据
|
||||
* @return mixed 获取到的数据
|
||||
*/
|
||||
public function image($stream = null)
|
||||
{
|
||||
@@ -85,7 +82,6 @@ class Gif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::
|
||||
@@ -110,8 +106,7 @@ class Gif
|
||||
::
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
*/
|
||||
|
||||
class GIFEncoder
|
||||
class GIFEncode
|
||||
{
|
||||
public $GIF = "GIF89a"; /* GIF header 6 bytes */
|
||||
public $VER = "GIFEncoder V2.05"; /* Encoder version */
|
||||
@@ -139,14 +134,14 @@ class GIFEncoder
|
||||
$GIF_src, $GIF_dly, $GIF_lop, $GIF_dis,
|
||||
$GIF_red, $GIF_grn, $GIF_blu, $GIF_mod
|
||||
) {
|
||||
if (!is_array($GIF_src) && !is_array($GIF_tim)) {
|
||||
if (!is_array($GIF_src)) {
|
||||
printf("%s: %s", $this->VER, $this->ERR['ERR00']);
|
||||
exit(0);
|
||||
}
|
||||
$this->LOP = ($GIF_lop > -1) ? $GIF_lop : 0;
|
||||
$this->DIS = ($GIF_dis > -1) ? (($GIF_dis < 3) ? $GIF_dis : 3) : 2;
|
||||
$this->COL = ($GIF_red > -1 && $GIF_grn > -1 && $GIF_blu > -1) ?
|
||||
($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1;
|
||||
($GIF_red | ($GIF_grn << 8) | ($GIF_blu << 16)) : -1;
|
||||
|
||||
for ($i = 0; $i < count($GIF_src); $i++) {
|
||||
if (strToLower($GIF_mod) == "url") {
|
||||
@@ -163,23 +158,23 @@ class GIFEncoder
|
||||
}
|
||||
for ($j = (13 + 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07))), $k = true; $k; $j++) {
|
||||
switch ($this->BUF[$i]{ $j}) {
|
||||
case "!":
|
||||
if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") {
|
||||
printf("%s: %s ( %s source )!", $this->VER, $this->ERR['ERR03'], ($i + 1));
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
case ";":
|
||||
$k = false;
|
||||
break;
|
||||
case "!":
|
||||
if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") {
|
||||
printf("%s: %s ( %s source )!", $this->VER, $this->ERR['ERR03'], ($i + 1));
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
case ";":
|
||||
$k = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
GIFEncoder::GIFAddHeader();
|
||||
self::GIFAddHeader();
|
||||
for ($i = 0; $i < count($this->BUF); $i++) {
|
||||
GIFEncoder::GIFAddFrames($i, $GIF_dly[$i]);
|
||||
self::GIFAddFrames($i, $GIF_dly[$i]);
|
||||
}
|
||||
GIFEncoder::GIFAddFooter();
|
||||
self::GIFAddFooter();
|
||||
}
|
||||
/*
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
@@ -189,14 +184,13 @@ class GIFEncoder
|
||||
*/
|
||||
public function GIFAddHeader()
|
||||
{
|
||||
$cmap = 0;
|
||||
|
||||
if (ord($this->BUF[0]{10}) & 0x80) {
|
||||
$cmap = 3 * (2 << (ord($this->BUF[0]{10}) & 0x07));
|
||||
|
||||
$this->GIF .= substr($this->BUF[0], 6, 7);
|
||||
$this->GIF .= substr($this->BUF[0], 13, $cmap);
|
||||
$this->GIF .= "!\377\13NETSCAPE2.0\3\1" . GIFEncoder::GIFWord($this->LOP) . "\0";
|
||||
$this->GIF .= "!\377\13NETSCAPE2.0\3\1" . self::GIFWord($this->LOP) . "\0";
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -207,7 +201,7 @@ class GIFEncoder
|
||||
*/
|
||||
public function GIFAddFrames($i, $d)
|
||||
{
|
||||
|
||||
$Locals_img='';
|
||||
$Locals_str = 13 + 3 * (2 << (ord($this->BUF[$i]{10}) & 0x07));
|
||||
|
||||
$Locals_end = strlen($this->BUF[$i]) - $Locals_str - 1;
|
||||
@@ -217,12 +211,12 @@ class GIFEncoder
|
||||
$Locals_len = 2 << (ord($this->BUF[$i]{10}) & 0x07);
|
||||
|
||||
$Global_rgb = substr($this->BUF[0], 13,
|
||||
3 * (2 << (ord($this->BUF[0]{10}) & 0x07)));
|
||||
3 * (2 << (ord($this->BUF[0]{10}) & 0x07)));
|
||||
$Locals_rgb = substr($this->BUF[$i], 13,
|
||||
3 * (2 << (ord($this->BUF[$i]{10}) & 0x07)));
|
||||
3 * (2 << (ord($this->BUF[$i]{10}) & 0x07)));
|
||||
|
||||
$Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 0) .
|
||||
chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0";
|
||||
chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0";
|
||||
|
||||
if ($this->COL > -1 && ord($this->BUF[$i]{10}) & 0x80) {
|
||||
for ($j = 0; $j < (2 << (ord($this->BUF[$i]{10}) & 0x07)); $j++) {
|
||||
@@ -232,24 +226,27 @@ class GIFEncoder
|
||||
ord($Locals_rgb{3 * $j + 2}) == (($this->COL >> 0) & 0xFF)
|
||||
) {
|
||||
$Locals_ext = "!\xF9\x04" . chr(($this->DIS << 2) + 1) .
|
||||
chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0";
|
||||
chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ($Locals_tmp{0}) {
|
||||
case "!":
|
||||
$Locals_img = substr($Locals_tmp, 8, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
|
||||
break;
|
||||
case ",":
|
||||
$Locals_img = substr($Locals_tmp, 0, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
|
||||
break;
|
||||
case "!":
|
||||
/**
|
||||
* @var string $Locals_img;
|
||||
*/
|
||||
$Locals_img = substr($Locals_tmp, 8, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
|
||||
break;
|
||||
case ",":
|
||||
$Locals_img = substr($Locals_tmp, 0, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
|
||||
break;
|
||||
}
|
||||
if (ord($this->BUF[$i]{10}) & 0x80 && $this->IMG > -1) {
|
||||
if ($Global_len == $Locals_len) {
|
||||
if (GIFEncoder::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
|
||||
if (self::GIFBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
|
||||
$this->GIF .= ($Locals_ext . $Locals_img . $Locals_tmp);
|
||||
} else {
|
||||
$byte = ord($Locals_img{9});
|
||||
@@ -460,7 +457,6 @@ class GIFDecoder
|
||||
*/
|
||||
public function GIFReadDescriptor()
|
||||
{
|
||||
$GIF_screen = array();
|
||||
|
||||
GIFDecoder::GIFGetByte(9);
|
||||
$GIF_screen = $this->GIF_buffer;
|
||||
|
||||
@@ -38,7 +38,7 @@ class Baidu extends Driver
|
||||
* @param string $api 百度API
|
||||
* @param string $param 调用API的额外参数
|
||||
* @param string $method HTTP请求方法 默认为GET
|
||||
* @return json
|
||||
* @return array
|
||||
*/
|
||||
public function call($api, $param = '', $method = 'GET')
|
||||
{
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace think;
|
||||
class Parser
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array $handler
|
||||
*/
|
||||
private static $handler = [];
|
||||
|
||||
// 解析内容
|
||||
|
||||
@@ -34,10 +34,13 @@ class Validate
|
||||
|
||||
/**
|
||||
* 自动表单验证
|
||||
* @access protected
|
||||
* @access protected
|
||||
*
|
||||
* @param array $data 创建数据
|
||||
* @param string $type 创建类型
|
||||
* @return boolean
|
||||
* @param array $rule
|
||||
*
|
||||
* @return bool
|
||||
* @internal param string $type 创建类型
|
||||
*/
|
||||
public function valid($data, $rule = [])
|
||||
{
|
||||
@@ -96,7 +99,7 @@ class Validate
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,8 +66,9 @@ class App
|
||||
// 执行操作
|
||||
if (!preg_match('/^[A-Za-z](\/|\.|\w)*$/', CONTROLLER_NAME)) {
|
||||
// 安全检测
|
||||
$instance = false;
|
||||
} elseif ($config['action_bind_class']) {
|
||||
throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists');
|
||||
}
|
||||
if ($config['action_bind_class']) {
|
||||
$class = self::bindActionClass($config['empty_controller']);
|
||||
$instance = new $class;
|
||||
// 操作绑定到类后 固定执行run入口
|
||||
@@ -77,9 +78,6 @@ class App
|
||||
// 获取当前操作名
|
||||
$action = ACTION_NAME . $config['action_suffix'];
|
||||
}
|
||||
if (!$instance) {
|
||||
throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists');
|
||||
}
|
||||
|
||||
try {
|
||||
// 操作方法开始监听
|
||||
@@ -213,7 +211,10 @@ class App
|
||||
/**
|
||||
* URL调度
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
* @param $config
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function dispatch($config)
|
||||
{
|
||||
|
||||
54
library/think/behavior.php
Normal file
54
library/think/behavior.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think;
|
||||
/**
|
||||
* ThinkPHP Behavior基础类
|
||||
* @category Think
|
||||
* @package Think
|
||||
* @subpackage Core
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
abstract class Behavior {
|
||||
|
||||
// 行为参数 和配置参数设置相同
|
||||
protected $options = array();
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct() {
|
||||
if(!empty($this->options)) {
|
||||
foreach ($this->options as $name=>$val){
|
||||
if(NULL !== C($name)) { // 参数已设置 则覆盖行为参数
|
||||
$this->options[$name] = C($name);
|
||||
}else{ // 参数未设置 则传入默认值到配置
|
||||
C($name,$val);
|
||||
}
|
||||
}
|
||||
array_change_key_case($this->options);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取行为参数
|
||||
public function __get($name){
|
||||
return $this->options[strtolower($name)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行行为 run方法是Behavior唯一的接口
|
||||
* @access public
|
||||
* @param mixed $params 行为参数
|
||||
* @return void
|
||||
*/
|
||||
abstract public function run(&$params);
|
||||
|
||||
}
|
||||
14
library/think/cache/driver/apc.php
vendored
14
library/think/cache/driver/apc.php
vendored
@@ -28,7 +28,10 @@ class Apc
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -58,7 +61,7 @@ class Apc
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -89,11 +92,12 @@ class Apc
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
/**删除缓存
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
*
|
||||
* @return bool|\string[]
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -103,7 +107,7 @@ class Apc
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
12
library/think/cache/driver/memcache.php
vendored
12
library/think/cache/driver/memcache.php
vendored
@@ -72,7 +72,7 @@ class Memcache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -106,9 +106,11 @@ class Memcache
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param bool|false $ttl
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rm($name, $ttl = false)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ class Memcache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
6
library/think/cache/driver/redis.php
vendored
6
library/think/cache/driver/redis.php
vendored
@@ -67,7 +67,7 @@ class Redis
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -107,7 +107,7 @@ class Redis
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ class Redis
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
2
library/think/cache/driver/secache.php
vendored
2
library/think/cache/driver/secache.php
vendored
@@ -65,7 +65,7 @@ class Secache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
|
||||
24
library/think/cache/driver/simple.php
vendored
24
library/think/cache/driver/simple.php
vendored
@@ -26,6 +26,8 @@ class Simple
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
@@ -67,13 +69,15 @@ class Simple
|
||||
|
||||
/**
|
||||
* 写入缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return boolen
|
||||
* @access public
|
||||
*
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
*
|
||||
* @return bool
|
||||
* @internal param int $expire 有效时间 0为永久
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
public function set($name, $value)
|
||||
{
|
||||
$filename = $this->filename($name);
|
||||
// 缓存数据
|
||||
@@ -88,7 +92,7 @@ class Simple
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -97,9 +101,9 @@ class Simple
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @access public
|
||||
* @return bool
|
||||
* @internal param string $name 缓存变量名
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
9
library/think/cache/driver/sqlite.php
vendored
9
library/think/cache/driver/sqlite.php
vendored
@@ -31,7 +31,10 @@ class Sqlite
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -74,7 +77,7 @@ class Sqlite
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -103,7 +106,7 @@ class Sqlite
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -116,7 +119,7 @@ class Sqlite
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
9
library/think/cache/driver/wincache.php
vendored
9
library/think/cache/driver/wincache.php
vendored
@@ -28,7 +28,10 @@ class Wincache
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
*
|
||||
* @param array $options 缓存参数
|
||||
*
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
@@ -59,7 +62,7 @@ class Wincache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -95,7 +98,7 @@ class Wincache
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -105,7 +108,7 @@ class Wincache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
6
library/think/cache/driver/xcache.php
vendored
6
library/think/cache/driver/xcache.php
vendored
@@ -62,7 +62,7 @@ class Xcache
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $value 存储数据
|
||||
* @param integer $expire 有效时间(秒)
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function set($name, $value, $expire = null)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class Xcache
|
||||
* 删除缓存
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function rm($name)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ class Xcache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @return boolen
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ class Controller
|
||||
/**
|
||||
* 架构函数 初始化视图类 并采用内置模板引擎
|
||||
* @access public
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
@@ -63,8 +65,8 @@ class Controller
|
||||
$this->config[$key] = $config[$key];
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,9 +57,12 @@ abstract class rest
|
||||
/**
|
||||
* REST 调用
|
||||
* @access public
|
||||
*
|
||||
* @param string $method 方法名
|
||||
* @param array $args 参数
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function _empty($method, $args)
|
||||
{
|
||||
|
||||
@@ -51,17 +51,19 @@ class Cookie
|
||||
{
|
||||
if (empty($prefix)) {
|
||||
return self::$config['prefix'];
|
||||
} else {
|
||||
self::$config['prefix'] = $prefix;
|
||||
}
|
||||
self::$config['prefix'] = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie 设置、获取、删除
|
||||
* @param string $name cookie名称
|
||||
* @param mixed $value cookie值
|
||||
* @param mixed $options cookie参数
|
||||
*
|
||||
* @param string $name cookie名称
|
||||
* @param mixed $value cookie值
|
||||
* @param null $option
|
||||
*
|
||||
* @return mixed
|
||||
* @internal param mixed $options cookie参数
|
||||
*/
|
||||
public static function set($name, $value = '', $option = null)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,10 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 架构函数 读取数据库配置信息
|
||||
* @access public
|
||||
* @param array $config 数据库配置数组
|
||||
*
|
||||
* @param array|string $config 数据库配置数组
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($config = '')
|
||||
{
|
||||
@@ -45,11 +48,18 @@ class Mongo extends Driver
|
||||
$this->config['params'] = [];
|
||||
}
|
||||
}
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接数据库方法
|
||||
* @access public
|
||||
*
|
||||
* @param string $config
|
||||
* @param int $linkNum
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public function connect($config = '', $linkNum = 0)
|
||||
{
|
||||
@@ -71,10 +81,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 切换当前操作的Db和Collection
|
||||
* @access public
|
||||
* @param string $collection collection
|
||||
* @param string $db db
|
||||
* @param boolean $master 是否主服务器
|
||||
* @return void
|
||||
*
|
||||
* @param string $collection collection
|
||||
* @param string $db db
|
||||
* @param boolean $master 是否主服务器
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function switchCollection($collection, $db = '', $master = true)
|
||||
{
|
||||
@@ -137,9 +149,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 执行语句
|
||||
* @access public
|
||||
* @param string $code sql指令
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @param string $code sql指令
|
||||
* @param array $args 参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute($code, $args = [])
|
||||
{
|
||||
@@ -185,10 +200,13 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 插入记录
|
||||
* @access public
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 参数表达式
|
||||
*
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 参数表达式
|
||||
* @param boolean $replace 是否replace
|
||||
* @return false | integer
|
||||
*
|
||||
* @return false|int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insert($data, $options = [], $replace = false)
|
||||
{
|
||||
@@ -222,9 +240,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 插入多条记录
|
||||
* @access public
|
||||
*
|
||||
* @param array $dataList 数据
|
||||
* @param array $options 参数表达式
|
||||
* @param array $options 参数表达式
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insertAll($dataList, $options = [])
|
||||
{
|
||||
@@ -246,8 +267,11 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 生成下一条记录ID 用于自增非MongoId主键
|
||||
* @access public
|
||||
*
|
||||
* @param string $pk 主键名
|
||||
* @return integer
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getMongoNextId($pk)
|
||||
{
|
||||
@@ -268,9 +292,12 @@ class Mongo extends Driver
|
||||
/**
|
||||
* 更新记录
|
||||
* @access public
|
||||
* @param mixed $data 数据
|
||||
*
|
||||
* @param mixed $data 数据
|
||||
* @param array $options 表达式
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($data, $options)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,9 @@ class Mysql extends Driver
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
* @param $tableName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName)
|
||||
{
|
||||
@@ -68,6 +71,10 @@ class Mysql extends Driver
|
||||
/**
|
||||
* 取得数据库的表信息
|
||||
* @access public
|
||||
*
|
||||
* @param string $dbName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($dbName = '')
|
||||
{
|
||||
|
||||
@@ -94,6 +94,10 @@ class Oracle extends Driver
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
*
|
||||
* @param $tableName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName)
|
||||
{
|
||||
@@ -120,9 +124,11 @@ class Oracle extends Driver
|
||||
|
||||
/**
|
||||
* 取得数据库的表信息(暂时实现取得用户表信息)
|
||||
* @access public
|
||||
* @access public
|
||||
* @return array
|
||||
* @internal param string $dbName
|
||||
*/
|
||||
public function getTables($dbName = '')
|
||||
public function getTables()
|
||||
{
|
||||
$result = $this->query("select table_name from user_tables");
|
||||
$info = [];
|
||||
@@ -151,10 +157,11 @@ class Oracle extends Driver
|
||||
}
|
||||
return $limitStr ? ' WHERE ' . $limitStr : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锁机制
|
||||
* @access protected
|
||||
* @param bool|false $lock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function parseLock($lock = false)
|
||||
|
||||
@@ -332,6 +332,7 @@ class Lite
|
||||
* 并显示当前的SQL语句
|
||||
* @access public
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
|
||||
@@ -84,9 +84,11 @@ class Error
|
||||
|
||||
/**
|
||||
* 错误输出
|
||||
*
|
||||
* @param mixed $error 错误
|
||||
* @param int $errno 错误代码
|
||||
* @return void
|
||||
* @param int $code
|
||||
*
|
||||
* @internal param int $errno 错误代码
|
||||
*/
|
||||
public static function halt($error, $code = 1)
|
||||
{
|
||||
@@ -99,7 +101,8 @@ class Error
|
||||
$data['code'] = $code;
|
||||
$data['msg'] = $message;
|
||||
$data['time'] = NOW_TIME;
|
||||
exit(Response::returnData($data));
|
||||
Response::returnData($data);
|
||||
exit();
|
||||
}
|
||||
$e = [];
|
||||
if (APP_DEBUG) {
|
||||
|
||||
@@ -159,10 +159,16 @@ class Input
|
||||
|
||||
/**
|
||||
* 获取系统变量 支持过滤和默认值
|
||||
* @access public
|
||||
* @param string $method 输入数据类型
|
||||
* @param array $args 参数 [key,filter,default]
|
||||
* @access public
|
||||
*
|
||||
* @param $name
|
||||
* @param $input
|
||||
* @param $filter
|
||||
* @param $default
|
||||
*
|
||||
* @return mixed
|
||||
* @internal param string $method 输入数据类型
|
||||
* @internal param array $args 参数 [key,filter,default]
|
||||
*/
|
||||
private static function getData($name, $input, $filter, $default)
|
||||
{
|
||||
|
||||
@@ -229,12 +229,14 @@ class Loader
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得对象实例 支持调用类的静态方法
|
||||
* @param string $class 对象类名
|
||||
*
|
||||
* @param string $class 对象类名
|
||||
* @param string $method 类的静态方法名
|
||||
* @return object
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function instance($class, $method = '')
|
||||
{
|
||||
@@ -244,7 +246,7 @@ class Loader
|
||||
if (class_exists($class)) {
|
||||
$o = new $class();
|
||||
if (!empty($method) && method_exists($o, $method)) {
|
||||
$_instance[$identify] = call_user_func_array([ & $o, $method]);
|
||||
$_instance[$identify] = call_user_func_array([ & $o, $method],[]);
|
||||
} else {
|
||||
$_instance[$identify] = $o;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,12 @@ class Log
|
||||
|
||||
/**
|
||||
* 记录日志 并且会过滤未经设置的级别
|
||||
* @access public
|
||||
* @access public
|
||||
*
|
||||
* @param string $message 日志信息
|
||||
* @param string $level 日志级别
|
||||
* @param boolean $record 是否强制记录
|
||||
* @return void
|
||||
* @param string $level 日志级别
|
||||
*
|
||||
* @internal param bool $record 是否强制记录
|
||||
*/
|
||||
public static function record($message, $level = 'INFO')
|
||||
{
|
||||
|
||||
@@ -36,9 +36,12 @@ class MongoModel extends \Think\Model
|
||||
/**
|
||||
* 利用__call方法实现一些特殊的Model方法
|
||||
* @access public
|
||||
*
|
||||
* @param string $method 方法名称
|
||||
* @param array $args 调用参数
|
||||
* @param array $args 调用参数
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
@@ -54,7 +57,6 @@ class MongoModel extends \Think\Model
|
||||
return $this->where($where)->getField($args[1]);
|
||||
} else {
|
||||
throw new \think\Exception(__CLASS__ . ':' . $method . Lang::get('_METHOD_NOT_EXIST_'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,9 +179,12 @@ class Session
|
||||
|
||||
/**
|
||||
* 判断session数据
|
||||
*
|
||||
* @param string $name session名称
|
||||
* @param mixed $value session值
|
||||
* @return boolean
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return bool
|
||||
* @internal param mixed $value session值
|
||||
*/
|
||||
public static function has($name, $prefix = '')
|
||||
{
|
||||
|
||||
@@ -74,9 +74,14 @@ class TagLib
|
||||
|
||||
/**
|
||||
* TagLib标签属性分析 返回标签属性数组
|
||||
* @access public
|
||||
* @param string $tagStr 标签内容
|
||||
* @access public
|
||||
*
|
||||
* @param $attr
|
||||
* @param $tag
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @internal param string $tagStr 标签内容
|
||||
*/
|
||||
public function parseXmlAttr($attr, $tag)
|
||||
{
|
||||
@@ -92,25 +97,25 @@ class TagLib
|
||||
}
|
||||
$xml = (array) ($xml->tag->attributes());
|
||||
$array = array_change_key_case($xml['@attributes']);
|
||||
if ($array) {
|
||||
$tag = strtolower($tag);
|
||||
if (isset($this->tags[$tag]['attr'])) {
|
||||
$attrs = explode(',', $this->tags[$tag]['attr']);
|
||||
if (isset($this->tags[strtolower($tag)]['must'])) {
|
||||
$must = explode(',', $this->tags[$tag]['must']);
|
||||
} else {
|
||||
$must = [];
|
||||
}
|
||||
foreach ($attrs as $name) {
|
||||
if (isset($array[$name])) {
|
||||
$array[$name] = str_replace('___', '&', $array[$name]);
|
||||
} elseif (false !== array_search($name, $must)) {
|
||||
throw new Exception('_PARAM_ERROR_:' . $name);
|
||||
}
|
||||
if (!is_array($array)) return [];
|
||||
$tag = strtolower($tag);
|
||||
if (isset($this->tags[$tag]['attr'])) {
|
||||
$attrs = explode(',', $this->tags[$tag]['attr']);
|
||||
if (isset($this->tags[strtolower($tag)]['must'])) {
|
||||
$must = explode(',', $this->tags[$tag]['must']);
|
||||
} else {
|
||||
$must = [];
|
||||
}
|
||||
foreach ($attrs as $name) {
|
||||
if (isset($array[$name])) {
|
||||
$array[$name] = str_replace('___', '&', $array[$name]);
|
||||
} elseif (false !== array_search($name, $must)) {
|
||||
throw new Exception('_PARAM_ERROR_:' . $name);
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,10 +113,14 @@ class View
|
||||
/**
|
||||
* 解析和获取模板内容 用于输出
|
||||
* @access public
|
||||
*
|
||||
* @param string $template 模板文件名或者内容
|
||||
* @param array $vars 模板输出变量
|
||||
* @param string $cache_id 模板缓存标识
|
||||
* @param bool $renderContent
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fetch($template = '', $vars = [], $cache_id = '', $renderContent = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user