#14 develop

Merged
tianya merged 8 commits from develop into master 2 years ago
  1. +2
    -1
      .gitignore
  2. +6
    -0
      docs/changelog.md
  3. +1
    -0
      src/a/.dedekeep
  4. +3
    -1
      src/admin/sys_safetest.php
  5. +1
    -1
      src/admin/templets/index.htm
  6. +1
    -1
      src/admin/templets/index_body.htm
  7. +13
    -0
      src/admin/templets/mychannel_edit.htm
  8. +1
    -1
      src/admin/templets/sys_safetest.htm
  9. +7
    -7
      src/apps/advancedsearch.php
  10. +1
    -1
      src/install/index.php
  11. +0
    -3
      src/install/sql-dfdata.txt
  12. +1
    -1
      src/install/templates/step-1.html
  13. +1
    -0
      src/static/enums/.dedekeep
  14. +2
    -2
      src/system/archive/archives.class.php
  15. +29
    -49
      src/system/common.inc.php
  16. +18
    -4
      src/system/customfields.func.php
  17. +26
    -29
      src/system/enums.func.php
  18. +39
    -41
      src/system/helpers/cache.helper.php
  19. +1
    -19
      src/system/inc/inc_fun_funAdmin.php
  20. +12
    -4
      src/system/libraries/dedebiz.class.php
  21. +4
    -9
      src/system/taglib/channel/stepselect.lib.php
  22. +18
    -4
      src/system/taglib/infoguide.lib.php
  23. +15
    -2
      src/system/taglib/infolink.lib.php

+ 2
- 1
.gitignore View File

@@ -14,7 +14,6 @@ src/install/index.html
src/install/module-install.php.bak
src/a/*/
src/.txt
src/data/enums/
src/index.html
src/uploads/*.php
src/data/time.lock.inc
@@ -40,3 +39,5 @@ src/data/module/*.php
src/data/*.db
src/uploads/soft/*/
src/static/allimg/*/
src/data/time.lock
src/static/enums/*.json

+ 6
- 0
docs/changelog.md View File

@@ -1,6 +1,12 @@
# 更新记录
通过访问 https://www.dedebiz.com/git 获取完整更新记录

# v6.1.1
- 修正子目录安装问题;
- 生产环境错误处理调整;
- 重写联动类型缓存模式&移除对memcache支持;
- 移除无效资源;

# v6.1.0
- 兼容PHP8+;
- 修正已知存在的安全问题;


+ 1
- 0
src/a/.dedekeep View File

@@ -0,0 +1 @@
DedeBIZ

+ 3
- 1
src/admin/sys_safetest.php View File

@@ -9,6 +9,7 @@
* @link https://www.dedebiz.com
*/
require_once(dirname(__FILE__).'/config.php');
require_once(DEDEINC.'/libraries/dedehttpdown.class.php');
CheckPurview('sys_Edit');
if (empty($action)) $action = '';
if (empty($message)) $message = '尚未进行检测……';
@@ -50,10 +51,11 @@ function TestOneFile($f)
if (preg_match("#(".$info.")[ \r\n\t]{0,}([\[\(])#i", $str)) {
$trfile = preg_replace("#^".DEDEROOT."#", '', $f);
$oldTrfile = $trfile;
$trfile = substr(str_replace("/", "\\", $trfile), 1);
$trfile = '/'.substr(str_replace("\\", "/", $trfile), 1);

$localFilehash = md5_file($f);
$remoteFilehash = isset($offFiles[$trfile]) ? $offFiles[$trfile] : '';

if ($localFilehash === $remoteFilehash) {
return 0;
}


+ 1
- 1
src/admin/templets/index.htm View File

@@ -40,7 +40,7 @@
<div class="top_link">
<ul>
<li class="welcome">
<a target="main" href="sys_admin_user_edit.php?id=<?php echo $cuserLogin->getUserID(); ?>&dopost=edit"><img src="/static/img/avatar.png" title="<?php echo $cuserLogin->getUserName(); ?>"><?php echo $cuserLogin->getUserName(); ?></a>
<a target="main" href="sys_admin_user_edit.php?id=<?php echo $cuserLogin->getUserID(); ?>&dopost=edit"><img src="../static/img/avatar.png" title="<?php echo $cuserLogin->getUserName(); ?>"><?php echo $cuserLogin->getUserName(); ?></a>
<a href="exit.php">退出</a>
</li>
<?php


+ 1
- 1
src/admin/templets/index_body.htm View File

@@ -226,7 +226,7 @@
infoStr += `
<tr>
<td class="nline" style="text-align:left">授权域名:</td>
<td class="nline" style="text-align:left">${rsp.result.domain}<a href="<?php echo $cfg_biz_dedebizUrl;?>/auth/?domain=${rsp.result.domain}" class="btn btn-danger btn-sm">查看</a></td>
<td class="nline" style="text-align:left">${rsp.result.domain} <a href="<?php echo $cfg_biz_dedebizUrl;?>/auth/?domain=${rsp.result.domain}" class="btn btn-danger btn-sm">查看</a></td>
</tr>
`;
}


