|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <?php
- if (!defined('DEDEINC')) exit('dedebiz');
-
- if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
- if (!function_exists('mysql_connect') and function_exists('mysqli_connect')) {
- function mysql_connect($server, $username, $password)
- {
- return mysqli_connect($server, $username, $password);
- }
- }
- if (!function_exists('mysql_query') and function_exists('mysqli_query')) {
- function mysql_query($query, $link)
- {
- return mysqli_query($link, $query);
- }
- }
- if (!function_exists('mysql_select_db') and function_exists('mysqli_select_db')) {
- function mysql_select_db($database_name, $link)
- {
- return mysqli_select_db($link, $database_name);
- }
- }
- if (!function_exists('mysql_fetch_array') and function_exists('mysqli_fetch_array')) {
- function mysql_fetch_array($result)
- {
- return mysqli_fetch_array($result);
- }
- }
- if (!function_exists('mysql_close') and function_exists('mysqli_close')) {
- function mysql_close($link)
- {
- return mysqli_close($link);
- }
- }
- if (!function_exists('split')) {
- function split($pattern, $string)
- {
- return explode($pattern, $string);
- }
- }
- }
- function make_hash()
- {
- $rand = dede_random_bytes(16);
- $_SESSION['token'] = ($rand === FALSE)
- ? md5(uniqid(mt_rand(), TRUE))
- : bin2hex($rand);
- return $_SESSION['token'];
- }
- function dede_random_bytes($length)
- {
- if (empty($length) or !ctype_digit((string) $length)) {
- return FALSE;
- }
- if (function_exists('openssl_random_pseudo_bytes')) {
- return openssl_random_pseudo_bytes($length);
- }
- if (function_exists('random_bytes')) {
- try {
- return random_bytes((int) $length);
- } catch (Exception $e) {
- return FALSE;
- }
- }
- if (defined('MCRYPT_DEV_URANDOM') && ($output = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM)) !== FALSE) {
- return $output;
- }
- if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
- version_compare(PHP_VERSION, '5.4.0', '>=') && stream_set_chunk_size($fp, $length);
- $output = fread($fp, $length);
- fclose($fp);
- if ($output !== FALSE) {
- return $output;
- }
- }
- return FALSE;
- }
-
- $_helpers = array();
- function helper($helpers)
- {
-
- if (is_array($helpers)) {
- foreach ($helpers as $dede) {
- helper($dede);
- }
- return;
- }
- if (isset($_helpers[$helpers])) {
- return;
- }
- if (file_exists(DEDEINC.'/helpers/'.$helpers.'.helper.php')) {
- include_once(DEDEINC.'/helpers/'.$helpers.'.helper.php');
- $_helpers[$helpers] = TRUE;
- }
-
- if (!isset($_helpers[$helpers])) {
- exit('Unable to load the requested file: helpers/'.$helpers.'.helper.php');
- }
- }
- function dede_htmlspecialchars($str)
- {
- global $cfg_soft_lang;
- if (version_compare(PHP_VERSION, '5.4.0', '<')) return htmlspecialchars($str);
- if ($cfg_soft_lang == 'gb2312') return htmlspecialchars($str, ENT_COMPAT, 'ISO-8859-1');
- else return htmlspecialchars($str);
- }
-
- function helpers($helpers)
- {
- helper($helpers);
- }
-
- if (!function_exists('file_put_contents')) {
- function file_put_contents($n, $d)
- {
- $f = @fopen($n, "w");
- if (!$f) {
- return FALSE;
- } else {
- fwrite($f, $d);
- fclose($f);
- return TRUE;
- }
- }
- }
-
- function UpdateStat()
- {
- include_once(DEDEINC."/inc/inc_stat.php");
- return SpUpdateStat();
- }
- $arrs1 = array();
- $arrs2 = array();
-
- function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
- {
- global $cfg_soft_lang, $cfg_cmsurl;
- 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'><base target='_self'></head>";
- $htmlhead .= "<body>".(isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '')."<center><script>";
- $htmlfoot = "</script></center></body></html>";
- $litime = ($limittime == 0 ? 1000 : $limittime);
- $func = '';
- if ($gourl == '-1') {
- if ($limittime == 0) $litime = 5000;
- $gourl = "javascript:history.go(-1);";
- }
- if ($gourl == '' || $onlymsg == 1) {
- $msg = "<script>alert(\"".str_replace("\"", "“", $msg)."\");</script>";
- } else {
-
- if (preg_match('/close::/', $gourl)) {
- $tgobj = trim(preg_replace('/close::/', '', $gourl));
- $gourl = 'javascript:;';
- $func .= "window.parent.document.getElementById('{$tgobj}').style.display='none';\r\n";
- }
- $func .= "var pgo=0;function JumpUrl(){if (pgo==0){location='$gourl'; pgo=1;}}";
- $rmsg = $func;
- $rmsg .= "document.write(\"<style>body{margin:0;line-height:1.5;font:14px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;color:#424b51;background:#f2f2f2}a{color:#28a745;text-decoration:none}.tips{margin:68px auto 0;padding:0;width:420px;height:auto;background:#fff;border-radius:.2rem}.tips-head{margin:0 20px;padding:16px 0;border-bottom:1px solid #f6f6f6}.tips-head p{margin:0;padding-left:10px;line-height:16px;text-align:left;border-left:3px solid #ff5722}.tips-box{padding:20px;min-height:120px;color:#666}.btn a{display:inline-block;margin:20px auto 0;padding:.375rem .75rem;font-size:12px;color:#fff;background:#28a745;border-radius:.2rem;text-align:center;transition:all .6s}.btn a:focus{background:#006829;border-color:#005b24;box-shadow:0 0 0 0.2rem rgba(38,159,86,.5)}@media (max-width:768px){body{padding:0 15px}.tips{width:100%}}</style>\");";
- $rmsg .= "document.write(\"<div class='tips'>";
- $rmsg .= "<div class='tips-head'><p>提示信息</p></div>\");";
- $rmsg .= "document.write(\"<div class='tips-box'>\");";
- $rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");";
- $rmsg .= "document.write(\"";
- if($onlymsg==0)
- {
- if( $gourl != 'javascript:;' && $gourl != '')
- {
- $rmsg .= "<div class='btn'><a href='{$gourl}'>点击反应</a></div>\");";
- $rmsg .= "setTimeout('JumpUrl()',$litime);";
- } else {
- $rmsg .= "</div>\");";
- }
- } else {
- $rmsg .= "</div>\");";
- }
- $msg = $htmlhead.$rmsg.$htmlfoot;
- }
- echo $msg;
- }
-
- function GetCkVdValue()
- {
- @session_id($_COOKIE['PHPSESSID']);
- @session_start();
- return isset($_SESSION['securimage_code_value']) ? $_SESSION['securimage_code_value'] : '';
- }
-
- function ResetVdValue()
- {
- @session_start();
- $_SESSION['securimage_code_value'] = '';
- }
- function IndexSub($idx, $num)
- {
- return intval($idx) - intval($num) == 0 ? '0 ' : intval($idx) - intval($num);
- }
-
- function IndexActive($idx)
- {
- if ($idx == 1) {
- return ' active';
- } else {
- return '';
- }
- }
-
-
- if (file_exists(DEDEINC.'/extend.func.php')) {
- require_once(DEDEINC.'/extend.func.php');
- }
|