@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文件管理逻辑类 | * 文件管理逻辑类 | ||||
* | * | ||||
@@ -13,8 +13,7 @@ class FileManagement | |||||
{ | { | ||||
var $baseDir = ""; | var $baseDir = ""; | ||||
var $activeDir = ""; | var $activeDir = ""; | ||||
//是否允许文件管理器删除目录; | |||||
//默认为不允许 0 ,如果希望可能管理整个目录,请把值设为 1 ; | |||||
//是否允许文件管理器删除目录,默认为不允许0,如果希望可能管理整个目录,请把值设为1 | |||||
var $allowDeleteDir = 0; | var $allowDeleteDir = 0; | ||||
//初始化系统 | //初始化系统 | ||||
function Init() | function Init() | ||||
@@ -145,7 +145,7 @@ else if ($dopost == 'edituser') { | |||||
$uname = isset($uname)? HtmlReplace($uname,1) : ''; | $uname = isset($uname)? HtmlReplace($uname,1) : ''; | ||||
$spacesta = isset($spacesta)? HtmlReplace($spacesta,1) : ''; | $spacesta = isset($spacesta)? HtmlReplace($spacesta,1) : ''; | ||||
$exptime = isset($exptime)? HtmlReplace($exptime,1) : ''; | $exptime = isset($exptime)? HtmlReplace($exptime,1) : ''; | ||||
if (!isset($_POST['id'])) exit('dedebiz'); | |||||
if (!isset($_POST['id'])) exit ('dedebiz'); | |||||
$pwdsql = empty($pwd) ? '' : ",pwd='".md5($pwd)."'"; | $pwdsql = empty($pwd) ? '' : ",pwd='".md5($pwd)."'"; | ||||
if (function_exists('password_hash')) { | if (function_exists('password_hash')) { | ||||
$pwdsql = empty($pwd) ? '' : ",pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'"; | $pwdsql = empty($pwd) ? '' : ",pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'"; | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
/** | /** | ||||
* 用于地址跳转 | |||||
* 地址跳转 | |||||
* | * | ||||
* @version $id:jump.php$ | * @version $id:jump.php$ | ||||
* @package DedeBIZ.Site | * @package DedeBIZ.Site | ||||
@@ -68,7 +68,7 @@ function LoadTestDiv() { | |||||
newobj.style.top = posTop; | newobj.style.top = posTop; | ||||
newobj.style.left = posLeft; | newobj.style.left = posLeft; | ||||
document.body.appendChild(newobj); | document.body.appendChild(newobj); | ||||
} else{ | |||||
} else { | |||||
newobj.style.display = "block"; | newobj.style.display = "block"; | ||||
} | } | ||||
const formData = new FormData() | const formData = new FormData() | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文档类 | |||||
* 文档 | |||||
* | * | ||||
* @version $id:archives.class.php 4 15:13 2010年7月7日 tianya $ | * @version $id:archives.class.php 4 15:13 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 自由列表类 | |||||
* 自由列表 | |||||
* | * | ||||
* @version $id:freelist.class.php 3 15:15 2010年7月7日 tianya $ | * @version $id:freelist.class.php 3 15:15 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文档列表类 | |||||
* 文档列表 | |||||
* | * | ||||
* @version $id:listview.class.php 2 15:15 2010年7月7日 tianya $ | * @version $id:listview.class.php 2 15:15 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 视图类 | |||||
* 视图 | |||||
* | * | ||||
* @version $id:partview.class.php 14:17 2010年7月7日 tianya $ | * @version $id:partview.class.php 14:17 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 搜索视图类 | |||||
* 搜索视图 | |||||
* | * | ||||
* @version $id:searchview.class.php 15:26 2010年7月7日 tianya $ | * @version $id:searchview.class.php 15:26 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 自定义模型列表类 | |||||
* 自定义模型列表 | |||||
* | * | ||||
* @version $id:sglistview.class.php 15:48 2010年7月7日 tianya $ | * @version $id:sglistview.class.php 15:48 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 自定义模型视图类 | |||||
* 自定义模型视图 | |||||
* | * | ||||
* @version $id:sgpage.class.php 15:48 2010年7月7日 tianya $ | * @version $id:sgpage.class.php 15:48 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 专题视图类 | |||||
* 专题视图 | |||||
* | * | ||||
* @version $id:specview.class.php 18:17 2010年7月7日 tianya $ | * @version $id:specview.class.php 18:17 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 标签列表类 | |||||
* 标签列表 | |||||
* | * | ||||
* @version $id:taglist.class.php 18:17 2010年7月7日 tianya $ | * @version $id:taglist.class.php 18:17 2010年7月7日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* @version $id:autoload.inc.php 17:44 2020-09-22 tianya $ | * @version $id:autoload.inc.php 17:44 2020-09-22 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -27,7 +27,7 @@ function __autoload($classname) | |||||
echo '</pre>'; | echo '</pre>'; | ||||
exit (); | exit (); | ||||
} else { | } else { | ||||
header ( "location:/404.html" ); | |||||
header ("location:/404.html"); | |||||
die (); | die (); | ||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* @version $id:autoload7.inc.php 17:44 2020-09-22 tianya $ | * @version $id:autoload7.inc.php 17:44 2020-09-22 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -27,7 +27,7 @@ function dede_autoloader($classname) | |||||
echo '</pre>'; | echo '</pre>'; | ||||
exit (); | exit (); | ||||
} else { | } else { | ||||
header ( "location:/404.html" ); | |||||
header ("location:/404.html"); | |||||
die (); | die (); | ||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 栏目模型 | * 栏目模型 | ||||
* | * | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 栏目小助手 | |||||
* 栏目助手 | |||||
* | * | ||||
* @version $id:channelunit.func.php 2 16:46 2010年7月6日 tianya $ | * @version $id:channelunit.func.php 2 16:46 2010年7月6日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 字符编码转换 | * 字符编码转换 | ||||
* | * | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 系统核心函数存放文件 | |||||
* 系统核心函数存放 | |||||
* | * | ||||
* @version $id:common.func.php 4 16:39 2010年7月6日 tianya $ | * @version $id:common.func.php 4 16:39 2010年7月6日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -230,7 +230,7 @@ if (!function_exists('CheckSql')) { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 载入小助手,系统默认载入小助手示例 | |||||
* 载入助手,系统默认载入助手示例 | |||||
* <code> | * <code> | ||||
* if (!function_exists('HelloDede')) | * if (!function_exists('HelloDede')) | ||||
* { | * { | ||||
@@ -240,10 +240,10 @@ if (!function_exists('CheckSql')) { | |||||
* } | * } | ||||
* } | * } | ||||
* </code> | * </code> | ||||
* 开发中使用这个小助手的时候直接使用函数helper('test');初始化它,然后在文件中就可以直接使用:HelloDede();调用 | |||||
* 开发中使用这个助手的时候直接使用函数helper('test');初始化它,然后在文件中就可以直接使用:HelloDede();调用 | |||||
* | * | ||||
* @access public | * @access public | ||||
* @param mix $helpers 小助手名称,可以是数组,可以是单个字符串 | |||||
* @param mix $helpers 助手名称,可以是数组,可以是单个字符串 | |||||
* @return void | * @return void | ||||
*/ | */ | ||||
$_helpers = array(); | $_helpers = array(); | ||||
@@ -263,7 +263,7 @@ function helper($helpers) | |||||
include_once(DEDEINC.'/helpers/'.$helpers.'.helper.php'); | include_once(DEDEINC.'/helpers/'.$helpers.'.helper.php'); | ||||
$_helpers[$helpers] = TRUE; | $_helpers[$helpers] = TRUE; | ||||
} | } | ||||
//无法载入小助手 | |||||
//无法载入助手 | |||||
if (!isset($_helpers[$helpers])) { | if (!isset($_helpers[$helpers])) { | ||||
exit('Unable to load the requested file: helpers/'.$helpers.'.helper.php'); | exit('Unable to load the requested file: helpers/'.$helpers.'.helper.php'); | ||||
} | } | ||||
@@ -276,7 +276,7 @@ function dede_htmlspecialchars($str) | |||||
else return htmlspecialchars($str); | else return htmlspecialchars($str); | ||||
} | } | ||||
/** | /** | ||||
* 载入小助手,这里会员可能载入用helps载入多个小助手 | |||||
* 载入助手,这里会员可能载入用helps载入多个助手 | |||||
* | * | ||||
* @access public | * @access public | ||||
* @param string | * @param string | ||||
@@ -263,23 +263,23 @@ if ($GLOBALS['cfg_dbtype'] == 'mysql' || $GLOBALS['cfg_dbtype'] == 'mysqli') { | |||||
} else { | } else { | ||||
require_once(DEDEINC.'/database/dedesqlite.class.php'); | require_once(DEDEINC.'/database/dedesqlite.class.php'); | ||||
} | } | ||||
//载入小助手配置,并对其进行默认初始化 | |||||
//载入助手配置,并对其进行默认初始化 | |||||
$cfg_helper_autoload = array( | $cfg_helper_autoload = array( | ||||
'charset', /* 编码小助手 */ | |||||
'channelunit',/* 模型单元小助手 */ | |||||
'string', /* 字符串小助手 */ | |||||
'time', /* 日期小助手 */ | |||||
'file', /* 文件小助手 */ | |||||
'util', /* 单元小助手 */ | |||||
'validate', /* 数据验证小助手 */ | |||||
'filter', /* 过滤器小助手 */ | |||||
'cookie', /* cookies小助手 */ | |||||
'debug', /* 调试小助手 */ | |||||
'archive', /* 文档小助手 */ | |||||
'upload', /* 上传小助手 */ | |||||
'extend', /* 扩展小助手 */ | |||||
'code', /* 代码小助手 */ | |||||
'charset', /* 编码助手 */ | |||||
'channelunit',/* 模型单元助手 */ | |||||
'string', /* 字符串助手 */ | |||||
'time', /* 日期助手 */ | |||||
'file', /* 文件助手 */ | |||||
'util', /* 单元助手 */ | |||||
'validate', /* 数据验证助手 */ | |||||
'filter', /* 过滤器助手 */ | |||||
'cookie', /* cookies助手 */ | |||||
'debug', /* 调试助手 */ | |||||
'archive', /* 文档助手 */ | |||||
'upload', /* 上传助手 */ | |||||
'extend', /* 扩展助手 */ | |||||
'code', /* 代码助手 */ | |||||
); | ); | ||||
//初始化小助手 | |||||
//初始化助手 | |||||
helper($cfg_helper_autoload); | helper($cfg_helper_autoload); | ||||
?> | ?> |
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 系统核心函数 | * 系统核心函数 | ||||
* @version $id:customfields.func.php 2 20:50 2010年7月7日 tianya $ | * @version $id:customfields.func.php 2 20:50 2010年7月7日 tianya $ | ||||
@@ -1,8 +1,8 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 系统底层数据库核心类 | |||||
* 调用这个类前,请先设定这些外部变量 | |||||
* 系统底层数据库核心,调用这个类前,请先设定这些外部变量 | |||||
* | |||||
* $GLOBALS['cfg_dbhost']; | * $GLOBALS['cfg_dbhost']; | ||||
* $GLOBALS['cfg_dbuser']; | * $GLOBALS['cfg_dbuser']; | ||||
* $GLOBALS['cfg_dbpwd']; | * $GLOBALS['cfg_dbpwd']; | ||||
@@ -1,8 +1,8 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 系统底层数据库核心类 | |||||
* 调用这个类前,请先设定这些外部变量 | |||||
* 系统底层数据库核心,调用这个类前,请先设定这些外部变量 | |||||
* | |||||
* $GLOBALS['cfg_dbhost']; | * $GLOBALS['cfg_dbhost']; | ||||
* $GLOBALS['cfg_dbuser']; | * $GLOBALS['cfg_dbuser']; | ||||
* $GLOBALS['cfg_dbpwd']; | * $GLOBALS['cfg_dbpwd']; | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 动态分页 | * 动态分页 | ||||
* | * | ||||
@@ -99,7 +99,7 @@ class DedeAttParse | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 解析属性(私有成员,仅给SetSource调用) | |||||
* 解析属性,私有成员,仅给SetSource调用 | |||||
* | * | ||||
* @access private | * @access private | ||||
* @return void | * @return void | ||||
@@ -113,9 +113,7 @@ class DedeAttParse | |||||
$ddtag = ""; | $ddtag = ""; | ||||
$notAttribute = TRUE; | $notAttribute = TRUE; | ||||
$strLen = strlen($this->SourceString); | $strLen = strlen($this->SourceString); | ||||
//这里是获得Tag的名称,可视情况是否需要 | |||||
//如果不在这个里解析,则在解析整个Tag时解析 | |||||
//属性中不应该存在tagname这个名称 | |||||
//这里是获得Tag的名称,可视情况是否需要,如果不在这个里解析,则在解析整个Tag时解析,属性中不应该存在tagname这个名称 | |||||
for ($i = 0; $i < $strLen; $i++) { | for ($i = 0; $i < $strLen; $i++) { | ||||
$d = substr($this->SourceString, $i, 1); | $d = substr($this->SourceString, $i, 1); | ||||
if ($d == ' ') { | if ($d == ' ') { | ||||
@@ -155,7 +153,6 @@ class DedeAttParse | |||||
} else if ($startdd == 0) { | } else if ($startdd == 0) { | ||||
switch ($d) { | switch ($d) { | ||||
case ' ': | case ' ': | ||||
//continue; | |||||
break; | break; | ||||
case '\'': | case '\'': | ||||
$ddtag = '\''; | $ddtag = '\''; | ||||
@@ -174,7 +171,7 @@ class DedeAttParse | |||||
} else if ($startdd == 1) { | } else if ($startdd == 1) { | ||||
if ($d == $ddtag) { | if ($d == $ddtag) { | ||||
$this->CAtt->Count++; | $this->CAtt->Count++; | ||||
$this->CAtt->Items[$tmpatt] = trim($tmpvalue); //strtolower(trim($tmpvalue)); | |||||
$this->CAtt->Items[$tmpatt] = trim($tmpvalue); | |||||
$tmpatt = ""; | $tmpatt = ""; | ||||
$tmpvalue = ""; | $tmpvalue = ""; | ||||
$startdd = -1; | $startdd = -1; | ||||
@@ -185,10 +182,9 @@ class DedeAttParse | |||||
} | } | ||||
if ($tmpatt != "") { | if ($tmpatt != "") { | ||||
$this->CAtt->Count++; | $this->CAtt->Count++; | ||||
$this->CAtt->Items[$tmpatt] = trim($tmpvalue); //strtolower(trim($tmpvalue)); | |||||
} //完成属性解析 | |||||
} //for | |||||
} //has Attribute | |||||
}//End DedeAttParse | |||||
$this->CAtt->Items[$tmpatt] = trim($tmpvalue); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
?> | ?> |
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 采集小助手 | |||||
* 采集助手 | |||||
* | * | ||||
* @version $id:charset.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:charset.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 模块插件 | * 模块插件 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 模板主题 | * 模板主题 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 模板主题引擎 | * 模板主题引擎 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 投票 | * 投票 | ||||
* | * | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 自定义表单解析 | |||||
* 自定义表单 | |||||
* | * | ||||
* @version $id:diyform.class.php 10:31 2010年7月6日 tianya $ | * @version $id:diyform.class.php 10:31 2010年7月6日 tianya $ | ||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 防采集混淆字符串 | * 防采集混淆字符串 | ||||
* | * | ||||
@@ -9,6 +9,6 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
* @license https://www.dedebiz.com/license | * @license https://www.dedebiz.com/license | ||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
//仅作一个映射,开发直接采用helper('downmix');进行调用 | |||||
//仅作一个映射,开发直接采用helper('downmix');调用 | |||||
helper('downmix'); | helper('downmix'); | ||||
?> | ?> |
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 联动菜单 | * 联动菜单 | ||||
* | * | ||||
@@ -1,4 +1,4 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
//这里扩展自己的函数 | //这里扩展自己的函数 | ||||
?> | ?> |
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 过滤核心处理 | * 过滤核心处理 | ||||
* | * | ||||
@@ -35,7 +35,7 @@ function _FilterAll($fk, &$svar) | |||||
} | } | ||||
return $svar; | return $svar; | ||||
} | } | ||||
/* 对_GET,_POST,_COOKIE进行过滤 */ | |||||
//对_GET,_POST,_COOKIE进行过滤 | |||||
foreach (array('_GET', '_POST', '_COOKIE') as $_request) { | foreach (array('_GET', '_POST', '_COOKIE') as $_request) { | ||||
foreach ($$_request as $_k => $_v) { | foreach ($$_request as $_k => $_v) { | ||||
${$_k} = _FilterAll($_k, $_v); | ${$_k} = _FilterAll($_k, $_v); | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文档小助手 | |||||
* 文档助手 | |||||
* | * | ||||
* @version $id:archive.helper.php 2 23:00 2010年7月5日 tianya $ | * @version $id:archive.helper.php 2 23:00 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 缓存小助手,支持文件和dedebiz cache | |||||
* 缓存助手,支持文件和dedebiz cache | |||||
* | * | ||||
* @version $id:cache.helper.php 10:46 2011-3-2 tianya $ | * @version $id:cache.helper.php 10:46 2011-3-2 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文档小助手 | |||||
* 文档助手 | |||||
* | * | ||||
* @version $id:channelunit.helper.php 16:49 2010年7月6日 tianya $ | * @version $id:channelunit.helper.php 16:49 2010年7月6日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -29,10 +29,7 @@ if (!function_exists('GetRankStar')) { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 获得文档网址 | |||||
* 如果要获得文件的路径,直接用 | |||||
* GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money) | |||||
* 即是不指定站点参数则返回相当对根目录的真实路径 | |||||
* 获得文档网址,如果要获得文件的路径,直接用GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money)即是不指定站点参数则返回相当对根目录的真实路径 | |||||
* | * | ||||
* @param int $aid 文档id | * @param int $aid 文档id | ||||
* @param int $typeid 栏目id | * @param int $typeid 栏目id | ||||
@@ -83,7 +80,7 @@ if (!function_exists('GetFileUrl')) { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 获得新文件名(本函数会自动创建目录) | |||||
* 获得新文件名,本函数会自动创建目录 | |||||
* | * | ||||
* @param int $aid 文档id | * @param int $aid 文档id | ||||
* @param int $typeid 栏目id | * @param int $typeid 栏目id | ||||
@@ -122,7 +119,7 @@ if (!function_exists('GetFileNewName')) { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 获得文件相对于主站点根目录的物理文件名(动态网址返回url) | |||||
* 获得文件相对于主站点根目录的物理文件名,动态网址返回url | |||||
* | * | ||||
* @param int $aid 文档id | * @param int $aid 文档id | ||||
* @param int $typeid 栏目id | * @param int $typeid 栏目id | ||||
@@ -184,8 +181,7 @@ if (!function_exists('GetFileName')) { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 获得指定栏目链接 | |||||
* 对于使用封面文件和单独页面的情况,强制使用默认页名称 | |||||
* 获得指定栏目链接,对于使用封面文件和单独页面的情况,强制使用默认页名称 | |||||
* | * | ||||
* @param int $typeid 栏目id | * @param int $typeid 栏目id | ||||
* @param string $typedir 栏目目录 | * @param string $typedir 栏目目录 | ||||
@@ -208,7 +204,7 @@ if (!function_exists('GetTypeUrl')) { | |||||
if ($isdefault==-1) { | if ($isdefault==-1) { | ||||
//动态 | //动态 | ||||
if ($cfg_rewrite == 'Y') { | if ($cfg_rewrite == 'Y') { | ||||
//网页版return $GLOBALS['cfg_cmspath']."/list-".$typeid.".html"; | |||||
//网页版,栏目形式:域名/list-1.html、域名/list-2.html,分页形式:域名/list-1-1.html、域名/list-1-2.htmlreturn $GLOBALS['cfg_cmspath']."/list-".$typeid.".html"; | |||||
//目录版默认,栏目形式:域名/list-1、域名/list-2,分页形式:域名/list-1-1、域名/list-1-2 | //目录版默认,栏目形式:域名/list-1、域名/list-2,分页形式:域名/list-1-1、域名/list-1-2 | ||||
return $GLOBALS['cfg_cmspath']."/list-".$typeid.""; | return $GLOBALS['cfg_cmspath']."/list-".$typeid.""; | ||||
} else { | } else { | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* DedeBIZ中用到的字符编码转换的小助手函数 | |||||
* DedeBIZ中字符编码转换助手 | |||||
* | * | ||||
* @version $id:charset.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:charset.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -12,7 +12,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
$UC2GBTABLE = $CODETABLE = $BIG5_DATA = $GB_DATA = ''; | $UC2GBTABLE = $CODETABLE = $BIG5_DATA = $GB_DATA = ''; | ||||
$GbkUniDic = null; | $GbkUniDic = null; | ||||
/** | /** | ||||
* UTF-8 转GB编码 | |||||
* UTF-8转GB编码 | |||||
* | * | ||||
* @access public | * @access public | ||||
* @param string $utfstr 需要转换的字符串 | * @param string $utfstr 需要转换的字符串 | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
//允许的函数 | //允许的函数 | ||||
$GLOBALS['allowedCalls'] = array( | $GLOBALS['allowedCalls'] = array( | ||||
//系统 | //系统 | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* Cookie处理小助手 | |||||
* Cookie处理助手 | |||||
* | * | ||||
* @version $id:file.helper.php 13:58 2010年7月5日 tianya $ | * @version $id:file.helper.php 13:58 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 验证小助手 | |||||
* 验证助手 | |||||
* | * | ||||
* @version $id:validate.helper.php 2 13:56 2010年7月5日 tianya $ | * @version $id:validate.helper.php 2 13:56 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -10,7 +10,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
/** | /** | ||||
* 浏览器友好的变量输出,便于调试时候使用 | |||||
* 浏览器友好的变量输出,便于调试时候使用 | |||||
* | * | ||||
* @param mixed $var 要输出查看的文档 | * @param mixed $var 要输出查看的文档 | ||||
* @param bool $echo 是否直接输出 | * @param bool $echo 是否直接输出 | ||||
@@ -1,4 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 防采集混淆字符串 | * 防采集混淆字符串 | ||||
* | * | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 扩展小助手 | |||||
* 扩展助手 | |||||
* | * | ||||
* @version $id:extend.helper.php 13:58 2010年7月5日 tianya $ | * @version $id:extend.helper.php 13:58 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 文件处理小助手 | |||||
* 文件处理助手 | |||||
* | * | ||||
* @version $id:file.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:file.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 过滤小助手 | |||||
* 过滤助手 | |||||
* | * | ||||
* @version $id:filter.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:filter.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,6 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once DEDEINC."/libraries/imageresize.class.php"; | require_once DEDEINC."/libraries/imageresize.class.php"; | ||||
/** | /** | ||||
* 图像处理相关函数 | * 图像处理相关函数 | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 字符串小助手 | |||||
* 字符串助手 | |||||
* | * | ||||
* @version $id:string.helper.php 5 14:24 2010年7月5日 tianya $ | * @version $id:string.helper.php 5 14:24 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -12,8 +12,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
//拼音的缓冲数组 | //拼音的缓冲数组 | ||||
$pinyins = array(); | $pinyins = array(); | ||||
/** | /** | ||||
* 中文截取2,单字节截取模式 | |||||
* 如果是request的文档,必须使用这个函数 | |||||
* 中文截取2,单字节截取模式,如果是request的文档,必须使用这个函数 | |||||
* | * | ||||
* @access public | * @access public | ||||
* @param string $str 需要截取的字符串 | * @param string $str 需要截取的字符串 | ||||
@@ -1,8 +1,6 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 仅用于测试 | |||||
* | |||||
* @version $id:test.helper.php 5 15:01 2010年7月5日 tianya $ | * @version $id:test.helper.php 5 15:01 2010年7月5日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
* @copyright Copyright (c) 2022 DedeBIZ.COM | * @copyright Copyright (c) 2022 DedeBIZ.COM | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 时间戳小助手 | |||||
* 时间戳助手 | |||||
* | * | ||||
* @version $id:time.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:time.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 上传处理小助手 | |||||
* 上传处理助手 | |||||
* | * | ||||
* @version $id:upload.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:upload.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 核心小助手 | |||||
* 核心助手 | |||||
* | * | ||||
* @version $id:util.helper.php 4 19:20 2010年7月6日 tianya $ | * @version $id:util.helper.php 4 19:20 2010年7月6日 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 验证小助手 | |||||
* 验证助手 | |||||
* | * | ||||
* @version $id:validate.helper.php 2010-07-05 11:43:09 tianya $ | * @version $id:validate.helper.php 2010-07-05 11:43:09 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 图像处理 | * 图像处理 | ||||
* | * | ||||
@@ -12,7 +12,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
class image | class image | ||||
{ | { | ||||
var $attachinfo; | var $attachinfo; | ||||
var $targetfile; //图片路径 | |||||
var $targetfile; //图片路径 | |||||
var $imagecreatefromfunc; | var $imagecreatefromfunc; | ||||
var $imagefunc; | var $imagefunc; | ||||
var $attach; | var $attach; | ||||
@@ -21,7 +21,7 @@ class image | |||||
var $watermarktext; | var $watermarktext; | ||||
var $thumbstatus; | var $thumbstatus; | ||||
var $watermarkstatus; | var $watermarkstatus; | ||||
//析构函数,兼容PHP4 | |||||
//析构函数,兼容PHP4 | |||||
function image($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans, $trueMarkimg, $attach = array()) | function image($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans, $trueMarkimg, $attach = array()) | ||||
{ | { | ||||
$this->__construct($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans, $trueMarkimg, $attach); | $this->__construct($targetfile, $cfg_thumb, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $cfg_watermarktype, $photo_marktrans, $trueMarkimg, $attach); | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 图像处理相关函数 | * 图像处理相关函数 | ||||
* | * | ||||
@@ -52,6 +52,6 @@ if (function_exists("imagecreatefromwebp") && function_exists("imagewebp")) { | |||||
$cfg_photo_typenames[] = "image/webp"; | $cfg_photo_typenames[] = "image/webp"; | ||||
$cfg_photo_support .= "WEBP "; | $cfg_photo_support .= "WEBP "; | ||||
} | } | ||||
//引入图像处理小助手 | |||||
//引入图像处理助手 | |||||
helper('image'); | helper('image'); | ||||
?> | ?> |
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 管理员后台基本函数 | * 管理员后台基本函数 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
function SpHtml2Text($str) | function SpHtml2Text($str) | ||||
{ | { | ||||
$str = preg_replace("/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU","",$str); | $str = preg_replace("/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU","",$str); | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once(DEDEINC."/libraries/crawlerdetect.class.php"); | require_once(DEDEINC."/libraries/crawlerdetect.class.php"); | ||||
require_once(DEDEINC."/libraries/mobiledetect.class.php"); | require_once(DEDEINC."/libraries/mobiledetect.class.php"); | ||||
//copyright https://github.com/jenssegers/agent | //copyright https://github.com/jenssegers/agent | ||||
@@ -1,17 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
//Copyright 2020 The DedeBiz Authors. All rights reserved. | |||||
//license that can be found in the LICENSE file. | |||||
//@copyright Copyright (c) 2022 DedeBIZ.COM | |||||
//@license https://www.dedebiz.com/license | |||||
//@link https://www.dedebiz.com | |||||
/* | |||||
The MIT License (MIT) | |||||
Copyright (c) 2014-2019 British Columbia Institute of Technology | |||||
Copyright (c) 2019-2020 CodeIgniter Foundation | |||||
*/ | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
function is_cli() | function is_cli() | ||||
{ | { | ||||
return (PHP_SAPI === 'cli' || defined('STDIN')); | return (PHP_SAPI === 'cli' || defined('STDIN')); | ||||
@@ -54,8 +42,7 @@ class DedeCli | |||||
]; | ]; | ||||
public static function init() | public static function init() | ||||
{ | { | ||||
if (is_cli()) | |||||
{ | |||||
if (is_cli()) { | |||||
static::$readline_support = extension_loaded('readline'); | static::$readline_support = extension_loaded('readline'); | ||||
static::parseCommandLine(); | static::parseCommandLine(); | ||||
static::$initialized = true; | static::$initialized = true; | ||||
@@ -66,22 +53,18 @@ class DedeCli | |||||
private static function parseCommandLine() | private static function parseCommandLine() | ||||
{ | { | ||||
$optionsFound = false; | $optionsFound = false; | ||||
for ($i=1; $i < $_SERVER['argc']; $i++) | |||||
{ | |||||
if (! $optionsFound && strpos($_SERVER['argv'][$i], '-') === false) | |||||
{ | |||||
for ($i=1; $i < $_SERVER['argc']; $i++) { | |||||
if (! $optionsFound && strpos($_SERVER['argv'][$i], '-') === false) { | |||||
static::$segments[] = $_SERVER['argv'][$i]; | static::$segments[] = $_SERVER['argv'][$i]; | ||||
continue; | continue; | ||||
} | } | ||||
$optionsFound = true; | $optionsFound = true; | ||||
if (substr($_SERVER['argv'][$i], 0, 1) != '-') | |||||
{ | |||||
if (substr($_SERVER['argv'][$i], 0, 1) != '-') { | |||||
continue; | continue; | ||||
} | } | ||||
$arg = str_replace('-', '', $_SERVER['argv'][$i]); | $arg = str_replace('-', '', $_SERVER['argv'][$i]); | ||||
$value = null; | $value = null; | ||||
if (isset($_SERVER['argv'][$i+1]) && substr($_SERVER['argv'][$i+1], 0, 1) != '-') | |||||
{ | |||||
if (isset($_SERVER['argv'][$i+1]) && substr($_SERVER['argv'][$i+1], 0, 1) != '-') { | |||||
$value = $_SERVER['argv'][$i+1]; | $value = $_SERVER['argv'][$i+1]; | ||||
$i++; | $i++; | ||||
} | } | ||||
@@ -92,8 +75,7 @@ class DedeCli | |||||
} | } | ||||
public static function getOption(string $name) | public static function getOption(string $name) | ||||
{ | { | ||||
if (! array_key_exists($name, static::$options)) | |||||
{ | |||||
if (! array_key_exists($name, static::$options)) { | |||||
return null; | return null; | ||||
} | } | ||||
$val = static::$options[$name] === null | $val = static::$options[$name] === null | ||||
@@ -107,15 +89,13 @@ class DedeCli | |||||
} | } | ||||
public static function getOptionString(): string | public static function getOptionString(): string | ||||
{ | { | ||||
if (! count(static::$options)) | |||||
{ | |||||
if (! count(static::$options)) { | |||||
return ''; | return ''; | ||||
} | } | ||||
$out = ''; | $out = ''; | ||||
foreach (static::$options as $name => $value) | foreach (static::$options as $name => $value) | ||||
{ | { | ||||
if (mb_strpos($value, ' ') !== false) | |||||
{ | |||||
if (mb_strpos($value, ' ') !== false) { | |||||
$value = '"'.$value.'"'; | $value = '"'.$value.'"'; | ||||
} | } | ||||
$out .= "-{$name} $value "; | $out .= "-{$name} $value "; | ||||
@@ -124,8 +104,7 @@ class DedeCli | |||||
} | } | ||||
public static function newLine(int $num = 1) | public static function newLine(int $num = 1) | ||||
{ | { | ||||
for ($i = 0; $i < $num; $i++) | |||||
{ | |||||
for ($i = 0; $i < $num; $i++) { | |||||
static::write(''); | static::write(''); | ||||
} | } | ||||
} | } | ||||
@@ -135,25 +114,20 @@ class DedeCli | |||||
} | } | ||||
public static function color(string $text, string $foreground, string $background = null, string $format = null) | public static function color(string $text, string $foreground, string $background = null, string $format = null) | ||||
{ | { | ||||
if (static::isWindows() && ! isset($_SERVER['ANSICON'])) | |||||
{ | |||||
if (static::isWindows() && ! isset($_SERVER['ANSICON'])) { | |||||
return $text; | return $text; | ||||
} | } | ||||
if ( ! array_key_exists($foreground, static::$foreground_colors)) | |||||
{ | |||||
if ( ! array_key_exists($foreground, static::$foreground_colors)) { | |||||
throw new \RuntimeException('Invalid CLI foreground color: '.$foreground); | throw new \RuntimeException('Invalid CLI foreground color: '.$foreground); | ||||
} | } | ||||
if ($background !== null && ! array_key_exists($background, static::$background_colors)) | |||||
{ | |||||
if ($background !== null && ! array_key_exists($background, static::$background_colors)) { | |||||
throw new \RuntimeException('Invalid CLI background color: '.$background); | throw new \RuntimeException('Invalid CLI background color: '.$background); | ||||
} | } | ||||
$string = "\033[".static::$foreground_colors[$foreground]."m"; | $string = "\033[".static::$foreground_colors[$foreground]."m"; | ||||
if ($background !== null) | |||||
{ | |||||
if ($background !== null) { | |||||
$string .= "\033[".static::$background_colors[$background]."m"; | $string .= "\033[".static::$background_colors[$background]."m"; | ||||
} | } | ||||
if ($format === 'underline') | |||||
{ | |||||
if ($format === 'underline') { | |||||
$string .= "\033[4m"; | $string .= "\033[4m"; | ||||
} | } | ||||
$string .= $text."\033[0m"; | $string .= $text."\033[0m"; | ||||
@@ -161,16 +135,14 @@ class DedeCli | |||||
} | } | ||||
public static function getWidth(int $default = 80): int | public static function getWidth(int $default = 80): int | ||||
{ | { | ||||
if (static::isWindows()) | |||||
{ | |||||
if (static::isWindows()) { | |||||
return $default; | return $default; | ||||
} | } | ||||
return (int)shell_exec('tput cols'); | return (int)shell_exec('tput cols'); | ||||
} | } | ||||
public static function getHeight(int $default = 32): int | public static function getHeight(int $default = 32): int | ||||
{ | { | ||||
if (static::isWindows()) | |||||
{ | |||||
if (static::isWindows()) { | |||||
return $default; | return $default; | ||||
} | } | ||||
return (int)shell_exec('tput lines'); | return (int)shell_exec('tput lines'); | ||||
@@ -178,13 +150,11 @@ class DedeCli | |||||
public static function showProgress($thisStep = 1, int $totalSteps = 10, int $pos = 0,int $total = 0) | public static function showProgress($thisStep = 1, int $totalSteps = 10, int $pos = 0,int $total = 0) | ||||
{ | { | ||||
static $inProgress = false; | static $inProgress = false; | ||||
if ($inProgress !== false && $inProgress <= $thisStep) | |||||
{ | |||||
if ($inProgress !== false && $inProgress <= $thisStep) { | |||||
fwrite(STDOUT, "\033[1A"); | fwrite(STDOUT, "\033[1A"); | ||||
} | } | ||||
$inProgress = $thisStep; | $inProgress = $thisStep; | ||||
if ($thisStep !== false) | |||||
{ | |||||
if ($thisStep !== false) { | |||||
$thisStep = abs($thisStep); | $thisStep = abs($thisStep); | ||||
$totalSteps = $totalSteps < 1 ? 1 : $totalSteps; | $totalSteps = $totalSteps < 1 ? 1 : $totalSteps; | ||||
$percent = intval(($thisStep / $totalSteps) * 100); | $percent = intval(($thisStep / $totalSteps) * 100); | ||||
@@ -201,28 +171,23 @@ class DedeCli | |||||
} | } | ||||
public static function wrap(string $string = null, int $max = 0, int $pad_left = 0): string | public static function wrap(string $string = null, int $max = 0, int $pad_left = 0): string | ||||
{ | { | ||||
if (empty($string)) | |||||
{ | |||||
if (empty($string)) { | |||||
return ''; | return ''; | ||||
} | } | ||||
if ($max == 0) | |||||
{ | |||||
if ($max == 0) { | |||||
$max = DedeCli::getWidth(); | $max = DedeCli::getWidth(); | ||||
} | } | ||||
if (DedeCli::getWidth() < $max) | |||||
{ | |||||
if (DedeCli::getWidth() < $max) { | |||||
$max = DedeCli::getWidth(); | $max = DedeCli::getWidth(); | ||||
} | } | ||||
$max = $max - $pad_left; | $max = $max - $pad_left; | ||||
$lines = wordwrap($string, $max); | $lines = wordwrap($string, $max); | ||||
if ($pad_left > 0) | |||||
{ | |||||
if ($pad_left > 0) { | |||||
$lines = explode(PHP_EOL, $lines); | $lines = explode(PHP_EOL, $lines); | ||||
$first = true; | $first = true; | ||||
array_walk($lines, function (&$line, $index) use ($max, $pad_left, &$first) | array_walk($lines, function (&$line, $index) use ($max, $pad_left, &$first) | ||||
{ | { | ||||
if ( ! $first) | |||||
{ | |||||
if ( ! $first) { | |||||
$line = str_repeat(" ", $pad_left).$line; | $line = str_repeat(" ", $pad_left).$line; | ||||
} else { | } else { | ||||
$first = false; | $first = false; | ||||
@@ -240,25 +205,19 @@ class DedeCli | |||||
} | } | ||||
public static function input(string $prefix = null): string | public static function input(string $prefix = null): string | ||||
{ | { | ||||
if (static::$readline_support) | |||||
{ | |||||
if (static::$readline_support) { | |||||
return readline($prefix); | return readline($prefix); | ||||
} | } | ||||
echo $prefix; | echo $prefix; | ||||
return fgets(STDIN); | return fgets(STDIN); | ||||
} | } | ||||
/** | /** | ||||
* 询问会员输入.这个可以1个或2个参数. | |||||
* | |||||
* 使用: | |||||
* | |||||
* 询问会员输入,可以1个或2个参数 | |||||
* | |||||
* //等待任何输入 | * //等待任何输入 | ||||
* DedeCli::prompt(); | * DedeCli::prompt(); | ||||
* | |||||
* $color = DedeCli::prompt('What is your favorite color?'); | * $color = DedeCli::prompt('What is your favorite color?'); | ||||
* | |||||
* $color = DedeCli::prompt('What is your favourite color?', 'white'); | * $color = DedeCli::prompt('What is your favourite color?', 'white'); | ||||
* | |||||
* $ready = DedeCli::prompt('Are you ready?', array('y','n')); | * $ready = DedeCli::prompt('Are you ready?', array('y','n')); | ||||
* | * | ||||
* @return string the user input | * @return string the user input | ||||
@@ -298,29 +257,21 @@ class DedeCli | |||||
$output = $args[0]; | $output = $args[0]; | ||||
} | } | ||||
break; | break; | ||||
} | |||||
if ($output !== '') | |||||
{ | |||||
} if ($output !== '') { | |||||
$extra_output = ''; | $extra_output = ''; | ||||
if ($default !== null) | |||||
{ | |||||
if ($default !== null) { | |||||
$extra_output = ' [ Default: "'.$default.'" ]'; | $extra_output = ' [ Default: "'.$default.'" ]'; | ||||
} | |||||
elseif ($options !== []) | |||||
{ | |||||
} elseif ($options !== []) { | |||||
$extra_output = ' [ '.implode(', ', $options).' ]'; | $extra_output = ' [ '.implode(', ', $options).' ]'; | ||||
} | } | ||||
fwrite(STDOUT, $output.$extra_output.': '); | fwrite(STDOUT, $output.$extra_output.': '); | ||||
} | } | ||||
$input = trim(static::input()) ? : $default; | $input = trim(static::input()) ? : $default; | ||||
if (empty($input) && $required === true) | |||||
{ | |||||
if (empty($input) && $required === true) { | |||||
static::write('This is required.'); | static::write('This is required.'); | ||||
static::newLine(); | static::newLine(); | ||||
$input = forward_static_call_array([__CLASS__, 'prompt'], $args); | $input = forward_static_call_array([__CLASS__, 'prompt'], $args); | ||||
} | |||||
if ( ! empty($options) && ! in_array($input, $options)) | |||||
{ | |||||
} if (! empty($options) && ! in_array($input, $options)) { | |||||
static::write('This is not a valid option. Please try again.'); | static::write('This is not a valid option. Please try again.'); | ||||
static::newLine(); | static::newLine(); | ||||
$input = forward_static_call_array([__CLASS__, 'prompt'], $args); | $input = forward_static_call_array([__CLASS__, 'prompt'], $args); | ||||
@@ -329,8 +280,7 @@ class DedeCli | |||||
} | } | ||||
public static function wait(int $seconds, bool $countdown = false) | public static function wait(int $seconds, bool $countdown = false) | ||||
{ | { | ||||
if ($countdown === true) | |||||
{ | |||||
if ($countdown === true) { | |||||
$time = $seconds; | $time = $seconds; | ||||
while ($time > 0) | while ($time > 0) | ||||
{ | { | ||||
@@ -340,8 +290,7 @@ class DedeCli | |||||
} | } | ||||
static::write(); | static::write(); | ||||
} else { | } else { | ||||
if ($seconds > 0) | |||||
{ | |||||
if ($seconds > 0) { | |||||
sleep($seconds); | sleep($seconds); | ||||
} else { | } else { | ||||
static::write(static::$wait_msg); | static::write(static::$wait_msg); | ||||
@@ -351,16 +300,14 @@ class DedeCli | |||||
} | } | ||||
public static function error(string $text, string $foreground = 'light_red', string $background = null) | public static function error(string $text, string $foreground = 'light_red', string $background = null) | ||||
{ | { | ||||
if ($foreground || $background) | |||||
{ | |||||
if ($foreground || $background) { | |||||
$text = static::color($text, $foreground, $background); | $text = static::color($text, $foreground, $background); | ||||
} | } | ||||
fwrite(STDERR, $text.PHP_EOL); | fwrite(STDERR, $text.PHP_EOL); | ||||
} | } | ||||
public static function write(string $text = '', string $foreground = null, string $background = null) | public static function write(string $text = '', string $foreground = null, string $background = null) | ||||
{ | { | ||||
if ($foreground || $background) | |||||
{ | |||||
if ($foreground || $background) { | |||||
$text = static::color($text, $foreground, $background); | $text = static::color($text, $foreground, $background); | ||||
} | } | ||||
fwrite(STDOUT, $text.PHP_EOL); | fwrite(STDOUT, $text.PHP_EOL); | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/* | /* | ||||
* This file is part of Crawler Detect - the web crawler detection library. | * This file is part of Crawler Detect - the web crawler detection library. | ||||
* | * | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
//用于DedeBIZ商业组件通信 | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
//DedeBIZ商业组件通信 | |||||
define("DEDEBIZ", true); | define("DEDEBIZ", true); | ||||
class DedeBizClient | class DedeBizClient | ||||
{ | { | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* HTTP下载类 | * HTTP下载类 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/* | /* | ||||
* This file is part of Crawler Detect - the web crawler detection library. | * This file is part of Crawler Detect - the web crawler detection library. | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/* | /* | ||||
* This file is part of Crawler Detect - the web crawler detection library. | * This file is part of Crawler Detect - the web crawler detection library. | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/* | /* | ||||
* This file is part of Crawler Detect - the web crawler detection library. | * This file is part of Crawler Detect - the web crawler detection library. | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/* | /* | ||||
* This file is part of Crawler Detect - the web crawler detection library. | * This file is part of Crawler Detect - the web crawler detection library. | ||||
* | * | ||||
@@ -1,4 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 图片缩放尺寸 | * 图片缩放尺寸 | ||||
* | * | ||||
@@ -12,7 +13,6 @@ | |||||
class ImageResizeException extends \Exception | class ImageResizeException extends \Exception | ||||
{ | { | ||||
} | } | ||||
/** | /** | ||||
* PHP class to resize and scale images | * PHP class to resize and scale images | ||||
*/ | */ | ||||
@@ -28,38 +28,26 @@ class ImageResize | |||||
const IMG_FLIP_HORIZONTAL = 0; | const IMG_FLIP_HORIZONTAL = 0; | ||||
const IMG_FLIP_VERTICAL = 1; | const IMG_FLIP_VERTICAL = 1; | ||||
const IMG_FLIP_BOTH = 2; | const IMG_FLIP_BOTH = 2; | ||||
public $quality_jpg = 85; | public $quality_jpg = 85; | ||||
public $quality_webp = 85; | public $quality_webp = 85; | ||||
public $quality_png = 6; | public $quality_png = 6; | ||||
public $quality_truecolor = true; | public $quality_truecolor = true; | ||||
public $gamma_correct = false; | public $gamma_correct = false; | ||||
public $interlace = 1; | public $interlace = 1; | ||||
public $source_type; | public $source_type; | ||||
protected $source_image; | protected $source_image; | ||||
protected $original_w; | protected $original_w; | ||||
protected $original_h; | protected $original_h; | ||||
protected $dest_x = 0; | protected $dest_x = 0; | ||||
protected $dest_y = 0; | protected $dest_y = 0; | ||||
protected $source_x; | protected $source_x; | ||||
protected $source_y; | protected $source_y; | ||||
protected $dest_w; | protected $dest_w; | ||||
protected $dest_h; | protected $dest_h; | ||||
protected $source_w; | protected $source_w; | ||||
protected $source_h; | protected $source_h; | ||||
protected $source_info; | protected $source_info; | ||||
protected $filters = []; | protected $filters = []; | ||||
/** | /** | ||||
* Create instance from a strng | * Create instance from a strng | ||||
* | * | ||||
@@ -75,8 +63,6 @@ class ImageResize | |||||
$resize = new self('data://application/octet-stream;base64,'.base64_encode($image_data)); | $resize = new self('data://application/octet-stream;base64,'.base64_encode($image_data)); | ||||
return $resize; | return $resize; | ||||
} | } | ||||
/** | /** | ||||
* Add filter function for use right before save image to file. | * Add filter function for use right before save image to file. | ||||
* | * | ||||
@@ -88,7 +74,6 @@ class ImageResize | |||||
$this->filters[] = $filter; | $this->filters[] = $filter; | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Apply filters. | * Apply filters. | ||||
* | * | ||||
@@ -101,7 +86,6 @@ class ImageResize | |||||
$function($image, $filterType); | $function($image, $filterType); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Loads image source and its properties to the instanciated object | * Loads image source and its properties to the instanciated object | ||||
* | * | ||||
@@ -114,15 +98,12 @@ class ImageResize | |||||
if (!defined('IMAGETYPE_WEBP')) { | if (!defined('IMAGETYPE_WEBP')) { | ||||
define('IMAGETYPE_WEBP', 18); | define('IMAGETYPE_WEBP', 18); | ||||
} | } | ||||
if (!defined('IMAGETYPE_BMP')) { | if (!defined('IMAGETYPE_BMP')) { | ||||
define('IMAGETYPE_BMP', 6); | define('IMAGETYPE_BMP', 6); | ||||
} | } | ||||
if ($filename === null || empty($filename) || (substr($filename, 0, 5) !== 'data:' && !is_file($filename))) { | if ($filename === null || empty($filename) || (substr($filename, 0, 5) !== 'data:' && !is_file($filename))) { | ||||
throw new ImageResizeException('File does not exist'); | throw new ImageResizeException('File does not exist'); | ||||
} | } | ||||
$finfo = finfo_open(FILEINFO_MIME_TYPE); | $finfo = finfo_open(FILEINFO_MIME_TYPE); | ||||
$checkWebp = false; | $checkWebp = false; | ||||
if (strstr(finfo_file($finfo, $filename), 'image') === false) { | if (strstr(finfo_file($finfo, $filename), 'image') === false) { | ||||
@@ -136,91 +117,68 @@ class ImageResize | |||||
$checkWebp = true; | $checkWebp = true; | ||||
$this->source_type = IMAGETYPE_WEBP; | $this->source_type = IMAGETYPE_WEBP; | ||||
} | } | ||||
if (!$image_info = getimagesize($filename, $this->source_info)) { | if (!$image_info = getimagesize($filename, $this->source_info)) { | ||||
$image_info = getimagesize($filename); | $image_info = getimagesize($filename); | ||||
} | } | ||||
if (!$checkWebp) { | if (!$checkWebp) { | ||||
if (!$image_info) { | if (!$image_info) { | ||||
if (strstr(finfo_file($finfo, $filename), 'image') !== false) { | if (strstr(finfo_file($finfo, $filename), 'image') !== false) { | ||||
throw new ImageResizeException('Unsupported image type'); | throw new ImageResizeException('Unsupported image type'); | ||||
} | } | ||||
throw new ImageResizeException('Could not read file'); | throw new ImageResizeException('Could not read file'); | ||||
} | } | ||||
$this->original_w = $image_info[0]; | $this->original_w = $image_info[0]; | ||||
$this->original_h = $image_info[1]; | $this->original_h = $image_info[1]; | ||||
$this->source_type = $image_info[2]; | $this->source_type = $image_info[2]; | ||||
} | } | ||||
switch ($this->source_type) { | switch ($this->source_type) { | ||||
case IMAGETYPE_GIF: | case IMAGETYPE_GIF: | ||||
$this->source_image = imagecreatefromgif($filename); | $this->source_image = imagecreatefromgif($filename); | ||||
break; | break; | ||||
case IMAGETYPE_JPEG: | case IMAGETYPE_JPEG: | ||||
$this->source_image = $this->imageCreateJpegfromExif($filename); | $this->source_image = $this->imageCreateJpegfromExif($filename); | ||||
// set new width and height for image, maybe it has changed | // set new width and height for image, maybe it has changed | ||||
$this->original_w = imagesx($this->source_image); | $this->original_w = imagesx($this->source_image); | ||||
$this->original_h = imagesy($this->source_image); | $this->original_h = imagesy($this->source_image); | ||||
break; | break; | ||||
case IMAGETYPE_PNG: | case IMAGETYPE_PNG: | ||||
$this->source_image = imagecreatefrompng($filename); | $this->source_image = imagecreatefrompng($filename); | ||||
break; | break; | ||||
case IMAGETYPE_WEBP: | case IMAGETYPE_WEBP: | ||||
$this->source_image = imagecreatefromwebp($filename); | $this->source_image = imagecreatefromwebp($filename); | ||||
$this->original_w = imagesx($this->source_image); | $this->original_w = imagesx($this->source_image); | ||||
$this->original_h = imagesy($this->source_image); | $this->original_h = imagesy($this->source_image); | ||||
break; | break; | ||||
case IMAGETYPE_BMP: | case IMAGETYPE_BMP: | ||||
if (version_compare(PHP_VERSION, '7.2.0', '<')) { | if (version_compare(PHP_VERSION, '7.2.0', '<')) { | ||||
throw new ImageResizeException('For bmp support PHP >= 7.2.0 is required'); | throw new ImageResizeException('For bmp support PHP >= 7.2.0 is required'); | ||||
} | } | ||||
$this->source_image = imagecreatefrombmp($filename); | $this->source_image = imagecreatefrombmp($filename); | ||||
break; | break; | ||||
default: | default: | ||||
throw new ImageResizeException('Unsupported image type'); | throw new ImageResizeException('Unsupported image type'); | ||||
} | } | ||||
if (!$this->source_image) { | if (!$this->source_image) { | ||||
throw new ImageResizeException('Could not load image'); | throw new ImageResizeException('Could not load image'); | ||||
} | } | ||||
finfo_close($finfo); | finfo_close($finfo); | ||||
return $this->resize($this->getSourceWidth(), $this->getSourceHeight()); | return $this->resize($this->getSourceWidth(), $this->getSourceHeight()); | ||||
} | } | ||||
// http://stackoverflow.com/a/28819866 | |||||
//http://stackoverflow.com/a/28819866 | |||||
public function imageCreateJpegfromExif($filename) | public function imageCreateJpegfromExif($filename) | ||||
{ | { | ||||
$img = imagecreatefromjpeg($filename); | $img = imagecreatefromjpeg($filename); | ||||
if (!function_exists('exif_read_data') || !isset($this->source_info['APP1']) || strpos($this->source_info['APP1'], 'Exif') !== 0) { | if (!function_exists('exif_read_data') || !isset($this->source_info['APP1']) || strpos($this->source_info['APP1'], 'Exif') !== 0) { | ||||
return $img; | return $img; | ||||
} | |||||
try { | |||||
} try { | |||||
$exif = @exif_read_data($filename); | $exif = @exif_read_data($filename); | ||||
} catch (Exception $e) { | } catch (Exception $e) { | ||||
$exif = null; | $exif = null; | ||||
} | } | ||||
if (!$exif || !isset($exif['Orientation'])) { | if (!$exif || !isset($exif['Orientation'])) { | ||||
return $img; | return $img; | ||||
} | } | ||||
$orientation = $exif['Orientation']; | $orientation = $exif['Orientation']; | ||||
if ($orientation === 6 || $orientation === 5) { | if ($orientation === 6 || $orientation === 5) { | ||||
$img = imagerotate($img, 270, 0); | $img = imagerotate($img, 270, 0); | ||||
} elseif ($orientation === 3 || $orientation === 4) { | } elseif ($orientation === 3 || $orientation === 4) { | ||||
@@ -228,14 +186,11 @@ class ImageResize | |||||
} elseif ($orientation === 8 || $orientation === 7) { | } elseif ($orientation === 8 || $orientation === 7) { | ||||
$img = imagerotate($img, 90, 0); | $img = imagerotate($img, 90, 0); | ||||
} | } | ||||
if ($orientation === 5 || $orientation === 4 || $orientation === 7) { | if ($orientation === 5 || $orientation === 4 || $orientation === 7) { | ||||
imageflip($img, IMG_FLIP_HORIZONTAL); | imageflip($img, IMG_FLIP_HORIZONTAL); | ||||
} | } | ||||
return $img; | return $img; | ||||
} | } | ||||
/** | /** | ||||
* Saves new image | * Saves new image | ||||
* | * | ||||
@@ -250,70 +205,61 @@ class ImageResize | |||||
{ | { | ||||
$image_type = $image_type ?: $this->source_type; | $image_type = $image_type ?: $this->source_type; | ||||
$quality = is_numeric($quality) ? (int) abs($quality) : null; | $quality = is_numeric($quality) ? (int) abs($quality) : null; | ||||
switch ($image_type) { | switch ($image_type) { | ||||
case IMAGETYPE_GIF: | case IMAGETYPE_GIF: | ||||
if( !empty($exact_size) && is_array($exact_size) ){ | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | $dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | ||||
} else{ | |||||
} else { | |||||
$dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | ||||
} | } | ||||
$background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); | $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); | ||||
imagecolortransparent($dest_image, $background); | imagecolortransparent($dest_image, $background); | ||||
imagefill($dest_image, 0, 0, $background); | imagefill($dest_image, 0, 0, $background); | ||||
imagesavealpha($dest_image, true); | imagesavealpha($dest_image, true); | ||||
break; | break; | ||||
case IMAGETYPE_JPEG: | case IMAGETYPE_JPEG: | ||||
if( !empty($exact_size) && is_array($exact_size) ){ | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | $dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | ||||
$background = imagecolorallocate($dest_image, 255, 255, 255); | $background = imagecolorallocate($dest_image, 255, 255, 255); | ||||
imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | ||||
} else{ | |||||
} else { | |||||
$dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | ||||
$background = imagecolorallocate($dest_image, 255, 255, 255); | $background = imagecolorallocate($dest_image, 255, 255, 255); | ||||
imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | ||||
} | } | ||||
break; | break; | ||||
case IMAGETYPE_WEBP: | case IMAGETYPE_WEBP: | ||||
if (version_compare(PHP_VERSION, '5.5.0', '<')) { | if (version_compare(PHP_VERSION, '5.5.0', '<')) { | ||||
throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | ||||
} | } | ||||
if( !empty($exact_size) && is_array($exact_size) ){ | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | $dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | ||||
$background = imagecolorallocate($dest_image, 255, 255, 255); | $background = imagecolorallocate($dest_image, 255, 255, 255); | ||||
imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | ||||
} else{ | |||||
} else { | |||||
$dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | ||||
$background = imagecolorallocate($dest_image, 255, 255, 255); | $background = imagecolorallocate($dest_image, 255, 255, 255); | ||||
imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | ||||
} | } | ||||
imagealphablending($dest_image, false); | imagealphablending($dest_image, false); | ||||
imagesavealpha($dest_image, true); | imagesavealpha($dest_image, true); | ||||
break; | break; | ||||
case IMAGETYPE_PNG: | case IMAGETYPE_PNG: | ||||
if (!$this->quality_truecolor || !imageistruecolor($this->source_image)) { | if (!$this->quality_truecolor || !imageistruecolor($this->source_image)) { | ||||
if( !empty($exact_size) && is_array($exact_size) ){ | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreate($exact_size[0], $exact_size[1]); | $dest_image = imagecreate($exact_size[0], $exact_size[1]); | ||||
} else{ | |||||
} else { | |||||
$dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight()); | $dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight()); | ||||
} | } | ||||
} else { | } else { | ||||
if( !empty($exact_size) && is_array($exact_size) ){ | |||||
if(!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | $dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | ||||
} else{ | |||||
} else { | |||||
$dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | ||||
} | } | ||||
} | } | ||||
imagealphablending($dest_image, false); | imagealphablending($dest_image, false); | ||||
imagesavealpha($dest_image, true); | imagesavealpha($dest_image, true); | ||||
$background = imagecolorallocatealpha($dest_image, 255, 255, 255, 127); | $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 127); | ||||
imagecolortransparent($dest_image, $background); | imagecolortransparent($dest_image, $background); | ||||
imagefill($dest_image, 0, 0, $background); | imagefill($dest_image, 0, 0, $background); | ||||
@@ -323,8 +269,7 @@ class ImageResize | |||||
if (version_compare(PHP_VERSION, '7.2.0', '<')) { | if (version_compare(PHP_VERSION, '7.2.0', '<')) { | ||||
throw new ImageResizeException('For WebP support PHP >= 7.2.0 is required'); | throw new ImageResizeException('For WebP support PHP >= 7.2.0 is required'); | ||||
} | } | ||||
if(!empty($exact_size) && is_array($exact_size)) { | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
$dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | $dest_image = imagecreatetruecolor($exact_size[0], $exact_size[1]); | ||||
$background = imagecolorallocate($dest_image, 255, 255, 255); | $background = imagecolorallocate($dest_image, 255, 255, 255); | ||||
imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | imagefilledrectangle($dest_image, 0, 0, $exact_size[0], $exact_size[1], $background); | ||||
@@ -335,14 +280,11 @@ class ImageResize | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
imageinterlace($dest_image, $this->interlace); | imageinterlace($dest_image, $this->interlace); | ||||
if ($this->gamma_correct) { | if ($this->gamma_correct) { | ||||
imagegammacorrect($this->source_image, 2.2, 1.0); | imagegammacorrect($this->source_image, 2.2, 1.0); | ||||
} | } | ||||
if( !empty($exact_size) && is_array($exact_size) ) { | |||||
if (!empty($exact_size) && is_array($exact_size)) { | |||||
if ($this->getSourceHeight() < $this->getSourceWidth()) { | if ($this->getSourceHeight() < $this->getSourceWidth()) { | ||||
$this->dest_x = 0; | $this->dest_x = 0; | ||||
$this->dest_y = ($exact_size[1] - $this->getDestHeight()) / 2; | $this->dest_y = ($exact_size[1] - $this->getDestHeight()) / 2; | ||||
@@ -352,7 +294,6 @@ class ImageResize | |||||
$this->dest_y = 0; | $this->dest_y = 0; | ||||
} | } | ||||
} | } | ||||
imagecopyresampled( | imagecopyresampled( | ||||
$dest_image, | $dest_image, | ||||
$this->source_image, | $this->source_image, | ||||
@@ -365,27 +306,20 @@ class ImageResize | |||||
$this->source_w, | $this->source_w, | ||||
$this->source_h | $this->source_h | ||||
); | ); | ||||
if ($this->gamma_correct) { | if ($this->gamma_correct) { | ||||
imagegammacorrect($dest_image, 1.0, 2.2); | imagegammacorrect($dest_image, 1.0, 2.2); | ||||
} | } | ||||
$this->applyFilter($dest_image); | $this->applyFilter($dest_image); | ||||
switch ($image_type) { | switch ($image_type) { | ||||
case IMAGETYPE_GIF: | case IMAGETYPE_GIF: | ||||
imagegif($dest_image, $filename); | imagegif($dest_image, $filename); | ||||
break; | break; | ||||
case IMAGETYPE_JPEG: | case IMAGETYPE_JPEG: | ||||
if ($quality === null || $quality > 100) { | if ($quality === null || $quality > 100) { | ||||
$quality = $this->quality_jpg; | $quality = $this->quality_jpg; | ||||
} | } | ||||
imagejpeg($dest_image, $filename, $quality); | imagejpeg($dest_image, $filename, $quality); | ||||
break; | break; | ||||
case IMAGETYPE_WEBP: | case IMAGETYPE_WEBP: | ||||
if (version_compare(PHP_VERSION, '5.5.0', '<')) { | if (version_compare(PHP_VERSION, '5.5.0', '<')) { | ||||
throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | ||||
@@ -393,32 +327,24 @@ class ImageResize | |||||
if ($quality === null) { | if ($quality === null) { | ||||
$quality = $this->quality_webp; | $quality = $this->quality_webp; | ||||
} | } | ||||
imagewebp($dest_image, $filename, $quality); | imagewebp($dest_image, $filename, $quality); | ||||
break; | break; | ||||
case IMAGETYPE_PNG: | case IMAGETYPE_PNG: | ||||
if ($quality === null || $quality > 9) { | if ($quality === null || $quality > 9) { | ||||
$quality = $this->quality_png; | $quality = $this->quality_png; | ||||
} | } | ||||
imagepng($dest_image, $filename, $quality); | imagepng($dest_image, $filename, $quality); | ||||
break; | break; | ||||
case IMAGETYPE_BMP: | case IMAGETYPE_BMP: | ||||
imagebmp($dest_image, $filename, $quality); | imagebmp($dest_image, $filename, $quality); | ||||
break; | break; | ||||
} | } | ||||
if ($permissions) { | if ($permissions) { | ||||
chmod($filename, $permissions); | chmod($filename, $permissions); | ||||
} | } | ||||
imagedestroy($dest_image); | imagedestroy($dest_image); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Convert the image to string | * Convert the image to string | ||||
* | * | ||||
@@ -429,16 +355,11 @@ class ImageResize | |||||
public function getImageAsString($image_type = null, $quality = null) | public function getImageAsString($image_type = null, $quality = null) | ||||
{ | { | ||||
$string_temp = tempnam(sys_get_temp_dir(), ''); | $string_temp = tempnam(sys_get_temp_dir(), ''); | ||||
$this->save($string_temp, $image_type, $quality); | $this->save($string_temp, $image_type, $quality); | ||||
$string = file_get_contents($string_temp); | $string = file_get_contents($string_temp); | ||||
unlink($string_temp); | unlink($string_temp); | ||||
return $string; | return $string; | ||||
} | } | ||||
/** | /** | ||||
* Convert the image to string with the current settings | * Convert the image to string with the current settings | ||||
* | * | ||||
@@ -448,7 +369,6 @@ class ImageResize | |||||
{ | { | ||||
return $this->getImageAsString(); | return $this->getImageAsString(); | ||||
} | } | ||||
/** | /** | ||||
* Outputs image to browser | * Outputs image to browser | ||||
* @param string $image_type | * @param string $image_type | ||||
@@ -457,12 +377,9 @@ class ImageResize | |||||
public function output($image_type = null, $quality = null) | public function output($image_type = null, $quality = null) | ||||
{ | { | ||||
$image_type = $image_type ?: $this->source_type; | $image_type = $image_type ?: $this->source_type; | ||||
header('Content-Type: '.image_type_to_mime_type($image_type)); | header('Content-Type: '.image_type_to_mime_type($image_type)); | ||||
$this->save(null, $image_type, $quality); | $this->save(null, $image_type, $quality); | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to the given short side (short side proportional) | * Resizes image according to the given short side (short side proportional) | ||||
* | * | ||||
@@ -475,18 +392,14 @@ class ImageResize | |||||
if ($this->getSourceHeight() < $this->getSourceWidth()) { | if ($this->getSourceHeight() < $this->getSourceWidth()) { | ||||
$ratio = $max_short / $this->getSourceHeight(); | $ratio = $max_short / $this->getSourceHeight(); | ||||
$long = (int) ($this->getSourceWidth() * $ratio); | $long = (int) ($this->getSourceWidth() * $ratio); | ||||
$this->resize($long, $max_short, $allow_enlarge); | $this->resize($long, $max_short, $allow_enlarge); | ||||
} else { | } else { | ||||
$ratio = $max_short / $this->getSourceWidth(); | $ratio = $max_short / $this->getSourceWidth(); | ||||
$long = (int) ($this->getSourceHeight() * $ratio); | $long = (int) ($this->getSourceHeight() * $ratio); | ||||
$this->resize($max_short, $long, $allow_enlarge); | $this->resize($max_short, $long, $allow_enlarge); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to the given long side (short side proportional) | * Resizes image according to the given long side (short side proportional) | ||||
* | * | ||||
@@ -499,18 +412,14 @@ class ImageResize | |||||
if ($this->getSourceHeight() > $this->getSourceWidth()) { | if ($this->getSourceHeight() > $this->getSourceWidth()) { | ||||
$ratio = $max_long / $this->getSourceHeight(); | $ratio = $max_long / $this->getSourceHeight(); | ||||
$short = (int) ($this->getSourceWidth() * $ratio); | $short = (int) ($this->getSourceWidth() * $ratio); | ||||
$this->resize($short, $max_long, $allow_enlarge); | $this->resize($short, $max_long, $allow_enlarge); | ||||
} else { | } else { | ||||
$ratio = $max_long / $this->getSourceWidth(); | $ratio = $max_long / $this->getSourceWidth(); | ||||
$short = (int) ($this->getSourceHeight() * $ratio); | $short = (int) ($this->getSourceHeight() * $ratio); | ||||
$this->resize($max_long, $short, $allow_enlarge); | $this->resize($max_long, $short, $allow_enlarge); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to the given height (width proportional) | * Resizes image according to the given height (width proportional) | ||||
* | * | ||||
@@ -522,12 +431,9 @@ class ImageResize | |||||
{ | { | ||||
$ratio = $height / $this->getSourceHeight(); | $ratio = $height / $this->getSourceHeight(); | ||||
$width = (int) ($this->getSourceWidth() * $ratio); | $width = (int) ($this->getSourceWidth() * $ratio); | ||||
$this->resize($width, $height, $allow_enlarge); | $this->resize($width, $height, $allow_enlarge); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to the given width (height proportional) | * Resizes image according to the given width (height proportional) | ||||
* | * | ||||
@@ -539,12 +445,9 @@ class ImageResize | |||||
{ | { | ||||
$ratio = $width / $this->getSourceWidth(); | $ratio = $width / $this->getSourceWidth(); | ||||
$height = (int) ($this->getSourceHeight() * $ratio); | $height = (int) ($this->getSourceHeight() * $ratio); | ||||
$this->resize($width, $height, $allow_enlarge); | $this->resize($width, $height, $allow_enlarge); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Resizes image to best fit inside the given dimensions | * Resizes image to best fit inside the given dimensions | ||||
* | * | ||||
@@ -558,19 +461,15 @@ class ImageResize | |||||
if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) { | if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) { | ||||
return $this; | return $this; | ||||
} | } | ||||
$ratio = $this->getSourceHeight() / $this->getSourceWidth(); | $ratio = $this->getSourceHeight() / $this->getSourceWidth(); | ||||
$width = $max_width; | $width = $max_width; | ||||
$height = (int) ($width * $ratio); | $height = (int) ($width * $ratio); | ||||
if ($height > $max_height) { | if ($height > $max_height) { | ||||
$height = $max_height; | $height = $max_height; | ||||
$width = (int) ($height / $ratio); | $width = (int) ($height / $ratio); | ||||
} | } | ||||
return $this->resize($width, $height, $allow_enlarge); | return $this->resize($width, $height, $allow_enlarge); | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to given scale (proportionally) | * Resizes image according to given scale (proportionally) | ||||
* | * | ||||
@@ -581,12 +480,9 @@ class ImageResize | |||||
{ | { | ||||
$width = (int) ($this->getSourceWidth() * $scale / 100); | $width = (int) ($this->getSourceWidth() * $scale / 100); | ||||
$height = (int) ($this->getSourceHeight() * $scale / 100); | $height = (int) ($this->getSourceHeight() * $scale / 100); | ||||
$this->resize($width, $height, true); | $this->resize($width, $height, true); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Resizes image according to the given width and height | * Resizes image according to the given width and height | ||||
* | * | ||||
@@ -601,25 +497,19 @@ class ImageResize | |||||
// if the user hasn't explicitly allowed enlarging, | // if the user hasn't explicitly allowed enlarging, | ||||
// but either of the dimensions are larger then the original, | // but either of the dimensions are larger then the original, | ||||
// then just use original dimensions - this logic may need rethinking | // then just use original dimensions - this logic may need rethinking | ||||
if ($width > $this->getSourceWidth() || $height > $this->getSourceHeight()) { | if ($width > $this->getSourceWidth() || $height > $this->getSourceHeight()) { | ||||
$width = $this->getSourceWidth(); | $width = $this->getSourceWidth(); | ||||
$height = $this->getSourceHeight(); | $height = $this->getSourceHeight(); | ||||
} | } | ||||
} | } | ||||
$this->source_x = 0; | $this->source_x = 0; | ||||
$this->source_y = 0; | $this->source_y = 0; | ||||
$this->dest_w = $width; | $this->dest_w = $width; | ||||
$this->dest_h = $height; | $this->dest_h = $height; | ||||
$this->source_w = $this->getSourceWidth(); | $this->source_w = $this->getSourceWidth(); | ||||
$this->source_h = $this->getSourceHeight(); | $this->source_h = $this->getSourceHeight(); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Crops image according to the given width, height and crop position | * Crops image according to the given width, height and crop position | ||||
* | * | ||||
@@ -635,42 +525,30 @@ class ImageResize | |||||
// this logic is slightly different to resize(), | // this logic is slightly different to resize(), | ||||
// it will only reset dimensions to the original | // it will only reset dimensions to the original | ||||
// if that particular dimenstion is larger | // if that particular dimenstion is larger | ||||
if ($width > $this->getSourceWidth()) { | if ($width > $this->getSourceWidth()) { | ||||
$width = $this->getSourceWidth(); | $width = $this->getSourceWidth(); | ||||
} | } | ||||
if ($height > $this->getSourceHeight()) { | if ($height > $this->getSourceHeight()) { | ||||
$height = $this->getSourceHeight(); | $height = $this->getSourceHeight(); | ||||
} | } | ||||
} | } | ||||
$ratio_source = $this->getSourceWidth() / $this->getSourceHeight(); | $ratio_source = $this->getSourceWidth() / $this->getSourceHeight(); | ||||
$ratio_dest = $width / $height; | $ratio_dest = $width / $height; | ||||
if ($ratio_dest < $ratio_source) { | if ($ratio_dest < $ratio_source) { | ||||
$this->resizeToHeight($height, $allow_enlarge); | $this->resizeToHeight($height, $allow_enlarge); | ||||
$excess_width = (int) (($this->getDestWidth() - $width) * $this->getSourceWidth() / $this->getDestWidth()); | $excess_width = (int) (($this->getDestWidth() - $width) * $this->getSourceWidth() / $this->getDestWidth()); | ||||
$this->source_w = $this->getSourceWidth() - $excess_width; | $this->source_w = $this->getSourceWidth() - $excess_width; | ||||
$this->source_x = $this->getCropPosition($excess_width, $position); | $this->source_x = $this->getCropPosition($excess_width, $position); | ||||
$this->dest_w = $width; | $this->dest_w = $width; | ||||
} else { | } else { | ||||
$this->resizeToWidth($width, $allow_enlarge); | $this->resizeToWidth($width, $allow_enlarge); | ||||
$excess_height = (int) (($this->getDestHeight() - $height) * $this->getSourceHeight() / $this->getDestHeight()); | $excess_height = (int) (($this->getDestHeight() - $height) * $this->getSourceHeight() / $this->getDestHeight()); | ||||
$this->source_h = $this->getSourceHeight() - $excess_height; | $this->source_h = $this->getSourceHeight() - $excess_height; | ||||
$this->source_y = $this->getCropPosition($excess_height, $position); | $this->source_y = $this->getCropPosition($excess_height, $position); | ||||
$this->dest_h = $height; | $this->dest_h = $height; | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Crops image according to the given width, height, x and y | * Crops image according to the given width, height, x and y | ||||
* | * | ||||
@@ -692,19 +570,15 @@ class ImageResize | |||||
} else { | } else { | ||||
$this->source_w = $width; | $this->source_w = $width; | ||||
} | } | ||||
if ($height > $this->getSourceHeight() - $y) { | if ($height > $this->getSourceHeight() - $y) { | ||||
$this->source_h = $this->getSourceHeight() - $y; | $this->source_h = $this->getSourceHeight() - $y; | ||||
} else { | } else { | ||||
$this->source_h = $height; | $this->source_h = $height; | ||||
} | } | ||||
$this->dest_w = $width; | $this->dest_w = $width; | ||||
$this->dest_h = $height; | $this->dest_h = $height; | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Gets source width | * Gets source width | ||||
* | * | ||||
@@ -714,7 +588,6 @@ class ImageResize | |||||
{ | { | ||||
return $this->original_w; | return $this->original_w; | ||||
} | } | ||||
/** | /** | ||||
* Gets source height | * Gets source height | ||||
* | * | ||||
@@ -724,7 +597,6 @@ class ImageResize | |||||
{ | { | ||||
return $this->original_h; | return $this->original_h; | ||||
} | } | ||||
/** | /** | ||||
* Gets width of the destination image | * Gets width of the destination image | ||||
* | * | ||||
@@ -734,7 +606,6 @@ class ImageResize | |||||
{ | { | ||||
return $this->dest_w; | return $this->dest_w; | ||||
} | } | ||||
/** | /** | ||||
* Gets height of the destination image | * Gets height of the destination image | ||||
* @return integer | * @return integer | ||||
@@ -743,7 +614,6 @@ class ImageResize | |||||
{ | { | ||||
return $this->dest_h; | return $this->dest_h; | ||||
} | } | ||||
/** | /** | ||||
* Gets crop position (X or Y) according to the given position | * Gets crop position (X or Y) according to the given position | ||||
* | * | ||||
@@ -769,7 +639,6 @@ class ImageResize | |||||
} | } | ||||
return (int) $size; | return (int) $size; | ||||
} | } | ||||
/** | /** | ||||
* Enable or not the gamma color correction on the image, enabled by default | * Enable or not the gamma color correction on the image, enabled by default | ||||
* | * | ||||
@@ -779,7 +648,6 @@ class ImageResize | |||||
public function gamma($enable = false) | public function gamma($enable = false) | ||||
{ | { | ||||
$this->gamma_correct = $enable; | $this->gamma_correct = $enable; | ||||
return $this; | return $this; | ||||
} | } | ||||
} | } |
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class Condition | class Condition | ||||
{ | { | ||||
/** | /** | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class ConditionNotAllowedException extends \Exception | class ConditionNotAllowedException extends \Exception | ||||
{ | { | ||||
public function __construct($message = "Condition not allowed exception", $code = 0, \Throwable $previous = null) | public function __construct($message = "Condition not allowed exception", $code = 0, \Throwable $previous = null) | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class FileNotFoundException extends \Exception | class FileNotFoundException extends \Exception | ||||
{ | { | ||||
public function __construct($message = "File not found exception", $code = 0, \Throwable $previous = null) | public function __construct($message = "File not found exception", $code = 0, \Throwable $previous = null) | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class InvalidJsonException extends \Exception | class InvalidJsonException extends \Exception | ||||
{ | { | ||||
public function __construct($message = "Invalid JSON format", $code = 0, \Throwable $previous = null) | public function __construct($message = "Invalid JSON format", $code = 0, \Throwable $previous = null) | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class InvalidNodeException extends \Exception | class InvalidNodeException extends \Exception | ||||
{ | { | ||||
public function __construct($message = "Invalid JSON node exception", $code = 0, \Throwable $previous = null) | public function __construct($message = "Invalid JSON node exception", $code = 0, \Throwable $previous = null) | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
class NullValueException extends \Exception | class NullValueException extends \Exception | ||||
{ | { | ||||
public function __construct($message = "Null value exception", $code = 0, \Throwable $previous = null) | public function __construct($message = "Null value exception", $code = 0, \Throwable $previous = null) | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once(dirname(__FILE__)."/Exceptions/ConditionNotAllowedException.php"); | require_once(dirname(__FILE__)."/Exceptions/ConditionNotAllowedException.php"); | ||||
require_once(dirname(__FILE__)."/Exceptions/FileNotFoundException.php"); | require_once(dirname(__FILE__)."/Exceptions/FileNotFoundException.php"); | ||||
require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php"); | require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php"); | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once(dirname(__FILE__)."/Exceptions/ConditionNotAllowedException.php"); | require_once(dirname(__FILE__)."/Exceptions/ConditionNotAllowedException.php"); | ||||
require_once(dirname(__FILE__)."/Exceptions/FileNotFoundException.php"); | require_once(dirname(__FILE__)."/Exceptions/FileNotFoundException.php"); | ||||
require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php"); | require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php"); | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* This class represents a query result where a given | * This class represents a query result where a given | ||||
* value was queried but did not exist. | * value was queried but did not exist. | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* SMTP邮件操作类 | * SMTP邮件操作类 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* Mobile Detect Library | * Mobile Detect Library | ||||
* Motto: "Every business should have a mobile detection script to detect mobile readers" | * Motto: "Every business should have a mobile detection script to detect mobile readers" | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 提示窗口对话框类 | * 提示窗口对话框类 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* Unicode编码词典的php分词器 | * Unicode编码词典的php分词器 | ||||
* | * | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once(DEDEINC."/libraries/agent.class.php"); | require_once(DEDEINC."/libraries/agent.class.php"); | ||||
/** | /** | ||||
* 轻量级流量统计 | * 轻量级流量统计 | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 会员登录 | * 会员登录 | ||||
* | * | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝App支付网关 | * 支付宝App支付网关 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝电子面单下载 | * 支付宝电子面单下载 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝刷卡支付 | * 支付宝刷卡支付 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝扫码支付 | * 支付宝扫码支付 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝标准接口 | * 支付宝标准接口 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
use WeChat\Exceptions\InvalidArgumentException; | use WeChat\Exceptions\InvalidArgumentException; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 手机WAP网站支付支持 | * 手机WAP网站支付支持 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace AliPay; | namespace AliPay; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicAliPay; | use WeChat\Contracts\BasicAliPay; | ||||
/** | /** | ||||
* 支付宝网站支付 | * 支付宝网站支付 | ||||
@@ -1,5 +1,5 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\DataArray; | use WeChat\Contracts\DataArray; | ||||
use WeChat\Exceptions\InvalidInstanceException; | use WeChat\Exceptions\InvalidInstanceException; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat; | namespace WeChat; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Contracts\BasicWeChat; | use WeChat\Contracts\BasicWeChat; | ||||
/** | /** | ||||
* 卡券管理 | * 卡券管理 | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Exceptions\InvalidArgumentException; | use WeChat\Exceptions\InvalidArgumentException; | ||||
use WeChat\Exceptions\InvalidResponseException; | use WeChat\Exceptions\InvalidResponseException; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Exceptions\InvalidArgumentException; | use WeChat\Exceptions\InvalidArgumentException; | ||||
use WeChat\Exceptions\InvalidDecryptException; | use WeChat\Exceptions\InvalidDecryptException; | ||||
use WeChat\Exceptions\InvalidResponseException; | use WeChat\Exceptions\InvalidResponseException; | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Exceptions\InvalidArgumentException; | use WeChat\Exceptions\InvalidArgumentException; | ||||
use WeChat\Exceptions\InvalidResponseException; | use WeChat\Exceptions\InvalidResponseException; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use WeChat\Exceptions\InvalidArgumentException; | use WeChat\Exceptions\InvalidArgumentException; | ||||
use WeChat\Exceptions\InvalidResponseException; | use WeChat\Exceptions\InvalidResponseException; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 企业微信基础类 | * 企业微信基础类 | ||||
* Class BasicWeWork | * Class BasicWeWork | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
use ArrayAccess; | use ArrayAccess; | ||||
/** | /** | ||||
* Class DataArray | * Class DataArray | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 错误消息处理 | * 错误消息处理 | ||||
* Class DataError | * Class DataError | ||||
@@ -1,6 +1,6 @@ | |||||
<?php | <?php | ||||
namespace WeChat\Contracts; | namespace WeChat\Contracts; | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | |||||
if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
/** | /** | ||||
* 自定义CURL文件类 | * 自定义CURL文件类 | ||||
* Class MyCurlFile | * Class MyCurlFile | ||||