+ 13
- 0
src/admin/templets/mychannel_edit.htm View File

@@ -43,6 +43,13 @@
}

function ShowItem2() {
setTimeout(() => {
var editor = CodeMirror.fromTextArea(document.getElementById('fieldset'), {
lineNumbers: true,
lineWrapping: true,
mode: 'text/html'
});
}, 100);
ShowObj('head2'); ShowObj('adset');
HideObj('head1'); HideObj('needset');
}
@@ -50,6 +57,12 @@
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/codemirror.css">
<script type="text/javascript" src="js/codemirror.js"></script>
<script type="text/javascript" src="js/mode/xml/xml.js"></script>
<script type="text/javascript" src="js/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="js/mode/css/css.js"></script>
<script type="text/javascript" src="js/mode/htmlmixed/htmlmixed.js"></script>
</head>
<body topmargin="8">
<form name="form1" action="mychannel_edit.php" method="post">


+ 1
- 1
src/admin/templets/sys_safetest.htm View File

@@ -51,7 +51,7 @@
<td height="73" colspan="2" bgcolor="#FFFFFF">
<strong>安全建议:</strong>
<br>
1、有条件的用户把中 data、templets、uploads、html、special、images、install目录设置为不允许执行脚本,其它目录禁止写入,系统将更安全;<br>
1、有条件的用户把data、system、theme更改为不可对外访问,static、a目录设置为不允许执行脚本,其它目录禁止写入,系统将更安全;<br>
2、本检测程以开发模式为标准,如果您的网站目录包含其它系统,此检测程序可能会产生错误判断;<br>
3、检测程序会跳过对模板缓存目录的检测,为了安全起见,检测完成后建议清空模板缓存
</td>


+ 7
- 7
src/apps/advancedsearch.php View File

