|
@@ -1,5 +1,5 @@ |
|
|
<?php |
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
if (!defined('DEDEINC')) exit('dedebiz'); |
|
|
/** |
|
|
/** |
|
|
* 系统核心函数存放文件 |
|
|
* 系统核心函数存放文件 |
|
|
* @version $Id: common.func.php 4 16:39 2010年7月6日Z tianya $ |
|
|
* @version $Id: common.func.php 4 16:39 2010年7月6日Z tianya $ |
|
@@ -8,8 +8,6 @@ |
|
|
* @license https://www.dedebiz.com/license |
|
|
* @license https://www.dedebiz.com/license |
|
|
* @link https://www.dedebiz.com |
|
|
* @link https://www.dedebiz.com |
|
|
*/ |
|
|
*/ |
|
|
if (!defined('DEDEINC')) exit('dedebiz'); |
|
|
|
|
|
|
|
|
|
|
|
if (version_compare(PHP_VERSION, '7.0.0', '>=')) { |
|
|
if (version_compare(PHP_VERSION, '7.0.0', '>=')) { |
|
|
if (!function_exists('mysql_connect') and function_exists('mysqli_connect')) { |
|
|
if (!function_exists('mysql_connect') and function_exists('mysqli_connect')) { |
|
|
function mysql_connect($server, $username, $password) |
|
|
function mysql_connect($server, $username, $password) |
|
@@ -17,28 +15,24 @@ if (version_compare(PHP_VERSION, '7.0.0', '>=')) { |
|
|
return mysqli_connect($server, $username, $password); |
|
|
return mysqli_connect($server, $username, $password); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!function_exists('mysql_query') and function_exists('mysqli_query')) { |
|
|
if (!function_exists('mysql_query') and function_exists('mysqli_query')) { |
|
|
function mysql_query($query, $link) |
|
|
function mysql_query($query, $link) |
|
|
{ |
|
|
{ |
|
|
return mysqli_query($link, $query); |
|
|
return mysqli_query($link, $query); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!function_exists('mysql_select_db') and function_exists('mysqli_select_db')) { |
|
|
if (!function_exists('mysql_select_db') and function_exists('mysqli_select_db')) { |
|
|
function mysql_select_db($database_name, $link) |
|
|
function mysql_select_db($database_name, $link) |
|
|
{ |
|
|
{ |
|
|
return mysqli_select_db($link, $database_name); |
|
|
return mysqli_select_db($link, $database_name); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!function_exists('mysql_fetch_array') and function_exists('mysqli_fetch_array')) { |
|
|
if (!function_exists('mysql_fetch_array') and function_exists('mysqli_fetch_array')) { |
|
|
function mysql_fetch_array($result) |
|
|
function mysql_fetch_array($result) |
|
|
{ |
|
|
{ |
|
|
return mysqli_fetch_array($result); |
|
|
return mysqli_fetch_array($result); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!function_exists('mysql_close') and function_exists('mysqli_close')) { |
|
|
if (!function_exists('mysql_close') and function_exists('mysqli_close')) { |
|
|
function mysql_close($link) |
|
|
function mysql_close($link) |
|
|
{ |
|
|
{ |
|
@@ -52,7 +46,6 @@ if (version_compare(PHP_VERSION, '7.0.0', '>=')) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function make_hash() |
|
|
function make_hash() |
|
|
{ |
|
|
{ |
|
|
$rand = dede_random_bytes(16); |
|
|
$rand = dede_random_bytes(16); |
|
@@ -61,17 +54,14 @@ function make_hash() |
|
|
: bin2hex($rand); |
|
|
: bin2hex($rand); |
|
|
return $_SESSION['token']; |
|
|
return $_SESSION['token']; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function dede_random_bytes($length) |
|
|
function dede_random_bytes($length) |
|
|
{ |
|
|
{ |
|
|
if (empty($length) or !ctype_digit((string) $length)) { |
|
|
if (empty($length) or !ctype_digit((string) $length)) { |
|
|
return FALSE; |
|
|
return FALSE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (function_exists('openssl_random_pseudo_bytes')) { |
|
|
if (function_exists('openssl_random_pseudo_bytes')) { |
|
|
return openssl_random_pseudo_bytes($length); |
|
|
return openssl_random_pseudo_bytes($length); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (function_exists('random_bytes')) { |
|
|
if (function_exists('random_bytes')) { |
|
|
try { |
|
|
try { |
|
|
return random_bytes((int) $length); |
|
|
return random_bytes((int) $length); |
|
@@ -90,11 +80,8 @@ function dede_random_bytes($length) |
|
|
return $output; |
|
|
return $output; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return FALSE; |
|
|
return FALSE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 载入小助手,系统默认载入小助手 |
|
|
* 载入小助手,系统默认载入小助手 |
|
|
* 在/data/helper.inc.php中进行默认小助手初始化的设置 |
|
|
* 在/data/helper.inc.php中进行默认小助手初始化的设置 |
|
@@ -127,7 +114,6 @@ function helper($helpers) |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isset($_helpers[$helpers])) { |
|
|
if (isset($_helpers[$helpers])) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@@ -135,12 +121,11 @@ 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'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function dede_htmlspecialchars($str) |
|
|
function dede_htmlspecialchars($str) |
|
|
{ |
|
|
{ |
|
|
global $cfg_soft_lang; |
|
|
global $cfg_soft_lang; |
|
@@ -148,7 +133,6 @@ function dede_htmlspecialchars($str) |
|
|
if ($cfg_soft_lang == 'gb2312') return htmlspecialchars($str, ENT_COMPAT, 'ISO-8859-1'); |
|
|
if ($cfg_soft_lang == 'gb2312') return htmlspecialchars($str, ENT_COMPAT, 'ISO-8859-1'); |
|
|
else return htmlspecialchars($str); |
|
|
else return htmlspecialchars($str); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 载入小助手,这里用户可能载入用helps载入多个小助手 |
|
|
* 载入小助手,这里用户可能载入用helps载入多个小助手 |
|
|
* |
|
|
* |
|
@@ -160,7 +144,6 @@ function helpers($helpers) |
|
|
{ |
|
|
{ |
|
|
helper($helpers); |
|
|
helper($helpers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//兼容php4的file_put_contents |
|
|
//兼容php4的file_put_contents |
|
|
if (!function_exists('file_put_contents')) { |
|
|
if (!function_exists('file_put_contents')) { |
|
|
function file_put_contents($n, $d) |
|
|
function file_put_contents($n, $d) |
|
@@ -175,7 +158,6 @@ if (!function_exists('file_put_contents')) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 显示更新信息 |
|
|
* 显示更新信息 |
|
|
* |
|
|
* |
|
@@ -186,15 +168,8 @@ function UpdateStat() |
|
|
include_once(DEDEINC . "/inc/inc_stat.php"); |
|
|
include_once(DEDEINC . "/inc/inc_stat.php"); |
|
|
return SpUpdateStat(); |
|
|
return SpUpdateStat(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$arrs1 = array(0x63, 0x66, 0x67, 0x5f, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x62, 0x79); |
|
|
|
|
|
$arrs2 = array( |
|
|
|
|
|
0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, |
|
|
|
|
|
0x77, 0x77, 0x77, 0x2e, 0x64, 0x65, 0x64, 0x65, 0x63, 0x6d, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x74, 0x61, 0x72, |
|
|
|
|
|
0x67, 0x65, 0x74, 0x3d, 0x27, 0x5f, 0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x27, 0x3e, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x20, |
|
|
|
|
|
0x62, 0x79, 0x20, 0x44, 0x65, 0x64, 0x65, 0x43, 0x6d, 0x73, 0x3c, 0x2f, 0x61, 0x3e |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$arrs1 = array(); |
|
|
|
|
|
$arrs2 = array(); |
|
|
/** |
|
|
/** |
|
|
* 短消息函数,可以在某个动作处理后友好的提示信息 |
|
|
* 短消息函数,可以在某个动作处理后友好的提示信息 |
|
|
* |
|
|
* |
|
@@ -207,21 +182,16 @@ $arrs2 = array( |
|
|
function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) |
|
|
function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) |
|
|
{ |
|
|
{ |
|
|
global $cfg_soft_lang, $cfg_cmsurl; |
|
|
global $cfg_soft_lang, $cfg_cmsurl; |
|
|
if (empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..'; |
|
|
|
|
|
|
|
|
|
|
|
$htmlhead = "<html>\r\n<head>\r\n<title>DedeBIZ提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$cfg_soft_lang}\" />\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">"; |
|
|
|
|
|
$htmlhead .= "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style><link href=\"{$cfg_cmsurl}/static/font-awesome/css/font-awesome.min.css\" rel=\"stylesheet\">"; |
|
|
|
|
|
$htmlhead .= "<base target='_self'/></head>\r\n<body leftmargin='0' topmargin='0' bgcolor='#FFFFFF'>" . (isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '') . "\r\n<center>\r\n<script>\r\n"; |
|
|
|
|
|
$htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..'; |
|
|
|
|
|
$htmlhead = "<html><head><meta charset='utf-8'><title>提示信息</title><meta name='viewport' content='width=device-width,initial-scale=1'>"; |
|
|
|
|
|
$htmlhead .= "<base target='_self'></head><body>".(isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '')."<center><script>"; |
|
|
|
|
|
$htmlfoot = "</script></center></body></html>"; |
|
|
$litime = ($limittime == 0 ? 1000 : $limittime); |
|
|
$litime = ($limittime == 0 ? 1000 : $limittime); |
|
|
$func = ''; |
|
|
$func = ''; |
|
|
|
|
|
|
|
|
if ($gourl == '-1') { |
|
|
if ($gourl == '-1') { |
|
|
if ($limittime == 0) $litime = 5000; |
|
|
if ($limittime == 0) $litime = 5000; |
|
|
$gourl = "javascript:history.go(-1);"; |
|
|
$gourl = "javascript:history.go(-1);"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($gourl == '' || $onlymsg == 1) { |
|
|
if ($gourl == '' || $onlymsg == 1) { |
|
|
$msg = "<script>alert(\"" . str_replace("\"", "“", $msg) . "\");</script>"; |
|
|
$msg = "<script>alert(\"" . str_replace("\"", "“", $msg) . "\");</script>"; |
|
|
} else { |
|
|
} else { |
|
@@ -231,33 +201,30 @@ function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) |
|
|
$gourl = 'javascript:;'; |
|
|
$gourl = 'javascript:;'; |
|
|
$func .= "window.parent.document.getElementById('{$tgobj}').style.display='none';\r\n"; |
|
|
$func .= "window.parent.document.getElementById('{$tgobj}').style.display='none';\r\n"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$func .= " var pgo=0; |
|
|
|
|
|
function JumpUrl(){ |
|
|
|
|
|
if(pgo==0){ location='$gourl'; pgo=1; } |
|
|
|
|
|
}\r\n"; |
|
|
|
|
|
|
|
|
$func .= "var pgo=0;function JumpUrl(){if (pgo==0){location='$gourl'; pgo=1;}}"; |
|
|
$rmsg = $func; |
|
|
$rmsg = $func; |
|
|
$rmsg .= "document.write(\"<main class='container'><div class='modal' tabindex='-1' role='dialog' style='display:block'><div class='modal-dialog'><div class='modal-content'><div class='modal-header'><h6 class='modal-title'>"; |
|
|
|
|
|
$rmsg .= "DedeBIZ 提示信息!</h6></div><div class='modal-body'>\");\r\n"; |
|
|
|
|
|
$rmsg .= "document.write(\"" . str_replace("\"", "“", $msg) . "\");\r\n"; |
|
|
|
|
|
|
|
|
$rmsg .= "document.write(\"<style>body{margin:0;line-height:1.6;font:12px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;color:#666;background:#f2f2f2}a{color:#009688;text-decoration:none}.xushu-tips{margin:68px auto 0;padding:0;width:360px;height:auto;background:#fff;border-radius:2px;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}.tips{margin:0 20px;padding:12px 0;border-bottom:1px solid #f6f6f6}.tips p{margin:0;padding-left:10px;line-height:16px;font-size:14px;color:#424b51;text-align:left;border-left:3px solid #ff5722}.frame{padding:20px;height:120px}.go a{display:inline-block;margin:20px auto 0;padding:0 10px;line-height:30px;color:#fff;background:#28a745;border:1px solid #28a745;box-sizing:border-box;border-radius:2px;text-align:center;transition:all .4s}.go a:hover{color:#fff;opacity:.8}@media (max-width:768px){body{padding:0 14px}.xushu-tips{width:100%}}</style>\");"; |
|
|
|
|
|
$rmsg .= "document.write(\"<div class='xushu-tips'>"; |
|
|
|
|
|
$rmsg .= "<div class='tips'><p>提示信息</p></div>\");"; |
|
|
|
|
|
$rmsg .= "document.write(\"<div class='frame'>\");"; |
|
|
|
|
|
$rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");"; |
|
|
$rmsg .= "document.write(\""; |
|
|
$rmsg .= "document.write(\""; |
|
|
|
|
|
|
|
|
if ($onlymsg == 0) { |
|
|
|
|
|
if ($gourl != 'javascript:;' && $gourl != '') { |
|
|
|
|
|
$rmsg .= "<br /><a href='{$gourl}'>如果你的浏览器没反应,请点击这里...</a>"; |
|
|
|
|
|
$rmsg .= "</div></div></div></div></main>\");\r\n"; |
|
|
|
|
|
|
|
|
if($onlymsg==0) |
|
|
|
|
|
{ |
|
|
|
|
|
if( $gourl != 'javascript:;' && $gourl != '') |
|
|
|
|
|
{ |
|
|
|
|
|
$rmsg .= "<div class='go'><a href='{$gourl}'>点击反应</a></div>\");"; |
|
|
$rmsg .= "setTimeout('JumpUrl()',$litime);"; |
|
|
$rmsg .= "setTimeout('JumpUrl()',$litime);"; |
|
|
} else { |
|
|
} else { |
|
|
$rmsg .= "</div></div></div></div></main>\");\r\n"; |
|
|
|
|
|
|
|
|
$rmsg .= "</div>\");"; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
$rmsg .= "</div></div></div></div></main>\");\r\n"; |
|
|
|
|
|
|
|
|
$rmsg .= "</div>\");"; |
|
|
} |
|
|
} |
|
|
$msg = $htmlhead . $rmsg . $htmlfoot; |
|
|
|
|
|
|
|
|
$msg = $htmlhead.$rmsg.$htmlfoot; |
|
|
} |
|
|
} |
|
|
echo $msg; |
|
|
echo $msg; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取验证码的session值 |
|
|
* 获取验证码的session值 |
|
|
* |
|
|
* |
|
@@ -269,7 +236,6 @@ function GetCkVdValue() |
|
|
@session_start(); |
|
|
@session_start(); |
|
|
return isset($_SESSION['securimage_code_value']) ? $_SESSION['securimage_code_value'] : ''; |
|
|
return isset($_SESSION['securimage_code_value']) ? $_SESSION['securimage_code_value'] : ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* PHP某些版本有Bug,不能在同一作用域中同时读session并改注销它,因此调用后需执行本函数 |
|
|
* PHP某些版本有Bug,不能在同一作用域中同时读session并改注销它,因此调用后需执行本函数 |
|
|
* |
|
|
* |
|
@@ -280,12 +246,10 @@ function ResetVdValue() |
|
|
@session_start(); |
|
|
@session_start(); |
|
|
$_SESSION['securimage_code_value'] = ''; |
|
|
$_SESSION['securimage_code_value'] = ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function IndexSub($idx, $num) |
|
|
function IndexSub($idx, $num) |
|
|
{ |
|
|
{ |
|
|
return intval($idx) - intval($num) == 0 ? '0 ' : intval($idx) - intval($num); |
|
|
return intval($idx) - intval($num) == 0 ? '0 ' : intval($idx) - intval($num); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 用来返回index的active |
|
|
// 用来返回index的active |
|
|
function IndexActive($idx) |
|
|
function IndexActive($idx) |
|
|
{ |
|
|
{ |
|
@@ -295,9 +259,8 @@ function IndexActive($idx) |
|
|
return ''; |
|
|
return ''; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 自定义函数接口 |
|
|
// 自定义函数接口 |
|
|
// 这里主要兼容早期的用户扩展,v5.7之后我们建议使用小助手helper进行扩展 |
|
|
// 这里主要兼容早期的用户扩展,v5.7之后我们建议使用小助手helper进行扩展 |
|
|
if (file_exists(DEDEINC . '/extend.func.php')) { |
|
|
if (file_exists(DEDEINC . '/extend.func.php')) { |
|
|
require_once(DEDEINC . '/extend.func.php'); |
|
|
require_once(DEDEINC . '/extend.func.php'); |
|
|
} |
|
|
|
|
|
|
|
|
} |