diff --git a/src/admin/catalog_add.php b/src/admin/catalog_add.php index 8da51e10..53518566 100644 --- a/src/admin/catalog_add.php +++ b/src/admin/catalog_add.php @@ -166,7 +166,7 @@ if ($dopost == 'quick') { } //创建目录 if ($ispart != 2) { - $true_typedir = str_replace("{cmspath}", "", $typedir); + $true_typedir = str_replace("{cmspath}", $cfg_cmspath, $typedir); $true_typedir = preg_replace("#\/{1,}#", "/", $true_typedir); if (!CreateDir($true_typedir)) { ShowMsg("创建目录{$true_typedir}失败,请检查路径是否存在问题", "-1"); diff --git a/src/admin/dialog/select_soft.php b/src/admin/dialog/select_soft.php index 8543e3b6..6691487f 100644 --- a/src/admin/dialog/select_soft.php +++ b/src/admin/dialog/select_soft.php @@ -157,7 +157,7 @@ if (!empty($noeditor)) { window.opener.CKEDITOR.tools.callFunction(funcNum, reimg); } if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") { - let addonHTML = `<a href='${reimg}' target='_blank'><img src='/static/web/img/icon_addon.png'> 附件:${reimg}</a>`; + let addonHTML = `<a href='${reimg}' target='_blank'><img src='<?php echo $cfg_cmspath ?>/static/web/img/icon_addon.png'>附件:${reimg}</a>`; window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML); } if (window.opener.document.<?php echo $f ?> != null) { diff --git a/src/admin/file_manage_main.php b/src/admin/file_manage_main.php index 52ba6085..e705b50b 100644 --- a/src/admin/file_manage_main.php +++ b/src/admin/file_manage_main.php @@ -10,7 +10,7 @@ */ require(dirname(__FILE__)."/config.php"); CheckPurview('plus_文件管理器'); -if (!isset($activepath)) $activepath = DEDEBIZ_SAFE_MODE? $cfg_medias_dir : '/'; +if (!isset($activepath)) $activepath = DEDEBIZ_SAFE_MODE? $cfg_medias_dir : $cfg_cmspath; $inpath = ''; $activepath = str_replace("..", "", $activepath); $activepath = preg_replace("#^\/{1,}#", "/", $activepath); diff --git a/src/admin/friendlink_edit.php b/src/admin/friendlink_edit.php index bb50073a..7c8d6bd3 100644 --- a/src/admin/friendlink_edit.php +++ b/src/admin/friendlink_edit.php @@ -60,7 +60,7 @@ if ($dopost == "delete") { $fullfilename = DEDEROOT.'/static/flink/'.$logoimg_name; move_uploaded_file($logoimg, $fullfilename) or die("上传文件到".$fullfilename."失败"); @unlink($logoimg); - $logo = '/static/flink/'.$logoimg_name; + $logo = $cfg_cmspath.'/static/flink/'.$logoimg_name; } $sortrank = isset($sortrank)? intval($sortrank) : 1; $url = isset($url)? HtmlReplace($url, -1) : ''; diff --git a/src/admin/inc/inc_archives_all.php b/src/admin/inc/inc_archives_all.php index b23fd831..fdb0bd8a 100644 --- a/src/admin/inc/inc_archives_all.php +++ b/src/admin/inc/inc_archives_all.php @@ -153,7 +153,7 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '') fclose($fp); return $addvar; } else { - $ipath = '/data/textdata'; + $ipath = $GLOBALS['cfg_cmspath']."/data/textdata"; $tpath = ceil($aid / 5000); if (!is_dir($GLOBALS['cfg_basedir'].$ipath)) { MkdirAll($GLOBALS['cfg_basedir'].$ipath, $cfg_dir_purview); diff --git a/src/admin/makehtml_taglist_action.php b/src/admin/makehtml_taglist_action.php index 6f593fb7..11ce9343 100644 --- a/src/admin/makehtml_taglist_action.php +++ b/src/admin/makehtml_taglist_action.php @@ -20,7 +20,7 @@ if (empty($maxpagesize)) $maxpagesize = 30; $startid = isset($startid) ? intval($startid) : 0; $endid = isset($endid) ? intval($endid) : 0; $tagid = isset($tagid) ? intval($tagid) : 0; -$tagsdir = str_replace("{cmspath}", "", $cfg_tags_dir); +$tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); //生成 if ($tagid > 0) { $upall = 0; //更新单个模式 @@ -50,7 +50,7 @@ if ($ctagid == 0 && $allfinish) { } $tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;"); //创建TAGS目录 -$tagsDir = str_replace("{cmspath}", "", $cfg_tags_dir); +$tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir); MkdirAll($cfg_basedir.$tagsDir, $cfg_dir_purview); if (is_array($tag) && count($tag) > 0) { $dlist = new TagList($tag['id'], 'tag_list.htm'); diff --git a/src/admin/module_main.php b/src/admin/module_main.php index 843d0444..22f4f926 100644 --- a/src/admin/module_main.php +++ b/src/admin/module_main.php @@ -237,7 +237,8 @@ if ($action == '') { $setupsql = preg_replace("#TYPE=MyISAM#i", $sql41tmp, $setupsql); } //_ROOTURL_ - $rooturl = $cfg_basehost; + if ($cfg_cmspath == '/') $cfg_cmspath = ''; + $rooturl = $cfg_basehost.$cfg_cmspath; $setupsql = preg_replace("#_ROOTURL_#i", $rooturl, $setupsql); $setupsql = preg_replace("#[\r\n]{1,}#", "\n", $setupsql); $sqls = preg_split('/;[ \t]{0,}\n/', $setupsql); diff --git a/src/admin/mychannel_edit.php b/src/admin/mychannel_edit.php index 7071dbab..77542e7b 100644 --- a/src/admin/mychannel_edit.php +++ b/src/admin/mychannel_edit.php @@ -440,7 +440,7 @@ if ($dopost == "show") { $addonfields = ''; } $template = trim($template); - $forms = "<form action=\"/apps/advancedsearch.php\" method=\"post\">"; + $forms = "<form action=\"$cfg_cmspath/apps/advancedsearch.php\" method=\"post\">"; $forms .= "<input type=\"hidden\" name=\"mid\" value=\"$mid\">"; $forms .= "<input type=\"hidden\" name=\"dopost\" value=\"search\">"; $forms .= "<label>关键词:<input type=\"text\" name=\"q\"></label><br>"; diff --git a/src/admin/templets/makehtml_spec.htm b/src/admin/templets/makehtml_spec.htm index 0bc5009a..921ec535 100644 --- a/src/admin/templets/makehtml_spec.htm +++ b/src/admin/templets/makehtml_spec.htm @@ -16,7 +16,7 @@ <div class="card shadow-sm"> <div class="card-header">更新专题</div> <div class="card-body"> - <div class="alert alert-info">发布专题后需要手动更新,建议专题目录设置仅可读写权限,存放目录:<?php echo $cfg_special.'/index.html';?></div> + <div class="alert alert-info">发布专题后需要手动更新,建议专题目录设置仅可读写权限,存放目录:<?php echo $cfg_cmspath.$cfg_special."/index.html"?></div> <form name="form1" action="makehtml_spec.php" method="get" target="stafrm"> <input type="hidden" name="dopost" value="ok"> <div class="table-responsive"> diff --git a/src/admin/templets_one_edit.php b/src/admin/templets_one_edit.php index c2f5daa7..7718ba50 100644 --- a/src/admin/templets_one_edit.php +++ b/src/admin/templets_one_edit.php @@ -45,7 +45,7 @@ if ($dopost == "saveedit") { ShowMsg("系统文件禁止重名", "javascript:;"); exit(); } - $oldfilename = $cfg_basedir.'/'.$oldfilename; + $oldfilename = $cfg_basedir.$cfg_cmspath."/".$oldfilename; if (is_file($oldfilename)) { unlink($oldfilename); } @@ -64,7 +64,7 @@ if ($dopost == "saveedit") { exit(); } else if ($dopost == "delete") { $row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'"); - $filename = preg_replace("#\/{1,}#", "/", $cfg_basedir."/".$row['filename']); + $filename = preg_replace("#\/{1,}#", "/", $cfg_basedir.$cfg_cmspath."/".$row['filename']); $dsql->ExecuteNoneQuery(" DELETE FROM `#@__sgpage` WHERE aid='$aid' "); if (is_file($filename)) { unlink($filename); diff --git a/src/apps/diy.php b/src/apps/diy.php index 155d479c..b9729908 100755 --- a/src/apps/diy.php +++ b/src/apps/diy.php @@ -74,7 +74,7 @@ if ($action == 'post') { $goto = "diy.php?action=list&diyid={$diy->diyid}"; $bkmsg = '提交成功,正在前往表单列表'; } else { - $goto = '/'; + $goto = !empty($cfg_cmspath) ? $cfg_cmspath : '/'; $bkmsg = '提交成功,请等待管理员处理'; } ShowMsg($bkmsg, $goto); diff --git a/src/apps/feedback.php b/src/apps/feedback.php index b0cc16ef..16f27f85 100755 --- a/src/apps/feedback.php +++ b/src/apps/feedback.php @@ -65,7 +65,7 @@ if ($action == '' || $action == 'show') { $dsql->Execute('fb', $querystring." LIMIT 20 "); $data = array(); while ($row = $dsql->GetArray('fb')) { - $row['face'] = empty($row['mface']) ? '/static/web/img/admin.png' : $row['mface']; + $row['face'] = empty($row['mface']) ? $GLOBALS['cfg_cmspath'].'/static/web/img/admin.png' : $row['mface']; $row['dtimestr'] = MyDate('Y-m-d', $row['dtime']); unset($row['ip']); $data[] = $row; diff --git a/src/system/archive/archives.class.php b/src/system/archive/archives.class.php index 9d98e808..a178849a 100755 --- a/src/system/archive/archives.class.php +++ b/src/system/archive/archives.class.php @@ -219,7 +219,7 @@ class Archives //处理默认缩略图等 if (isset($this->Fields['litpic'])) { if ($this->Fields['litpic'] == '-' || $this->Fields['litpic'] == '') { - $this->Fields['litpic'] = '/static/web/img/thumbnail.jpg'; + $this->Fields['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("#^http:\/\/#i", $this->Fields['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $this->Fields['litpic'] = $GLOBALS['cfg_mainsite'].$this->Fields['litpic']; @@ -232,7 +232,7 @@ class Archives if (isset($this->Fields['voteid']) && !empty($this->Fields['voteid'])) { $this->Fields['vote'] = ''; $voteid = $this->Fields['voteid']; - $this->Fields['vote'] = "<script src='/data/vote/vote_{$voteid}.js'></script>"; + $this->Fields['vote'] = "<script src='{$GLOBALS['cfg_cmspath']}/data/vote/vote_{$voteid}.js'></script>"; if ($GLOBALS['cfg_multi_site'] == 'Y') { $this->Fields['vote'] = "<script src='{$GLOBALS['cfg_mainsite']}/data/vote/vote_{$voteid}.js'></script>"; } @@ -681,7 +681,7 @@ class Archives $preRow['siteurl'], $preRow['sitepath'] ); - $preRow['litpic'] = (empty($preRow['litpic'])) ? '/static/web/img/thumbnail.jpg' : $preRow['litpic']; + $preRow['litpic'] = (empty($preRow['litpic'])) ? $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg' : $preRow['litpic']; $this->PreNext['diy']['pre']['id'] = $preRow['id']; $this->PreNext['diy']['pre']['arcurl'] = $mlink; $this->PreNext['diy']['pre']['title'] = $preRow['title']; @@ -709,7 +709,7 @@ class Archives $nextRow['siteurl'], $nextRow['sitepath'] ); - $nextRow['litpic'] = (empty($nextRow['litpic'])) ? '/static/web/img/thumbnail.jpg' : $nextRow['litpic']; + $nextRow['litpic'] = (empty($nextRow['litpic'])) ? $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg' : $nextRow['litpic']; $this->PreNext['diy']['next']['id'] = $nextRow['id']; $this->PreNext['diy']['next']['arcurl'] = $mlink; $this->PreNext['diy']['next']['title'] = $nextRow['title']; diff --git a/src/system/archive/freelist.class.php b/src/system/archive/freelist.class.php index a9479ad3..f5e19ce0 100755 --- a/src/system/archive/freelist.class.php +++ b/src/system/archive/freelist.class.php @@ -229,7 +229,7 @@ class FreeList $this->dtp->SaveTo($makeFile); } if ($this->FLInfos['nodefault'] == 0) { - $murl = '/'.str_replace('{cmspath}', $this->FLInfos['listdir']); + $murl = '/'.str_replace('{cmspath}', $GLOBALS['cfg_cmspath'], $this->FLInfos['listdir']); $murl .= '/'.$this->FLInfos['defaultpage']; $indexfile = $GLOBALS['cfg_basedir'].$murl; $murl = preg_replace("#\/{1,}#", "/", $murl); @@ -355,7 +355,7 @@ class FreeList $okfile = ''; $namerule = $this->FLInfos['namerule']; $listdir = $this->FLInfos['listdir']; - $listdir = str_replace('{cmspath}', $listdir); + $listdir = str_replace('{cmspath}', $GLOBALS['cfg_cmspath'], $listdir); $okfile = str_replace('{listid}', $this->FLInfos['aid'], $namerule); $okfile = str_replace('{listdir}', $listdir, $okfile); $okfile = str_replace("\\", "/", $okfile); @@ -540,7 +540,7 @@ class FreeList } $row['description'] = cn_substr($row['description'], $infolen); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/archive/listview.class.php b/src/system/archive/listview.class.php index 7eb180a0..015091de 100755 --- a/src/system/archive/listview.class.php +++ b/src/system/archive/listview.class.php @@ -525,7 +525,7 @@ class ListView $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; @@ -945,7 +945,7 @@ class ListView $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; @@ -1014,6 +1014,7 @@ class ListView */ function GetPageListST($list_len, $listitem = "index,end,pre,next,pageno") { + global $cfg_cmspath; $prepage = $nextpage = ''; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; @@ -1102,7 +1103,7 @@ class ListView */ function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno") { - global $cfg_rewrite; + global $cfg_cmspath, $cfg_rewrite; $prepage = $nextpage = ''; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; diff --git a/src/system/archive/searchview.class.php b/src/system/archive/searchview.class.php index 50063efe..6a80918a 100755 --- a/src/system/archive/searchview.class.php +++ b/src/system/archive/searchview.class.php @@ -568,7 +568,7 @@ class SearchView $row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen)); $row["id"] = $row["id"]; if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("/^(http|https):\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/archive/sglistview.class.php b/src/system/archive/sglistview.class.php index 0d6b1a8e..39a5ec31 100755 --- a/src/system/archive/sglistview.class.php +++ b/src/system/archive/sglistview.class.php @@ -431,7 +431,7 @@ class SgListView $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; @@ -780,7 +780,7 @@ class SgListView $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/archive/sgpage.class.php b/src/system/archive/sgpage.class.php index faf1484b..dc940625 100755 --- a/src/system/archive/sgpage.class.php +++ b/src/system/archive/sgpage.class.php @@ -80,7 +80,7 @@ class sgpage */ function SaveToHtml() { - $filename = $GLOBALS['cfg_basedir'].'/'.$this->Fields['filename']; + $filename = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_cmspath'].'/'.$this->Fields['filename']; $filename = preg_replace("/\/{1,}/", '/', $filename); $this->dtp->SaveTo($filename); } diff --git a/src/system/archive/specview.class.php b/src/system/archive/specview.class.php index 3f892cb2..478c4858 100755 --- a/src/system/archive/specview.class.php +++ b/src/system/archive/specview.class.php @@ -348,7 +348,7 @@ class SpecView $row["title"] = cn_substr($row["title"], $titlelen); $row["id"] = $row["id"]; if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/archive/taglist.class.php b/src/system/archive/taglist.class.php index 044dc01b..4f37d77f 100755 --- a/src/system/archive/taglist.class.php +++ b/src/system/archive/taglist.class.php @@ -156,8 +156,8 @@ class TagList */ function Display() { - global $cfg_tags_dir; - $tagsDir = str_replace("{cmspath}", "", $cfg_tags_dir); + global $cfg_cmspath, $cfg_tags_dir; + $tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir); $makeDir = empty($this->Tag) ? $this->GetTruePath().$tagsDir."/index.html" : $this->GetTruePath().$tagsDir."/".$this->Tag."/index.html"; if ($this->Tag != '') { $this->CountRecord(); @@ -346,7 +346,7 @@ class TagList $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } /*if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; @@ -559,16 +559,16 @@ class TagList } function SetTagsDir($dir = '') { - global $cfg_tags_dir; - if ($dir == "") $dir = str_replace("{cmspath}", "", $cfg_tags_dir); + global $cfg_tags_dir, $cfg_cmspath; + if ($dir == "") $dir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); $this->tagsDir = $dir; } //生成静态标签 function MakeHtml($startpage = 1, $makepagesize = 0) { - global $cfg_dir_purview, $envs, $cfg_tags_dir, $cfg_cmsurl; + global $cfg_dir_purview, $envs, $cfg_cmspath, $cfg_tags_dir, $cfg_cmsurl; $envs['makeTag'] = 1; - $tagsdir = str_replace("{cmspath}", "", $cfg_tags_dir); + $tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); if (isset($envs['makeTag']) && $envs['makeTag'] == 1) { $this->Fields['position'] = $cfg_cmsurl.$tagsdir."/"; } diff --git a/src/system/common.inc.php b/src/system/common.inc.php index 89799b7a..153c4848 100755 --- a/src/system/common.inc.php +++ b/src/system/common.inc.php @@ -152,32 +152,32 @@ if (PHP_SAPI === 'cli') { $cfg_clihost = 'http://'.$_SERVER['HTTP_HOST']; } //站点根目录 -$cfg_basedir = preg_replace('#'.'\/system$#i', '', DEDEINC); +$cfg_basedir = preg_replace('#'.$cfg_cmspath.'\/system$#i', '', DEDEINC); if ($cfg_multi_site == 'Y') { $cfg_mainsite = $cfg_basehost; } else { $cfg_mainsite = ''; } //模板存放目录 -$cfg_templets_dir = '/theme'; +$cfg_templets_dir = $cfg_cmspath.'/theme'; $cfg_templeturl = $cfg_mainsite.$cfg_templets_dir; $cfg_templets_skin = empty($cfg_df_style) ? $cfg_mainsite.$cfg_templets_dir."/templets" : $cfg_mainsite.$cfg_templets_dir."/$cfg_df_style"; //安装目录网址 -$cfg_cmsurl = $cfg_mainsite; +$cfg_cmsurl = $cfg_mainsite.$cfg_cmspath; //模块插件目录 -$cfg_plus_dir = '/apps'; +$cfg_plus_dir = $cfg_cmspath.'/apps'; $cfg_phpurl = $cfg_mainsite.$cfg_plus_dir; //一些缓存配置数据存放目录 -$cfg_data_dir = '/data'; +$cfg_data_dir = $cfg_cmspath.'/data'; $cfg_dataurl = $cfg_mainsite.$cfg_data_dir; //专题存放目录 -$cfg_special = '/a/special'; +$cfg_special = $cfg_cmspath.'/a/special'; $cfg_specialurl = $cfg_mainsite.$cfg_special; //会员会员目录 -$cfg_member_dir = '/user'; +$cfg_member_dir = $cfg_cmspath.'/user'; $cfg_memberurl = $cfg_mainsite.$cfg_member_dir; //静态文件存放目录 -$cfg_static_dir = '/static'; +$cfg_static_dir = $cfg_cmspath.'/static'; $cfg_staticurl = $cfg_mainsite.$cfg_static_dir; //上传图片存放目录,建议按默认 $cfg_image_dir = $cfg_medias_dir.'/allimg'; @@ -188,7 +188,7 @@ $cfg_soft_dir = $cfg_medias_dir.'/soft'; //上传多媒体文件存放目录 $cfg_other_medias = $cfg_medias_dir.'/media'; //附件目录 -$cfg_medias_dir = $cfg_medias_dir; +$cfg_medias_dir = $cfg_cmspath.$cfg_medias_dir; $cfg_mediasurl = $cfg_mainsite.$cfg_medias_dir; //程序信息摘要,请不要删除则系统无法接收升级信息 $cfg_version = 'V6'; diff --git a/src/system/customfields.func.php b/src/system/customfields.func.php index e0e80e81..ee1c6325 100755 --- a/src/system/customfields.func.php +++ b/src/system/customfields.func.php @@ -38,19 +38,20 @@ function GetFormItem($ctag, $admintype = 'admin') $myformItem .= "</select>"; $innertext = $myformItem; } else if ($fieldType == 'stepselect') { - global $hasSetEnumJs; + global $hasSetEnumJs, $cfg_cmspath; + $cmspath = ((empty($cfg_cmspath) || !preg_match('/[/$]/', $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath); $myformItem = ''; $myformItem .= "<input type='hidden' id='hidden_{$fieldname}' name='{$fieldname}' value='0'>"; $myformItem .= "<span id='span_{$fieldname}'></span>"; $myformItem .= "<span id='span_{$fieldname}_son'></span>"; $myformItem .= "<span id='span_{$fieldname}_sec'></span>"; if ($hasSetEnumJs != 'hasset') { - $myformItem .= '<script src="/static/web/js/enums.js"></script>'.""; + $myformItem .= '<script src="'.$cmspath.'static/web/js/enums.js"></script>'.""; $GLOBALS['hasSetEnumJs'] = 'hasset'; } $myformItem .= "<script> var em_{$fieldname}s = []; - fetch('/static/enums/{$fieldname}.json').then((resp)=>resp.json()).then((d) => { + 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]; }); @@ -156,7 +157,7 @@ EOT; */ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '', $admintype = 'admin', $fieldname = '') { - global $cfg_basedir, $adminid, $cfg_ml, $cfg_cookie_encode; + global $cfg_basedir, $cfg_cmspath, $adminid, $cfg_ml, $cfg_cookie_encode; if (!empty($adminid)) { $adminid = $adminid; } else { @@ -200,7 +201,7 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '', $a } return $dvalue; } else if ($dtype == "textdata") { - $ipath = '/data/textdata'; + $ipath = $cfg_cmspath."/data/textdata"; $tpath = ceil($aid / 5000); if (!is_dir($cfg_basedir.$ipath)) { MkdirAll($cfg_basedir.$ipath, $GLOBALS['cfg_dir_purview']); @@ -271,19 +272,20 @@ function GetFormItemValue($ctag, $fvalue, $admintype = 'admin', $fieldname = '') $myformItem .= "</select>"; $innertext = $myformItem; } else if ($ctag->GetAtt("type") == 'stepselect') { - global $hasSetEnumJs; + global $hasSetEnumJs, $cfg_cmspath; + $cmspath = ((empty($cfg_cmspath) || preg_match('/[/$]/', $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath); $myformItem = ''; $myformItem .= "<input type='hidden' id='hidden_{$fieldname}' name='{$fieldname}' value='{$fvalue}'>"; $myformItem .= "<span id='span_{$fieldname}'></span>"; $myformItem .= "<span id='span_{$fieldname}_son'></span>"; $myformItem .= "<span id='span_{$fieldname}_sec'></span>"; if ($hasSetEnumJs != 'hasset') { - $myformItem .= '<script src="/static/web/js/enums.js"></script>'.""; + $myformItem .= '<script src="'.$cmspath.'static/web/js/enums.js"></script>'.""; $GLOBALS['hasSetEnumJs'] = 'hasset'; } $myformItem .= "<script> var em_{$fieldname}s = []; - fetch('/static/enums/{$fieldname}.json').then((resp)=>resp.json()).then((d) => { + 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]; }); diff --git a/src/system/extend.func.php b/src/system/extend.func.php index d566793c..848c8721 100755 --- a/src/system/extend.func.php +++ b/src/system/extend.func.php @@ -25,12 +25,12 @@ if (!function_exists('obtaintheme')) { if (!function_exists('obtaintags')) { function obtaintags($aid, $num = 3) { - global $dsql; + global $dsql, $cfg_cmspath; $tags = ''; $query = "SELECT * FROM `#@__taglist` WHERE aid='$aid' LIMIT $num"; $dsql->Execute('tag', $query); while($row = $dsql->GetArray('tag')) { - $link = "/apps/tags.php?/{$row['tid']}"; + $link = $cfg_cmspath."/apps/tags.php?/{$row['tid']}"; $tags .= ($tags == '' ? "<a href='{$link}'>{$row['tag']}</a>" : "<a href='{$link}'>{$row['tag']}</a>"); } return $tags; diff --git a/src/system/helpers/channelunit.helper.php b/src/system/helpers/channelunit.helper.php index 35b5d558..30da23fa 100755 --- a/src/system/helpers/channelunit.helper.php +++ b/src/system/helpers/channelunit.helper.php @@ -1,671 +1,671 @@ -<?php -if (!defined('DEDEINC')) exit ('dedebiz'); -/** - * 文档助手 - * - * @version $id:channelunit.helper.php 16:49 2010年7月6日 tianya $ - * @package DedeBIZ.Helpers - * @copyright Copyright (c) 2022 DedeBIZ.COM - * @license GNU GPL v2 (https://www.dedebiz.com/license) - * @link https://www.dedebiz.com - */ -/** - * 用星表示软件或Flash的等级 - * - * @param string $rank 星星数 - * @return string - */ -if (!function_exists('GetRankStar')) { - function GetRankStar($rank) - { - $nstar = ''; - for ($i = 1; $i <= $rank; $i++) { - $nstar .= "★"; - } - for ($i; $i <= 5; $i++) { - $nstar .= "☆"; - } - return $nstar; - } -} -/** - * 获得文档网址,如果要获得文件的路径,直接用GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money)即是不指定站点参数则返回相当对根目录的真实路径 - * - * @param int $aid 文档id - * @param int $typeid 栏目id - * @param int $timetag 时间戳 - * @param string $title 标题 - * @param int $ismake 是否生成 - * @param int $rank 阅读权限 - * @param string $namerule 名称规则 - * @param string $typedir 栏目dir - * @param string $money 需要金币 - * @param string $filename 文件名称 - * @param string $moresite 多站点 - * @param string $siteurl 站点地址 - * @param string $sitepath 站点路径 - * @return string - */ -if (!function_exists('GetFileUrl')) { - function GetFileUrl( - $aid, - $typeid, - $timetag, - $title, - $ismake = 0, - $rank = 0, - $namerule = '', - $typedir = '', - $money = 0, - $filename = '', - $moresite = 0, - $siteurl = '', - $sitepath = '' - ) { - $articleUrl = GetFileName($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $typedir, $money, $filename); - $sitepath = MfTypedir($sitepath); - //是否强制使用绝对网址 - if ($GLOBALS['cfg_multi_site'] == 'Y') { - if ($siteurl == '') { - $siteurl = $GLOBALS['cfg_basehost']; - } - if ($moresite == 1) { - $articleUrl = preg_replace("#^".$sitepath.'#', '', $articleUrl); - } - if (!preg_match("/http:/", $articleUrl)) { - $articleUrl = $siteurl.$articleUrl; - } - } - return $articleUrl; - } -} -/** - * 获得新文件名,本函数会自动创建目录 - * - * @param int $aid 文档id - * @param int $typeid 栏目id - * @param int $timetag 时间戳 - * @param string $title 标题 - * @param int $ismake 是否生成 - * @param int $rank 阅读权限 - * @param string $namerule 名称规则 - * @param string $typedir 栏目dir - * @param string $money 需要金币 - * @param string $filename 文件名称 - * @return string - */ -if (!function_exists('GetFileNewName')) { - function GetFileNewName($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = '', $typedir = '', $money = 0, $filename = '') - { - global $cfg_arc_dirname; - $articlename = GetFileName($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $typedir, $money, $filename); - if (preg_match("/\?/", $articlename)) { - return $articlename; - } - if ($cfg_arc_dirname == 'Y' && preg_match("/\/$/", $articlename)) { - $articlename = $articlename."index.html"; - } - $slen = strlen($articlename) - 1; - $subpos = 0; - for ($i = $slen; $i >= 0; $i--) { - if ($articlename[$i] == '/') { - $subpos = $i; - break; - } - } - $okdir = substr($articlename, 0, $subpos); - if ($ismake != -1 || $cfg_rewrite == 'N') CreateDir($okdir); - return $articlename; - } -} -/** - * 获得栏目链接 - * - * @param int $typeid 栏目id - * @param string $typedir 栏目目录 - * @param int $isdefault 是否默认 - * @param string $defaultname 默认名称 - * @param int $ispart 栏目属性 - * @param string $namerule2 名称规则 - * @param string $moresite 多站点 - * @param string $siteurl 站点地址 - * @param string $sitepath 站点目录 - * @return string - */ -if (!function_exists('GetTypeUrl')) { - function GetTypeUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $moresite = 0, $siteurl = '', $sitepath = '') - { - global $cfg_typedir_df, $cfg_rewrite; - $typedir = MfTypedir($typedir); - $sitepath = MfTypedir($sitepath); - //动态栏目 - if ($isdefault == -1) { - if ($cfg_rewrite == 'Y') { - //开启伪静态栏目/list-1、/list-2,则分页/list-1-1、/list-1-2 - $reurl = "/list-".$typeid.""; - } else { - $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid; - } - } - //跳转网址 - else if ($ispart == 2) { - $reurl = $typedir; - return $reurl; - } else { - if ($isdefault == 0 && $ispart == 0) { - $reurl = str_replace("{page}", "1", $namerule2); - $reurl = str_replace("{tid}", $typeid, $reurl); - $reurl = str_replace("{typedir}", $typedir, $reurl); - } else { - if ($cfg_typedir_df == 'N' || $isdefault == 0) $reurl = $typedir.'/'.$defaultname; - else $reurl = $typedir.'/'; - } - } - if (!preg_match("/^http:\/\//", $reurl)) { - $reurl = preg_replace("/\/{1,}/i", '/', $reurl); - } - if ($GLOBALS['cfg_multi_site'] == 'Y') { - if ($siteurl == '') { - $siteurl = $GLOBALS['cfg_basehost']; - } - if ($moresite == 1) { - $reurl = preg_replace("#^".$sitepath."#", '', $reurl); - } - if (!preg_match("/^http:\/\//", $reurl)) { - $reurl = $siteurl.$reurl; - } - } - return $reurl; - } -} -/** - * 获得文档链接 - * - * @param int $aid 文档id - * @param int $typeid 栏目id - * @param int $timetag 时间戳 - * @param string $title 标题 - * @param int $ismake 是否生成 - * @param int $rank 阅读权限 - * @param string $namerule 名称规则 - * @param string $typedir 栏目dir - * @param string $money 需要金币 - * @param string $filename 文件名称 - * @return string - */ -if (!function_exists('GetFileName')) { - function GetFileName($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = '', $typedir = '', $money = 0, $filename = '') - { - global $cfg_arcdir, $cfg_special, $cfg_arc_dirname, $cfg_rewrite; - //没指定栏目时用固定专题规则 - if (empty($namerule)) { - $namerule = $cfg_special.'/{aid}.html'; - $typeid = -1; - } - //动态文档 - if ($rank != 0 || $ismake == -1 || $typeid == 0 || $money > 0) { - if ($cfg_rewrite == 'Y') { - //开启伪静态文档/doc-1.html、/doc-2.html,则分页/doc-1-1.html、/doc-1-2.html - return "/doc-".$aid.".html"; - } else { - return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid"; - } - } else { - $articleDir = MfTypedir($typedir); - $articleRule = strtolower($namerule); - if ($articleRule == '') { - $articleRule = strtolower($GLOBALS['cfg_df_namerule']); - } - if ($typedir == '') { - $articleDir = $GLOBALS['cfg_arcdir']; - } - $dtime = GetDateMk($timetag); - list($y, $m, $d) = explode('-', $dtime); - $arr_rpsource = array('{typedir}', '{y}', '{m}', '{d}', '{timestamp}', '{aid}', '{cc}'); - $arr_rpvalues = array($articleDir, $y, $m, $d, $timetag, $aid, dd2char($m.$d.$aid.$y)); - if ($filename != '') { - $articleRule = dirname($articleRule).'/'.$filename.$GLOBALS['cfg_df_ext']; - } - $articleRule = str_replace($arr_rpsource, $arr_rpvalues, $articleRule); - if (preg_match("/\{p/", $articleRule)) { - $articleRule = str_replace('{pinyin}', GetPinyin($title).'-'.$aid, $articleRule); - $articleRule = str_replace('{py}', GetPinyin($title, 1).'-'.$aid, $articleRule); - } - $articleUrl = '/'.preg_replace("/^\//", '', $articleRule); - if (preg_match("/index\.html/", $articleUrl) && $cfg_arc_dirname == 'Y') { - $articleUrl = str_replace('index.html', '', $articleUrl); - } - return $articleUrl; - } - } -} -/** - * 魔法变量,用于获取两个可变的值 - * - * @param string $v1 第一个变量 - * @param string $v2 第二个变量 - * @return string - */ -if (!function_exists('MagicVar')) { - function MagicVar($v1, $v2) - { - return $GLOBALS['autoindex'] % 2 == 0 ? $v1 : $v2; - } -} -/** - * 获取某个栏目的所有上级栏目id - * - * @param int $tid 栏目id - * @return string - */ -if (!function_exists('GetTopids')) { - function GetTopids($tid) - { - $arr = GetParentIds($tid); - return join(',', $arr); - } -} -/** - * 获取上级id列表 - * - * @access public - * @param string $tid 栏目id - * @return string - */ -if (!function_exists('GetParentIds')) { - function GetParentIds($tid) - { - global $cfg_Cs; - $GLOBALS['pTypeArrays'][] = $tid; - if (!is_array($cfg_Cs)) { - require_once(DEDEDATA."/cache/inc_catalog_base.inc"); - } - if (!isset($cfg_Cs[$tid]) || $cfg_Cs[$tid][0] == 0) { - return $GLOBALS['pTypeArrays']; - } else { - return GetParentIds($cfg_Cs[$tid][0]); - } - } -} -/** - * 检测栏目是否是另一个栏目的父目录 - * - * @access public - * @param string $sid 顶级目录id - * @param string $pid 下级目录id - * @return bool - */ -if (!function_exists('IsParent')) { - function IsParent($sid, $pid) - { - $pTypeArrays = GetParentIds($sid); - return in_array($pid, $pTypeArrays); - } -} -/** - * 获取一个栏目的顶级栏目id - * - * @param string $tid 栏目id - * @return string - */ -if (!function_exists('GetTopid')) { - function GetTopid($tid) - { - global $cfg_Cs; - if (!is_array($cfg_Cs)) { - require_once(DEDEDATA."/cache/inc_catalog_base.inc"); - } - if (!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0] == 0) { - return $tid; - } else { - return GetTopid($cfg_Cs[$tid][0]); - } - } -} -/** - * 获得某id的所有下级id - * - * @param string $id 栏目id - * @param string $channel 模型id - * @param string $addthis 是否包含本身 - * @return string - */ -function GetSonIds($id, $channel = 0, $addthis = true) -{ - global $cfg_Cs; - $GLOBALS['idArray'] = array(); - if (!is_array($cfg_Cs) && file_exists(DEDEDATA."/cache/inc_catalog_base.inc")) { - require_once(DEDEDATA."/cache/inc_catalog_base.inc"); - } - GetSonIdsLogic($id, $cfg_Cs, $channel, $addthis); - $rquery = join(',', $GLOBALS['idArray']); - $rquery = preg_replace("/,$/", "", $rquery); - return $rquery; -} -//递归逻辑 -function GetSonIdsLogic($id, $sArr, $channel = 0, $addthis = false) -{ - if ($id != 0 && $addthis) { - $GLOBALS['idArray'][$id] = $id; - } - if (is_array($sArr)) { - foreach ($sArr as $k => $v) { - if ($v[0] == $id && ($channel == 0 || $v[1] == $channel)) { - GetSonIdsLogic($k, $sArr, $channel, true); - } - } - } -} -/** - * 栏目目录规则 - * - * @param string $typedir 栏目目录 - * @return string - */ -function MfTypedir($typedir) -{ - if (preg_match("/^(http|https|ftp):/i", $typedir)) return $typedir; - $typedir = str_replace("{cmspath}", "", $typedir); - $typedir = preg_replace("/\/{1,}/", "/", $typedir); - return $typedir; -} -/** - * 模板目录规则 - * - * @param string $tmpdir 模板目录 - * @return string - */ -function MfTemplet($tmpdir) -{ - $tmpdir = str_replace("{style}", $GLOBALS['cfg_df_style'], $tmpdir); - $tmpdir = preg_replace("/\/{1,}/", "/", $tmpdir); - return $tmpdir; -} -/** - * 清除用于js的空白块 - * - * @param string $atme 字符 - * @return string - */ -function FormatScript($atme) -{ - return $atme == ' ' ? '' : $atme; -} -/** - * 给属性默认值 - * - * @param array $atts 属性 - * @param string $attlist 属性列表 - * @return void - */ -function FillAttsDefault(&$atts, $attlist) -{ - $attlists = explode(',', (string)$attlist); - if (is_array($attlists)) { - for ($i = 0; isset($attlists[$i]); $i++) { - if (empty($attlists[$i])) { - continue; - } - list($k, $v) = explode('|', $attlists[$i]); - if (!isset($atts[$k])) { - $atts[$k] = $v; - } - } - } -} -/** - * 给块标记赋值 - * - * @param object $dtp 模板解析引擎 - * @param object $refObj 实例化对象 - * @param object $parfield - * @return string - */ -function MakeOneTag(&$dtp, &$refObj, $parfield = 'Y') -{ - $alltags = array(); - $dtp->setRefObj($refObj); - //读取自由调用tag列表 - $dh = dir(DEDEINC.'/taglib'); - while ($filename = $dh->read()) { - if (preg_match("/\.lib\./", $filename)) { - $alltags[] = str_replace('.lib.php', '', $filename); - } - } - $dh->Close(); - //遍历tag元素 - if (!is_array($dtp->CTags)) { - return ''; - } - foreach ($dtp->CTags as $tagid => $ctag) { - $tagname = $ctag->GetName(); - if ($tagname == 'field' && $parfield == 'Y') { - $vname = $ctag->GetAtt('name'); - if ($vname == 'array' && isset($refObj->Fields)) { - $dtp->Assign($tagid, $refObj->Fields); - } else if (isset($refObj->Fields[$vname])) { - $dtp->Assign($tagid, $refObj->Fields[$vname]); - } else if ($ctag->GetAtt('noteid') != '') { - if (isset($refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')])) { - $dtp->Assign($tagid, $refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')]); - } - } - continue; - } - //由于考虑兼容性,原来文档调用使用的标记别名统一保留,这些标记实际调用的解析文件为inc_arclist.php - if (preg_match("/^(artlist|likeart|hotart|imglist|imginfolist|coolart|specart|autolist)$/", $tagname)) { - $tagname = 'arclist'; - } - if ($tagname == 'friendlink') { - $tagname = 'flink'; - } - if (in_array($tagname, $alltags)) { - if (DEBUG_LEVEL == TRUE) { - $ttt1 = ExecTime(); - } - $filename = DEDEINC.'/taglib/'.$tagname.'.lib.php'; - include_once($filename); - $funcname = 'lib_'.$tagname; - $dtp->Assign($tagid, $funcname($ctag, $refObj)); - if (DEBUG_LEVEL == TRUE) { - $queryTime = ExecTime() - $ttt1; - if (PHP_SAPI === 'cli') { - echo '标签:'.$tagname.' 载入花费时间:'.$queryTime."\r\n"; - } else { - echo DedeAlert('标签:'.$tagname.' 载入花费时间:'.$queryTime, ALERT_WARNING); - } - - } - } - } -} -/** - * 获取某栏目链接 - * - * @param array $typeinfos 栏目信息 - * @return string - */ -function GetOneTypeUrlA($typeinfos) -{ - return GetTypeUrl( - $typeinfos['id'], - MfTypedir($typeinfos['typedir']), - $typeinfos['isdefault'], - $typeinfos['defaultname'], - $typeinfos['ispart'], - $typeinfos['namerule2'], - $typeinfos['moresite'], - $typeinfos['siteurl'], - $typeinfos['sitepath'] - ); -} -/** - * 设置全局环境变量 - * - * @param int $typeid 栏目id - * @param string $typename 栏目名称 - * @param string $aid 文档id - * @param string $title 标题 - * @param string $curfile 当前文件 - * @return string - */ -function SetSysEnv($typeid = 0, $typename = '', $aid = 0, $title = '', $curfile = '') -{ - global $_sys_globals; - if (empty($_sys_globals['curfile'])) { - $_sys_globals['curfile'] = $curfile; - } - if (empty($_sys_globals['typeid'])) { - $_sys_globals['typeid'] = $typeid; - } - if (empty($_sys_globals['typename'])) { - $_sys_globals['typename'] = $typename; - } - if (empty($_sys_globals['aid'])) { - $_sys_globals['aid'] = $aid; - } -} -/** - * 根据ID生成目录 - * - * @param string $aid 文档id - * @return int - */ -function DedeID2Dir($aid) -{ - $n = ceil($aid / 1000); - return $n; -} -/** - * 获得自由列表的网址 - * - * @param string $lid 列表id - * @param string $namerule 命名规则 - * @param string $listdir 列表目录 - * @param string $defaultpage 默认页面 - * @param string $nodefault 没有默认页面 - * @return string - */ -function GetFreeListUrl($lid, $namerule, $listdir, $defaultpage, $nodefault) -{ - $listdir = str_replace('{cmspath}', $listdir); - if ($nodefault == 1) { - $okfile = str_replace('{page}', '1', $namerule); - $okfile = str_replace('{listid}', $lid, $okfile); - $okfile = str_replace('{listdir}', $listdir, $okfile); - } else { - $okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid"; - return $okfile; - } - $okfile = str_replace("\\", "/", $okfile); - $okfile = str_replace("//", "/", $okfile); - $trueFile = $GLOBALS['cfg_basedir'].$okfile; - if (!@file_exists($trueFile)) { - $okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid"; - } - return $okfile; -} -/** - * 获取网站搜索的热门关键词 - * - * @param object $dsql - * @param string $num 获取数目 - * @param string $nday 天数 - * @param string $klen 关键词字数 - * @param string $orderby 排列顺序 - * @return string - */ -function GetHotKeywords(&$dsql, $num = 8, $nday = 365, $klen = 16, $orderby = 'count') -{ - global $cfg_phpurl; - $nowtime = time(); - $num = @intval($num); - $nday = @intval($nday); - $klen = @intval($klen); - if (empty($nday)) { - $nday = 365; - } - if (empty($num)) { - $num = 6; - } - if (empty($klen)) { - $klen = 16; - } - $klen = $klen + 1; - $mintime = $nowtime - ($nday * 24 * 3600); - if (empty($orderby)) { - $orderby = 'count'; - } - $dsql->SetQuery("SELECT keyword FROM `#@__search_keywords` WHERE lasttime>$mintime AND length(keyword)<$klen ORDER BY $orderby DESC LIMIT 0,$num"); - $dsql->Execute('hw'); - $hotword = ''; - while ($row = $dsql->GetArray('hw')) { - $hotword .= "<a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."&searchtype=titlekeyword'>".$row['keyword']."</a> "; - } - return $hotword; -} -/** - * 使用绝对网址 - * - * @param string $gurl 地址 - * @return string - */ -function Gmapurl($gurl) -{ - return preg_match("/http[s]?:\/\//i", $gurl) ? $gurl : $GLOBALS['cfg_basehost'].$gurl; -} -/** - * 引用回复标记处理 - * - * @param string $quote - * @return string - */ -function Quote_replace($quote) -{ - $quote = str_replace('{quote}', '<div class="decmt-box">', $quote); - $quote = str_replace('{title}', '<div class="decmt-title"><span class="username">', $quote); - $quote = str_replace('{/title}', '</span></div>', $quote); - $quote = str_replace('<br/>', '<br>', $quote); - $quote = str_replace('<', '<', $quote); - $quote = str_replace('>', '>', $quote); - $quote = str_replace('{content}', '<div class="decmt-content">', $quote); - $quote = str_replace('{/content}', '</div>', $quote); - $quote = str_replace('{/quote}', '</div>', $quote); - return $quote; -} -/** - * 获取、写入指定cacheid的块 - * - * @param string $cacheid 缓存ID - * @return string - */ -function GetCacheBlock($cacheid) -{ - global $cfg_puccache_time; - $cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc'; - if ( - !file_exists($cachefile) || filesize($cachefile) == 0 || - $cfg_puccache_time == 0 || time() - filemtime($cachefile) > $cfg_puccache_time - ) { - return ''; - } - $fp = fopen($cachefile, 'r'); - $str = @fread($fp, filesize($cachefile)); - fclose($fp); - return $str; -} -/** - * 写入缓存块 - * - * @param string $cacheid 缓存ID - * @param string $str 字符串信息 - * @return string - */ -function WriteCacheBlock($cacheid, $str) -{ - $cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc'; - $fp = fopen($cachefile, 'w'); - $str = fwrite($fp, $str); - fclose($fp); -} +<?php +if (!defined('DEDEINC')) exit ('dedebiz'); +/** + * 文档助手 + * + * @version $id:channelunit.helper.php 16:49 2010年7月6日 tianya $ + * @package DedeBIZ.Helpers + * @copyright Copyright (c) 2022 DedeBIZ.COM + * @license GNU GPL v2 (https://www.dedebiz.com/license) + * @link https://www.dedebiz.com + */ +/** + * 用星表示软件或Flash的等级 + * + * @param string $rank 星星数 + * @return string + */ +if (!function_exists('GetRankStar')) { + function GetRankStar($rank) + { + $nstar = ''; + for ($i = 1; $i <= $rank; $i++) { + $nstar .= "★"; + } + for ($i; $i <= 5; $i++) { + $nstar .= "☆"; + } + return $nstar; + } +} +/** + * 获得文档网址,如果要获得文件的路径,直接用GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money)即是不指定站点参数则返回相当对根目录的真实路径 + * + * @param int $aid 文档id + * @param int $typeid 栏目id + * @param int $timetag 时间戳 + * @param string $title 标题 + * @param int $ismake 是否生成 + * @param int $rank 阅读权限 + * @param string $namerule 名称规则 + * @param string $typedir 栏目dir + * @param string $money 需要金币 + * @param string $filename 文件名称 + * @param string $moresite 多站点 + * @param string $siteurl 站点地址 + * @param string $sitepath 站点路径 + * @return string + */ +if (!function_exists('GetFileUrl')) { + function GetFileUrl( + $aid, + $typeid, + $timetag, + $title, + $ismake = 0, + $rank = 0, + $namerule = '', + $typedir = '', + $money = 0, + $filename = '', + $moresite = 0, + $siteurl = '', + $sitepath = '' + ) { + $articleUrl = GetFileName($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $typedir, $money, $filename); + $sitepath = MfTypedir($sitepath); + //是否强制使用绝对网址 + if ($GLOBALS['cfg_multi_site'] == 'Y') { + if ($siteurl == '') { + $siteurl = $GLOBALS['cfg_basehost']; + } + if ($moresite == 1) { + $articleUrl = preg_replace("#^".$sitepath.'#', '', $articleUrl); + } + if (!preg_match("/http:/", $articleUrl)) { + $articleUrl = $siteurl.$articleUrl; + } + } + return $articleUrl; + } +} +/** + * 获得新文件名,本函数会自动创建目录 + * + * @param int $aid 文档id + * @param int $typeid 栏目id + * @param int $timetag 时间戳 + * @param string $title 标题 + * @param int $ismake 是否生成 + * @param int $rank 阅读权限 + * @param string $namerule 名称规则 + * @param string $typedir 栏目dir + * @param string $money 需要金币 + * @param string $filename 文件名称 + * @return string + */ +if (!function_exists('GetFileNewName')) { + function GetFileNewName($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = '', $typedir = '', $money = 0, $filename = '') + { + global $cfg_arc_dirname; + $articlename = GetFileName($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $typedir, $money, $filename); + if (preg_match("/\?/", $articlename)) { + return $articlename; + } + if ($cfg_arc_dirname == 'Y' && preg_match("/\/$/", $articlename)) { + $articlename = $articlename."index.html"; + } + $slen = strlen($articlename) - 1; + $subpos = 0; + for ($i = $slen; $i >= 0; $i--) { + if ($articlename[$i] == '/') { + $subpos = $i; + break; + } + } + $okdir = substr($articlename, 0, $subpos); + if ($ismake != -1 || $cfg_rewrite == 'N') CreateDir($okdir); + return $articlename; + } +} +/** + * 获得栏目链接 + * + * @param int $typeid 栏目id + * @param string $typedir 栏目目录 + * @param int $isdefault 是否默认 + * @param string $defaultname 默认名称 + * @param int $ispart 栏目属性 + * @param string $namerule2 名称规则 + * @param string $moresite 多站点 + * @param string $siteurl 站点地址 + * @param string $sitepath 站点目录 + * @return string + */ +if (!function_exists('GetTypeUrl')) { + function GetTypeUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $moresite = 0, $siteurl = '', $sitepath = '') + { + global $cfg_typedir_df, $cfg_rewrite; + $typedir = MfTypedir($typedir); + $sitepath = MfTypedir($sitepath); + //动态栏目 + if ($isdefault == -1) { + if ($cfg_rewrite == 'Y') { + //开启伪静态栏目/list-1、/list-2,则分页/list-1-1、/list-1-2 + return $GLOBALS['cfg_cmspath']."/list-".$typeid.""; + } else { + $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid; + } + } + //跳转网址 + else if ($ispart == 2) { + $reurl = $typedir; + return $reurl; + } else { + if ($isdefault == 0 && $ispart == 0) { + $reurl = str_replace("{page}", "1", $namerule2); + $reurl = str_replace("{tid}", $typeid, $reurl); + $reurl = str_replace("{typedir}", $typedir, $reurl); + } else { + if ($cfg_typedir_df == 'N' || $isdefault == 0) $reurl = $typedir.'/'.$defaultname; + else $reurl = $typedir.'/'; + } + } + if (!preg_match("/^http:\/\//", $reurl)) { + $reurl = preg_replace("/\/{1,}/i", '/', $reurl); + } + if ($GLOBALS['cfg_multi_site'] == 'Y') { + if ($siteurl == '') { + $siteurl = $GLOBALS['cfg_basehost']; + } + if ($moresite == 1) { + $reurl = preg_replace("#^".$sitepath."#", '', $reurl); + } + if (!preg_match("/^http:\/\//", $reurl)) { + $reurl = $siteurl.$reurl; + } + } + return $reurl; + } +} +/** + * 获得文档链接 + * + * @param int $aid 文档id + * @param int $typeid 栏目id + * @param int $timetag 时间戳 + * @param string $title 标题 + * @param int $ismake 是否生成 + * @param int $rank 阅读权限 + * @param string $namerule 名称规则 + * @param string $typedir 栏目dir + * @param string $money 需要金币 + * @param string $filename 文件名称 + * @return string + */ +if (!function_exists('GetFileName')) { + function GetFileName($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = '', $typedir = '', $money = 0, $filename = '') + { + global $cfg_cmspath, $cfg_arcdir, $cfg_special, $cfg_arc_dirname, $cfg_rewrite; + //没指定栏目时用固定专题规则 + if (empty($namerule)) { + $namerule = $cfg_special.'/{aid}.html'; + $typeid = -1; + } + //动态文档 + if ($rank != 0 || $ismake == -1 || $typeid == 0 || $money > 0) { + if ($cfg_rewrite == 'Y') { + //开启伪静态文档/doc-1.html、/doc-2.html,则分页/doc-1-1.html、/doc-1-2.html + return $GLOBALS['cfg_cmspath']."/doc-".$aid.".html"; + } else { + return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid"; + } + } else { + $articleDir = MfTypedir($typedir); + $articleRule = strtolower($namerule); + if ($articleRule == '') { + $articleRule = strtolower($GLOBALS['cfg_df_namerule']); + } + if ($typedir == '') { + $articleDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir']; + } + $dtime = GetDateMk($timetag); + list($y, $m, $d) = explode('-', $dtime); + $arr_rpsource = array('{typedir}', '{y}', '{m}', '{d}', '{timestamp}', '{aid}', '{cc}'); + $arr_rpvalues = array($articleDir, $y, $m, $d, $timetag, $aid, dd2char($m.$d.$aid.$y)); + if ($filename != '') { + $articleRule = dirname($articleRule).'/'.$filename.$GLOBALS['cfg_df_ext']; + } + $articleRule = str_replace($arr_rpsource, $arr_rpvalues, $articleRule); + if (preg_match("/\{p/", $articleRule)) { + $articleRule = str_replace('{pinyin}', GetPinyin($title).'-'.$aid, $articleRule); + $articleRule = str_replace('{py}', GetPinyin($title, 1).'-'.$aid, $articleRule); + } + $articleUrl = '/'.preg_replace("/^\//", '', $articleRule); + if (preg_match("/index\.html/", $articleUrl) && $cfg_arc_dirname == 'Y') { + $articleUrl = str_replace('index.html', '', $articleUrl); + } + return $articleUrl; + } + } +} +/** + * 魔法变量,用于获取两个可变的值 + * + * @param string $v1 第一个变量 + * @param string $v2 第二个变量 + * @return string + */ +if (!function_exists('MagicVar')) { + function MagicVar($v1, $v2) + { + return $GLOBALS['autoindex'] % 2 == 0 ? $v1 : $v2; + } +} +/** + * 获取某个栏目的所有上级栏目id + * + * @param int $tid 栏目id + * @return string + */ +if (!function_exists('GetTopids')) { + function GetTopids($tid) + { + $arr = GetParentIds($tid); + return join(',', $arr); + } +} +/** + * 获取上级id列表 + * + * @access public + * @param string $tid 栏目id + * @return string + */ +if (!function_exists('GetParentIds')) { + function GetParentIds($tid) + { + global $cfg_Cs; + $GLOBALS['pTypeArrays'][] = $tid; + if (!is_array($cfg_Cs)) { + require_once(DEDEDATA."/cache/inc_catalog_base.inc"); + } + if (!isset($cfg_Cs[$tid]) || $cfg_Cs[$tid][0] == 0) { + return $GLOBALS['pTypeArrays']; + } else { + return GetParentIds($cfg_Cs[$tid][0]); + } + } +} +/** + * 检测栏目是否是另一个栏目的父目录 + * + * @access public + * @param string $sid 顶级目录id + * @param string $pid 下级目录id + * @return bool + */ +if (!function_exists('IsParent')) { + function IsParent($sid, $pid) + { + $pTypeArrays = GetParentIds($sid); + return in_array($pid, $pTypeArrays); + } +} +/** + * 获取一个栏目的顶级栏目id + * + * @param string $tid 栏目id + * @return string + */ +if (!function_exists('GetTopid')) { + function GetTopid($tid) + { + global $cfg_Cs; + if (!is_array($cfg_Cs)) { + require_once(DEDEDATA."/cache/inc_catalog_base.inc"); + } + if (!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0] == 0) { + return $tid; + } else { + return GetTopid($cfg_Cs[$tid][0]); + } + } +} +/** + * 获得某id的所有下级id + * + * @param string $id 栏目id + * @param string $channel 模型id + * @param string $addthis 是否包含本身 + * @return string + */ +function GetSonIds($id, $channel = 0, $addthis = true) +{ + global $cfg_Cs; + $GLOBALS['idArray'] = array(); + if (!is_array($cfg_Cs) && file_exists(DEDEDATA."/cache/inc_catalog_base.inc")) { + require_once(DEDEDATA."/cache/inc_catalog_base.inc"); + } + GetSonIdsLogic($id, $cfg_Cs, $channel, $addthis); + $rquery = join(',', $GLOBALS['idArray']); + $rquery = preg_replace("/,$/", "", $rquery); + return $rquery; +} +//递归逻辑 +function GetSonIdsLogic($id, $sArr, $channel = 0, $addthis = false) +{ + if ($id != 0 && $addthis) { + $GLOBALS['idArray'][$id] = $id; + } + if (is_array($sArr)) { + foreach ($sArr as $k => $v) { + if ($v[0] == $id && ($channel == 0 || $v[1] == $channel)) { + GetSonIdsLogic($k, $sArr, $channel, true); + } + } + } +} +/** + * 栏目目录规则 + * + * @param string $typedir 栏目目录 + * @return string + */ +function MfTypedir($typedir) +{ + if (preg_match("/^(http|https|ftp):/i", $typedir)) return $typedir; + $typedir = str_replace("{cmspath}", $GLOBALS['cfg_cmspath'], $typedir); + $typedir = preg_replace("/\/{1,}/", "/", $typedir); + return $typedir; +} +/** + * 模板目录规则 + * + * @param string $tmpdir 模板目录 + * @return string + */ +function MfTemplet($tmpdir) +{ + $tmpdir = str_replace("{style}", $GLOBALS['cfg_df_style'], $tmpdir); + $tmpdir = preg_replace("/\/{1,}/", "/", $tmpdir); + return $tmpdir; +} +/** + * 清除用于js的空白块 + * + * @param string $atme 字符 + * @return string + */ +function FormatScript($atme) +{ + return $atme == ' ' ? '' : $atme; +} +/** + * 给属性默认值 + * + * @param array $atts 属性 + * @param string $attlist 属性列表 + * @return void + */ +function FillAttsDefault(&$atts, $attlist) +{ + $attlists = explode(',', (string)$attlist); + if (is_array($attlists)) { + for ($i = 0; isset($attlists[$i]); $i++) { + if (empty($attlists[$i])) { + continue; + } + list($k, $v) = explode('|', $attlists[$i]); + if (!isset($atts[$k])) { + $atts[$k] = $v; + } + } + } +} +/** + * 给块标记赋值 + * + * @param object $dtp 模板解析引擎 + * @param object $refObj 实例化对象 + * @param object $parfield + * @return string + */ +function MakeOneTag(&$dtp, &$refObj, $parfield = 'Y') +{ + $alltags = array(); + $dtp->setRefObj($refObj); + //读取自由调用tag列表 + $dh = dir(DEDEINC.'/taglib'); + while ($filename = $dh->read()) { + if (preg_match("/\.lib\./", $filename)) { + $alltags[] = str_replace('.lib.php', '', $filename); + } + } + $dh->Close(); + //遍历tag元素 + if (!is_array($dtp->CTags)) { + return ''; + } + foreach ($dtp->CTags as $tagid => $ctag) { + $tagname = $ctag->GetName(); + if ($tagname == 'field' && $parfield == 'Y') { + $vname = $ctag->GetAtt('name'); + if ($vname == 'array' && isset($refObj->Fields)) { + $dtp->Assign($tagid, $refObj->Fields); + } else if (isset($refObj->Fields[$vname])) { + $dtp->Assign($tagid, $refObj->Fields[$vname]); + } else if ($ctag->GetAtt('noteid') != '') { + if (isset($refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')])) { + $dtp->Assign($tagid, $refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')]); + } + } + continue; + } + //由于考虑兼容性,原来文档调用使用的标记别名统一保留,这些标记实际调用的解析文件为inc_arclist.php + if (preg_match("/^(artlist|likeart|hotart|imglist|imginfolist|coolart|specart|autolist)$/", $tagname)) { + $tagname = 'arclist'; + } + if ($tagname == 'friendlink') { + $tagname = 'flink'; + } + if (in_array($tagname, $alltags)) { + if (DEBUG_LEVEL == TRUE) { + $ttt1 = ExecTime(); + } + $filename = DEDEINC.'/taglib/'.$tagname.'.lib.php'; + include_once($filename); + $funcname = 'lib_'.$tagname; + $dtp->Assign($tagid, $funcname($ctag, $refObj)); + if (DEBUG_LEVEL == TRUE) { + $queryTime = ExecTime() - $ttt1; + if (PHP_SAPI === 'cli') { + echo '标签:'.$tagname.' 载入花费时间:'.$queryTime."\r\n"; + } else { + echo DedeAlert('标签:'.$tagname.' 载入花费时间:'.$queryTime, ALERT_WARNING); + } + + } + } + } +} +/** + * 获取某栏目链接 + * + * @param array $typeinfos 栏目信息 + * @return string + */ +function GetOneTypeUrlA($typeinfos) +{ + return GetTypeUrl( + $typeinfos['id'], + MfTypedir($typeinfos['typedir']), + $typeinfos['isdefault'], + $typeinfos['defaultname'], + $typeinfos['ispart'], + $typeinfos['namerule2'], + $typeinfos['moresite'], + $typeinfos['siteurl'], + $typeinfos['sitepath'] + ); +} +/** + * 设置全局环境变量 + * + * @param int $typeid 栏目id + * @param string $typename 栏目名称 + * @param string $aid 文档id + * @param string $title 标题 + * @param string $curfile 当前文件 + * @return string + */ +function SetSysEnv($typeid = 0, $typename = '', $aid = 0, $title = '', $curfile = '') +{ + global $_sys_globals; + if (empty($_sys_globals['curfile'])) { + $_sys_globals['curfile'] = $curfile; + } + if (empty($_sys_globals['typeid'])) { + $_sys_globals['typeid'] = $typeid; + } + if (empty($_sys_globals['typename'])) { + $_sys_globals['typename'] = $typename; + } + if (empty($_sys_globals['aid'])) { + $_sys_globals['aid'] = $aid; + } +} +/** + * 根据id生成目录 + * + * @param string $aid 文档id + * @return int + */ +function DedeID2Dir($aid) +{ + $n = ceil($aid / 1000); + return $n; +} +/** + * 获得自由列表的网址 + * + * @param string $lid 列表id + * @param string $namerule 命名规则 + * @param string $listdir 列表目录 + * @param string $defaultpage 默认页面 + * @param string $nodefault 没有默认页面 + * @return string + */ +function GetFreeListUrl($lid, $namerule, $listdir, $defaultpage, $nodefault) +{ + $listdir = str_replace('{cmspath}', $GLOBALS['cfg_cmspath'], $listdir); + if ($nodefault == 1) { + $okfile = str_replace('{page}', '1', $namerule); + $okfile = str_replace('{listid}', $lid, $okfile); + $okfile = str_replace('{listdir}', $listdir, $okfile); + } else { + $okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid"; + return $okfile; + } + $okfile = str_replace("\\", "/", $okfile); + $okfile = str_replace("//", "/", $okfile); + $trueFile = $GLOBALS['cfg_basedir'].$okfile; + if (!@file_exists($trueFile)) { + $okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid"; + } + return $okfile; +} +/** + * 获取网站搜索的热门关键词 + * + * @param object $dsql + * @param string $num 获取数目 + * @param string $nday 天数 + * @param string $klen 关键词字数 + * @param string $orderby 排列顺序 + * @return string + */ +function GetHotKeywords(&$dsql, $num = 8, $nday = 365, $klen = 16, $orderby = 'count') +{ + global $cfg_phpurl; + $nowtime = time(); + $num = @intval($num); + $nday = @intval($nday); + $klen = @intval($klen); + if (empty($nday)) { + $nday = 365; + } + if (empty($num)) { + $num = 6; + } + if (empty($klen)) { + $klen = 16; + } + $klen = $klen + 1; + $mintime = $nowtime - ($nday * 24 * 3600); + if (empty($orderby)) { + $orderby = 'count'; + } + $dsql->SetQuery("SELECT keyword FROM `#@__search_keywords` WHERE lasttime>$mintime AND length(keyword)<$klen ORDER BY $orderby DESC LIMIT 0,$num"); + $dsql->Execute('hw'); + $hotword = ''; + while ($row = $dsql->GetArray('hw')) { + $hotword .= "<a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."&searchtype=titlekeyword'>".$row['keyword']."</a> "; + } + return $hotword; +} +/** + * 使用绝对网址 + * + * @param string $gurl 地址 + * @return string + */ +function Gmapurl($gurl) +{ + return preg_match("/http[s]?:\/\//i", $gurl) ? $gurl : $GLOBALS['cfg_basehost'].$gurl; +} +/** + * 引用回复标记处理 + * + * @param string $quote + * @return string + */ +function Quote_replace($quote) +{ + $quote = str_replace('{quote}', '<div class="decmt-box">', $quote); + $quote = str_replace('{title}', '<div class="decmt-title"><span class="username">', $quote); + $quote = str_replace('{/title}', '</span></div>', $quote); + $quote = str_replace('<br/>', '<br>', $quote); + $quote = str_replace('<', '<', $quote); + $quote = str_replace('>', '>', $quote); + $quote = str_replace('{content}', '<div class="decmt-content">', $quote); + $quote = str_replace('{/content}', '</div>', $quote); + $quote = str_replace('{/quote}', '</div>', $quote); + return $quote; +} +/** + * 获取、写入指定cacheid的块 + * + * @param string $cacheid 缓存ID + * @return string + */ +function GetCacheBlock($cacheid) +{ + global $cfg_puccache_time; + $cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc'; + if ( + !file_exists($cachefile) || filesize($cachefile) == 0 || + $cfg_puccache_time == 0 || time() - filemtime($cachefile) > $cfg_puccache_time + ) { + return ''; + } + $fp = fopen($cachefile, 'r'); + $str = @fread($fp, filesize($cachefile)); + fclose($fp); + return $str; +} +/** + * 写入缓存块 + * + * @param string $cacheid 缓存ID + * @param string $str 字符串信息 + * @return string + */ +function WriteCacheBlock($cacheid, $str) +{ + $cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc'; + $fp = fopen($cachefile, 'w'); + $str = fwrite($fp, $str); + fclose($fp); +} ?> \ No newline at end of file diff --git a/src/system/libraries/statistics.class.php b/src/system/libraries/statistics.class.php index b404d4b0..b2070a8b 100644 --- a/src/system/libraries/statistics.class.php +++ b/src/system/libraries/statistics.class.php @@ -52,7 +52,7 @@ class DedeStatistics { ksort($pm); $pm['sign'] = sha1(http_build_query($pm).md5($cfg_cookie_encode)); $pm['dopost'] = "stat"; - $url = '/apps/statistics.php?'.http_build_query($pm); + $url = $GLOBALS['cfg_cmspath'].'/apps/statistics.php?'.http_build_query($pm); return " (function() { let u = '{$url}'; diff --git a/src/system/taglib/arclist.lib.php b/src/system/taglib/arclist.lib.php index 717956d4..8ac76ec8 100755 --- a/src/system/taglib/arclist.lib.php +++ b/src/system/taglib/arclist.lib.php @@ -344,7 +344,7 @@ function lib_arclistDone (&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlele $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("#^(http|https):\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/taglib/arclistsg.lib.php b/src/system/taglib/arclistsg.lib.php index 3e6d33f2..7b398df3 100755 --- a/src/system/taglib/arclistsg.lib.php +++ b/src/system/taglib/arclistsg.lib.php @@ -178,7 +178,7 @@ function lib_arclistsg(&$ctag, &$refObj) $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("#^(http|https):\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/taglib/feedback.lib.php b/src/system/taglib/feedback.lib.php index e274838c..c240fa19 100755 --- a/src/system/taglib/feedback.lib.php +++ b/src/system/taglib/feedback.lib.php @@ -45,7 +45,7 @@ function lib_feedback(&$ctag, &$refObj) $ctp->LoadSource($innertext); $dsql->Execute('fb', $equery); while ($arr = $dsql->GetArray('fb')) { - $arr['face'] = empty($arr['mface']) ? '/static/web/img/admin.png' : $arr['mface']; + $arr['face'] = empty($arr['mface']) ? $GLOBALS['cfg_cmspath'].'/static/web/img/admin.png' : $arr['mface']; $arr['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$arr['userid']; $arr['title'] = cn_substr($arr['arctitle'], $titlelen); $arr['msg'] = jsTrim(Html2Text($arr['msg']), $infolen); diff --git a/src/system/taglib/infoguide.lib.php b/src/system/taglib/infoguide.lib.php index 8d12b8d6..f6d4289e 100755 --- a/src/system/taglib/infoguide.lib.php +++ b/src/system/taglib/infoguide.lib.php @@ -11,7 +11,8 @@ if (!defined('DEDEINC')) exit ('dedebiz'); */ function lib_infoguide(&$ctag, &$refObj) { - global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_mainsite; + global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite; + $cmspath = ((empty($cfg_cmspath) || preg_match('#[/$]#', $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath); if (empty($refObj->Fields['typeid'])) { $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' "); $typeid = (is_array($row) ? $row['id'] : 0); @@ -29,7 +30,7 @@ function lib_infoguide(&$ctag, &$refObj) $revalue = $seli = ''; $fields = array('nativeplace' => '', 'infotype' => '', 'typeid' => $typeid); if ($hasSetEnumJs != 'has') { - $revalue .= '<script src="'.$cfg_mainsite.'/static/web/js/enums.js"></script>'."\r\n"; + $revalue .= '<script src="'.$cfg_mainsite.$cmspath.'static/web/js/enums.js"></script>'."\r\n"; $GLOBALS['hasSetEnumJs'] = 'hasset'; } $fields['nativeplace'] = $fields['infotype'] = ''; @@ -40,7 +41,7 @@ function lib_infoguide(&$ctag, &$refObj) $fields['nativeplace'] .= "<span id='span_nativeplace_son'></span>\r\n<span id='span_nativeplace_sec'></span>\r\n"; $fields['nativeplace'] .= "<script> var em_nativeplaces = []; - fetch('/static/enums/nativeplace.json').then((resp)=>resp.json()).then((d)=>{ + fetch('{$cmspath}static/enums/nativeplace.json').then((resp)=>resp.json()).then((d)=>{ Object.entries(d).forEach(v=>{ em_nativeplaces[parseFloat(v[0])]= v[1]; }); @@ -52,7 +53,7 @@ function lib_infoguide(&$ctag, &$refObj) $fields['infotype'] .= "<span id='span_infotype_son'></span><span id='span_infotype_sec'></span>\r\n"; $fields['infotype'] .= "<script> var em_infotypes = []; - fetch('/static/enums/infotype.json').then((resp)=>resp.json()).then((d)=>{ + fetch('{$cmspath}static/enums/infotype.json').then((resp)=>resp.json()).then((d)=>{ Object.entries(d).forEach(v=>{ em_infotypes[parseFloat(v[0])]= v[1]; }); diff --git a/src/system/taglib/infolink.lib.php b/src/system/taglib/infolink.lib.php index 54e588a2..32421b49 100755 --- a/src/system/taglib/infolink.lib.php +++ b/src/system/taglib/infolink.lib.php @@ -25,11 +25,12 @@ function is_str_float($value){ } function lib_infolink(&$ctag, &$refObj) { - global $dsql, $nativeplace, $infotype, $cfg_rewrite, $cfg_mainsite, $em_nativeplaces, $em_infotypes; + global $dsql, $nativeplace, $infotype, $cfg_rewrite, $cfg_cmspath, $cfg_mainsite, $em_nativeplaces, $em_infotypes; //$attlist="row|10,titlelen|30"; //FillAttsDefault($ctag->CAttribute->Items,$attlist); //extract($ctag->CAttribute->Items, EXTR_SKIP); - $baseurl = preg_replace("#\/$#", '', $cfg_mainsite); + $cmspath = ((empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath); + $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath; $smalltypes = ''; if (!empty($refObj->TypeLink->TypeInfos['smalltypes'])) { $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']); diff --git a/src/system/taglib/likearticle.lib.php b/src/system/taglib/likearticle.lib.php index f6105e54..cdf84402 100755 --- a/src/system/taglib/likearticle.lib.php +++ b/src/system/taglib/likearticle.lib.php @@ -122,7 +122,7 @@ function lib_likearticle(&$ctag, &$refObj) $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("#^(http|https):\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/taglib/relation.lib.php b/src/system/taglib/relation.lib.php index 7af5d7d4..85ce18f5 100644 --- a/src/system/taglib/relation.lib.php +++ b/src/system/taglib/relation.lib.php @@ -108,7 +108,7 @@ function lib_relation(&$ctag, &$refObj) $row['sitepath'] ); if ($row['litpic'] == '-' || $row['litpic'] == '') { - $row['litpic'] = '/static/web/img/thumbnail.jpg'; + $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; } if (!preg_match("#^(http|https):\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; diff --git a/src/system/taglib/statistics.lib.php b/src/system/taglib/statistics.lib.php index adac8c3d..b811d43f 100755 --- a/src/system/taglib/statistics.lib.php +++ b/src/system/taglib/statistics.lib.php @@ -21,7 +21,7 @@ function lib_statistics(&$ctag, &$refObj) $pms['typeid'] = isset($envs['typeid'])? $envs['typeid'] : 0; $pms['aid'] = isset($envs['aid'])? $envs['aid'] : 0; $pms['value'] = isset($envs['value'])? $envs['value'] : ''; - $revalue = '<script async src="'.'/apps/statistics.php?'.http_build_query($pms).'"></script>'; + $revalue = '<script async src="'.$GLOBALS['cfg_cmspath'].'/apps/statistics.php?'.http_build_query($pms).'"></script>'; return $revalue; } ?> \ No newline at end of file diff --git a/src/system/taglib/tag.lib.php b/src/system/taglib/tag.lib.php index 85b8dac1..03313727 100755 --- a/src/system/taglib/tag.lib.php +++ b/src/system/taglib/tag.lib.php @@ -21,7 +21,7 @@ function lib_tag(&$ctag, &$refObj) $ltype = $sort; $num = $row; $addsql = ''; - $tagsdir = str_replace("{cmspath}", "", $cfg_tags_dir); + $tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); if ($getall == 0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid'])) { $dsql->SetQuery("SELECT tid FROM `#@__taglist` WHERE aid = '{$refObj->Fields['aid']}' "); $dsql->Execute(); diff --git a/src/system/tpllib/plus_userarclist.php b/src/system/tpllib/plus_userarclist.php index ac3f4541..ecc793dc 100644 --- a/src/system/tpllib/plus_userarclist.php +++ b/src/system/tpllib/plus_userarclist.php @@ -28,7 +28,7 @@ function plus_userarclist(&$atts, &$refObj, &$fields) $row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']); $row['typeurl'] = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'], $row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); - if ($row['litpic']=='') $row['litpic'] = '/static/web/img/thumbnail.jpg'; + if ($row['litpic']=='') $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; if (!preg_match("#^(http|https):\/\/#i", $row['litpic'])) { $row['picname'] = $row['litpic'] = $GLOBALS['cfg_cmsurl'].$row['litpic']; } else { diff --git a/src/system/typelink/typelink.class.php b/src/system/typelink/typelink.class.php index 664b9868..c53f5285 100755 --- a/src/system/typelink/typelink.class.php +++ b/src/system/typelink/typelink.class.php @@ -75,7 +75,7 @@ class TypeLink function GetTypeDir() { if (empty($this->TypeInfos['typedir'])) { - return $GLOBALS['cfg_arcdir']; + return $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir']; } else { return $this->TypeInfos['typedir']; } diff --git a/src/system/typelink/typeunit.class.admin.php b/src/system/typelink/typeunit.class.admin.php index 9efbd94e..e6bbbba8 100755 --- a/src/system/typelink/typeunit.class.admin.php +++ b/src/system/typelink/typeunit.class.admin.php @@ -23,7 +23,7 @@ class TypeUnit function __construct() { $this->idCounter = 0; - $this->artDir = $GLOBALS['cfg_arcdir']; + $this->artDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir']; $this->baseDir = $GLOBALS['cfg_basedir']; $this->shortName = $GLOBALS['art_shortname']; $this->idArray = array(); diff --git a/src/user/index_do.php b/src/user/index_do.php index 6a8d2921..cb1c228d 100755 --- a/src/user/index_do.php +++ b/src/user/index_do.php @@ -21,7 +21,7 @@ if ($fmdo == 'sendMail') { exit(); } $userhash = md5($cfg_cookie_encode.'--'.$cfg_ml->fields['mid'].'--'.$cfg_ml->fields['email']); - $url = $cfg_basehost.$cfg_memberurl."/index_do.php?fmdo=checkMail&mid={$cfg_ml->fields['mid']}&userhash={$userhash}&do=1"; + $url = $cfg_basehost.(empty($cfg_cmspath) ? '/' : $cfg_cmspath)."/user/index_do.php?fmdo=checkMail&mid={$cfg_ml->fields['mid']}&userhash={$userhash}&do=1"; $url = preg_replace("#http:\/\/#i", '', $url); $proto = IsSSL()? "https://" : "http://"; $url = $proto.preg_replace("#\/\/#i", '/', $url);