@@ -14,7 +14,6 @@ src/install/index.html | |||||
src/install/module-install.php.bak | src/install/module-install.php.bak | ||||
src/a/*/ | src/a/*/ | ||||
src/.txt | src/.txt | ||||
src/data/enums/ | |||||
src/index.html | src/index.html | ||||
src/uploads/*.php | src/uploads/*.php | ||||
src/data/time.lock.inc | src/data/time.lock.inc | ||||
@@ -40,3 +39,5 @@ src/data/module/*.php | |||||
src/data/*.db | src/data/*.db | ||||
src/uploads/soft/*/ | src/uploads/soft/*/ | ||||
src/static/allimg/*/ | src/static/allimg/*/ | ||||
src/data/time.lock | |||||
src/static/enums/*.json |
@@ -0,0 +1 @@ | |||||
DedeBIZ |
@@ -9,6 +9,7 @@ | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(dirname(__FILE__).'/config.php'); | require_once(dirname(__FILE__).'/config.php'); | ||||
require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); | |||||
CheckPurview('sys_Edit'); | CheckPurview('sys_Edit'); | ||||
if (empty($action)) $action = ''; | if (empty($action)) $action = ''; | ||||
if (empty($message)) $message = '尚未进行检测……'; | if (empty($message)) $message = '尚未进行检测……'; | ||||
@@ -50,10 +51,11 @@ function TestOneFile($f) | |||||
if (preg_match("#(".$info.")[ \r\n\t]{0,}([\[\(])#i", $str)) { | if (preg_match("#(".$info.")[ \r\n\t]{0,}([\[\(])#i", $str)) { | ||||
$trfile = preg_replace("#^".DEDEROOT."#", '', $f); | $trfile = preg_replace("#^".DEDEROOT."#", '', $f); | ||||
$oldTrfile = $trfile; | $oldTrfile = $trfile; | ||||
$trfile = substr(str_replace("/", "\\", $trfile), 1); | |||||
$trfile = '/'.substr(str_replace("\\", "/", $trfile), 1); | |||||
$localFilehash = md5_file($f); | $localFilehash = md5_file($f); | ||||
$remoteFilehash = isset($offFiles[$trfile]) ? $offFiles[$trfile] : ''; | $remoteFilehash = isset($offFiles[$trfile]) ? $offFiles[$trfile] : ''; | ||||
if ($localFilehash === $remoteFilehash) { | if ($localFilehash === $remoteFilehash) { | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -15,7 +15,7 @@ $timestamp = time(); | |||||
@session_start(); | @session_start(); | ||||
//限制同时搜索数量 | //限制同时搜索数量 | ||||
$timelock = '../../data/time.lock'; | |||||
$timelock = DEDEDATA.'/time.lock'; | |||||
if ($cfg_allsearch_limit < 1) { | if ($cfg_allsearch_limit < 1) { | ||||
$cfg_allsearch_limit = 1; | $cfg_allsearch_limit = 1; | ||||
} | } | ||||
@@ -34,7 +34,7 @@ if ($mid == 0) { | |||||
exit(); | exit(); | ||||
} | } | ||||
$query = "SELECT maintable, mainfields, addontable, addonfields, template FROM #@__advancedsearch WHERE mid='$mid'"; | |||||
$query = "SELECT maintable, mainfields, addontable, addonfields, template FROM `#@__advancedsearch` WHERE mid='$mid'"; | |||||
$searchinfo = $dsql->GetOne($query); | $searchinfo = $dsql->GetOne($query); | ||||
if (!is_array($searchinfo)) { | if (!is_array($searchinfo)) { | ||||
showmsg('自定义搜索模型不存在', '-1'); | showmsg('自定义搜索模型不存在', '-1'); | ||||
@@ -171,12 +171,12 @@ if (empty($sql)) { | |||||
$where = str_replace('main.', 'addon.', $where); | $where = str_replace('main.', 'addon.', $where); | ||||
$orderby = str_replace('main.', 'addon.', $orderby); | $orderby = str_replace('main.', 'addon.', $orderby); | ||||
$query = "SELECT addon.*, arctype.* FROM $addontable addon | $query = "SELECT addon.*, arctype.* FROM $addontable addon | ||||
LEFT JOIN #@__arctype arctype ON arctype.id = addon.typeid | |||||
LEFT JOIN `#@__arctype` arctype ON arctype.id = addon.typeid | |||||
$where $orderby"; | $where $orderby"; | ||||
} else { | } else { | ||||
$query = "SELECT main.id AS aid,main.*,main.description AS description1, type.* | $query = "SELECT main.id AS aid,main.*,main.description AS description1, type.* | ||||
FROM $maintable main | FROM $maintable main | ||||
LEFT JOIN #@__arctype type ON type.id = main.typeid | |||||
LEFT JOIN `#@__arctype` type ON type.id = main.typeid | |||||
LEFT JOIN $addontable addon ON addon.aid = main.id | LEFT JOIN $addontable addon ON addon.aid = main.id | ||||
$where $orderby"; | $where $orderby"; | ||||
} | } | ||||
@@ -195,10 +195,10 @@ $dlist = new DataListCP(); | |||||
$dlist->pageSize = 20; | $dlist->pageSize = 20; | ||||
$dlist->SetParameter("hash", $sqlhash); | $dlist->SetParameter("hash", $sqlhash); | ||||
$dlist->SetParameter("mid", $mid); | $dlist->SetParameter("mid", $mid); | ||||
if (file_exists(DEDEROOT."/templets/default/$template")) { | |||||
$templatefile = DEDEROOT."/templets/default/$template"; | |||||
if (file_exists(DEDEROOT."/theme/templets/$template")) { | |||||
$templatefile = DEDEROOT."/theme/templets/$template"; | |||||
} else { | } else { | ||||
$templatefile = DEDEROOT."/templets/default/advancedsearch.htm"; | |||||
$templatefile = DEDEROOT."/theme/templets/advancedsearch.htm"; | |||||
} | } | ||||
$dlist->SetTemplate($templatefile); | $dlist->SetTemplate($templatefile); | ||||
$dlist->SetSource($query); | $dlist->SetSource($query); | ||||
@@ -4082,9 +4082,6 @@ INSERT INTO `#@__sysconfig` VALUES('1','cfg_basehost','站点网址(http://域 | |||||
('751','cfg_title_site','是否发布和编辑文档时远程发布,启用远程站点的前提下','2','bool','N'), | ('751','cfg_title_site','是否发布和编辑文档时远程发布,启用远程站点的前提下','2','bool','N'), | ||||
('752','cfg_mysql_type','数据库类型,支持MySQL和Mysqli','2','string','mysql'), | ('752','cfg_mysql_type','数据库类型,支持MySQL和Mysqli','2','string','mysql'), | ||||
('14', 'cfg_domain_cookie', '跨域共享Cookie的域名,例如: www.dedebiz.com', 2, 'string', ''), | ('14', 'cfg_domain_cookie', '跨域共享Cookie的域名,例如: www.dedebiz.com', 2, 'string', ''), | ||||
('756','cfg_memcache_enable','是否启用memcache缓存,如果为否,默认使用文件缓存',6,'bool','N'), | |||||
('757','cfg_memcache_mc_defa','默认MemCache缓存服务器地址',6,'string','memcache://127.0.0.1:123/default123'), | |||||
('758','cfg_memcache_mc_oth','附加MemCache缓存服务器地址',6,'string',''), | |||||
('759', 'cfg_cross_sectypeid', '支持交叉栏目显示副栏目内容', '7', 'bool', 'Y'), | ('759', 'cfg_cross_sectypeid', '支持交叉栏目显示副栏目内容', '7', 'bool', 'Y'), | ||||
('760', 'cfg_digg_update', '顶踩缓存异步更新间隔(0为不缓存)', '6', 'number', '0'), | ('760', 'cfg_digg_update', '顶踩缓存异步更新间隔(0为不缓存)', '6', 'number', '0'), | ||||
('761', 'cfg_feedback_guest', '是否允许匿名评论', '5', 'bool', 'N'), | ('761', 'cfg_feedback_guest', '是否允许匿名评论', '5', 'bool', 'N'), | ||||
@@ -0,0 +1 @@ | |||||
DedeBIZ |
@@ -17,6 +17,7 @@ define('DEBUG_LEVEL', FALSE);//如果设置为TRUE则会打印执行SQL的时间 | |||||
define('DEDEINC', str_replace("\\", '/', dirname(__FILE__))); | define('DEDEINC', str_replace("\\", '/', dirname(__FILE__))); | ||||
define('DEDEROOT', str_replace("\\", '/', substr(DEDEINC, 0, -6))); // 站点根目录 | define('DEDEROOT', str_replace("\\", '/', substr(DEDEINC, 0, -6))); // 站点根目录 | ||||
define('DEDEDATA', substr(DEDEINC, 0, -6).'data'); | define('DEDEDATA', substr(DEDEINC, 0, -6).'data'); | ||||
define('DEDESTATIC', DEDEROOT.'/static'); | |||||
define('DEDEMEMBER', DEDEROOT.'/user'); | define('DEDEMEMBER', DEDEROOT.'/user'); | ||||
define('DEDETEMPLATE', DEDEROOT.'/theme'); | define('DEDETEMPLATE', DEDEROOT.'/theme'); | ||||
define('DEDEBIZURL', "https://www.dedebiz.com");//Dede商业支持 | define('DEDEBIZURL', "https://www.dedebiz.com");//Dede商业支持 | ||||
@@ -231,16 +232,7 @@ if (isset($GLOBALS['PageNo'])) { | |||||
if (isset($GLOBALS['TotalResult'])) { | if (isset($GLOBALS['TotalResult'])) { | ||||
$GLOBALS['TotalResult'] = intval($GLOBALS['TotalResult']); | $GLOBALS['TotalResult'] = intval($GLOBALS['TotalResult']); | ||||
} | } | ||||
//设定缓存配置信息 | |||||
if ($cfg_memcache_enable == 'Y') { | |||||
$cache_helper_config = array(); | |||||
$cache_helper_config['memcache']['is_mc_enable'] = $GLOBALS["cfg_memcache_enable"]; | |||||
$cache_helper_config['memcache']['mc'] = array( | |||||
'default' => $GLOBALS["cfg_memcache_mc_defa"], | |||||
'other' => $GLOBALS["cfg_memcache_mc_oth"] | |||||
); | |||||
$cache_helper_config['memcache']['mc_cache_time'] = $GLOBALS["cfg_puccache_time"]; | |||||
} | |||||
if (!isset($cfg_NotPrintHead)) { | if (!isset($cfg_NotPrintHead)) { | ||||
if (PHP_SAPI != 'cli') { | if (PHP_SAPI != 'cli') { | ||||
header("Content-Type: text/html; charset={$cfg_soft_lang}"); | header("Content-Type: text/html; charset={$cfg_soft_lang}"); | ||||
@@ -49,8 +49,15 @@ function GetFormItem($ctag, $admintype = 'admin') | |||||
$myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n"; | $myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n"; | ||||
$GLOBALS['hasSetEnumJs'] = 'hasset'; | $GLOBALS['hasSetEnumJs'] = 'hasset'; | ||||
} | } | ||||
$myformItem .= "<script src='{$cmspath}data/enums/{$fieldname}.js'></script>\r\n"; | |||||
$myformItem .= '<script>MakeTopSelect("'.$fieldname.'", 0);</script>'."\r\n"; | |||||
$myformItem .= "<script> | |||||
var em_{$fieldname}s = []; | |||||
fetch('{$cmspath}static/enums/{$fieldname}.json').then((resp)=>resp.json()).then((d)=>{ | |||||
Object.entries(d).forEach(v=>{ | |||||
em_{$fieldname}s[parseFloat(v[0])]= v[1]; | |||||
}); | |||||
MakeTopSelect('$fieldname', 0); | |||||
}) | |||||
</script>\r\n"; | |||||
$formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); | $formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); | ||||
$formitem = str_replace('~form~', $myformItem, $formitem); | $formitem = str_replace('~form~', $myformItem, $formitem); | ||||
return $formitem; | return $formitem; | ||||
@@ -328,8 +335,15 @@ function GetFormItemValue($ctag, $fvalue, $admintype = 'admin', $fieldname = '') | |||||
$myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n"; | $myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n"; | ||||
$GLOBALS['hasSetEnumJs'] = 'hasset'; | $GLOBALS['hasSetEnumJs'] = 'hasset'; | ||||
} | } | ||||
$myformItem .= "<script src='{$cmspath}data/enums/{$fieldname}.js'></script>\r\n"; | |||||
$myformItem .= "<script>MakeTopSelect('$fieldname', $fvalue);</script>\r\n"; | |||||
$myformItem .= "<script> | |||||
var em_{$fieldname}s = []; | |||||
fetch('{$cmspath}static/enums/{$fieldname}.json').then((resp)=>resp.json()).then((d)=>{ | |||||
Object.entries(d).forEach(v=>{ | |||||
em_{$fieldname}s[parseFloat(v[0])]= v[1]; | |||||
}); | |||||
MakeTopSelect('$fieldname', $fvalue); | |||||
}) | |||||
</script>\r\n"; | |||||
$formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); | $formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); | ||||
$formitem = str_replace('~form~', $myformItem, $formitem); | $formitem = str_replace('~form~', $myformItem, $formitem); | ||||
return $formitem; | return $formitem; | ||||
@@ -33,22 +33,19 @@ function WriteEnumsCache($egroup = '') | |||||
$egroups[] = $nrow['egroup']; | $egroups[] = $nrow['egroup']; | ||||
} | } | ||||
foreach ($egroups as $egroup) { | foreach ($egroups as $egroup) { | ||||
$cachefile = DEDEDATA.'/enums/'.$egroup.'.php'; | |||||
$fp = fopen($cachefile, 'w'); | |||||
fwrite($fp, '<'."?php\r\nglobal \$em_{$egroup}s;\r\n\$em_{$egroup}s = array();\r\n"); | |||||
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json'; | |||||
$dsql->SetQuery("SELECT ename,evalue,issign FROM `#@__sys_enum` WHERE egroup='$egroup' ORDER BY disorder ASC, evalue ASC "); | $dsql->SetQuery("SELECT ename,evalue,issign FROM `#@__sys_enum` WHERE egroup='$egroup' ORDER BY disorder ASC, evalue ASC "); | ||||
$dsql->Execute('enum'); | $dsql->Execute('enum'); | ||||
$issign = -1; | $issign = -1; | ||||
$tenum = false; //三级联动标识 | $tenum = false; //三级联动标识 | ||||
$data = array(); | |||||
while ($nrow = $dsql->GetArray('enum')) { | while ($nrow = $dsql->GetArray('enum')) { | ||||
fwrite($fp, "\$em_{$egroup}s['{$nrow['evalue']}'] = '{$nrow['ename']}';\r\n"); | |||||
$data[$nrow['evalue']] = $nrow['ename']; | |||||
if ($issign == -1) $issign = $nrow['issign']; | if ($issign == -1) $issign = $nrow['issign']; | ||||
if ($nrow['issign'] == 2) $tenum = true; | if ($nrow['issign'] == 2) $tenum = true; | ||||
} | } | ||||
file_put_contents($cachefile,json_encode($data)); | |||||
if ($tenum) $dsql->ExecuteNoneQuery("UPDATE `#@__stepselect` SET `issign`=2 WHERE egroup='$egroup'; "); | if ($tenum) $dsql->ExecuteNoneQuery("UPDATE `#@__stepselect` SET `issign`=2 WHERE egroup='$egroup'; "); | ||||
fwrite($fp, '?'.'>'); | |||||
fclose($fp); | |||||
if (empty($issign)) WriteEnumsJs($egroup); | |||||
} | } | ||||
return '成功更新所有枚举缓存'; | return '成功更新所有枚举缓存'; | ||||
} | } | ||||
@@ -83,8 +80,11 @@ function GetEnumsTypes($v) | |||||
*/ | */ | ||||
function GetEnumsForm($egroup, $evalue = 0, $formid = '', $seltitle = '') | function GetEnumsForm($egroup, $evalue = 0, $formid = '', $seltitle = '') | ||||
{ | { | ||||
$cachefile = DEDEDATA.'/enums/'.$egroup.'.php'; | |||||
include($cachefile); | |||||
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
${'em_'.$egroup.'s'}[$key] = $value; | |||||
} | |||||
if ($formid == '') { | if ($formid == '') { | ||||
$formid = $egroup; | $formid = $egroup; | ||||
} | } | ||||
@@ -113,8 +113,11 @@ function GetEnumsForm($egroup, $evalue = 0, $formid = '', $seltitle = '') | |||||
function getTopData($egroup) | function getTopData($egroup) | ||||
{ | { | ||||
$data = array(); | $data = array(); | ||||
$cachefile = DEDEDATA.'/enums/'.$egroup.'.php'; | |||||
include($cachefile); | |||||
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
${'em_'.$egroup.'s'}[$key] = $value; | |||||
} | |||||
foreach (${'em_'.$egroup.'s'} as $k => $v) { | foreach (${'em_'.$egroup.'s'} as $k => $v) { | ||||
if ($k >= 500 && $k % 500 == 0) { | if ($k >= 500 && $k % 500 == 0) { | ||||
$data[$k] = $v; | $data[$k] = $v; | ||||
@@ -132,8 +135,12 @@ function getTopData($egroup) | |||||
function GetEnumsJs($egroup) | function GetEnumsJs($egroup) | ||||
{ | { | ||||
global ${'em_'.$egroup.'s'}; | global ${'em_'.$egroup.'s'}; | ||||
include_once(DEDEDATA.'/enums/'.$egroup.'.php'); | |||||
$jsCode = "<!--\r\n"; | |||||
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
${'em_'.$egroup.'s'}[$key] = $value; | |||||
} | |||||
$jsCode = ""; | |||||
$jsCode .= "em_{$egroup}s=new Array();\r\n"; | $jsCode .= "em_{$egroup}s=new Array();\r\n"; | ||||
foreach (${'em_'.$egroup.'s'} as $k => $v) { | foreach (${'em_'.$egroup.'s'} as $k => $v) { | ||||
//JS中将3级类目存放到第二个key中去 | //JS中将3级类目存放到第二个key中去 | ||||
@@ -144,23 +151,9 @@ function GetEnumsJs($egroup) | |||||
$jsCode .= "em_{$egroup}s[$k]='$v';\r\n"; | $jsCode .= "em_{$egroup}s[$k]='$v';\r\n"; | ||||
} | } | ||||
} | } | ||||
$jsCode .= "-->"; | |||||
return $jsCode; | return $jsCode; | ||||
} | } | ||||
/** | |||||
* 写入联动JS代码 | |||||
* | |||||
* @access public | |||||
* @param string $egroup 联动组 | |||||
* @return string | |||||
*/ | |||||
function WriteEnumsJs($egroup) | |||||
{ | |||||
$jsfile = DEDEDATA.'/enums/'.$egroup.'.js'; | |||||
$fp = fopen($jsfile, 'w'); | |||||
fwrite($fp, GetEnumsJs($egroup)); | |||||
fclose($fp); | |||||
} | |||||
/** | /** | ||||
* 获取枚举的值 | * 获取枚举的值 | ||||
* | * | ||||
@@ -171,7 +164,11 @@ function WriteEnumsJs($egroup) | |||||
*/ | */ | ||||
function GetEnumsValue($egroup, $evalue = 0) | function GetEnumsValue($egroup, $evalue = 0) | ||||
{ | { | ||||
include_once(DEDEDATA.'/enums/'.$egroup.'.php'); | |||||
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
${'em_'.$egroup.'s'}[$key] = $value; | |||||
} | |||||
if (isset(${'em_'.$egroup.'s'}[$evalue])) { | if (isset(${'em_'.$egroup.'s'}[$evalue])) { | ||||
return ${'em_'.$egroup.'s'}[$evalue]; | return ${'em_'.$egroup.'s'}[$evalue]; | ||||
} else { | } else { | ||||
@@ -1,7 +1,7 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit('dedebiz'); | if (!defined('DEDEINC')) exit('dedebiz'); | ||||
/** | /** | ||||
* 缓存小助手,支持文件和memcache | |||||
* 缓存小助手,支持文件和dedebiz cache | |||||
* | * | ||||
* @version $Id: cache.helper.php 1 10:46 2011-3-2 tianya $ | * @version $Id: cache.helper.php 1 10:46 2011-3-2 tianya $ | ||||
* @package DedeBIZ.Helpers | * @package DedeBIZ.Helpers | ||||
@@ -15,24 +15,24 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
* @access public | * @access public | ||||
* @param string $prefix 前缀 | * @param string $prefix 前缀 | ||||
* @param string $key 键 | * @param string $key 键 | ||||
* @param string $is_memcache 是否为memcache缓存 | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
if (!function_exists('GetCache')) { | if (!function_exists('GetCache')) { | ||||
function GetCache($prefix, $key, $is_memcache = TRUE) | |||||
function GetCache($prefix, $key) | |||||
{ | { | ||||
global $cache_helper_config; | |||||
global $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port; | |||||
$key = md5($key); | $key = md5($key); | ||||
//如果启用MC缓存 | |||||
if ($is_memcache === TRUE && !empty($cache_helper_config['memcache']) && $cache_helper_config['memcache']['is_mc_enable'] === 'Y') { | |||||
$mc_path = empty($cache_helper_config['memcache']['mc'][substr($key, 0, 1)]) ? $cache_helper_config['memcache']['mc']['default'] : $cache_helper_config['memcache']['mc'][substr($key, 0, 1)]; | |||||
$mc_path = parse_url($mc_path); | |||||
$key = ltrim($mc_path['path'], '/').'_'.$prefix.'_'.$key; | |||||
if (empty($GLOBALS['mc_'.$mc_path['host']])) { | |||||
$GLOBALS['mc_'.$mc_path['host']] = new Memcache(); | |||||
$GLOBALS['mc_'.$mc_path['host']]->connect($mc_path['host'], $mc_path['port']); | |||||
} | |||||
return $GLOBALS['mc_'.$mc_path['host']]->get($key); | |||||
// 商业组件缓存 | |||||
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { | |||||
$client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port); | |||||
$client->appid = $cfg_bizcore_appid; | |||||
$client->key = $cfg_bizcore_key; | |||||
$key = trim($prefix.'_'.$key); | |||||
$data = $client->CacheGet($key); | |||||
$result = unserialize($data->data); | |||||
$client->Close(); | |||||
return $result; | |||||
} | } | ||||
$key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | $key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | ||||
$result = @file_get_contents(DEDEDATA."/cache/$prefix/$key.php"); | $result = @file_get_contents(DEDEDATA."/cache/$prefix/$key.php"); | ||||
@@ -58,22 +58,20 @@ if (!function_exists('GetCache')) { | |||||
* @return int | * @return int | ||||
*/ | */ | ||||
if (!function_exists('SetCache')) { | if (!function_exists('SetCache')) { | ||||
function SetCache($prefix, $key, $value, $timeout = 3600, $is_memcache = TRUE) | |||||
function SetCache($prefix, $key, $value, $timeout = 3600) | |||||
{ | { | ||||
global $cache_helper_config; | |||||
global $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port; | |||||
$key = md5($key); | $key = md5($key); | ||||
//如果启用MC缓存 | |||||
if (!empty($cache_helper_config['memcache']) && $cache_helper_config['memcache']['is_mc_enable'] === 'Y' && $is_memcache === TRUE) { | |||||
$mc_path = empty($cache_helper_config['memcache']['mc'][substr($key, 0, 1)]) ? $cache_helper_config['memcache']['mc']['default'] : $cache_helper_config['memcache']['mc'][substr($key, 0, 1)]; | |||||
$mc_path = parse_url($mc_path); | |||||
$key = ltrim($mc_path['path'], '/').'_'.$prefix.'_'.$key; | |||||
if (empty($GLOBALS['mc_'.$mc_path['host']])) { | |||||
$GLOBALS['mc_'.$mc_path['host']] = new Memcache(); | |||||
$GLOBALS['mc_'.$mc_path['host']]->connect($mc_path['host'], $mc_path['port']); | |||||
//设置数据压缩门槛 | |||||
//$GLOBALS ['mc_'.$mc_path ['host']]->setCompressThreshold(2048, 0.2); | |||||
} | |||||
$result = $GLOBALS['mc_'.$mc_path['host']]->set($key, $value, MEMCACHE_COMPRESSED, $timeout); | |||||
// 商业组件缓存 | |||||
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { | |||||
$client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port); | |||||
$client->appid = $cfg_bizcore_appid; | |||||
$client->key = $cfg_bizcore_key; | |||||
$key = trim($prefix.'_'.$key); | |||||
$data = $client->CacheSet($key,serialize($value),$timeout); | |||||
$result = unserialize($data->data); | |||||
$client->Close(); | |||||
return $result; | return $result; | ||||
} | } | ||||
$key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | $key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | ||||
@@ -89,25 +87,25 @@ if (!function_exists('SetCache')) { | |||||
* @access public | * @access public | ||||
* @param string $prefix 前缀 | * @param string $prefix 前缀 | ||||
* @param string $key 键 | * @param string $key 键 | ||||
* @param string $is_memcache 是否为memcache缓存 | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
if (!function_exists('DelCache')) { | if (!function_exists('DelCache')) { | ||||
//删缓存 | //删缓存 | ||||
function DelCache($prefix, $key, $is_memcache = TRUE) | |||||
function DelCache($prefix, $key) | |||||
{ | { | ||||
global $cache_helper_config; | |||||
global $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port; | |||||
$key = md5($key); | $key = md5($key); | ||||
//如果启用MC缓存 | |||||
if (!empty($cache_helper_config['memcache']) && $cache_helper_config['memcache']['is_mc_enable'] === TRUE && $is_memcache === TRUE) { | |||||
$mc_path = empty($cache_helper_config['memcache']['mc'][substr($key, 0, 1)]) ? $cache_helper_config['memcache']['mc']['default'] : $cache_helper_config['memcache']['mc'][substr($key, 0, 1)]; | |||||
$mc_path = parse_url($mc_path); | |||||
$key = ltrim($mc_path['path'], '/').'_'.$prefix.'_'.$key; | |||||
if (empty($GLOBALS['mc_'.$mc_path['host']])) { | |||||
$GLOBALS['mc_'.$mc_path['host']] = new Memcache(); | |||||
$GLOBALS['mc_'.$mc_path['host']]->connect($mc_path['host'], $mc_path['port']); | |||||
} | |||||
return $GLOBALS['mc_'.$mc_path['host']]->delete($key); | |||||
// 商业组件缓存 | |||||
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { | |||||
$client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port); | |||||
$client->appid = $cfg_bizcore_appid; | |||||
$client->key = $cfg_bizcore_key; | |||||
$key = trim($prefix.'_'.$key); | |||||
$data = $client->CacheDel($key); | |||||
$client->Close(); | |||||
return true; | |||||
} | } | ||||
$key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | $key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key; | ||||
return @unlink(DEDEDATA."/cache/$prefix/$key.php"); | return @unlink(DEDEDATA."/cache/$prefix/$key.php"); | ||||
@@ -153,7 +153,7 @@ class DedeBizClient | |||||
"parms" => array( | "parms" => array( | ||||
"k" => $key, | "k" => $key, | ||||
"v" => $val, | "v" => $val, | ||||
"d" => $duration, | |||||
"d" => (string)$duration, | |||||
) | ) | ||||
); | ); | ||||
return $this->request($req); | return $this->request($req); | ||||
@@ -43,13 +43,27 @@ function lib_infoguide(&$ctag, &$refObj) | |||||
$fields['nativeplace'] .= "<input type='hidden' id='hidden_nativeplace' name='nativeplace' value='{$nativeplace}' />\r\n"; | $fields['nativeplace'] .= "<input type='hidden' id='hidden_nativeplace' name='nativeplace' value='{$nativeplace}' />\r\n"; | ||||
$fields['nativeplace'] .= "<span class='infosearchtxt'>地区:</span><span id='span_nativeplace'></span>\r\n"; | $fields['nativeplace'] .= "<span class='infosearchtxt'>地区:</span><span id='span_nativeplace'></span>\r\n"; | ||||
$fields['nativeplace'] .= "<span id='span_nativeplace_son'></span>\r\n<span id='span_nativeplace_sec'></span><br>\r\n"; | $fields['nativeplace'] .= "<span id='span_nativeplace_son'></span>\r\n<span id='span_nativeplace_sec'></span><br>\r\n"; | ||||
$fields['nativeplace'] .= "<script language='javascript' type='text/javascript' src='{$cfg_mainsite}{$cmspath}data/enums/nativeplace.js'></script>\r\n"; | |||||
$fields['nativeplace'] .= '<script language="javascript">MakeTopSelect("nativeplace", '.$nativeplace.');</script>'."\r\n"; | |||||
$fields['nativeplace'] .= "<script> | |||||
var em_nativeplaces = []; | |||||
fetch('{$cmspath}static/enums/nativeplace.json').then((resp)=>resp.json()).then((d)=>{ | |||||
Object.entries(d).forEach(v=>{ | |||||
em_nativeplaces[parseFloat(v[0])]= v[1]; | |||||
}); | |||||
MakeTopSelect('nativeplace', $nativeplace); | |||||
}) | |||||
</script>\r\n"; | |||||
$fields['infotype'] .= "<input type='hidden' id='hidden_infotype' name='infotype' value='{$infotype}' />\r\n"; | $fields['infotype'] .= "<input type='hidden' id='hidden_infotype' name='infotype' value='{$infotype}' />\r\n"; | ||||
$fields['infotype'] .= "<span class='infosearchtxt'>类型:</span><span id='span_infotype'></span>\r\n"; | $fields['infotype'] .= "<span class='infosearchtxt'>类型:</span><span id='span_infotype'></span>\r\n"; | ||||
$fields['infotype'] .= "<span id='span_infotype_son'></span><span id='span_infotype_sec'></span><br>\r\n"; | $fields['infotype'] .= "<span id='span_infotype_son'></span><span id='span_infotype_sec'></span><br>\r\n"; | ||||
$fields['infotype'] .= "<script language='javascript' type='text/javascript' src='{$cfg_mainsite}{$cmspath}data/enums/infotype.js'></script>\r\n"; | |||||
$fields['infotype'] .= '<script language="javascript">MakeTopSelect("infotype", '.$infotype.');</script>'."\r\n"; | |||||
$fields['infotype'] .= "<script> | |||||
var em_infotypes = []; | |||||
fetch('{$cmspath}static/enums/infotype.json').then((resp)=>resp.json()).then((d)=>{ | |||||
Object.entries(d).forEach(v=>{ | |||||
em_infotypes[parseFloat(v[0])]= v[1]; | |||||
}); | |||||
MakeTopSelect('infotype', $infotype); | |||||
}) | |||||
</script>\r\n"; | |||||
if (is_array($ctp->CTags)) { | if (is_array($ctp->CTags)) { | ||||
foreach ($ctp->CTags as $tagid => $ctag) { | foreach ($ctp->CTags as $tagid => $ctag) { | ||||
if (isset($fields[$ctag->GetName()])) { | if (isset($fields[$ctag->GetName()])) { | ||||
@@ -10,12 +10,25 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
require_once(DEDEINC.'/enums.func.php'); | require_once(DEDEINC.'/enums.func.php'); | ||||
require_once(DEDEDATA.'/enums/nativeplace.php'); | |||||
require_once(DEDEDATA.'/enums/infotype.php'); | |||||
$cachefile = DEDESTATIC.'/enums/nativeplace.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
$GLOBALS['em_nativeplaces'][$key] = $value; | |||||
} | |||||
$cachefile = DEDESTATIC.'/enums/infotype.json'; | |||||
$data = json_decode(file_get_contents($cachefile)); | |||||
foreach ($data as $key => $value) { | |||||
$GLOBALS['em_infotypes'][$key] = $value; | |||||
} | |||||
function lib_infolink(&$ctag, &$refObj) | function lib_infolink(&$ctag, &$refObj) | ||||
{ | { | ||||
global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite; | global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite; | ||||
global $em_nativeplaces, $em_infotypes; | global $em_nativeplaces, $em_infotypes; | ||||
//属性处理 | //属性处理 | ||||
//$attlist="row|12,titlelen|24"; | //$attlist="row|12,titlelen|24"; | ||||
//FillAttsDefault($ctag->CAttribute->Items,$attlist); | //FillAttsDefault($ctag->CAttribute->Items,$attlist); | ||||