@@ -15,7 +15,7 @@ $timestamp = time();
@session_start();
//限制同时搜索数量
$timelock = '../../data/time.lock';
$timelock = DEDEDATA.'/time.lock';
if ($cfg_allsearch_limit < 1) {
$cfg_allsearch_limit = 1;
}
@@ -34,7 +34,7 @@ if ($mid == 0) {
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);
if (!is_array($searchinfo)) {
showmsg('自定义搜索模型不存在', '-1');
@@ -171,12 +171,12 @@ if (empty($sql)) {
$where = str_replace('main.', 'addon.', $where);
$orderby = str_replace('main.', 'addon.', $orderby);
$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";
} else {
$query = "SELECT main.id AS aid,main.*,main.description AS description1, type.*
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
$where $orderby";
}
@@ -195,10 +195,10 @@ $dlist = new DataListCP();
$dlist->pageSize = 20;
$dlist->SetParameter("hash", $sqlhash);
$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 {
$templatefile = DEDEROOT."/templets/default/advancedsearch.htm";
$templatefile = DEDEROOT."/theme/templets/advancedsearch.htm";
}
$dlist->SetTemplate($templatefile);
$dlist->SetSource($query);


+ 1
- 1
src/install/index.php View File

@@ -17,7 +17,7 @@ if(file_exists(INSLOCKFILE))

$verMsg = 'V6';
$dfDbname = 'DedeBIZ';
$cfg_version_detail = '6.1.0'; //详细版本号
$cfg_version_detail = '6.1.1'; //详细版本号
$errmsg = '';
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
mysqli_report(MYSQLI_REPORT_OFF);


+ 0
- 3
src/install/sql-dfdata.txt View File

@@ -4082,9 +4082,6 @@ INSERT INTO `#@__sysconfig` VALUES('1','cfg_basehost','站点网址(http://域
('751','cfg_title_site','是否发布和编辑文档时远程发布,启用远程站点的前提下','2','bool','N'),
('752','cfg_mysql_type','数据库类型,支持MySQL和Mysqli','2','string','mysql'),
('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'),
('760', 'cfg_digg_update', '顶踩缓存异步更新间隔(0为不缓存)', '6', 'number', '0'),
('761', 'cfg_feedback_guest', '是否允许匿名评论', '5', 'bool', 'N'),


+ 1
- 1
src/install/templates/step-1.html View File

@@ -97,7 +97,7 @@
</div>
<div class="mb-3">
<label for="cmspath" class="form-label">安装目录</label>
<input name="cmspath" type="text" class="form-control" id="cmspath" placeholder="<?php echo $basepath; ?>">
<input name="cmspath" type="text" class="form-control" id="cmspath" value="<?php echo $basepath; ?>" placeholder="<?php echo $basepath; ?>">
<div class="form-text text-danger">在根目录安装时不必理会</div>
</div>
<button type="submit" class="btn btn-success">立即安装</button>


+ 1
- 0
src/static/enums/.dedekeep View File

@@ -0,0 +1 @@
DedeBIZ

+ 2
- 2
src/system/archive/archives.class.php View File

@@ -67,8 +67,8 @@ class Archives
//如果当前文档不是系统模型,为单表模型
$query = "SELECT arc.*,tp.reid,tp.typedir,ch.addtable
FROM `#@__archives` arc
LEFT JOIN #@__arctype tp on tp.id=arc.typeid
LEFT JOIN #@__channeltype as ch on arc.channel = ch.id
LEFT JOIN `#@__arctype` tp on tp.id=arc.typeid
LEFT JOIN `#@__channeltype` as ch on arc.channel = ch.id
WHERE arc.id='$aid' ";
$this->Fields = $this->dsql->GetOne($query);
} else {


+ 29
- 49
src/system/common.inc.php View File

@@ -9,14 +9,24 @@
//生产环境使用production,如果采用dev模式,会有一些php的报错信息提示,便于开发调试
define('DEDE_ENVIRONMENT', 'production');
if (DEDE_ENVIRONMENT == 'production') {
error_reporting(E_ALL || ~E_NOTICE);
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>='))
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
else
{
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
} else {
error_reporting(E_ALL);
error_reporting(-1);
ini_set('display_errors', 1);
}
define('DEBUG_LEVEL', FALSE);//如果设置为TRUE则会打印执行SQL的时间和标签加载时间方便调试
define('DEDEINC', str_replace("\\", '/', dirname(__FILE__)));
define('DEDEROOT', str_replace("\\", '/', substr(DEDEINC, 0, -6))); // 站点根目录
define('DEDEDATA', substr(DEDEINC, 0, -6).'data');
define('DEDESTATIC', DEDEROOT.'/static');
define('DEDEMEMBER', DEDEROOT.'/user');
define('DEDETEMPLATE', DEDEROOT.'/theme');
define('DEDEBIZURL', "https://www.dedebiz.com");//Dede商业支持
@@ -31,9 +41,6 @@ NQabUzX9JoYtXqPcpZRT7ymHrppU0KFdUSEJiW0utTWJo0HrDOBIT5qWlM0MP9p/
PwIDAQAB
-----END PUBLIC KEY-----'); //DedeBIZ系统公钥
define('DEDECDNURL', 'https://cdn.dedebiz.com'); //默认静态资源地址
if (version_compare(PHP_VERSION, '5.3.0', '<') && function_exists("get_magic_quotes_gpc")) {
set_magic_quotes_runtime(0);
}
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
if (!function_exists('session_register')) {
function session_register()
@@ -59,42 +66,25 @@ if (function_exists('mb_substr')) $cfg_is_mb = TRUE;
if (function_exists('iconv_substr')) $cfg_is_iconv = TRUE;
function _RunMagicQuotes(&$svar)
{
if (function_exists("get_magic_quotes_gpc") && !@get_magic_quotes_gpc()) {
if (is_array($svar)) {
foreach ($svar as $_k => $_v) $svar[$_k] = _RunMagicQuotes($_v);
} else {
if (strlen($svar) > 0 && preg_match('#^(cfg_|GLOBALS|_GET|_POST|_COOKIE|_SESSION)#', $svar)) {
exit('Request var not allow!');
}
$svar = addslashes($svar);
if (is_array($svar)) {
foreach ($svar as $_k => $_v) {
if ($_k == 'nvarname') continue;
_RunMagicQuotes($_k);
$svar[$_k] = _RunMagicQuotes($_v);
}
} else {
if (strlen($svar) > 0 && preg_match('#^(cfg_|GLOBALS|_GET|_REQUEST|_POST|_COOKIE|_SESSION)#', $svar)) {
exit('Request var not allow!');
}
$svar = addslashes($svar);
}
return $svar;
}
if (!defined('DEDEREQUEST')) {
//检查和注册外部提交的变量(2011.8.10 修改登录时相关过滤)
function CheckRequest(&$val)
{
if (is_array($val)) {
foreach ($val as $_k => $_v) {
if ($_k == 'nvarname') continue;
CheckRequest($_k);
CheckRequest($val[$_k]);
}
} else {
if (strlen($val) > 0 && preg_match('#^(cfg_|GLOBALS|_GET|_POST|_COOKIE|_SESSION)#', $val)) {
exit('Request var not allow!');
}
}
}
//var_dump($_REQUEST);exit;
CheckRequest($_REQUEST);
CheckRequest($_COOKIE);
foreach (array('_GET', '_POST', '_COOKIE') as $_request) {
foreach ($$_request as $_k => $_v) {
if ($_k == 'nvarname') ${$_k} = $_v;
else ${$_k} = _RunMagicQuotes($_v);
}

foreach (array('_GET', '_POST', '_COOKIE') as $_req) {
foreach ($$_req as $_k => $_v) {
if ($_k == 'nvarname') ${$_k} = $_v;
else ${$_k} = _RunMagicQuotes($_v);
}
}
//系统相关变量检测
@@ -194,7 +184,7 @@ $cfg_soft_dir = $cfg_medias_dir.'/soft';
$cfg_other_medias = $cfg_medias_dir.'/media';
//软件摘要信息,****请不要删除本项**** 否则系统无法正确接收系统漏洞或升级信息
$cfg_version = 'V6';
$cfg_version_detail = '6.1.0'; //详细版本号
$cfg_version_detail = '6.1.1'; //详细版本号
$cfg_soft_lang = 'utf-8';
$cfg_soft_public = 'base';
$cfg_softname = '织梦内容管理系统';
@@ -231,21 +221,11 @@ if (isset($GLOBALS['PageNo'])) {
if (isset($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 (PHP_SAPI != 'cli') {
header("Content-Type: text/html; charset={$cfg_soft_lang}");
}
}
//自动加载类库处理
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {


+ 18
- 4
src/system/customfields.func.php View File

@@ -49,8 +49,15 @@ function GetFormItem($ctag, $admintype = 'admin')
$myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n";
$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('~form~', $myformItem, $formitem);
return $formitem;
@@ -328,8 +335,15 @@ function GetFormItemValue($ctag, $fvalue, $admintype = 'admin', $fieldname = '')
$myformItem .= '<script src="'.$cmspath.'static/enums.js"></script>'."\r\n";
$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('~form~', $myformItem, $formitem);
return $formitem;


+ 26
- 29
src/system/enums.func.php View File

@@ -33,22 +33,19 @@ function WriteEnumsCache($egroup = '')
$egroups[] = $nrow['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->Execute('enum');
$issign = -1;
$tenum = false; //三级联动标识
$data = array();
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 ($nrow['issign'] == 2) $tenum = true;
}
file_put_contents($cachefile,json_encode($data));
if ($tenum) $dsql->ExecuteNoneQuery("UPDATE `#@__stepselect` SET `issign`=2 WHERE egroup='$egroup'; ");
fwrite($fp, '?'.'>');
fclose($fp);
if (empty($issign)) WriteEnumsJs($egroup);
}
return '成功更新所有枚举缓存';
}
@@ -83,8 +80,11 @@ function GetEnumsTypes($v)
*/
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 == '') {
$formid = $egroup;
}
@@ -113,8 +113,11 @@ function GetEnumsForm($egroup, $evalue = 0, $formid = '', $seltitle = '')
function getTopData($egroup)
{
$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) {
if ($k >= 500 && $k % 500 == 0) {
$data[$k] = $v;
@@ -132,8 +135,12 @@ function getTopData($egroup)
function GetEnumsJs($egroup)
{
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";
foreach (${'em_'.$egroup.'s'} as $k => $v) {
//JS中将3级类目存放到第二个key中去
@@ -144,23 +151,9 @@ function GetEnumsJs($egroup)
$jsCode .= "em_{$egroup}s[$k]='$v';\r\n";
}
}
$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)
{
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])) {
return ${'em_'.$egroup.'s'}[$evalue];
} else {


+ 39
- 41
src/system/helpers/cache.helper.php View File

@@ -1,7 +1,7 @@
<?php
if (!defined('DEDEINC')) exit('dedebiz');
/**
* 缓存小助手,支持文件和memcache
* 缓存小助手,支持文件和dedebiz cache
*
* @version $Id: cache.helper.php 1 10:46 2011-3-2 tianya $
* @package DedeBIZ.Helpers
@@ -15,24 +15,24 @@ if (!defined('DEDEINC')) exit('dedebiz');
* @access public
* @param string $prefix 前缀
* @param string $key 键
* @param string $is_memcache 是否为memcache缓存
* @return string
*/
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);
//如果启用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;
$result = @file_get_contents(DEDEDATA."/cache/$prefix/$key.php");
@@ -58,22 +58,20 @@ if (!function_exists('GetCache')) {
* @return int
*/
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);
//如果启用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;
}
$key = substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2).'/'.$key;
@@ -89,25 +87,25 @@ if (!function_exists('SetCache')) {
* @access public
* @param string $prefix 前缀
* @param string $key 键
* @param string $is_memcache 是否为memcache缓存
* @return string
*/
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);
//如果启用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;
return @unlink(DEDEDATA."/cache/$prefix/$key.php");


+ 1
- 19
src/system/inc/inc_fun_funAdmin.php View File

@@ -146,25 +146,7 @@ function SpGetEditor($fname, $fvalue, $nheight = "350", $etype = "Basic", $gtype
if ($gtype == "") {
$gtype = "print";
}
if ($GLOBALS['cfg_html_editor'] == 'fck') {
require_once(DEDEINC.'/FCKeditor/fckeditor.php');
$fck = new FCKeditor($fname);
$fck->BasePath = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/';
$fck->Width = '100%';
$fck->Height = $nheight;
$fck->ToolbarSet = $etype;
$fck->Config['FullPage'] = $isfullpage;
if ($GLOBALS['cfg_fck_xhtml'] == 'Y') {
$fck->Config['EnableXHTML'] = 'true';
$fck->Config['EnableSourceXHTML'] = 'true';
}
$fck->Value = $fvalue;
if ($gtype == "print") {
$fck->Create();
} else {
return $fck->CreateHtml();
}
} else if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
$addConfig = "";
if (defined("DEDEADMIN")) {
$addConfig = ",{allowedContent:true,filebrowserImageUploadUrl:'./dialog/select_images_post.php',filebrowserUploadUrl:'./dialog/select_media_post.php?ck=1',extraPlugins:'html5video,dedepagebreak,ddfilebrowser,mimage,textindent'}";


+ 12
- 4
src/system/libraries/dedebiz.class.php View File

@@ -153,7 +153,7 @@ class DedeBizClient
"parms" => array(
"k" => $key,
"v" => $val,
"d" => $duration,
"d" => (string)$duration,
)
);
return $this->request($req);
@@ -244,9 +244,17 @@ class DedeBizClient
function Close()
{
//这里避免重复释放
if (strtolower(get_resource_type($this->socket)) === "socket") {
socket_close($this->socket);
}
try {
if (strtolower(get_resource_type($this->socket)) === "socket") {
socket_close($this->socket);
}
return true;
} catch (TypeError $e) {
return false;
} catch (Exception $e) {
return false;
}
}
function __destruct()
{


+ 4
- 9
src/system/taglib/channel/stepselect.lib.php View File

@@ -16,15 +16,10 @@ function ch_stepselect($fvalue, &$arcTag, &$refObj, $fname = '')
function GetEnumsValue2($egroup, $evalue = 0)
{
if (!isset($GLOBALS['em_'.$egroup.'s'])) {
$cachefile = DEDEDATA.'/enums/'.$egroup.'.php';
if (!file_exists($cachefile)) {
require_once(DEDEINC.'/enums.func.php');
WriteEnumsCache();
}
if (!file_exists($cachefile)) {
return '';
} else {
require_once($cachefile);
$cachefile = DEDESTATIC.'/enums/'.$egroup.'.json';
$data = json_decode(file_get_contents($cachefile));
foreach ($data as $key => $value) {
$GLOBALS['em_'.$egroup.'s'][$key] = $value;
}
}
if ($evalue >= 500) {


+ 18
- 4
src/system/taglib/infoguide.lib.php View File

@@ -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'] .= "<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'] .= "<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'] .= "<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'] .= "<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)) {
foreach ($ctp->CTags as $tagid => $ctag) {
if (isset($fields[$ctag->GetName()])) {


+ 15
- 2
src/system/taglib/infolink.lib.php View File

@@ -10,12 +10,25 @@ if (!defined('DEDEINC')) exit('dedebiz');
* @link https://www.dedebiz.com
*/
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)
{
global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite;
global $em_nativeplaces, $em_infotypes;
//属性处理
//$attlist="row|12,titlelen|24";
//FillAttsDefault($ctag->CAttribute->Items,$attlist);


Loading…
Cancel
Save