@@ -1,3 +1,60 @@ | |||
# DedeV6Mobile | |||
DedeV6移动版 | |||
压缩包解压后覆盖前备份:栏目列表分页样式、标签列表分页样式、搜索列表分页样式等文件后自行处理列表样式。 | |||
/admin/inc/inc_archives_functions.php | |||
/admin/inc/inc_menu.php | |||
/system/archive/archives.class.php | |||
/system/archive/listview.class.php | |||
手机端模板启用静态链接,如列表“[field:typeurl/]”标签,文档“[field:arcurl/]”标签。那么手机端模模板中css和js等,建议用绝对路径引用,以免手机端更新后页面错误。缩略图标签前加电脑端链接为http://xxx.com[field:picname/],文档正文标签为{dede:field.body function='str_replace("/static/allimg/","http:xxx.com/static/allimg/",@me)'/},后台-系统设置-系统配置变量-是否支持多站点选择否,最后更新目录中有静态文件,则更新成功。 | |||
手机端模板启用动态链接,如列表list.php?tid=[field:id/]形式,文档view.php?aid=[field:id/]形式,手机端伪静态规则参考电脑端。 | |||
## 手机端静态识别设备跳转代码 | |||
以下代码放到电脑端前端模板的js里,或者创建一个js文件引用即可,域名换成您要跳转域名。 | |||
//电脑跳转移动 | |||
var nowurl = window.location.href; | |||
nowurl = nowurl.replace("www.dedebiz", "m.baidu"); | |||
if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) { | |||
if (window.location.href.indexOf("?agent=m") < 0) { | |||
try { | |||
if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) { | |||
window.location.href = nowurl | |||
} else if (/iPad/i.test(navigator.userAgent)) {} else { | |||
window.location.href = nowurl | |||
} | |||
} catch(e) {} | |||
} | |||
} | |||
//移动跳转电脑 | |||
var sUserAgent = navigator.userAgent.toLowerCase(); | |||
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; | |||
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; | |||
var bIsMidp = sUserAgent.match(/midp/i) == "midp"; | |||
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; | |||
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; | |||
var bIsAndroid = sUserAgent.match(/android/i) == "android"; | |||
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; | |||
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; | |||
if (! (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) { | |||
url = window.location.href; | |||
url = url.replace("m.baidu", "www.dedebiz"); | |||
window.location.href = url | |||
} | |||
## 手机端动态识别设备跳转代码 | |||
首页 | |||
<script>if ((navigator.userAgent.match(/(iPhone|iPod|Android|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {location.replace("{dede:global.cfg_cmsurl/}/m/");} else {}</script> | |||
列表页 | |||
<script>if ((navigator.userAgent.match(/(iPhone|iPod|Android|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {location.replace("{dede:global.cfg_cmsurl/}/m/list.php?tid={dede:field.typeid/}");} else {}</script> | |||
文档页 | |||
<script>if ((navigator.userAgent.match(/(iPhone|iPod|Android|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {location.replace("{dede:global.cfg_cmsurl/}/m/view.php?aid={dede:field.id/}");} else {}</script> |
@@ -0,0 +1,768 @@ | |||
<?php | |||
/** | |||
* 文档操作相关函数 | |||
* | |||
* @version $id:inc_archives_functions.php 9:56 2010年7月21日 tianya $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); | |||
require_once(DEDEINC.'/image.func.php'); | |||
require_once(DEDEINC.'/archive/partview.class.php'); | |||
$backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : ''; | |||
$backurl = preg_match("#content_#", $backurl) ? "<a href='$backurl' class='btn btn-success btn-sm'>记忆的列表页</a>" : ''; | |||
if (!isset($_NOT_ARCHIVES)) { | |||
require_once(DEDEINC.'/customfields.func.php'); | |||
} | |||
/** | |||
* 获得网页里的外部资源,针对图片 | |||
* | |||
* @access public | |||
* @param string $body 文档 | |||
* @param string $rfurl 来源地址 | |||
* @param string $firstdd 开始标记 | |||
* @return string | |||
*/ | |||
function GetCurContentAlbum($body, $rfurl, &$firstdd) | |||
{ | |||
global $dsql, $cfg_multi_site, $cfg_basehost, $cfg_ddimg_width, $cfg_basedir, $pagestyle, $cuserLogin, $cfg_addon_savetype; | |||
require_once(DEDEINC.'/dedecollection.func.php'); | |||
if (empty($cfg_ddimg_width)) $cfg_ddimg_width = 320; | |||
$rsimg = ''; | |||
$cfg_uploaddir = $GLOBALS['cfg_image_dir']; | |||
$cfg_basedir = $GLOBALS['cfg_basedir']; | |||
$basehost = IsSSL()? "https://".$_SERVER["HTTP_HOST"] : "http://".$_SERVER["HTTP_HOST"]; | |||
$img_array = array(); | |||
preg_match_all("/(src)=[\"|'| ]{0,}(http:\/\/([^>]*)\.(gif|jpg|png))/isU", $body, $img_array); | |||
$img_array = array_unique($img_array[2]); | |||
$imgUrl = $cfg_uploaddir.'/'.MyDate($cfg_addon_savetype, time()); | |||
$imgPath = $cfg_basedir.$imgUrl; | |||
if (!is_dir($imgPath.'/')) { | |||
MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); | |||
CloseFtp(); | |||
} | |||
$milliSecond = 'co'.dd2char(MyDate('ymdHis', time())); | |||
foreach ($img_array as $key => $value) { | |||
$value = trim($value); | |||
if ( | |||
preg_match("#".$basehost."#i", $value) || !preg_match("#^http:\/\/#i", $value) | |||
|| ($cfg_basehost != $basehost && preg_match("#".$cfg_basehost."#i", $value)) | |||
) { | |||
continue; | |||
} | |||
$itype = substr($value, -4, 4); | |||
if (!preg_match("#\.(gif|jpg|png)#", $itype)) $itype = ".jpg"; | |||
$rndFileName = $imgPath.'/'.$milliSecond.'-'.$key.$itype; | |||
$iurl = $imgUrl.'/'.$milliSecond.'-'.$key.$itype; | |||
//下载并保存文件 | |||
$rs = DownImageKeep($value, $rfurl, $rndFileName, '', 0, 30); | |||
if ($rs) { | |||
$info = ''; | |||
$imginfos = GetImageSize($rndFileName, $info); | |||
$fsize = filesize($rndFileName); | |||
$filename = $milliSecond.'-'.$key.$itype; | |||
//保存图片附件信息 | |||
$inquery = "INSERT INTO `#@__uploads` (arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES ('0','$filename','$iurl','1','{$imginfos[0]}','$imginfos[1]','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); "; | |||
$dsql->ExecuteNoneQuery($inquery); | |||
$fid = $dsql->GetLastID(); | |||
AddMyAddon($fid, $iurl); | |||
if ($pagestyle > 2) { | |||
$litpicname = GetImageMapDD($iurl, $cfg_ddimg_width); | |||
} else { | |||
$litpicname = $iurl; | |||
} | |||
if (empty($firstdd) && !empty($litpicname)) { | |||
$firstdd = $litpicname; | |||
if (!file_exists($cfg_basedir.$firstdd)) { | |||
$firstdd = $iurl; | |||
} | |||
} | |||
@WaterImg($rndFileName, 'down'); | |||
$rsimg .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n"; | |||
} | |||
} | |||
return $rsimg; | |||
} | |||
/** | |||
* 获得文档body里的外部资源 | |||
* | |||
* @access public | |||
* @param string $body 文档 | |||
* @return string | |||
*/ | |||
function GetCurContent($body) | |||
{ | |||
global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_image_dir, $arcID, $cuserLogin, $dsql; | |||
$cfg_uploaddir = $cfg_image_dir; | |||
$htd = new DedeHttpDown(); | |||
$basehost = IsSSL()? "https://".$_SERVER["HTTP_HOST"] : "http://".$_SERVER["HTTP_HOST"]; | |||
$img_array = array(); | |||
$body = str_replace("data-src=","src=", $body); | |||
preg_match_all("/src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU", $body, $img_array); | |||
$img_array = array_unique($img_array[1]); | |||
$imgUrl = $cfg_uploaddir.'/'.MyDate("ymd", time()); | |||
$imgPath = $cfg_basedir.$imgUrl; | |||
if (!is_dir($imgPath.'/')) { | |||
MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); | |||
CloseFtp(); | |||
} | |||
$milliSecond = MyDate('His', time()); | |||
foreach ($img_array as $key => $value) { | |||
if (preg_match("#".$basehost."#i", $value)) { | |||
continue; | |||
} | |||
if ($cfg_basehost != $basehost && preg_match("#".$cfg_basehost."#i", $value)) { | |||
continue; | |||
} | |||
if (!preg_match("#^(http|https):\/\/#i", $value)) { | |||
continue; | |||
} | |||
$v = str_replace('&','&',$value); | |||
$htd->OpenUrl($v); | |||
$itype = $htd->GetHead("content-type"); | |||
$isImage = true; | |||
if ($itype == 'image/gif') { | |||
$itype = ".gif"; | |||
} else if ($itype == 'image/png') { | |||
$itype = ".png"; | |||
} else if ($itype == 'audio/mpeg'){ | |||
$itype = ".mp3"; | |||
$isImage = false; | |||
} else if ($itype == 'image/jpeg') { | |||
$itype = '.jpg'; | |||
} else if ($itype == 'image/bmp') { | |||
$itype = '.bmp'; | |||
} else if ($itype == 'image/svg+xml') { | |||
$itype = '.svg'; | |||
$isImage = false; | |||
} else { | |||
continue; | |||
} | |||
$milliSecondN = dd2char($milliSecond.mt_rand(1000, 8000)); | |||
$value = trim($value); | |||
$rndFileName = $imgPath.'/'.$milliSecondN.'-'.$key.$itype; | |||
$fileurl = $imgUrl.'/'.$milliSecondN.'-'.$key.$itype; | |||
$rs = $htd->SaveToBin($rndFileName); | |||
if ($rs) { | |||
$info = ''; | |||
$imginfos = array(0,0); | |||
if ($isImage) { | |||
$imginfos = GetImageSize($rndFileName, $info); | |||
} | |||
$fsize = filesize($rndFileName); | |||
//保存图片附件信息 | |||
$inquery = "INSERT INTO `#@__uploads` (arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES ('{$arcID}','$rndFileName','$fileurl','1','{$imginfos[0]}','$imginfos[1]','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); "; | |||
$dsql->ExecuteNoneQuery($inquery); | |||
$fid = $dsql->GetLastID(); | |||
AddMyAddon($fid, $fileurl); | |||
if ($cfg_multi_site == 'Y') { | |||
$fileurl = $cfg_basehost.$fileurl; | |||
} | |||
$body = str_replace($value, $fileurl, $body); | |||
if ($isImage) { | |||
@WaterImg($rndFileName, 'down'); | |||
} | |||
} | |||
} | |||
$htd->Close(); | |||
return $body; | |||
} | |||
/** | |||
* 获取一个远程图片 | |||
* | |||
* @access public | |||
* @param string $url 地址 | |||
* @param int $uid 用户id | |||
* @return array | |||
*/ | |||
function GetRemoteImage($url, $uid = 0) | |||
{ | |||
global $cfg_basedir, $cfg_image_dir, $cfg_addon_savetype; | |||
$cfg_uploaddir = $cfg_image_dir; | |||
$revalues = array(); | |||
$ok = false; | |||
$htd = new DedeHttpDown(); | |||
$htd->OpenUrl($url); | |||
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp"); | |||
if (!in_array($htd->GetHead("content-type"), $sparr)) { | |||
return ''; | |||
} else { | |||
$imgUrl = $cfg_uploaddir.'/'.MyDate($cfg_addon_savetype, time()); | |||
$imgPath = $cfg_basedir.$imgUrl; | |||
CreateDir($imgUrl); | |||
$itype = $htd->GetHead("content-type"); | |||
if ($itype == "image/gif") { | |||
$itype = '.gif'; | |||
} else if ($itype == "image/png") { | |||
$itype = '.png'; | |||
} else if ($itype == "image/wbmp") { | |||
$itype = '.bmp'; | |||
} else { | |||
$itype = '.jpg'; | |||
} | |||
$rndname = dd2char($uid.'_'.MyDate('mdHis', time()).mt_rand(1000, 9999)); | |||
$rndtrueName = $imgPath.'/'.$rndname.$itype; | |||
$fileurl = $imgUrl.'/'.$rndname.$itype; | |||
$ok = $htd->SaveToBin($rndtrueName); | |||
@WaterImg($rndtrueName, 'down'); | |||
if ($ok) { | |||
$data = GetImageSize($rndtrueName); | |||
$revalues[0] = $fileurl; | |||
$revalues[1] = $data[0]; | |||
$revalues[2] = $data[1]; | |||
} | |||
} | |||
$htd->Close(); | |||
return ($ok ? $revalues : ''); | |||
} | |||
/** | |||
* 检测栏目id | |||
* | |||
* @access public | |||
* @param int $typeid 栏目id | |||
* @param int $channelid 栏目id | |||
* @return bool | |||
*/ | |||
function CheckChannel($typeid, $channelid) | |||
{ | |||
global $dsql; | |||
if ($typeid == 0) return TRUE; | |||
$row = $dsql->GetOne("SELECT ispart,channeltype FROM `#@__arctype` WHERE id='$typeid' "); | |||
if ($row['ispart'] != 0 || $row['channeltype'] != $channelid) return FALSE; | |||
else return TRUE; | |||
} | |||
/** | |||
* 检测文档权限 | |||
* | |||
* @access public | |||
* @param int $aid 文档aid | |||
* @param int $adminid 管理员id | |||
* @return bool | |||
*/ | |||
function CheckArcAdmin($aid, $adminid) | |||
{ | |||
global $dsql; | |||
$row = $dsql->GetOne("SELECT mid FROM `#@__archives` WHERE id='$aid' "); | |||
if ($row['mid'] != $adminid) return FALSE; | |||
else return TRUE; | |||
} | |||
/** | |||
* 文档自动分页 | |||
* | |||
* @access public | |||
* @param string $mybody 文档 | |||
* @param string $spsize 分页大小 | |||
* @param string $sptag 分页标记 | |||
* @return string | |||
*/ | |||
function SpLongBody($mybody, $spsize, $sptag) | |||
{ | |||
if (strlen($mybody) < $spsize) { | |||
return $mybody; | |||
} | |||
$mybody = stripslashes($mybody); | |||
$bds = explode('<', $mybody); | |||
$npageBody = ''; | |||
$istable = 0; | |||
$mybody = ''; | |||
foreach ($bds as $i => $k) { | |||
if ($i == 0) { | |||
$npageBody .= $bds[$i]; | |||
continue; | |||
} | |||
$bds[$i] = "<".$bds[$i]; | |||
if (strlen($bds[$i]) > 6) { | |||
$tname = substr($bds[$i], 1, 5); | |||
if (strtolower($tname) == 'table') { | |||
$istable++; | |||
} else if (strtolower($tname) == '/tabl') { | |||
$istable--; | |||
} | |||
if ($istable > 0) { | |||
$npageBody .= $bds[$i]; | |||
continue; | |||
} else { | |||
$npageBody .= $bds[$i]; | |||
} | |||
} else { | |||
$npageBody .= $bds[$i]; | |||
} | |||
if (strlen($npageBody) > $spsize) { | |||
$mybody .= $npageBody.$sptag; | |||
$npageBody = ''; | |||
} | |||
} | |||
if ($npageBody != '') { | |||
$mybody .= $npageBody; | |||
} | |||
return addslashes($mybody); | |||
} | |||
/** | |||
* 创建指定id的文档 | |||
* | |||
* @access public | |||
* @param string $aid 文档id | |||
* @param string $ismakesign 生成标志 | |||
* @param int $isremote 是否远程 | |||
* @return string | |||
*/ | |||
function MakeArt($aid, $mkindex = FALSE, $ismakesign = FALSE, $isremote = 0) | |||
{ | |||
global $envs, $typeid; | |||
require_once(DEDEINC.'/archive/archives.class.php'); | |||
if ($ismakesign) $envs['makesign'] = 'yes'; | |||
$arc = new Archives($aid); | |||
$reurl = $arc->MakeHtml($isremote); | |||
$arc->MakeHtml($isremote,1);//发布文档同步手机端 | |||
return $reurl; | |||
} | |||
/** | |||
* 取第一个图片为缩略图 | |||
* | |||
* @access public | |||
* @param string $body 文档 | |||
* @return string | |||
*/ | |||
function GetDDImgFromBody(&$body) | |||
{ | |||
$litpic = ''; | |||
preg_match_all("/(src)=[\"|'| ]{0,}([^>]*\.(gif|jpg|bmp|png))/isU", $body, $img_array); | |||
$img_array = array_unique($img_array[2]); | |||
if (count($img_array) > 0) { | |||
$picname = preg_replace("/[\"|'| ]{1,}/", '', $img_array[0]); | |||
if (preg_match("#_lit\.#", $picname)) $litpic = $picname; | |||
else $litpic = GetDDImage('ddfirst', $picname, 1); | |||
} | |||
return $litpic; | |||
} | |||
/** | |||
* 获得缩略图 | |||
* | |||
* @access public | |||
* @param string $litpic 缩略图 | |||
* @param string $picname 图片名称 | |||
* @param string $isremote 是否远程 | |||
* @return string | |||
*/ | |||
function GetDDImage($litpic, $picname, $isremote) | |||
{ | |||
global $cuserLogin, $cfg_ddimg_width, $cfg_ddimg_height, $cfg_basedir, $cfg_image_dir, $cfg_addon_savetype; | |||
$ntime = time(); | |||
if (($litpic != 'none' || $litpic != 'ddfirst') && !empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name']) | |||
) { | |||
//如果用户自行上传缩略图 | |||
$istype = 0; | |||
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png"); | |||
$_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type'])); | |||
if (!in_array($_FILES[$litpic]['type'], $sparr)) { | |||
ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种", "-1"); | |||
exit(); | |||
} | |||
$savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime); | |||
CreateDir($savepath); | |||
$fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999)); | |||
if (strtolower($_FILES[$litpic]['type']) == "image/gif") { | |||
$fullUrl = $fullUrl.".gif"; | |||
} else if (strtolower($_FILES[$litpic]['type']) == "image/png") { | |||
$fullUrl = $fullUrl.".png"; | |||
} else { | |||
$fullUrl = $fullUrl.".jpg"; | |||
} | |||
$mime = get_mime_type($_FILES[$litpic]['tmp_name']); | |||
if (preg_match("#^unknow#", $mime)) { | |||
ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1); | |||
exit; | |||
} | |||
if (!preg_match("#^(image|video|audio|application)#i", $mime)) { | |||
ShowMsg("仅支持媒体文件及应用程序上传", -1); | |||
exit; | |||
} | |||
@move_uploaded_file($_FILES[$litpic]['tmp_name'], $cfg_basedir.$fullUrl); | |||
$litpic = $fullUrl; | |||
if ($GLOBALS['cfg_ddimg_full'] == 'Y') @ImageResizeNew($cfg_basedir.$fullUrl, $cfg_ddimg_width, $cfg_ddimg_height); | |||
else @ImageResize($cfg_basedir.$fullUrl, $cfg_ddimg_width, $cfg_ddimg_height); | |||
$img = $cfg_basedir.$litpic; | |||
} else { | |||
$picname = trim($picname); | |||
if ($isremote == 1 && preg_match("#^http:\/\/#i", $picname)) { | |||
$litpic = $picname; | |||
$ddinfos = GetRemoteImage($litpic, $cuserLogin->getUserID()); | |||
if (!is_array($ddinfos)) { | |||
$litpic = ''; | |||
} else { | |||
$litpic = $ddinfos[0]; | |||
if ($ddinfos[1] > $cfg_ddimg_width || $ddinfos[2] > $cfg_ddimg_height) { | |||
if ($GLOBALS['cfg_ddimg_full'] == 'Y') @ImageResizeNew($cfg_basedir.$litpic, $cfg_ddimg_width, $cfg_ddimg_height); | |||
else @ImageResize($cfg_basedir.$litpic, $cfg_ddimg_width, $cfg_ddimg_height); | |||
} | |||
} | |||
} else { | |||
if ($litpic == 'ddfirst' && !preg_match("#^http:\/\/#i", $picname)) { | |||
$oldpic = $cfg_basedir.$picname; | |||
$litpic = str_replace('.', '-ty.', $picname); | |||
if ($GLOBALS['cfg_ddimg_full'] == 'Y') @ImageResizeNew($oldpic, $cfg_ddimg_width, $cfg_ddimg_height, $cfg_basedir.$litpic); | |||
else @ImageResize($oldpic, $cfg_ddimg_width, $cfg_ddimg_height, $cfg_basedir.$litpic); | |||
if (!is_file($cfg_basedir.$litpic)) $litpic = ''; | |||
} else { | |||
$litpic = $picname; | |||
return $litpic; | |||
} | |||
} | |||
} | |||
if ($litpic == 'litpic' || $litpic == 'ddfirst') $litpic = ''; | |||
return $litpic; | |||
} | |||
/** | |||
* 获得一个附加表单 | |||
* | |||
* @access public | |||
* @param object $ctag ctag | |||
* @return string | |||
*/ | |||
function GetFormItemA($ctag) | |||
{ | |||
return GetFormItem($ctag, 'admin'); | |||
} | |||
/** | |||
* 处理不同类型的数据 | |||
* | |||
* @access public | |||
* @param string $dvalue | |||
* @param string $dtype | |||
* @param int $aid | |||
* @param string $job | |||
* @param string $addvar | |||
* @return string | |||
*/ | |||
function GetFieldValueA($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '') | |||
{ | |||
return GetFieldValue($dvalue, $dtype, $aid, $job, $addvar, 'admin'); | |||
} | |||
/** | |||
* 获得带值的表单修改时用 | |||
* | |||
* @access public | |||
* @param object $ctag ctag | |||
* @param string $fvalue fvalue | |||
* @return string | |||
*/ | |||
function GetFormItemValueA($ctag, $fvalue) | |||
{ | |||
return GetFormItemValue($ctag, $fvalue, 'admin'); | |||
} | |||
/** | |||
* 载入自定义表单用于发布 | |||
* | |||
* @access public | |||
* @param string $fieldset 字段列表 | |||
* @param string $loadtype 载入类型 | |||
* @return string | |||
*/ | |||
function PrintAutoFieldsAdd($fieldset, $loadtype = 'all') | |||
{ | |||
$dtp = new DedeTagParse(); | |||
$dtp->SetNameSpace('field', '<', '>'); | |||
$dtp->LoadSource($fieldset); | |||
$dede_addonfields = ''; | |||
if (is_array($dtp->CTags)) { | |||
foreach ($dtp->CTags as $tid => $ctag) { | |||
if ( | |||
$loadtype != 'autofield' || ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1) | |||
) { | |||
$dede_addonfields .= ($dede_addonfields == "" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type')); | |||
echo GetFormItemA($ctag); | |||
} | |||
} | |||
} | |||
echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n"; | |||
} | |||
/** | |||
* 载入自定义表单用于修改 | |||
* | |||
* @access public | |||
* @param string $fieldset 字段列表 | |||
* @param string $fieldValues 字段值 | |||
* @param string $loadtype 载入类型 | |||
* @return string | |||
*/ | |||
function PrintAutoFieldsEdit(&$fieldset, &$fieldValues, $loadtype = 'all') | |||
{ | |||
$dtp = new DedeTagParse(); | |||
$dtp->SetNameSpace("field", "<", ">"); | |||
$dtp->LoadSource($fieldset); | |||
$dede_addonfields = ""; | |||
if (is_array($dtp->CTags)) { | |||
foreach ($dtp->CTags as $tid => $ctag) { | |||
if ( | |||
$loadtype != 'autofield' || ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1) | |||
) { | |||
$dede_addonfields .= ($dede_addonfields == '' ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type')); | |||
echo GetFormItemValueA($ctag, $fieldValues[$ctag->GetName()]); | |||
} | |||
} | |||
} | |||
echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n"; | |||
} | |||
/** | |||
* 处理网页文本,删除非站外链接,自动摘要,自动获取缩略图 | |||
* | |||
* @access public | |||
* @param string $body 文档 | |||
* @param string $description 描述 | |||
* @param string $litpic 缩略图 | |||
* @param string $keywords 关键词 | |||
* @param string $dtype 类型 | |||
* @return string | |||
*/ | |||
function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = '') | |||
{ | |||
global $autolitpic, $remote, $dellink, $autokey, $cfg_basehost, $cfg_auot_description, $id, $title, $cfg_soft_lang, $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port; | |||
$autolitpic = (empty($autolitpic) ? '' : $autolitpic); | |||
$body = stripslashes($body); | |||
//远程图片本地化 | |||
if ($remote == 1) { | |||
$body = GetCurContent($body); | |||
} | |||
//删除非站内链接 | |||
if ($dellink == 1) { | |||
$allow_urls = array($_SERVER['HTTP_HOST']); | |||
//读取允许的超链接设置 | |||
if (file_exists(DEDEDATA."/admin/allowurl.txt")) { | |||
$allow_urls = array_merge($allow_urls, file(DEDEDATA."/admin/allowurl.txt")); | |||
} | |||
$body = Replace_Links($body, $allow_urls); | |||
} | |||
//自动摘要 | |||
if ($description == '' && $cfg_auot_description > 0) { | |||
$description = cn_substr(html2text($body), $cfg_auot_description); | |||
$description = trim(preg_replace('/#p#|#e#/', '', $description)); | |||
$description = addslashes($description); | |||
} | |||
//自动获取缩略图 | |||
if ($autolitpic == 1 && $litpic == '') { | |||
$litpic = GetDDImgFromBody($body); | |||
} | |||
//自动获取关键词 | |||
if ($autokey == 2 && $keywords == '') { | |||
$subject = $title; | |||
$message = $body; | |||
//采用DedeBIZ Core分词组件分词 | |||
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { | |||
$keywords = ''; | |||
$client = new DedeBizClient(); | |||
$data = $client->Spliteword($subject.Html2Text($message)); | |||
$keywords = $data->data; | |||
$client->Close(); | |||
} else { | |||
include_once(DEDEINC.'/libraries/splitword.class.php'); | |||
$keywords = ''; | |||
$sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang); | |||
$sp->SetSource($subject, $cfg_soft_lang, $cfg_soft_lang); | |||
$sp->StartAnalysis(); | |||
$titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex()); | |||
$sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang); | |||
$sp->StartAnalysis(); | |||
$allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex()); | |||
if (is_array($allindexs) && is_array($titleindexs)) { | |||
foreach ($titleindexs as $k => $v) { | |||
if (strlen($keywords.$k) >= 60) { | |||
break; | |||
} else { | |||
if (strlen($k) <= 2) continue; | |||
$keywords .= $k.','; | |||
} | |||
} | |||
foreach ($allindexs as $k => $v) { | |||
if (strlen($keywords.$k) >= 60) { | |||
break; | |||
} else if (!in_array($k, $titleindexs)) { | |||
if (strlen($k) <= 2) continue; | |||
$keywords .= $k.','; | |||
} | |||
} | |||
} | |||
$sp = null; | |||
} | |||
} | |||
$body = GetFieldValueA($body, $dtype, $id); | |||
$body = addslashes($body); | |||
return $body; | |||
} | |||
/** | |||
* 删除非站内链接 | |||
* | |||
* @access public | |||
* @param string $body 文档 | |||
* @param array $allow_urls 允许的超链接 | |||
* @return string | |||
*/ | |||
function Replace_Links(&$body, $allow_urls = array()) | |||
{ | |||
$host_rule = join('|', $allow_urls); | |||
$host_rule = preg_replace("#[\n\r]#", '', $host_rule); | |||
$host_rule = str_replace('.', "\\.", $host_rule); | |||
$host_rule = str_replace('/', "\\/", $host_rule); | |||
$arr = array(); | |||
preg_match_all("#<a([^>]*)>(.*)<\/a>#iU", $body, $arr); | |||
if (is_array($arr[0])) { | |||
$rparr = array(); | |||
$tgarr = array(); | |||
foreach ($arr[0] as $i => $v) { | |||
if ($host_rule != '' && preg_match('#'.$host_rule.'#i', $arr[1][$i])) { | |||
continue; | |||
} else { | |||
$rparr[] = $v; | |||
$tgarr[] = $arr[2][$i]; | |||
} | |||
} | |||
if (!empty($rparr)) { | |||
$body = str_replace($rparr, $tgarr, $body); | |||
} | |||
} | |||
$arr = $rparr = $tgarr = ''; | |||
return $body; | |||
} | |||
/** | |||
* 图片里大图的小图 | |||
* | |||
* @access public | |||
* @param string $filename 图片名称 | |||
* @param string $maxwidth 最大宽度 | |||
* @return string | |||
*/ | |||
function GetImageMapDD($filename, $maxwidth) | |||
{ | |||
global $cuserLogin, $dsql, $cfg_ddimg_height, $cfg_ddimg_full; | |||
$ddn = substr($filename, -3); | |||
$ddpicok = preg_replace("#\.".$ddn."$#", "-ty.".$ddn, $filename); | |||
$toFile = $GLOBALS['cfg_basedir'].$ddpicok; | |||
if ($cfg_ddimg_full == 'Y') ImageResizeNew($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile); | |||
else ImageResize($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile); | |||
//保存图片附件信息 | |||
$fsize = filesize($toFile); | |||
$ddpicoks = explode('/', $ddpicok); | |||
$filename = $ddpicoks[count($ddpicoks) - 1]; | |||
$inquery = "INSERT INTO `#@__uploads` (arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES ('0','$filename','$ddpicok','1','0','0','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); "; | |||
$dsql->ExecuteNoneQuery($inquery); | |||
$fid = $dsql->GetLastID(); | |||
AddMyAddon($fid, $ddpicok); | |||
return $ddpicok; | |||
} | |||
/** | |||
* 上传一个未经处理的图片 | |||
* | |||
* @access public | |||
* @param string $upname 上传框名称 | |||
* @param string $handurl 手工填写的网址 | |||
* @param string $ddisremote 是否下载远程图片0不下,1下载 | |||
* @param string $ntitle 注解文字,如果表单有title字段可不管 | |||
* @return mixed | |||
*/ | |||
function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '') | |||
{ | |||
global $cuserLogin, $cfg_basedir, $cfg_image_dir, $title, $dsql; | |||
if ($ntitle != '') { | |||
$title = $ntitle; | |||
} | |||
$ntime = time(); | |||
$filename = ''; | |||
$isrm_up = FALSE; | |||
$handurl = trim($handurl); | |||
//如果用户自行上传了图片 | |||
if (!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name'])) { | |||
$istype = 0; | |||
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png"); | |||
$_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type'])); | |||
if (!in_array($_FILES[$upname]['type'], $sparr)) { | |||
ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种", "-1"); | |||
exit(); | |||
} | |||
if (!empty($handurl) && !preg_match("#^http:\/\/#i", $handurl) && file_exists($cfg_basedir.$handurl)) { | |||
if (!is_object($dsql)) { | |||
$dsql = new DedeSqli(); | |||
} | |||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads` WHERE url LIKE '$handurl' "); | |||
$fullUrl = preg_replace("#\.([a-z]*)$#i", "", $handurl); | |||
} else { | |||
$savepath = $cfg_image_dir.'/'.date("%Y-%m", $ntime); | |||
CreateDir($savepath); | |||
$fullUrl = $savepath.'/'.date("%d", $ntime).dd2char(date("%H%M%S", $ntime).'0'.$cuserLogin->getUserID().'0'.mt_rand(1000, 9999)); | |||
} | |||
if (strtolower($_FILES[$upname]['type']) == "image/gif") { | |||
$fullUrl = $fullUrl.".gif"; | |||
} else if (strtolower($_FILES[$upname]['type']) == "image/png") { | |||
$fullUrl = $fullUrl.".png"; | |||
} else { | |||
$fullUrl = $fullUrl.".jpg"; | |||
} | |||
$mime = get_mime_type($_FILES[$upname]['tmp_name']); | |||
if (preg_match("#^unknow#", $mime)) { | |||
ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1); | |||
exit; | |||
} | |||
if (!preg_match("#^(image|video|audio|application)#i", $mime)) { | |||
ShowMsg("仅支持媒体文件及应用程序上传", -1); | |||
exit; | |||
} | |||
//保存 | |||
@move_uploaded_file($_FILES[$upname]['tmp_name'], $cfg_basedir.$fullUrl); | |||
$filename = $fullUrl; | |||
//水印 | |||
@WaterImg($cfg_basedir.$fullUrl, 'up'); | |||
$isrm_up = TRUE; | |||
} else { | |||
//远程或选择本地图片 | |||
if ($handurl == '') { | |||
return ''; | |||
} | |||
//远程图片并要求本地化 | |||
if ($isremote == 1 && preg_match("#^http[s]?:\/\/#i", $handurl)) { | |||
$ddinfos = GetRemoteImage($handurl, $cuserLogin->getUserID()); | |||
if (!is_array($ddinfos)) { | |||
$litpic = ""; | |||
} else { | |||
$filename = $ddinfos[0]; | |||
} | |||
$isrm_up = TRUE; | |||
} else { | |||
//本地图片或远程不要求本地化 | |||
$filename = $handurl; | |||
} | |||
} | |||
$imgfile = $cfg_basedir.$filename; | |||
if (is_file($imgfile) && $isrm_up && $filename != '') { | |||
$info = ""; | |||
$imginfos = GetImageSize($imgfile, $info); | |||
//把新上传的图片信息保存到媒体文档管理文档中 | |||
$inquery = "INSERT INTO `#@__uploads` (title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."');"; | |||
$dsql->ExecuteNoneQuery($inquery); | |||
} | |||
return $filename; | |||
} | |||
/** | |||
* 获取更新测试信息 | |||
* | |||
* @access public | |||
* @return string | |||
*/ | |||
function GetUpdateTest() | |||
{ | |||
global $arcID, $typeid, $cfg_make_andcat, $cfg_makeindex, $cfg_make_prenext; | |||
$revalue = $dolist = ''; | |||
if ($cfg_makeindex == 'Y' || $cfg_make_andcat == 'Y' || $cfg_make_prenext == 'Y') { | |||
if ($cfg_make_prenext == 'Y' && !empty($typeid)) $dolist = 'makeprenext'; | |||
if ($cfg_makeindex == 'Y') $dolist .= empty($dolist) ? 'makeindex' : ',makeindex'; | |||
if ($cfg_make_andcat == 'Y') $dolist .= empty($dolist) ? 'makeparenttype' : ',makeparenttype'; | |||
$dolists = explode(',', $dolist); | |||
$jumpUrl = "task_do.php?typeid={$typeid}&aid={$arcID}&dopost={$dolists[0]}&nextdo=".preg_replace("#".$dolists[0]."[,]{0,1}#", '', $dolist); | |||
$revalue = "<table id='tgtable' class='maintable my-3'><tr><td bgcolor='#f8f8f8'>正在进行相关文档更新,请完成前不要进行其它操作:\r\n</td></tr>\r\n"; | |||
$revalue .= "<tr><td>\r\n<iframe name='stafrm' id='stafrm' frameborder='0' width='100%' height='200px' src='$jumpUrl'></iframe>\r\n</td></tr>\r\n"; | |||
$revalue .= "</table>"; | |||
} else { | |||
$revalue = ''; | |||
} | |||
return $revalue; | |||
} | |||
?> |
@@ -0,0 +1,129 @@ | |||
<?php | |||
/** | |||
* 后台管理菜单项 | |||
* | |||
* @version $id:inc_menu.php 10:32 2010年7月21日 tianya $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/../config.php"); | |||
require_once(dirname(__FILE__)."/inc_menu_module.php"); | |||
//载入可发布栏目 | |||
$addset = ''; | |||
//检测可用的文档模型 | |||
if ($cfg_admin_channel = 'array' && count($admin_catalogs) > 0) { | |||
$admin_catalog = join(',', $admin_catalogs); | |||
$dsql->SetQuery("SELECT channeltype FROM `#@__arctype` WHERE id IN({$admin_catalog}) GROUP BY channeltype "); | |||
} else { | |||
$dsql->SetQuery("SELECT channeltype FROM `#@__arctype` GROUP BY channeltype "); | |||
} | |||
$dsql->Execute('mc'); | |||
$candoChannel = ''; | |||
while ($row = $dsql->GetObject('mc')) { | |||
$candoChannel .= ($candoChannel == '' ? $row->channeltype : ','.$row->channeltype); | |||
} | |||
if (empty($candoChannel)) $candoChannel = 1; | |||
$dsql->SetQuery("SELECT id,typename,addcon,mancon FROM `#@__channeltype` WHERE id IN({$candoChannel}) AND id<>-1 AND isshow=1 ORDER BY id ASC"); | |||
$dsql->Execute('im'); | |||
while ($row = $dsql->GetObject('im')) { | |||
$addset .= "<m:item name='{$row->typename}' ischannel='1' link='{$row->mancon}?channelid={$row->id}' linkadd='{$row->addcon}?channelid={$row->id}' channelid='{$row->id}' rank='' target='main' />"; | |||
} | |||
$helpUrl = DEDEBIZURL."/help"; | |||
$gitUrl = DEDEBIZURL."/git"; | |||
$dedebizUrl = DEDEBIZURL; | |||
$adminMenu1 = $adminMenu2 = ''; | |||
if ($cuserLogin->getUserType() >= 10) { | |||
$adminMenu1 = (DEDEBIZ_SAFE_MODE? "" : "<m:top item='11_' name='模板管理' rank='temp_One,temp_Other,temp_MyTag,temp_test,temp_All' icon='fa-cube'> | |||
<m:item name='默认模板管理' link='templets_main.php' rank='temp_All' target='main' /> | |||
<m:item name='标签源码管理' link='templets_tagsource.php' rank='temp_All' target='main' /> | |||
<m:item name='智能标记向导' link='mytag_tag_guide.php' rank='temp_Other' target='main' /> | |||
<m:item name='全局标记测试' link='tag_test.php' rank='temp_Test' target='main' /> | |||
</m:top>")." | |||
<m:top item='4_' name='文档模型' rank='t_List,t_AccList,c_List,temp_One' icon='fa-area-chart'> | |||
<m:item name='文档模型管理' link='mychannel_main.php' rank='c_List' target='main' /> | |||
<m:item name='文档单页管理' link='templets_one.php' rank='temp_One' target='main' /> | |||
<m:item name='联动类别管理' link='stepselect_main.php' rank='c_Stepseclect' target='main' /> | |||
<m:item name='自由列表管理' link='freelist_main.php' rank='c_List' target='main' /> | |||
<m:item name='自定义宏标记' link='mytag_main.php' rank='temp_MyTag' target='main' /> | |||
<m:item name='自定义文档属性' link='content_att.php' rank='sys_Att' target='main' /> | |||
<m:item name='自定义表单管理' link='diy_main.php' rank='c_List' target='main' /> | |||
</m:top>"; | |||
$adminMenu2 = "<m:top item='10_' name='支付工具' rank='sys_Data' icon='fa-credit-card'> | |||
<m:item name='积分产品管理' link='cards_manage.php' rank='sys_Data' target='main' /> | |||
<m:item name='积分产品分类' link='cards_type.php' rank='sys_Data' target='main' /> | |||
<m:item name='会员消费记录' link='member_operations.php' rank='sys_Data' target='main' /> | |||
<m:item name='会员等级分类' link='member_type.php' rank='sys_Data' target='main' /> | |||
<m:item name='支付接口设置' link='sys_payment.php' .php' rank='sys_Data' target='main' /> | |||
</m:top> | |||
<m:top item='12_' name='系统设置' rank='sys_User,sys_Group,sys_Edit,sys_Log,sys_Data' icon='fa-cog'> | |||
<m:item name='系统配置变量' link='sys_info.php' rank='sys_Edit' target='main' /> | |||
<m:item name='系统日志管理' link='log_list.php' rank='sys_Log' target='main' /> | |||
<m:item name='系统会员管理' link='sys_admin_user.php' rank='sys_User' target='main' /> | |||
<m:item name='系统会员组管理' link='sys_group.php' rank='sys_Group' target='main' /> | |||
<m:item name='图片水印设置' link='sys_info_mark.php' rank='sys_Edit' target='main' /> | |||
<m:item name='软件下载设置' link='soft_config.php' rank='sys_SoftConfig' target='main' /> | |||
<m:item name='防采集小工具' link='article_string_mix.php' rank='sys_StringMix' target='main' /> | |||
".(DEDEBIZ_SAFE_MODE? "" : "<m:item name='数据备份还原' link='sys_data.php' rank='sys_Data' target='main' />")." | |||
".(DEDEBIZ_SAFE_MODE? "" : "<m:item name='SQL命令工具' link='sys_sql_query.php' rank='sys_Data' target='main' />")." | |||
<m:item name='文件扫描工具' link='sys_safetest.php' rank='sys_verify' target='main' /> | |||
<m:item name='系统修复工具' link='sys_repair.php' rank='sys_verify' target='main' /> | |||
</m:top>"; | |||
} | |||
$menusMain = "<m:top item='1_' name='常用操作' icon='fa-desktop'> | |||
<m:item name='网站栏目管理' link='catalog_main.php' ischannel='1' addalt='创建栏目' linkadd='catalog_add.php?listtype=all' rank='t_List,t_AccList' target='main' /> | |||
<m:item name='所有文档列表' link='content_list.php' rank='a_List,a_AccList' target='main' /> | |||
<m:item name='待审核的文档' link='content_list.php?arcrank=-1' rank='a_Check,a_AccCheck' target='main' /> | |||
<m:item name='我发布的文档' link='content_list.php?mid=".$cuserLogin->getUserID()."' rank='a_List,a_AccList,a_MyList' target='main' /> | |||
<m:item name='标签管理' link='tags_main.php' rank='sys_Keyword' target='main' /> | |||
<m:item name='评论管理' link='feedback_main.php' rank='sys_Feedback' target='main' /> | |||
<m:item name='专题管理' ischannel='1' link='content_s_list.php' linkadd='spec_add.php' channelid='-1' rank='spec_New' target='main' /> | |||
<m:item name='文档回收站' link='recycling.php' ischannel='1' addalt='清空文档' addico='fa-minus-circle' linkadd='archives_do.php?dopost=clear&aid=no&recycle=1' rank='a_List,a_AccList,a_MyList' target='main' /> | |||
</m:top> | |||
<m:top item='2_' name='文档管理' icon='fa-file-text'> | |||
$addset | |||
</m:top> | |||
<m:top item='3_' name='附件管理' rank='sys_Upload,sys_MyUpload,plus_文件管理器' icon='fa-folder'> | |||
<m:item name='上传新文件' link='media_add.php' rank='' target='main' /> | |||
<m:item name='附件管理' link='media_main.php' rank='sys_Upload,sys_MyUpload' target='main' /> | |||
<m:item name='文件管理器' link='media_main.php?dopost=filemanager' rank='plus_文件管理器' target='main' /> | |||
</m:top> | |||
$adminMenu1 | |||
<m:top item='5_' name='批量维护' icon='fa-circle-o-notch'> | |||
<m:item name='文档批量维护' link='content_batch_up.php' rank='sys_ArcBatch' target='main' /> | |||
<m:item name='文档重复检测' link='article_test_same.php' rank='sys_ArcBatch' target='main' /> | |||
<m:item name='文档关键词维护' link='article_keywords_main.php' rank='sys_Keyword' target='main' /> | |||
<m:item name='搜索关键词维护' link='search_keywords_main.php' rank='sys_Keyword' target='main' /> | |||
<m:item name='自动摘要分页' link='article_description_main.php' rank='sys_Keyword' target='main' /> | |||
".(DEDEBIZ_SAFE_MODE? "" : "<m:item name='数据库字段替换' link='sys_data_replace.php' rank='sys_ArcBatch' target='main' />")." | |||
</m:top> | |||
{$GLOBALS['menusMoudle']} | |||
<m:top item='8_' name='更新电脑端' rank='sys_MakeHtml' icon='fa-repeat'> | |||
<m:item name='更新整站' link='makehtml_all.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新首页' link='makehtml_homepage.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新栏目' link='makehtml_list.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新文档' link='makehtml_archives.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新标签' link='makehtml_taglist.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新专题' link='makehtml_spec.php' rank='sys_MakeHtml' target='main' /> | |||
<m:item name='更新缓存' link='sys_cache_up.php' rank='sys_ArcBatch' target='main' /> | |||
</m:top> | |||
<m:top item='8_' name='更新手机端' rank='sys_m_MakeHtml' icon='fa-spinner'> | |||
<m:item name='手机端配置' link='makehtml_m_config.php' rank='sys_m_MakeHtml' target='main' /> | |||
<m:item name='更新整站' link='makehtml_m_all.php' rank='sys_m_MakeHtml' target='main' /> | |||
<m:item name='更新首页' link='makehtml_m_homepage.php' rank='sys_m_MakeHtml' target='main' /> | |||
<m:item name='更新栏目' link='makehtml_m_list.php' rank='sys_m_MakeHtml' target='main' /> | |||
<m:item name='更新文档' link='makehtml_m_archives.php' rank='sys_m_MakeHtml' target='main' /> | |||
</m:top> | |||
<m:top item='9_' name='会员管理' rank='member_List,member_Type' icon='fa-user-circle'> | |||
<m:item name='所有会员列表' link='member_main.php' rank='member_List' target='main' /> | |||
<m:item name='会员短信管理' link='member_pm.php' rank='member_Type' target='main' /> | |||
<m:item name='会员级别设置' link='member_rank.php' rank='member_Type' target='main' /> | |||
<m:item name='积分头衔设置' link='member_scores.php' rank='member_Type' target='main' /> | |||
</m:top> | |||
$adminMenu2 | |||
<m:top item='12_' name='系统帮助' icon='fa-info-circle'> | |||
<m:item name='系统概况' link='$cfg_biz_helpUrl' rank='' target='_blank' /> | |||
<m:item name='代码托管' link='$cfg_biz_gitUrl' rank='' target='_blank' /> | |||
</m:top>"; | |||
?> |
@@ -0,0 +1,136 @@ | |||
<?php | |||
/** | |||
* 更新手机端所有页面 | |||
* | |||
* @version $id:makehtml_m_all.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
require_once(DEDEINC."/channelunit.func.php"); | |||
$action = (empty($action) ? '' : $action); | |||
if ($action == '') { | |||
require_once(DEDEADMIN."/templets/makehtml_m_all.htm"); | |||
exit(); | |||
} else if ($action == 'make') { | |||
//step = 1更新首页,step = 2更新文档,step = 3更新栏目 | |||
if (empty($step)) $step = 1; | |||
//更新文档前优化数据 | |||
if ($step == 1) { | |||
$starttime = GetMkTime($starttime); | |||
$mkvalue = ($uptype == 'time' ? $starttime : $startid); | |||
OptimizeData($dsql); | |||
ShowMsg("完成数据优化,开始更新文档", "makehtml_m_all.php?action=make&step=2&uptype=$uptype&mkvalue=$mkvalue"); | |||
exit(); | |||
} | |||
//更新文档 | |||
else if ($step == 2) { | |||
include_once(DEDEADMIN."/makehtml_m_archives_action.php"); | |||
exit(); | |||
} | |||
//更新首页 | |||
if ($step == 3) { | |||
include_once(DEDEINC."/archive/partview.class.php"); | |||
$pv = new PartView(); | |||
$row = $pv->dsql->GetOne("SELECT * FROM `#@__homepageset`"); | |||
$templet = str_replace("{style}", $cfg_df_style, $row['templet']); | |||
$homeFile = DEDEADMIN.'/'.$row['position']; | |||
$homeFile = str_replace("\\", '/', $homeFile); | |||
$homeFile = preg_replace("#\/{1,}#", '/', $homeFile); | |||
if ($row['showmod'] == 1) { | |||
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir.'/'.$templet); | |||
$pv->SaveToHtml($homeFile); | |||
$pv->Close(); | |||
} else { | |||
if (file_exists($homeFile)) echo "启用静态更新,建议删除"+$homeFile; | |||
} | |||
ShowMsg("完成所有文档更新,开始更新栏目", "makehtml_m_all.php?action=make&step=4&uptype=$uptype&mkvalue=$mkvalue"); | |||
exit(); | |||
} | |||
//更新栏目 | |||
else if ($step == 4) { | |||
$mkvalue = intval($mkvalue); | |||
$typeidsok = $typeids = array(); | |||
$adminID = $cuserLogin->getUserID(); | |||
$mkcachefile = DEDEDATA."/mkall_cache_{$adminID}.php"; | |||
if ($uptype == 'all' || empty($mkvalue)) { | |||
ShowMsg("不需要进行初处理,开始更新所有栏目", "makehtml_m_list_action.php?gotype=mkallct"); | |||
exit(); | |||
} else { | |||
if ($uptype == 'time') { | |||
$query = "SELECT DISTINCT typeid FROM `#@__arctiny` WHERE senddate >=".GetMkTime($mkvalue)." AND arcrank>-1"; | |||
} else { | |||
$query = "SELECT DISTINCT typeid FROM `#@__arctiny` WHERE id>=$mkvalue AND arcrank>-1"; | |||
} | |||
$dsql->SetQuery($query); | |||
$dsql->Execute(); | |||
while ($row = $dsql->GetArray()) { | |||
$typeids[$row['typeid']] = 1; | |||
} | |||
foreach ($typeids as $k => $v) { | |||
$vs = array(); | |||
$vs = GetParentIds($k); | |||
if (!isset($typeidsok[$k])) { | |||
$typeidsok[$k] = 1; | |||
} | |||
foreach ($vs as $k => $v) { | |||
if (!isset($typeidsok[$v])) { | |||
$typeidsok[$v] = 1; | |||
} | |||
} | |||
} | |||
} | |||
$fp = fopen($mkcachefile, 'w') or die("无法写入缓存文件<span class='text-primary'>{$mkcachefile}</span>所以无法更新栏目"); | |||
if (count($typeidsok) > 0) { | |||
fwrite($fp, "<"."?php\r\n"); | |||
$i = -1; | |||
foreach ($typeidsok as $k => $t) { | |||
if ($k != '') { | |||
$i++; | |||
fwrite($fp, "\$idArray[$i]={$k};\r\n"); | |||
} | |||
} | |||
fwrite($fp, "?".">"); | |||
fclose($fp); | |||
ShowMsg("完成栏目缓存处理,开始更新栏目", "makehtml_m_list_action.php?gotype=mkall"); | |||
exit(); | |||
} else { | |||
fclose($fp); | |||
ShowMsg("没有可更新的栏目,最后数据优化", "makehtml_m_all.php?action=make&step=10"); | |||
exit(); | |||
} | |||
} | |||
//成功状态 | |||
else if ($step == 10) { | |||
$adminID = $cuserLogin->getUserID(); | |||
$mkcachefile = DEDEDATA."/mkall_cache_{$adminID}.php"; | |||
@unlink($mkcachefile); | |||
OptimizeData($dsql); | |||
ShowMsg("完成所有栏目文档更新", "javascript:;"); | |||
exit(); | |||
}//make step | |||
}//action=='make' | |||
/** | |||
* 优化数据 | |||
* | |||
* @access public | |||
* @param object $dsql 数据库对象 | |||
* @return void | |||
*/ | |||
function OptimizeData($dsql) | |||
{ | |||
global $cfg_dbprefix; | |||
$tptables = array("{$cfg_dbprefix}archives", "{$cfg_dbprefix}arctiny"); | |||
$dsql->SetQuery("SELECT maintable,addtable FROM `#@__channeltype`"); | |||
$dsql->Execute(); | |||
while ($row = $dsql->GetObject()) { | |||
$addtable = str_replace('#@__', $cfg_dbprefix, $row->addtable); | |||
if ($addtable != '' && !in_array($addtable, $tptables)) $tptables[] = $addtable; | |||
} | |||
$tptable = ''; | |||
foreach ($tptables as $t) $tptable .= ($tptable == '' ? "`{$t}`" : ",`{$t}`"); | |||
$dsql->ExecuteNoneQuery(" OPTIMIZE TABLE $tptable; "); | |||
} | |||
?> |
@@ -0,0 +1,14 @@ | |||
<?php | |||
/** | |||
* 更新手机端文档 | |||
* | |||
* @version $id:makehtml_m_archives.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
require_once(DEDEINC."/typelink/typelink.class.php"); | |||
include DedeInclude('templets/makehtml_m_archives.htm'); | |||
?> |
@@ -0,0 +1,113 @@ | |||
<?php | |||
/** | |||
* 更新手机端文档操作 | |||
* | |||
* @version $id:makehtml_m_archives_action.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
CheckPurview('sys_m_MakeHtml'); | |||
require_once(DEDEINC."/archive/archives.m.class.php"); | |||
$est1 = ExecTime(); | |||
$startid = (empty($startid) ? -1 : $startid); | |||
$endid = (empty($endid) ? 0 : $endid); | |||
$startdd = (empty($startdd) ? 0 : $startdd); | |||
$pagesize = (empty($pagesize) ? 30 : $pagesize); | |||
$totalnum = (empty($totalnum) ? 0 : $totalnum); | |||
$typeid = (empty($typeid) ? 0 : $typeid); | |||
$seltime = (empty($seltime) ? 0 : $seltime); | |||
$stime = (empty($stime) ? '' : $stime); | |||
$etime = (empty($etime) ? '' : $etime); | |||
$sstime = (empty($sstime) ? 0 : $sstime); | |||
$mkvalue = (empty($mkvalue) ? 0 : $mkvalue); | |||
$isremote = (empty($isremote)? 0 : $isremote); | |||
$serviterm = empty($serviterm)? "" : $serviterm; | |||
//一键更新传递的参数 | |||
if (!empty($uptype)) { | |||
if ($uptype != 'time') $startid = $mkvalue; | |||
else $t1 = $mkvalue; | |||
} else { | |||
$uptype = ''; | |||
} | |||
//获取条件 | |||
$idsql = ''; | |||
$gwhere = ($startid == -1 ? " WHERE arcrank=0 " : " WHERE id>=$startid AND arcrank=0 "); | |||
if ($endid > $startid && $startid > 0) $gwhere .= " AND id <= $endid "; | |||
if ($typeid != 0) { | |||
$ids = GetSonIds($typeid); | |||
$gwhere .= " AND typeid in($ids) "; | |||
} | |||
if ($idsql == '') $idsql = $gwhere; | |||
if ($seltime == 1) { | |||
$t1 = GetMkTime($stime); | |||
$t2 = GetMkTime($etime); | |||
$idsql .= " And (senddate >= $t1 And senddate <= $t2) "; | |||
} else if (isset($t1) && is_numeric($t1)) { | |||
$idsql .= " And senddate >= $t1 "; | |||
} | |||
//统计记录总数 | |||
if ($totalnum == 0) { | |||
$row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__arctiny` $idsql"); | |||
$totalnum = $row['dd']; | |||
//清空缓存 | |||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache`"); | |||
} | |||
//获取记录,并更新网页 | |||
if ($totalnum > $startdd + $pagesize) { | |||
$limitSql = " LIMIT $startdd,$pagesize"; | |||
} else { | |||
$limitSql = " LIMIT $startdd,".($totalnum - $startdd); | |||
} | |||
$tjnum = $startdd; | |||
if (empty($sstime)) $sstime = time(); | |||
//如果更新数量大于500,并且没选栏目,按栏目排序更新 | |||
if ($totalnum > 500 && empty($typeid)) { | |||
$dsql->Execute('out', "SELECT id FROM `#@__arctiny` $idsql ORDER BY typeid ASC $limitSql"); | |||
} else { | |||
$dsql->Execute('out', "SELECT id FROM `#@__arctiny` $idsql $limitSql"); | |||
} | |||
if ($cfg_remote_site=='Y' && $isremote=="1") { | |||
if ($serviterm!="") { | |||
list($servurl, $servuser, $servpwd) = explode(',', $serviterm); | |||
$config = array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE'); | |||
} else { | |||
$config=array(); | |||
} | |||
if(!$ftp->connect($config)) exit('Error:None FTP Connection!'); | |||
} | |||
while ($row = $dsql->GetObject('out')) { | |||
$tjnum++; | |||
$id = $row->id; | |||
$ac = new ArchivesMobile($id); | |||
$rurl = $ac->MakeHtml($isremote); | |||
} | |||
$t2 = ExecTime(); | |||
$t2 = ($t2 - $est1); | |||
$ttime = time() - $sstime; | |||
$ttime = number_format(($ttime / 60), 2); | |||
//返回提示信息 | |||
$tjlen = $totalnum > 0 ? ceil(($tjnum / $totalnum) * 100) : 100; | |||
$tjsta = "<div style='margin:0 auto 20px;width:360px;height:16px;text-align:left;border:1px solid #1eb867;border-radius:.2rem'><div style='max-width:360px;width:$tjlen%;height:16px;background:#1eb867'></div></div>"; | |||
$tjsta .= "到达位置<span class='text-primary'>".($startdd + $pagesize)."</span>,用时<span class='text-primary'>{$ttime}</span>分钟,完成更新文档总数<span class='text-primary'>$tjlen</span>%"; | |||
//速度测试 | |||
if ($tjnum < $totalnum) { | |||
$nurl = "makehtml_m_archives_action.php?endid=$endid&startid=$startid&typeid=$typeid"; | |||
$nurl .= "&totalnum=$totalnum&startdd=".($startdd + $pagesize)."&pagesize=$pagesize"; | |||
$nurl .= "&seltime=$seltime&sstime=$sstime&stime=".urlencode($stime)."&etime=".urlencode($etime)."&uptype=$uptype&mkvalue=$mkvalue"; | |||
ShowMsg($tjsta, $nurl, 0, 100); | |||
exit(); | |||
} else { | |||
if ($typeid != '') { | |||
ShowMsg("更新文档<span class='text-primary'>$totalnum</span>,用时<span class='text-primary'>{$ttime}</span>分钟,开始更新栏目", "makehtml_m_list_action.php?typeid=$typeid&uptype=all&maxpagesize=50&upnext=1"); | |||
} else { | |||
if ($uptype == '') { | |||
ShowMsg("更新文档<span class='text-primary'>$totalnum</span>,用时<span class='text-primary'>{$ttime}</span>分钟,完成所有文档更新", "javascript:;"); | |||
} else { | |||
ShowMsg("完成所有文档更新,开始更新首页", "makehtml_m_all.php?action=make&step=3&uptype=$uptype&mkvalue=$mkvalue"); | |||
} | |||
} | |||
} | |||
?> |
@@ -0,0 +1,98 @@ | |||
<?php | |||
/** | |||
* 手机端配置 | |||
* | |||
* @version $id:makehtml_m_config.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
if (empty($dopost)) $dopost = ""; | |||
$configfile = DEDEDATA.'/config.cache.inc.php'; | |||
//更新配置函数 | |||
function ReWriteConfig() | |||
{ | |||
global $dsql, $configfile; | |||
if (!is_writeable($configfile)) { | |||
echo "配置文件<span class='text-primary'>{$configfile}</span>不支持写入,修改手机端更新配置失败"; | |||
exit(); | |||
} | |||
$fp = fopen($configfile,'w'); | |||
flock ($fp,3); | |||
fwrite ($fp,"<"."?php\r\n"); | |||
$dsql->SetQuery("SELECT `varname`,`type`,`value`,`groupid` FROM `#@__sysconfig` ORDER BY aid ASC"); | |||
$dsql->Execute(); | |||
while($row = $dsql->GetArray()) | |||
{ | |||
if ($row['type']=='number') { | |||
if ($row['value']=='') $row['value'] = 0; | |||
fwrite($fp,"\${$row['varname']} = ".$row['value'].";\r\n"); | |||
} else { | |||
fwrite($fp,"\${$row['varname']} = '".str_replace("'",'',$row['value'])."';\r\n"); | |||
} | |||
} | |||
fwrite($fp,"?".">"); | |||
fclose($fp); | |||
} | |||
function checkMobileTemplate() | |||
{ | |||
global $dsql, $cfg_basedir, $cfg_templets_dir, $dedebiz_path; | |||
if (!$dedebiz_path) $dedebiz_path = '/m/'; | |||
$row = $dsql->GetOne("SELECT * FROM `#@__homepageset`"); | |||
$row['templet'] = MfTemplet($row['templet']); | |||
$row['templet'] =str_replace('.htm','_m.htm',$row['templet']); | |||
$index_path = $cfg_basedir.$cfg_templets_dir."/".$row['templet']; | |||
$content = file_get_contents($index_path); | |||
} | |||
function getRandString() | |||
{ | |||
$str = strtoupper(md5(uniqid(md5(microtime(true)),true))); | |||
return substr($str,0,8).'-'.substr($str,8,4).'-'.substr($str,12,4).'-'.substr($str,16,4).'-'.substr($str,20); | |||
} | |||
//保存配置的改动 | |||
if ($dopost=="save") { | |||
$info = $_POST['info']; | |||
$data = $_POST['data']; | |||
foreach($data as $k=>$v) | |||
{ | |||
$row = $dsql->GetOne("SELECT varname FROM `#@__sysconfig` WHERE varname LIKE '$k'"); | |||
if (is_array($row)) { | |||
//存在就更新 | |||
$dsql->ExecuteNoneQuery("UPDATE `#@__sysconfig` SET `value`='$v' WHERE varname='$k'"); | |||
} else { | |||
$row = $dsql->GetOne("SELECT aid FROM `#@__sysconfig` ORDER BY aid DESC"); | |||
$aid = $row['aid'] + 1; | |||
$inquery = "INSERT INTO `#@__sysconfig`(`aid`,`varname`,`info`,`value`,`type`,`groupid`) VALUES ('$aid','$k','{$info[$k]}','$v','string','8')"; | |||
$rs = $dsql->ExecuteNoneQuery($inquery); | |||
if (!$rs) { | |||
ShowMsg("存在非法字符"); | |||
exit(); | |||
} | |||
if (!is_writeable($configfile)) { | |||
ShowMsg("由于<span class='text-primary'>$configfile</span>无法写入,修改手机端更新配置失败"); | |||
exit(); | |||
} | |||
} | |||
} | |||
ReWriteConfig(); | |||
ShowMsg("成功修改手机端更新配置", "makehtml_m_config.php"); | |||
exit(); | |||
} | |||
$dsql->SetQuery("SELECT * FROM `#@__sysconfig` WHERE groupid='8' ORDER BY aid ASC"); | |||
$dsql->Execute(); | |||
$i = 1; | |||
$data = array(); | |||
while ($row = $dsql->GetArray()) { | |||
$data[$row['varname']] = $row['value']; | |||
$i++; | |||
} | |||
if (!isset($data['dedebiz_usetype']) && !isset($data['dedebiz_usetype'])){ | |||
$data['dedebiz_usetype'] = 1; | |||
$data['dedebiz_usearc'] = 1; | |||
} | |||
//检查手机端模板路径 | |||
$msg = checkMobileTemplate(); | |||
include DedeInclude('templets/makehtml_m_config.htm'); | |||
?> |
@@ -0,0 +1,27 @@ | |||
<?php | |||
/** | |||
* 更新手机端首页 | |||
* | |||
* @version $id:makehtml_m_homepage.php 15:15 2022年3月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once (dirname(__FILE__)."/../system/common.inc.php"); | |||
require_once DEDEINC."/archive/partview.class.php"; | |||
$GLOBALS['_arclistEnv'] = 'index'; | |||
$row = $dsql->GetOne("SELECT * FROM `#@__homepageset`"); | |||
$row['templet'] = MfTemplet($row['templet']); | |||
$pv = new PartView(); | |||
$row['templet'] =str_replace('.htm','_m.htm',$row['templet']); | |||
if (!file_exists($cfg_basedir.$cfg_templets_dir."/".$row['templet'])) { | |||
echo "主题模板文件不存在,无法显示网页"; | |||
exit(); | |||
} | |||
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$row['templet']); | |||
$row['showmod'] = isset($row['showmod'])? $row['showmod'] : 0; | |||
$GLOBALS['dedebiz_path'] = isset($GLOBALS['dedebiz_path']) ? $GLOBALS['dedebiz_path'] : '/m'; | |||
$pv->SaveToHtml(DEDEROOT.$GLOBALS['dedebiz_path'].'/index.html'); | |||
ShowMsg("更新手机端首页成功,<a href='{$GLOBALS['dedebiz_path']}/index.html' target='_blank' class='txt-success'>浏览首页</a>","javascript:;"); | |||
?> |
@@ -0,0 +1,14 @@ | |||
<?php | |||
/** | |||
* 更新手机端列表栏目 | |||
* | |||
* @version $id:makehtml_m_list.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
require_once(DEDEINC."/typelink/typelink.class.php"); | |||
include DedeInclude('templets/makehtml_m_list.htm'); | |||
?> |
@@ -0,0 +1,125 @@ | |||
<?php | |||
/** | |||
* 更新手机端列表栏目操作 | |||
* | |||
* @version $id:makehtml_m_list_action.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Administrator | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/config.php"); | |||
CheckPurview('sys_m_MakeHtml'); | |||
require_once(DEDEDATA."/cache/inc_catalog_base.inc"); | |||
require_once(DEDEINC."/channelunit.func.php"); | |||
if (!isset($upnext)) $upnext = 1; | |||
if (empty($gotype)) $gotype = ''; | |||
if (empty($pageno)) $pageno = 0; | |||
if (empty($mkpage)) $mkpage = 1; | |||
if (empty($typeid)) $typeid = 0; | |||
if (!isset($uppage)) $uppage = 0; | |||
if (empty($maxpagesize)) $maxpagesize = 30; | |||
$adminID = $cuserLogin->getUserID(); | |||
$isremote = (empty($isremote) ? 0 : $isremote); | |||
$serviterm = empty($serviterm)? "" : $serviterm; | |||
//检测获取所有栏目id,普通更新或一键更新时更新所有栏目 | |||
if ($gotype == '' || $gotype == 'mkallct') { | |||
if ($upnext == 1 || $typeid == 0) { | |||
if ($typeid > 0) { | |||
$tidss = GetSonIds($typeid, 0); | |||
$idArray = explode(',', $tidss); | |||
} else { | |||
foreach ($cfg_Cs as $k => $v) $idArray[] = $k; | |||
} | |||
} else { | |||
$idArray = array(); | |||
$idArray[] = $typeid; | |||
} | |||
} | |||
//一键更新带缓存的情况 | |||
else if ($gotype == 'mkall') { | |||
$uppage = 1; | |||
$mkcachefile = DEDEDATA."/mkall_cache_{$adminID}.php"; | |||
$idArray = array(); | |||
if (file_exists($mkcachefile)) require_once($mkcachefile); | |||
} | |||
//当前更新栏目id | |||
$totalpage = count($idArray); | |||
if (isset($idArray[$pageno])) { | |||
$tid = $idArray[$pageno]; | |||
} else { | |||
if ($gotype == '') { | |||
ShowMsg("完成所有栏目更新", "javascript:;"); | |||
exit(); | |||
} else if ($gotype == 'mkall' || $gotype == 'mkallct') { | |||
ShowMsg("完成所有栏目更新,最后数据优化", "makehtml_m_all.php?action=make&step=10"); | |||
exit(); | |||
} | |||
} | |||
if ($pageno == 0 && $mkpage == 1) //清空缓存 | |||
{ | |||
$dsql->ExecuteNoneQuery("DELETE FROM `#@__arccache`"); | |||
} | |||
$reurl = ''; | |||
//更新数组所记录栏目 | |||
if (!empty($tid)) { | |||
if (!isset($cfg_Cs[$tid])) { | |||
ShowMsg('没有该栏目数据,可能缓存文件没有更新,请检查是否有写入权限', 'javascript:;'); | |||
exit(); | |||
} | |||
if ($cfg_Cs[$tid][1] > 0) { | |||
require_once(DEDEINC."/archive/listview.m.class.php"); | |||
$lv = new ListViewMobile($tid); | |||
$position = MfTypedir($lv->Fields['typedir']); | |||
} else { | |||
require_once(DEDEINC."/archive/sglistview.class.php"); | |||
$lv = new SgListView($tid); | |||
} | |||
//这里统一统计 | |||
$lv->CountRecord(); | |||
if ($lv->TypeLink->TypeInfos['ispart'] == 0 && $lv->TypeLink->TypeInfos['isdefault'] != -1) $ntotalpage = $lv->TotalPage; | |||
else $ntotalpage = 1; | |||
if ($cfg_remote_site=='Y' && $isremote=="1") { | |||
if ($serviterm!="") { | |||
list($servurl, $servuser, $servpwd) = explode(',',$serviterm); | |||
$config = array('hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE'); | |||
} else { | |||
$config=array(); | |||
} | |||
if (!$ftp->connect($config)) exit('Error:None FTP Connection!'); | |||
} | |||
//如果栏目的文档太多,分多批次更新 | |||
if ($ntotalpage <= $maxpagesize || $lv->TypeLink->TypeInfos['ispart'] != 0 || $lv->TypeLink->TypeInfos['isdefault'] == -1) { | |||
$reurl = $lv->MakeHtml('', '', $isremote); | |||
$finishType = TRUE; | |||
} else { | |||
$reurl = $lv->MakeHtml($mkpage, $maxpagesize, $isremote); | |||
$finishType = FALSE; | |||
$mkpage = $mkpage + $maxpagesize; | |||
if ($mkpage >= ($ntotalpage + 1)) $finishType = TRUE; | |||
} | |||
} | |||
$nextpage = $pageno + 1; | |||
if ($nextpage >= $totalpage && $finishType) { | |||
if ($gotype == '') { | |||
if (empty($reurl)) { | |||
$reurl = '../m/list.php?tid='.$tid; | |||
} | |||
ShowMsg("完成所有栏目更新,<a href='$reurl' target='_blank'>浏览栏目</a>", "javascript:;"); | |||
exit(); | |||
} else if ($gotype == 'mkall' || $gotype == 'mkallct') { | |||
ShowMsg("完成所有栏目更新,最后数据优化", "makehtml_m_all.php?action=make&step=10"); | |||
exit(); | |||
} | |||
} else { | |||
if ($finishType) { | |||
$gourl = "makehtml_m_list_action.php?gotype={$gotype}&uppage=$uppage&maxpagesize=$maxpagesize&typeid=$typeid&pageno=$nextpage"; | |||
ShowMsg("更新栏目<span class='text-primary'>".$tid."</span>,继续执行任务", $gourl, 0, 100); | |||
exit(); | |||
} else { | |||
$gourl = "makehtml_m_list_action.php?gotype={$gotype}&uppage=$uppage&mkpage=$mkpage&maxpagesize=$maxpagesize&typeid=$typeid&pageno=$pageno"; | |||
ShowMsg("更新栏目<span class='text-primary'>".$tid."</span>,继续执行任务", $gourl, 0, 100); | |||
exit(); | |||
} | |||
} | |||
?> |
@@ -0,0 +1,100 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> | |||
<title>更新整站</title> | |||
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/admin.css"> | |||
<link rel="stylesheet" href="../static/web/css/daterangepicker.css"> | |||
<script src="../static/web/js/jquery.min.js"></script> | |||
<script src="../static/web/js/moment.min.js"></script> | |||
<script src="../static/web/js/daterangepicker.js"></script> | |||
<script> | |||
$(document).ready(function() { | |||
$('.datepicker').daterangepicker({ | |||
"singleDatePicker": true, | |||
"autoApply": true, | |||
"showDropdowns": true, | |||
"linkedCalendars": false, | |||
"timePicker": true, | |||
"timePicker24Hour": true, | |||
"showCustomRangeLabel": false, | |||
ranges: { | |||
'今日': [moment(), moment()], | |||
'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], | |||
'本月': [moment().startOf('month'), moment().startOf('month')], | |||
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month') | |||
.startOf('month') | |||
] | |||
}, | |||
"locale": { | |||
format: 'YYYY-MM-DD HH:mm', | |||
applyLabel: '确定', | |||
cancelLabel: '取消', | |||
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'], | |||
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], | |||
firstDay: 1 | |||
} | |||
}, function(start) { | |||
$(this).val(start.format("YYYY-MM-DD HH:mm")); | |||
}); | |||
}) | |||
</script> | |||
<script> | |||
function SelUp() { | |||
var ob1 = document.getElementById("uptype1"); | |||
var ob2 = document.getElementById("uptype2"); | |||
var ob3 = document.getElementById("uptype3"); | |||
if (ob1.checked) { | |||
document.getElementById("seltime").style.display = ""; | |||
document.getElementById("selid").style.display = "none"; | |||
} else if (ob2.checked) { | |||
document.getElementById("seltime").style.display = "none"; | |||
document.getElementById("selid").style.display = ""; | |||
} else { | |||
document.getElementById("seltime").style.display = "none"; | |||
document.getElementById("selid").style.display = "none"; | |||
} | |||
} | |||
</script> | |||
</head> | |||
<body> | |||
<table cellpadding="3" cellspacing="1" align="center" class="table maintable my-3"> | |||
<form name="form1" action="makehtml_m_all.php" target="stafrm" method="post"> | |||
<input type="hidden" name="action" value="make"> | |||
<tr> | |||
<td bgcolor="#f5f5f5" colspan="2">更新整站</td> | |||
</tr> | |||
<tr> | |||
<td width="260">更新选项:</td> | |||
<td> | |||
<label><input type="radio" name="uptype" id="uptype1" onClick="SelUp()" value="time" checked="checked"> 指定时间的所有更新</label> | |||
<label><input type="radio" name="uptype" id="uptype2" onClick="SelUp()" value="id"> 指定文档的所有更新</label> | |||
<label><input type="radio" name="uptype" id="uptype3" onClick="SelUp()" value="mkall"> 更新所有</label> | |||
</td> | |||
</tr> | |||
<tr id="seltime"> | |||
<td>起始时间:</td> | |||
<td><input type="text" name="starttime" id="starttime" value="<?php echo GetDateMk(time());?>" class="datepicker" class="admin-input-sm"></td> | |||
</tr> | |||
<tr id="selid" style="display:none"> | |||
<td>起始id:</td> | |||
<td><input type="text" name="startid" id="startid" value="0" class="admin-input-sm"></td> | |||
</tr> | |||
<tr> | |||
<td bgcolor="#e9ecef" colspan="2" align="center"><button type="submit" class="btn btn-success btn-sm">开始更新</button></td> | |||
</tr> | |||
</form> | |||
<tr> | |||
<td colspan="2">结果:</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2" id="mtd"> | |||
<div id="mdv" class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="360px"></iframe></div> | |||
</td> | |||
</tr> | |||
</table> | |||
</body> | |||
</html> |
@@ -0,0 +1,57 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> | |||
<title>更新文档</title> | |||
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/admin.css"> | |||
</head> | |||
<body> | |||
<table cellpadding="3" cellspacing="1" align="center" class="table maintable my-3"> | |||
<form name="form1" action="makehtml_m_archives_action.php" method="get" target="stafrm"> | |||
<tr> | |||
<td bgcolor="#f5f5f5" colspan="2">更新文档</td> | |||
</tr> | |||
<tr> | |||
<td width="260">选择栏目:</td> | |||
<td> | |||
<?php | |||
if (empty($cid)) $cid="0"; | |||
$tl = new TypeLink($cid); | |||
$typeOptions = $tl->GetOptionArray($cid,$admin_catalogs,0); | |||
echo "<select name='typeid' class='admin-input-sm'>"; | |||
if ($cid=="0") echo "<option value='0' selected>更新所有文档</option>"; | |||
echo $typeOptions; | |||
echo "</select>"; | |||
?> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>起始id:</td> | |||
<td><input type="text" name="startid" id="startid" class="admin-input-sm">(空或0表示从头开始)</td> | |||
</tr> | |||
<tr> | |||
<td>结束id:</td> | |||
<td><input type="text" name="endid" id="endid" class="admin-input-sm">(空或0表示直到结束id)</td> | |||
</tr> | |||
<tr> | |||
<td>每页生成:</td> | |||
<td> <input type="text" name="pagesize" id="pagesize" value="20" class="admin-input-sm"> 个文件</td> | |||
</tr> | |||
<tr> | |||
<td bgcolor="#e9ecef" colspan="2" align="center"><button type="submit" name="b112" class="btn btn-success btn-sm">开始更新</button></td> | |||
</tr> | |||
</form> | |||
<tr> | |||
<td colspan="2">结果:</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2" id="mtd"> | |||
<div id="mdv" class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div> | |||
</td> | |||
</tr> | |||
</table> | |||
</body> | |||
</html> |
@@ -0,0 +1,81 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> | |||
<title>手机端配置</title> | |||
<script src="../static/web/js/jquery.min.js"></script> | |||
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/admin.css"> | |||
</head> | |||
<body> | |||
<table cellpadding="3" cellspacing="1" align="center" class="table maintable my-3"> | |||
<form action="makehtml_m_config.php" method="post" name="form1" _lpchecked="1"> | |||
<input type="hidden" name="dopost" value="save"> | |||
<tr> | |||
<td bgcolor="#f5f5f5" colspan="3">手机端配置</td> | |||
</tr> | |||
<tr> | |||
<td colspan="3"> | |||
<div class="alert alert-info mb-0"> | |||
<ul> | |||
<li>1、手机端模板启用静态链接,如列表“[field:typeurl/]”标签,文档“[field:arcurl/]”标签。那么手机端模模板中css和js等,建议用绝对路径引用,以免手机端更新后页面错误。缩略图标签前加电脑端链接为http://xxx.com[field:picname/],文档正文标签为{dede:field.body function='str_replace("/static/allimg/","http:xxx.com/static/allimg/",@me)'/},后台-系统设置-系统配置变量-是否支持多站点选择否,最后更新目录中有静态文件,则更新成功。</li> | |||
<li>2、手机端模板启用动态链接,如列表list.php?tid=[field:id/]形式,文档view.php?aid=[field:id/]形式,手机端伪静态规则参考电脑端。</li> | |||
<li>3、手机端自定义文档更新规则,如规则/html/{aid}.html形式,把view.php?aid=[field:id/]改为/m/html/[field:id/].html</li> | |||
</ul> | |||
</div> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td width="260">手机端更新目录:</td> | |||
<td> | |||
<input type="text" name="data[dedebiz_path]" id="dedebiz_path" class="w-75" value="<?php echo $data['dedebiz_path']?$data['dedebiz_path']:'/m'?>"> | |||
<input type="hidden" name="info[dedebiz_path]" id="path_info" class="w-75" value="手机端更新目录默认为m文件夹"> | |||
</td> | |||
<td>手机端更新目录默认为m文件夹</td> | |||
</tr> | |||
<tr> | |||
<td>电脑端栏目链接规则:</td> | |||
<td> | |||
<label><input type="radio" name="data[dedebiz_usetype]" value="1" <?php echo $data['dedebiz_usetype']==1?'checked':''?>> 启用</label> | |||
<label><input type="radio" name="data[dedebiz_usetype]" value="0" <?php echo $data['dedebiz_usetype']==0?'checked':''?>> 禁用</label> | |||
<input type="hidden" name="info[dedebiz_usetype]" id="usetype_info" class="w-75" value="是否启用电脑端栏目链接规则更新"> | |||
</td> | |||
<td>是否启用电脑端栏目链接规则更新</td> | |||
</tr> | |||
<tr> | |||
<td>电脑端文档链接规则:</td> | |||
<td> | |||
<label><input type="radio" name="data[dedebiz_usearc]" value="1" <?php echo $data['dedebiz_usearc']==1?'checked':''?>> 启用</label> | |||
<label><input type="radio" name="data[dedebiz_usearc]" value="0" <?php echo $data['dedebiz_usearc']==0?'checked':''?>> 禁用</label> | |||
<input type="hidden" name="info[dedebiz_usearc]" id="usearc_info" class="w-75" value="是否启用电脑端文档链接规则更新"> | |||
</td> | |||
<td>是否启用电脑端文档链接规则更新</td> | |||
</tr> | |||
<tr> | |||
<td>手机端栏目链接规则:</td> | |||
<td> | |||
<input type="text" name="data[dedebiz_typerule]" id="dedebiz_typerule" class="w-75" value="<?php echo $data['dedebiz_typerule']?$data['dedebiz_typerule']:'{typedir}/{tid}-{page}.html'?>"> | |||
<input type="hidden" name="info[dedebiz_typerule]" id="typerule_info" class="w-75" value="禁用电脑端栏目链接规则时生效"> | |||
</td> | |||
<td>禁用电脑端栏目链接规则时生效</td> | |||
</tr> | |||
<tr> | |||
<td>手机端文档链接规则:</td> | |||
<td> | |||
<input type="text" name="data[dedebiz_arcrule]" id="dedebiz_arcrule" class="w-75" value="<?php echo $data['dedebiz_arcrule']?$data['dedebiz_arcrule']:'{typedir}/{aid}.html'?>"> | |||
<input type="hidden" name="info[dedebiz_arcrule]" id="arcrule_info" class="w-75" value="禁用电脑端文档链接规则时生效"> | |||
</td> | |||
<td>禁用电脑端文档链接规则时生效</td> | |||
</tr> | |||
<tr> | |||
<td bgcolor="#f5f5f5" colspan="3" align="center"> | |||
<button type="submit" class="btn btn-success btn-sm">保存</button> | |||
<button type="button" class="btn btn-outline-success btn-sm" onclick="document.form1.reset()">重置</button> | |||
</td> | |||
</tr> | |||
</form> | |||
</table> | |||
</body> | |||
</html> |
@@ -0,0 +1,56 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> | |||
<title>更新栏目</title> | |||
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css"> | |||
<link rel="stylesheet" href="../static/web/css/admin.css"> | |||
</head> | |||
<body> | |||
<table cellpadding="3" cellspacing="1" align="center" class="table maintable my-3"> | |||
<form name="form1" action="makehtml_m_list_action.php" method="get" target="stafrm"> | |||
<tr> | |||
<td bgcolor="#f5f5f5" colspan="2">更新栏目</td> | |||
</tr> | |||
<tr> | |||
<td width="260">选择栏目:</td> | |||
<td> | |||
<?php | |||
if (empty($cid)) $cid=0; | |||
$tl = new TypeLink($cid); | |||
$typeOptions = $tl->GetOptionArray($cid,$admin_catalogs,0,1); | |||
echo "<select name='typeid' class='admin-input-sm'>"; | |||
if ($cid=='0') echo "<option value='0' selected='1'>更新所有栏目</option>"; | |||
echo $typeOptions; | |||
echo "</select>"; | |||
?> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>每次最大创建页数:</td> | |||
<td><input name="maxpagesize" type="text" id="maxpagesize" value="50" class="admin-input-sm"> 个文件</td> | |||
</tr> | |||
<tr> | |||
<td>是否更新子栏目:</td> | |||
<td> | |||
<label><input type="radio" name="upnext" value="1" checked="1"> 更新子级栏目</label> | |||
<label><input type="radio" name="upnext" value="0"> 仅更新所选栏目</label> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td bgcolor="#e9ecef" colspan="2" align="center"><button type="submit" name="b112" class="btn btn-success btn-sm">开始更新</button></td> | |||
</tr> | |||
</form> | |||
<tr> | |||
<td colspan="2">结果:</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2" id="mtd"> | |||
<div id="mdv" class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div> | |||
</td> | |||
</tr> | |||
</table> | |||
</body> | |||
</html> |
@@ -0,0 +1,40 @@ | |||
<?php | |||
/** | |||
* 手机端首页 | |||
* | |||
* @version $id:index.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
if (!file_exists(dirname(__FILE__).'/../data/common.inc.php')) { | |||
header('Location:install/index.php'); | |||
exit(); | |||
} | |||
if (preg_match("#PHP (.*) Development Server#",$_SERVER['SERVER_SOFTWARE'])) { | |||
if ($_SERVER['REQUEST_URI'] == dirname($_SERVER['SCRIPT_NAME']) ) { | |||
header('HTTP/1.1 301 Moved Permanently'); | |||
header('Location:'.$_SERVER['REQUEST_URI'].'/'); | |||
} | |||
} | |||
if (isset($_GET['upcache']) || !file_exists('index.html')) { | |||
require_once (dirname(__FILE__)."/../system/common.inc.php"); | |||
require_once DEDEINC."/archive/partview.class.php"; | |||
$GLOBALS['_arclistEnv'] = 'index'; | |||
$row = $dsql->GetOne("Select * From `#@__homepageset`"); | |||
$row['templet'] = MfTemplet($row['templet']); | |||
$pv = new PartView(); | |||
$row['templet'] =str_replace('.htm','_m.htm',$row['templet']); | |||
if (!file_exists($cfg_basedir.$cfg_templets_dir."/".$row['templet'])) { | |||
echo "主题模板文件不存在,无法显示网页"; | |||
exit(); | |||
} | |||
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$row['templet']); | |||
$pv->Display(); | |||
exit(); | |||
} else { | |||
header('HTTP/1.1 301 Moved Permanently'); | |||
header('Location:index.html'); | |||
} | |||
?> |
@@ -0,0 +1,59 @@ | |||
<?php | |||
/** | |||
* 手机端栏目页 | |||
* | |||
* @version $id:list.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
define('DEDEMOB', 'Y'); | |||
require_once(dirname(__FILE__)."/../system/common.inc.php"); | |||
$tid = (isset($tid) && is_numeric($tid) ? $tid : 0); | |||
$channelid = (isset($channelid) && is_numeric($channelid) ? $channelid : 0); | |||
if ($tid==0 && $channelid==0) die("Request Error!"); | |||
if (isset($TotalResult)) $TotalResult = intval(preg_replace("/[^\d]/", '', $TotalResult)); | |||
//如果指定了内容模型ID但没有指定栏目id,那么自动获得为这个内容模型的第一个顶级栏目作为频道默认栏目 | |||
if (!empty($channelid) && empty($tid)) { | |||
$tinfos = $dsql->GetOne("SELECT tp.id,ch.issystem FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.channeltype='$channelid' And tp.reid=0 order by sortrank asc"); | |||
if (!is_array($tinfos)) die(" No catalogs in the channel! "); | |||
$tid = $tinfos['id']; | |||
} else { | |||
$tinfos = $dsql->GetOne("SELECT ch.issystem FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$tid'"); | |||
} | |||
if ($tinfos['issystem']==-1) { | |||
$nativeplace = ((empty($nativeplace) || !is_numeric($nativeplace)) ? 0 : $nativeplace ); | |||
$infotype = ((empty($infotype) || !is_numeric($infotype)) ? 0 : $infotype ); | |||
if (!empty($keyword)) $keyword = FilterSearch($keyword); | |||
$cArr = array(); | |||
if (!empty($nativeplace)) $cArr['nativeplace'] = $nativeplace; | |||
if (!empty($infotype)) $cArr['infotype'] = $infotype; | |||
if (!empty($keyword)) $cArr['keyword'] = $keyword; | |||
include(DEDEINC."/archive/sglistview.class.php"); | |||
$lv = new SgListView($tid,$cArr); | |||
} else { | |||
include(DEDEINC."/archive/listview.class.php"); | |||
$lv = new ListView($tid); | |||
//对设置了会员级别的栏目进行处理 | |||
if (isset($lv->Fields['corank']) && $lv->Fields['corank'] > 0) | |||
{ | |||
require_once(DEDEINC.'/memberlogin.class.php'); | |||
$cfg_ml = new MemberLogin(); | |||
if ( $cfg_ml->M_Rank < $lv->Fields['corank'] ) { | |||
$dsql->Execute('me' , "SELECT * FROM `#@__arcrank` "); | |||
while($row = $dsql->GetObject('me')) | |||
{ | |||
$memberTypes[$row->rank] = $row->membername; | |||
} | |||
$memberTypes[0] = "游客或没权限会员"; | |||
$msgtitle = "您没有权限浏览栏目:{$lv->Fields['typename']}"; | |||
$moremsg = "该栏目需要<span class='text-primary'>".$memberTypes[$lv->Fields['corank']]."</span>才能浏览,您目前等级是<span class='text-primary'>".$memberTypes[$cfg_ml->M_Rank]."</span>"; | |||
include_once(DEDETEMPLATE.'/plus/view_msg_catalog.htm'); | |||
exit(); | |||
} | |||
} | |||
} | |||
if ($lv->IsError) ParamError(); | |||
$lv->Display(); | |||
?> |
@@ -0,0 +1,94 @@ | |||
<?php | |||
/** | |||
* 手机端搜索页 | |||
* | |||
* @version $id:search.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
define('DEDEMOB', 'Y'); | |||
require_once(dirname(__FILE__)."/../system/common.inc.php"); | |||
require_once(DEDEINC."/archive/searchview.class.php"); | |||
$pagesize = (isset($pagesize) && is_numeric($pagesize)) ? $pagesize : 10; | |||
$typeid = (isset($typeid) && is_numeric($typeid)) ? $typeid : 0; | |||
$channeltype = (isset($channeltype) && is_numeric($channeltype)) ? $channeltype : 0; | |||
$kwtype = (isset($kwtype) && is_numeric($kwtype)) ? $kwtype : 0; | |||
$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0; | |||
unset($typeArr); | |||
if (!isset($orderby)) $orderby = ''; | |||
else $orderby = preg_replace("#[^a-z]#i", '', $orderby); | |||
if (!isset($searchtype)) $searchtype = 'titlekeyword'; | |||
else $searchtype = preg_replace("#[^a-z]#i", '', $searchtype); | |||
if (!isset($keyword)) { | |||
if (!isset($q)) $q = ''; | |||
$keyword = $q; | |||
} | |||
$oldkeyword = $keyword = FilterSearch(stripslashes($keyword)); | |||
//查找栏目信息 | |||
if (empty($typeid)) { | |||
$typenameCacheFile = DEDEDATA.'/cache/typename.inc'; | |||
if (!file_exists($typenameCacheFile) || filemtime($typenameCacheFile) < time() - (3600 * 24)) { | |||
$fp = fopen(DEDEDATA.'/cache/typename.inc', 'w'); | |||
fwrite($fp, "<"."?php\r\n"); | |||
$dsql->SetQuery("SELECT id,typename,channeltype FROM `#@__arctype`"); | |||
$dsql->Execute(); | |||
while ($row = $dsql->GetArray()) { | |||
fwrite($fp, "\$typeArr[{$row['id']}] = '{$row['typename']}';\r\n"); | |||
} | |||
fwrite($fp, '?'.'>'); | |||
fclose($fp); | |||
} | |||
//引入栏目缓存并看关键词是否有相关栏目文档 | |||
require_once($typenameCacheFile); | |||
if (isset($typeArr) && is_array($typeArr)) { | |||
foreach ($typeArr as $id => $typename) { | |||
//$keywordn = str_replace($typename, ' ', $keyword); | |||
$keywordn = $keyword; | |||
if ($keyword != $keywordn) { | |||
$keyword = HtmlReplace($keywordn); | |||
$typeid = intval($id); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
$typeid = intval($typeid); | |||
$keyword = addslashes(cn_substr($keyword,30)); | |||
$typeid = intval($typeid); | |||
if ($cfg_notallowstr != '' && preg_match("#".$cfg_notallowstr."#i", $keyword)) { | |||
ShowMsg("您的搜索关键词中存在非法文档,被系统禁止", "-1"); | |||
exit(); | |||
} | |||
if (($keyword == '' || strlen($keyword) < 2) && empty($typeid)) { | |||
ShowMsg('关键词不能小于2个字节', '-1'); | |||
exit(); | |||
} | |||
//检查搜索间隔时间 | |||
$ip = GetIP(); | |||
$now = time(); | |||
$row = $dsql->GetOne("SELECT * FROM `#@__search_limits` WHERE ip='{$ip}'"); | |||
if (is_array($row)) { | |||
if (($now - $row['searchtime']) < $cfg_search_time) { | |||
ShowMsg('管理员设定搜索时间间隔为'.$cfg_search_time.'秒,请稍后再试', '-1'); | |||
exit; | |||
} | |||
$dsql->ExecuteNoneQuery("UPDATE `#@__search_limits` SET `searchtime`='{$now}' WHERE `ip`='{$ip}';"); | |||
} else { | |||
$dsql->ExecuteNoneQuery("INSERT INTO `#@__search_limits` (`ip`, `searchtime`) VALUES ('{$ip}', '{$now}');"); | |||
} | |||
//开始时间 | |||
if (empty($starttime)) $starttime = -1; | |||
else { | |||
$starttime = (is_numeric($starttime) ? $starttime : -1); | |||
if ($starttime > 0) { | |||
$dayst = GetMkTime("2008-1-2 0:0:0") - GetMkTime("2008-1-1 0:0:0"); | |||
$starttime = time() - ($starttime * $dayst); | |||
} | |||
} | |||
$t1 = ExecTime(); | |||
$sp = new SearchView($typeid, $keyword, $orderby, $channeltype, $searchtype, $starttime, $pagesize, $kwtype, $mid); | |||
$keyword = $oldkeyword; | |||
$sp->Display(); | |||
?> |
@@ -0,0 +1,28 @@ | |||
<?php | |||
/** | |||
* 手机端标签页 | |||
* | |||
* @version $id:tags.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__)."/../system/common.inc.php"); | |||
require_once(DEDEINC."/archive/taglist.class.php"); | |||
$PageNo = 1; | |||
if (isset($_SERVER['QUERY_STRING'])) { | |||
$tag = trim($_SERVER['QUERY_STRING']); | |||
$tags = explode('/', $tag); | |||
if (isset($tags[1])) $tag = $tags[1]; | |||
if (isset($tags[2])) $PageNo = intval($tags[2]); | |||
} else { | |||
$tag = ''; | |||
} | |||
$tag = FilterSearch(urldecode($tag)); | |||
if ($tag != addslashes($tag)) $tag = ''; | |||
if ($tag == '') $dlist = new TagList($tag, 'tag_m.htm'); | |||
else $dlist = new TagList($tag, 'taglist_m.htm'); | |||
$dlist->Display(); | |||
exit(); | |||
?> |
@@ -0,0 +1,96 @@ | |||
<?php | |||
/** | |||
* 手机端文档页 | |||
* | |||
* @version $id:view.php 10:46 2023年1月10日 xushubieli $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022, DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
define('DEDEMOB', 'Y'); | |||
require_once(dirname(__FILE__)."/../system/common.inc.php"); | |||
require_once(DEDEINC.'/archive/archives.class.php'); | |||
$t1 = ExecTime(); | |||
if (empty($okview)) $okview = ''; | |||
if (isset($arcID)) $aid = $arcID; | |||
if (!isset($dopost)) $dopost = ''; | |||
$app = (isset($app) && is_numeric($app) ? $app : 0); | |||
$arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0; | |||
if ($aid==0) die(" Request Error! "); | |||
$arc = new Archives($aid); | |||
if ($arc->IsError) ParamError(); | |||
//检查阅读权限 | |||
$needMoney = $arc->Fields['money']; | |||
$needRank = $arc->Fields['arcrank']; | |||
require_once(DEDEINC.'/memberlogin.class.php'); | |||
$cfg_ml = new MemberLogin(); | |||
if ($needRank < 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) { | |||
ShowMsg('文档未审核,暂时无法浏览', 'javascript:;'); | |||
exit(); | |||
} | |||
//设置了权限限制的文章 | |||
//arctitle msgtitle moremsg | |||
if ($needMoney>0 || $needRank>1) { | |||
$arctitle = $arc->Fields['title']; | |||
$arclink = $cfg_phpurl.'/view.php?aid='.$arc->ArcID; | |||
$arcLinktitle = "<a href=\"{$arclink}\">".$arctitle."</a>"; | |||
$description = $arc->Fields["description"]; | |||
$pubdate = GetDateTimeMk($arc->Fields["pubdate"]); | |||
//会员级别不足 | |||
if (($needRank>1 && $cfg_ml->M_Rank < $needRank && $arc->Fields['mid']!=$cfg_ml->M_ID)) { | |||
$dsql->Execute('me' , "SELECT * FROM `#@__arcrank` "); | |||
while($row = $dsql->GetObject('me')) | |||
{ | |||
$memberTypes[$row->rank] = $row->membername; | |||
} | |||
$memberTypes[0] = "游客或没权限会员"; | |||
$msgtitle = "您没有权限浏览文档:{$arctitle}"; | |||
$moremsg = "该文档需要<span class='text-primary'>".$memberTypes[$needRank]."</span>金币才能浏览,您目前金币".$memberTypes[$cfg_ml->M_Rank]."</span>"; | |||
include_once(DEDETEMPLATE.'/plus/view_msg.htm'); | |||
exit(); | |||
} | |||
//需要金币的情况 | |||
if ($needMoney > 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) { | |||
$sql = "SELECT aid,money FROM `#@__member_operation` WHERE buyid='ARCHIVE".$aid."' AND mid='".$cfg_ml->M_ID."'"; | |||
$row = $dsql->GetOne($sql); | |||
//未购买过此文章 | |||
if (!is_array($row)) { | |||
if ($cfg_ml->M_Money=='' || $needMoney > $cfg_ml->M_Money) { | |||
$msgtitle = "您没有权限浏览文档:{$arctitle}"; | |||
$moremsg = "该文档需要<span class='text-primary'>".$needMoney."</span>金币才能浏览,您目前金币".$cfg_ml->M_Money."</span>"; | |||
include_once(DEDETEMPLATE.'/plus/view_msg.htm'); | |||
$arc->Close(); | |||
exit(); | |||
} else { | |||
if ($dopost=='buy') { | |||
$inquery = "INSERT INTO `#@__member_operation`(mid,oldinfo,money,mtime,buyid,product,pname) VALUES ('".$cfg_ml->M_ID."','$arctitle','$needMoney','".time()."', 'ARCHIVE".$aid."', 'archive',''); "; | |||
if ($dsql->ExecuteNoneQuery($inquery)) { | |||
$inquery = "UPDATE `#@__member` SET money=money-$needMoney WHERE mid='".$cfg_ml->M_ID."'"; | |||
if (!$dsql->ExecuteNoneQuery($inquery)) { | |||
showmsg('购买失败,请返回', -1); | |||
exit; | |||
} | |||
if (defined('UC_APPID')) { | |||
include_once DEDEROOT.'/api/uc.func.php'; | |||
$row = $dsql->GetOne("SELECT `scores`,`userid` FROM `#@__member` WHERE `mid`='".$cfg_ml->M_ID."'"); | |||
uc_credit_note($row['userid'],-$needMoney,'money'); | |||
} | |||
showmsg('购买成功,购买扣点不会重扣金币', '/apps/view.php?aid='.$aid); | |||
exit; | |||
} else { | |||
showmsg('购买失败,请返回', -1); | |||
exit; | |||
} | |||
} | |||
$msgtitle = "扣金币购买阅读"; | |||
$moremsg = "该文档需要付费<span class='text-primary'>".$needMoney."</span>金币,您目前金币<span class='text-primary'>".$cfg_ml->M_Money."<br><a href='/apps/view.php?aid=".$aid."&dopost=buy' target='_blank'>确认付点阅读</a>" ; | |||
include_once($cfg_basedir.$cfg_templets_dir."/plus/view_msg.htm"); | |||
$arc->Close(); | |||
exit(); | |||
} | |||
} | |||
}//金币处理付处理 | |||
} | |||
$arc->Display(); | |||
?> |
@@ -0,0 +1,729 @@ | |||
<?php | |||
if (!defined('DEDEINC')) exit('dedebiz'); | |||
/** | |||
* 搜索视图类 | |||
* | |||
* @version $id:searchview.class.php 15:26 2010年7月7日 tianya $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(DEDEINC."/typelink/typelink.class.php"); | |||
require_once(DEDEINC."/dedetag.class.php"); | |||
require_once(DEDEINC."/libraries/splitword.class.php"); | |||
require_once(DEDEINC."/taglib/hotwords.lib.php"); | |||
require_once(DEDEINC."/taglib/channel.lib.php"); | |||
@set_time_limit(0); | |||
@ini_set('memory_limit', '512M'); | |||
class SearchView | |||
{ | |||
var $dsql; | |||
var $dtp; | |||
var $dtp2; | |||
var $TypeID; | |||
var $TypeLink; | |||
var $PageNo; | |||
var $TotalPage; | |||
var $TotalResult; | |||
var $pagesize; | |||
var $ChannelType; | |||
var $TempInfos; | |||
var $Fields; | |||
var $PartView; | |||
var $StartTime; | |||
var $Keywords; | |||
var $OrderBy; | |||
var $SearchType; | |||
var $mid; | |||
var $KType; | |||
var $Keyword; | |||
var $SearchMax; | |||
var $SearchMaxRc; | |||
var $SearchTime; | |||
var $AddSql; | |||
var $RsFields; | |||
/** | |||
* php5构造函数 | |||
* | |||
* @access public | |||
* @param int $typeid 栏目id | |||
* @param string $keyword 关键词 | |||
* @param string $orderby 排序 | |||
* @param string $achanneltype 栏目类型 | |||
* @param string $searchtype 搜索类型 | |||
* @param string $starttime 开始时间 | |||
* @param string $upagesize 页数 | |||
* @param string $kwtype 关键词类型 | |||
* @param string $mid 会员id | |||
* @return string | |||
*/ | |||
function __construct( | |||
$typeid, | |||
$keyword, | |||
$orderby, | |||
$achanneltype = "all", | |||
$searchtype = '', | |||
$starttime = 0, | |||
$upagesize = 20, | |||
$kwtype = 1, | |||
$mid = 0 | |||
) { | |||
global $cfg_search_max, $cfg_search_maxrc, $cfg_search_time,$envs; | |||
if (empty($upagesize)) { | |||
$upagesize = 10; | |||
} | |||
$this->TypeID = $typeid; | |||
$this->Keyword = $keyword; | |||
$this->OrderBy = $orderby; | |||
$this->KType = $kwtype; | |||
$this->pagesize = (int)$upagesize; | |||
$this->StartTime = $starttime; | |||
$this->ChannelType = $achanneltype; | |||
$this->SearchMax = $cfg_search_max; | |||
$this->SearchMaxRc = $cfg_search_maxrc; | |||
$this->SearchTime = $cfg_search_time; | |||
$this->mid = $mid; | |||
$this->RsFields = ''; | |||
$this->SearchType = $searchtype == '' ? 'titlekeyword' : $searchtype; | |||
$this->dsql = $GLOBALS['dsql']; | |||
$this->dtp = new DedeTagParse(); | |||
$this->dtp->SetRefObj($this); | |||
$this->dtp->SetNameSpace("dede", "{", "}"); | |||
$this->dtp2 = new DedeTagParse(); | |||
$this->dtp2->SetNameSpace("field", "[", "]"); | |||
$this->TypeLink = new TypeLink($typeid); | |||
//通过分词获取关键词 | |||
$this->Keywords = $this->GetKeywords($keyword); | |||
//设置一些全局参数的值 | |||
if ($this->TypeID == "0") { | |||
$this->ChannelTypeid = 1; | |||
} else { | |||
$row = $this->dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id={$this->TypeID}"); | |||
$this->ChannelTypeid = $row['channeltype']; | |||
} | |||
foreach ($GLOBALS['PubFields'] as $k => $v) { | |||
$this->Fields[$k] = $v; | |||
} | |||
$this->CountRecord(); | |||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm"; | |||
if (defined('DEDEMOB')) { | |||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||
} | |||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||
echo "模板文件不存在,无法解析"; | |||
exit(); | |||
} | |||
$this->dtp->LoadTemplate($tempfile); | |||
$this->TempInfos['tags'] = $this->dtp->CTags; | |||
$this->TempInfos['source'] = $this->dtp->SourceString; | |||
if ($this->pagesize == "") { | |||
$this->pagesize = 30; | |||
} | |||
$this->TotalPage = ceil($this->TotalResult / $this->pagesize); | |||
if ($this->PageNo == 1) { | |||
$this->dsql->ExecuteNoneQuery("UPDATE `#@__search_keywords` SET result='".$this->TotalResult."' WHERE keyword='".addslashes($keyword)."';"); | |||
} | |||
$envs['url_type'] = 3; | |||
$envs['value'] = $keyword; | |||
} | |||
//php4构造函数 | |||
function SearchView( | |||
$typeid, | |||
$keyword, | |||
$orderby, | |||
$achanneltype = "all", | |||
$searchtype = "", | |||
$starttime = 0, | |||
$upagesize = 20, | |||
$kwtype = 1, | |||
$mid = 0 | |||
) { | |||
$this->__construct($typeid, $keyword, $orderby, $achanneltype, $searchtype, $starttime, $upagesize, $kwtype, $mid); | |||
} | |||
//关闭相关资源 | |||
function Close() | |||
{ | |||
} | |||
/** | |||
* 获得关键词的分词结果,并保存到数据库 | |||
* | |||
* @access public | |||
* @param string $keyword 关键词 | |||
* @return string | |||
*/ | |||
function GetKeywords($keyword) | |||
{ | |||
global $cfg_soft_lang, $cfg_bizcore_appid, $cfg_bizcore_key; | |||
$keyword = cn_substr($keyword, 50); | |||
$row = $this->dsql->GetOne("SELECT spwords FROM `#@__search_keywords` WHERE keyword='".addslashes($keyword)."';"); | |||
if (!is_array($row)) { | |||
if (strlen($keyword) > 7) { | |||
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { | |||
$client = new DedeBizClient(); | |||
$data = $client->Spliteword($keyword); | |||
$kvs = explode(",", $data->data); | |||
$keywords = $keyword." "; | |||
foreach ($kvs as $key => $value) { | |||
$keywords .= ' '.$value; | |||
} | |||
$keywords = preg_replace("/[ ]{1,}/", " ", $keywords); | |||
$client->Close(); | |||
} else { | |||
$sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang); | |||
$sp->SetSource($keyword, $cfg_soft_lang, $cfg_soft_lang); | |||
$sp->SetResultType(2); | |||
$sp->StartAnalysis(TRUE); | |||
$keywords = $sp->GetFinallyResult(); | |||
$idx_keywords = $sp->GetFinallyIndex(); | |||
ksort($idx_keywords); | |||
$keywords = $keyword.' '; | |||
foreach ($idx_keywords as $key => $value) { | |||
if (strlen($key) <= 3) { | |||
continue; | |||
} | |||
$keywords .= ' '.$key; | |||
} | |||
$keywords = preg_replace("/[ ]{1,}/", " ", $keywords); | |||
unset($sp); | |||
} | |||
} else { | |||
$keywords = $keyword; | |||
} | |||
$inquery = "INSERT INTO `#@__search_keywords` (`keyword`,`spwords`,`count`,`result`,`lasttime`) VALUES ('".addslashes($keyword)."', '".addslashes($keywords)."', '1', '0', '".time()."'); "; | |||
$this->dsql->ExecuteNoneQuery($inquery); | |||
} else { | |||
$this->dsql->ExecuteNoneQuery("UPDATE `#@__search_keywords` SET count=count+1,lasttime='".time()."' WHERE keyword='".addslashes($keyword)."';"); | |||
$keywords = $row['spwords']; | |||
} | |||
return $keywords; | |||
} | |||
/** | |||
* 获得关键词SQL | |||
* | |||
* @access private | |||
* @return string | |||
*/ | |||
function GetKeywordSql() | |||
{ | |||
$ks = explode(' ', $this->Keywords); | |||
$kwsql = ''; | |||
$kwsqls = array(); | |||
foreach ($ks as $k) { | |||
$k = trim($k); | |||
if (strlen($k) < 1) { | |||
continue; | |||
} | |||
if (ord($k[0]) > 0x80 && strlen($k) < 2) { | |||
continue; | |||
} | |||
$k = addslashes($k); | |||
if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) { | |||
$kwsqls[] = " arc.title LIKE '%$k%' "; | |||
} else { | |||
if ($this->SearchType == "title") { | |||
$kwsqls[] = " arc.title LIKE '%$k%' "; | |||
} else { | |||
$kwsqls[] = " CONCAT(arc.title,' ',arc.writer,' ',arc.keywords) LIKE '%$k%' "; | |||
} | |||
} | |||
} | |||
if (!isset($kwsqls[0])) { | |||
return ''; | |||
} else { | |||
if ($this->KType == 1) { | |||
$kwsql = join(' OR ', $kwsqls); | |||
} else { | |||
$kwsql = join(' And ', $kwsqls); | |||
} | |||
return $kwsql; | |||
} | |||
} | |||
/** | |||
* 获得相关的关键词 | |||
* | |||
* @access public | |||
* @param string $num 关键词数目 | |||
* @return string | |||
*/ | |||
function GetLikeWords($num = 8) | |||
{ | |||
$ks = explode(' ', $this->Keywords); | |||
$lsql = ''; | |||
foreach ($ks as $k) { | |||
$k = trim($k); | |||
if (strlen($k) < 2) { | |||
continue; | |||
} | |||
if (ord($k[0]) > 0x80 && strlen($k) < 2) { | |||
continue; | |||
} | |||
$k = addslashes($k); | |||
if ($lsql == '') { | |||
$lsql = $lsql." CONCAT(spwords,' ') LIKE '%$k %' "; | |||
} else { | |||
$lsql = $lsql." OR CONCAT(spwords,' ') LIKE '%$k %' "; | |||
} | |||
} | |||
if ($lsql == '') { | |||
return ''; | |||
} else { | |||
$likeword = ''; | |||
$lsql = "(".$lsql.") AND NOT(keyword like '".addslashes($this->Keyword)."') "; | |||
$this->dsql->SetQuery("SELECT keyword,count FROM `#@__search_keywords` WHERE $lsql ORDER BY lasttime DESC LIMIT 0,$num;"); | |||
$this->dsql->Execute('l'); | |||
while ($row = $this->dsql->GetArray('l')) { | |||
if ($row['count'] > 1000) { | |||
$fstyle = " style='font-size:11pt;color:red'"; | |||
} else if ($row['count'] > 300) { | |||
$fstyle = " style='font-size:10pt;color:green'"; | |||
} else { | |||
$style = ""; | |||
} | |||
$likeword .= " <a href='search.php?keyword=".urlencode($row['keyword'])."&searchtype=titlekeyword'".$style.">".$row['keyword']."</a> "; | |||
} | |||
return $likeword; | |||
} | |||
} | |||
/** | |||
* 加粗关键词 | |||
* | |||
* @access private | |||
* @param string $fstr 关键词字符 | |||
* @return string | |||
*/ | |||
function GetRedKeyWord($fstr) | |||
{ | |||
$ks = explode(' ', $this->Keywords); | |||
foreach ($ks as $k) { | |||
$k = trim($k); | |||
if ($k == '') { | |||
continue; | |||
} | |||
if (ord($k[0]) > 0x80 && strlen($k) < 2) { | |||
continue; | |||
} | |||
//这里不区分大小写进行关键词替换 | |||
$fstr = str_ireplace($k, "<span class='text-primary'>$k</span>", $fstr); | |||
//速度更快,效率更高$fstr = str_replace($k, "<span class='text-primary'>$k</span>", $fstr); | |||
} | |||
return $fstr; | |||
} | |||
/** | |||
* 统计列表里的记录 | |||
* | |||
* @access public | |||
* @return string | |||
*/ | |||
function CountRecord() | |||
{ | |||
$this->TotalResult = -1; | |||
if (isset($GLOBALS['TotalResult'])) { | |||
$this->TotalResult = $GLOBALS['TotalResult']; | |||
$this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; | |||
} | |||
if (isset($GLOBALS['PageNo'])) { | |||
$this->PageNo = intval($GLOBALS['PageNo']); | |||
} else { | |||
$this->PageNo = 1; | |||
} | |||
$ksql = $this->GetKeywordSql(); | |||
$ksqls = array(); | |||
if ($this->StartTime > 0) { | |||
$ksqls[] = " arc.senddate>'".$this->StartTime."' "; | |||
} | |||
if ($this->TypeID > 0) { | |||
$ksqls[] = " typeid IN (".GetSonIds($this->TypeID).") "; | |||
} | |||
if ($this->ChannelType > 0) { | |||
$ksqls[] = " arc.channel='".$this->ChannelType."'"; | |||
} | |||
if ($this->mid > 0) { | |||
$ksqls[] = " arc.mid = '".$this->mid."'"; | |||
} | |||
$ksqls[] = " arc.arcrank > -1 "; | |||
$this->AddSql = ($ksql == '' ? join(' AND ', $ksqls) : join(' AND ', $ksqls)." AND ($ksql)"); | |||
if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) { | |||
if ($this->ChannelType == "0") $id = $this->ChannelTypeid; | |||
else $id = $this->ChannelType; | |||
$row = $this->dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id=$id"); | |||
$addtable = trim($row['addtable']); | |||
$this->AddTable = $addtable; | |||
} else { | |||
$this->AddTable = "#@__archives"; | |||
} | |||
$cquery = "SELECT * FROM `{$this->AddTable}` arc WHERE ".$this->AddSql; | |||
//var_dump($cquery); | |||
$hascode = md5($cquery); | |||
$row = $this->dsql->GetOne("SELECT * FROM `#@__arccache` WHERE `md5hash`='".$hascode."' "); | |||
$uptime = time(); | |||
if (is_array($row) && time() - $row['uptime'] < 3600 * 24) { | |||
$aids = explode(',', $row['cachedata']); | |||
$this->TotalResult = count($aids) - 1; | |||
$this->RsFields = $row['cachedata']; | |||
} else { | |||
if ($this->TotalResult == -1) { | |||
$this->dsql->SetQuery($cquery); | |||
$this->dsql->execute(); | |||
$aidarr = array(); | |||
$aidarr[] = 0; | |||
while ($row = $this->dsql->getarray()) { | |||
if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) $aidarr[] = $row['aid']; | |||
else $aidarr[] = $row['id']; | |||
} | |||
$nums = count($aidarr) - 1; | |||
$aids = implode(',', $aidarr); | |||
$delete = "DELETE FROM `#@__arccache` WHERE uptime<".(time() - 3600 * 24); | |||
$this->dsql->SetQuery($delete); | |||
$this->dsql->executenonequery(); | |||
$insert = "INSERT INTO `#@__arccache` (`md5hash`,`uptime`,`cachedata`) VALUES ('$hascode','$uptime','$aids')"; | |||
$this->dsql->SetQuery($insert); | |||
$this->dsql->executenonequery(); | |||
$this->TotalResult = $nums; | |||
} | |||
} | |||
} | |||
/** | |||
* 显示列表 | |||
* | |||
* @access public | |||
* @param string | |||
* @return string | |||
*/ | |||
function Display() | |||
{ | |||
foreach ($this->dtp->CTags as $tagid => $ctag) { | |||
$tagname = $ctag->GetName(); | |||
if ($tagname == "list") { | |||
$limitstart = ($this->PageNo - 1) * $this->pagesize; | |||
$row = $this->pagesize; | |||
if (trim($ctag->GetInnerText()) == "") { | |||
$InnerText = GetSysTemplets("list_fulllist.htm"); | |||
} else { | |||
$InnerText = trim($ctag->GetInnerText()); | |||
} | |||
$this->dtp->Assign( | |||
$tagid, | |||
$this->GetArcList( | |||
$limitstart, | |||
$row, | |||
$ctag->GetAtt("col"), | |||
$ctag->GetAtt("titlelen"), | |||
$ctag->GetAtt("infolen"), | |||
$ctag->GetAtt("imgwidth"), | |||
$ctag->GetAtt("imgheight"), | |||
$this->ChannelType, | |||
$this->OrderBy, | |||
$InnerText, | |||
$ctag->GetAtt("tablewidth") | |||
) | |||
); | |||
} else if ($tagname == "pagelist") { | |||
$list_len = trim($ctag->GetAtt("listsize")); | |||
$ctag->GetAtt("listitem") == "" ? $listitem = "index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem"); | |||
if ($list_len == "") { | |||
$list_len = 3; | |||
} | |||
$this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem)); | |||
} else if ($tagname == "likewords") { | |||
$this->dtp->Assign($tagid, $this->GetLikeWords($ctag->GetAtt('num'))); | |||
} else if ($tagname == "hotwords") { | |||
$this->dtp->Assign($tagid, lib_hotwords($ctag, $this)); | |||
} else if ($tagname == "field") { | |||
//类别的指定字段 | |||
if (isset($this->Fields[$ctag->GetAtt('name')])) { | |||
$this->dtp->Assign($tagid, $this->Fields[$ctag->GetAtt('name')]); | |||
} else { | |||
$this->dtp->Assign($tagid, ""); | |||
} | |||
} else if ($tagname == "channel") { | |||
//下级栏目列表 | |||
if ($this->TypeID > 0) { | |||
$typeid = $this->TypeID; | |||
$reid = $this->TypeLink->TypeInfos['reid']; | |||
} else { | |||
$typeid = 0; | |||
$reid = 0; | |||
} | |||
$GLOBALS['envs']['typeid'] = $typeid; | |||
$GLOBALS['envs']['reid'] = $typeid; | |||
$this->dtp->Assign($tagid, lib_channel($ctag, $this)); | |||
} //End if | |||
} | |||
global $keyword, $oldkeyword; | |||
if (!empty($oldkeyword)) $keyword = $oldkeyword; | |||
$this->dtp->Display(); | |||
} | |||
/** | |||
* 获得文档列表 | |||
* | |||
* @access public | |||
* @param int $limitstart 限制开始 | |||
* @param int $row 行数 | |||
* @param int $col 列数 | |||
* @param int $titlelen 标题长度 | |||
* @param int $infolen 描述长度 | |||
* @param int $imgwidth 图片宽度 | |||
* @param int $imgheight 图片高度 | |||
* @param string $achanneltype 列表类型 | |||
* @param string $orderby 排列顺序 | |||
* @param string $innertext 底层模板 | |||
* @param string $tablewidth 表格宽度 | |||
* @return string | |||
*/ | |||
function GetArcList( | |||
$limitstart = 0, | |||
$row = 10, | |||
$col = 1, | |||
$titlelen = 30, | |||
$infolen = 250, | |||
$imgwidth = 120, | |||
$imgheight = 90, | |||
$achanneltype = "all", | |||
$orderby = "default", | |||
$innertext = "", | |||
$tablewidth = "100" | |||
) { | |||
$typeid = $this->TypeID; | |||
if ($row == '') $row = 10; | |||
if ($limitstart == '') $limitstart = 0; | |||
if ($titlelen == '') $titlelen = 30; | |||
if ($infolen == '') $infolen = 250; | |||
if ($imgwidth == '') $imgwidth = 120; | |||
if ($imgheight = '') $imgheight = 120; | |||
if ($achanneltype == '') $achanneltype = '0'; | |||
$orderby = $orderby == '' ? 'default' : strtolower($orderby); | |||
$tablewidth = str_replace("%", "", $tablewidth); | |||
if ($tablewidth == '') $tablewidth = 100; | |||
if ($col == '') $col = 1; | |||
$colWidth = ceil(100 / $col); | |||
$tablewidth = $tablewidth."%"; | |||
$colWidth = $colWidth."%"; | |||
$innertext = trim($innertext); | |||
if ($innertext == '') { | |||
$innertext = GetSysTemplets("search_list.htm"); | |||
} | |||
//排序方式 | |||
$ordersql = ''; | |||
if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) { | |||
if ($orderby == "id") { | |||
$ordersql = "ORDER BY arc.aid desc"; | |||
} else { | |||
$ordersql = "ORDER BY arc.senddate desc"; | |||
} | |||
} else { | |||
if ($orderby == "senddate") { | |||
$ordersql = " ORDER BY arc.senddate desc"; | |||
} else if ($orderby == "pubdate") { | |||
$ordersql = " ORDER BY arc.pubdate desc"; | |||
} else if ($orderby == "id") { | |||
$ordersql = " ORDER BY arc.id desc"; | |||
} else { | |||
$ordersql = " ORDER BY arc.sortrank desc"; | |||
} | |||
} | |||
//搜索 | |||
$query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id WHERE {$this->AddSql} $ordersql LIMIT $limitstart,$row"; | |||
$this->dsql->SetQuery($query); | |||
$this->dsql->Execute("al"); | |||
$artlist = ""; | |||
if ($col > 1) { | |||
$artlist = "<table width='$tablewidth' cellspacing='0' cellpadding='0'>\r\n"; | |||
} | |||
$this->dtp2->LoadSource($innertext); | |||
for ($i = 0; $i < $row; $i++) { | |||
if ($col > 1) { | |||
$artlist .= "<tr>\r\n"; | |||
} | |||
for ($j = 0; $j < $col; $j++) { | |||
if ($col > 1) { | |||
$artlist .= "<td width='$colWidth'>\r\n"; | |||
} | |||
if ($row = $this->dsql->GetArray("al")) { | |||
if ($this->ChannelType < 0 || $this->ChannelTypeid < 0) { | |||
$row["id"] = $row["aid"]; | |||
$row["ismake"] = empty($row["ismake"]) ? "" : $row["ismake"]; | |||
$row["filename"] = empty($row["filename"]) ? "" : $row["filename"]; | |||
$row["money"] = empty($row["money"]) ? "" : $row["money"]; | |||
$row["description"] = empty($row["description "]) ? "" : $row["description"]; | |||
$row["pubdate"] = empty($row["pubdate "]) ? $row["senddate"] : $row["pubdate"]; | |||
} | |||
//处理一些特殊字段 | |||
$row["arcurl"] = GetFileUrl( | |||
$row["id"], | |||
$row["typeid"], | |||
$row["senddate"], | |||
$row["title"], | |||
$row["ismake"], | |||
$row["arcrank"], | |||
$row["namerule"], | |||
$row["typedir"], | |||
$row["money"], | |||
$row['filename'], | |||
$row["moresite"], | |||
$row["siteurl"], | |||
$row["sitepath"] | |||
); | |||
$row["description"] = $this->GetRedKeyWord(cn_substr($row["description"], $infolen)); | |||
$row["title"] = $this->GetRedKeyWord(cn_substr($row["title"], $titlelen)); | |||
$row["id"] = $row["id"]; | |||
if ($row['litpic'] == '-' || $row['litpic'] == '') { | |||
$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']; | |||
} | |||
$row['picname'] = $row['litpic']; | |||
$row["typeurl"] = GetTypeUrl($row["typeid"], $row["typedir"], $row["isdefault"], $row["defaultname"], $row["ispart"], $row["namerule2"], $row["moresite"], $row["siteurl"], $row["sitepath"]); | |||
$row["info"] = $row["description"]; | |||
$row["filename"] = $row["arcurl"]; | |||
$row["stime"] = GetDateMK($row["pubdate"]); | |||
$row["textlink"] = "<a href='".$row["filename"]."'>".$row["title"]."</a>"; | |||
$row["typelink"] = "[<a href='".$row["typeurl"]."'>".$row["typename"]."</a>]"; | |||
$row["imglink"] = "<a href='".$row["filename"]."'><img src='".$row["picname"]."' width='$imgwidth' height='$imgheight'></a>"; | |||
$row["image"] = "<img src='".$row["picname"]."' width='$imgwidth' height='$imgheight'>"; | |||
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl']; | |||
$row['memberurl'] = $GLOBALS['cfg_memberurl']; | |||
$row['templeturl'] = $GLOBALS['cfg_templeturl']; | |||
if (is_array($this->dtp2->CTags)) { | |||
foreach ($this->dtp2->CTags as $k => $ctag) { | |||
if ($ctag->GetName() == 'array') { | |||
//传递整个数组,在runphp模式中有特殊作用 | |||
$this->dtp2->Assign($k, $row); | |||
} else { | |||
if (isset($row[$ctag->GetName()])) { | |||
$this->dtp2->Assign($k, $row[$ctag->GetName()]); | |||
} else { | |||
$this->dtp2->Assign($k, ''); | |||
} | |||
} | |||
} | |||
} | |||
$artlist .= $this->dtp2->GetResult(); | |||
} //if hasRow | |||
else { | |||
$artlist .= ""; | |||
} | |||
if ($col > 1) $artlist .= "</td>\r\n"; | |||
} //Loop Col | |||
if ($col > 1) { | |||
$artlist .= "</tr>\r\n"; | |||
} | |||
} //Loop Line | |||
if ($col > 1) { | |||
$artlist .= "</table>\r\n"; | |||
} | |||
$this->dsql->FreeResult("al"); | |||
return $artlist; | |||
} | |||
/** | |||
* 获取动态的分页列表 | |||
* | |||
* @access public | |||
* @param string $list_len 列表宽度 | |||
* @return string | |||
*/ | |||
function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno") | |||
{ | |||
global $oldkeyword; | |||
$prepage = ""; | |||
$nextpage = ""; | |||
$prepagenum = $this->PageNo - 1; | |||
$nextpagenum = $this->PageNo + 1; | |||
if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) { | |||
$list_len = 3; | |||
} | |||
$totalpage = ceil($this->TotalResult / $this->pagesize); | |||
if ($totalpage <= 1 && $this->TotalResult > 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>"; | |||
} | |||
if ($this->TotalResult == 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>"; | |||
} | |||
$purl = $this->GetCurUrl(); | |||
$oldkeyword = (empty($oldkeyword) ? $this->Keyword : $oldkeyword); | |||
//当结果超过限制时,重设结果页数 | |||
if ($this->TotalResult > $this->SearchMaxRc) { | |||
$totalpage = ceil($this->SearchMaxRc / $this->pagesize); | |||
} | |||
$infos = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n"; | |||
$geturl = "keyword=".urlencode($oldkeyword)."&searchtype=".$this->SearchType; | |||
$hidenform = "<input type='hidden' name='keyword' value='".rawurldecode($oldkeyword)."'>\r\n"; | |||
$geturl .= "&channeltype=".$this->ChannelType."&orderby=".$this->OrderBy; | |||
$hidenform .= "<input type='hidden' name='channeltype' value='".$this->ChannelType."'>\r\n"; | |||
$hidenform .= "<input type='hidden' name='orderby' value='".$this->OrderBy."'>\r\n"; | |||
$geturl .= "&kwtype=".$this->KType."&pagesize=".$this->pagesize; | |||
$hidenform .= "<input type='hidden' name='kwtype' value='".$this->KType."'>\r\n"; | |||
$hidenform .= "<input type='hidden' name='pagesize' value='".$this->pagesize."'>\r\n"; | |||
$geturl .= "&typeid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; | |||
$hidenform .= "<input type='hidden' name='typeid' value='".$this->TypeID."'>\r\n"; | |||
$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n"; | |||
$purl .= "?".$geturl; | |||
//获得上一页和下一页的链接 | |||
if ($this->PageNo != 1) { | |||
$prepage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; | |||
$indexpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=1'>首页</a></li>\r\n"; | |||
} else { | |||
$indexpage = "<li class='page-item disabled'><a class='page-link'>首页</a></li>\r\n"; | |||
} | |||
if ($this->PageNo != $totalpage && $totalpage > 1) { | |||
$nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; | |||
$endpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; | |||
} else { | |||
$endpage = "<li class='page-item'><a class='page-link'>末页</a></li>\r\n"; | |||
} | |||
//获得数字链接 | |||
$listdd = ""; | |||
$total_list = $list_len * 2 + 1; | |||
if ($this->PageNo >= $total_list) { | |||
$j = $this->PageNo - $list_len; | |||
$total_list = $this->PageNo + $list_len; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} else { | |||
$j = 1; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} | |||
for ($j; $j <= $total_list; $j++) { | |||
if ($j == $this->PageNo) { | |||
$listdd .= "<li class='page-item active'><a class='page-link'>$j</a></li>\r\n"; | |||
} else { | |||
$listdd .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; | |||
} | |||
} | |||
$plist = ""; | |||
$plist .= "<form name='pagelist' action='".$this->GetCurUrl()."'>$hidenform"; | |||
$plist .= "<ul class='pagination justify-content-center pt-3'>"; | |||
$plist .= preg_match('/info/i', $listitem)? $infos : ""; | |||
$plist .= preg_match('/index/i', $listitem)? $indexpage : ""; | |||
$plist .= preg_match('/pre/i', $listitem)? $prepage : ""; | |||
$plist .= preg_match('/pageno/i', $listitem)? $listdd : ""; | |||
$plist .= preg_match('/next/i', $listitem)? $nextpage : ""; | |||
$plist .= preg_match('/end/i', $listitem)? $endpage : ""; | |||
$plist .= "</ul></form>\r\n"; | |||
return $plist; | |||
} | |||
/** | |||
* 获得当前的页面文件链接 | |||
* | |||
* @access public | |||
* @return string | |||
*/ | |||
function GetCurUrl() | |||
{ | |||
if (!empty($_SERVER["REQUEST_URI"])) { | |||
$nowurl = $_SERVER["REQUEST_URI"]; | |||
$nowurls = explode("?", $nowurl); | |||
$nowurl = $nowurls[0]; | |||
} else { | |||
$nowurl = $_SERVER["PHP_SELF"]; | |||
} | |||
return $nowurl; | |||
} | |||
}//End Class | |||
?> |
@@ -0,0 +1,853 @@ | |||
<?php | |||
if (!defined('DEDEINC')) exit('dedebiz'); | |||
/** | |||
* 自定义模型列表类 | |||
* | |||
* @version $id:sglistview.class.php 15:48 2010年7月7日 tianya $ | |||
* @package DedeBIZ.Libraries | |||
* @copyright Copyright (c) 2022 DedeBIZ.COM | |||
* @license https://www.dedebiz.com/license | |||
* @link https://www.dedebiz.com | |||
*/ | |||
@set_time_limit(0); | |||
require_once(DEDEINC."/archive/partview.class.php"); | |||
class SgListView | |||
{ | |||
var $dsql; | |||
var $dtp; | |||
var $dtp2; | |||
var $TypeID; | |||
var $TypeLink; | |||
var $PageNo; | |||
var $TotalPage; | |||
var $TotalResult; | |||
var $pagesize; | |||
var $ChannelUnit; | |||
var $ListType; | |||
var $Fields; | |||
var $PartView; | |||
var $addSql; | |||
var $IsError; | |||
var $CrossID; | |||
var $IsReplace; | |||
var $AddTable; | |||
var $ListFields; | |||
var $searchArr; | |||
var $sAddTable; | |||
/** | |||
* php5构造函数 | |||
* | |||
* @access public | |||
* @param int $typeid 栏目id | |||
* @param array $searchArr 检索数组 | |||
* @return void | |||
*/ | |||
function __construct($typeid, $searchArr = array()) | |||
{ | |||
global $dsql, $envs; | |||
$envs['url_type'] = 1; | |||
$this->TypeID = $typeid; | |||
$this->dsql = $dsql; | |||
$this->CrossID = ''; | |||
$this->IsReplace = false; | |||
$this->IsError = false; | |||
$this->dtp = new DedeTagParse(); | |||
$this->dtp->SetRefObj($this); | |||
$this->sAddTable = false; | |||
$this->dtp->SetNameSpace("dede", "{", "}"); | |||
$this->dtp2 = new DedeTagParse(); | |||
$this->dtp2->SetNameSpace("field", "[", "]"); | |||
$this->TypeLink = new TypeLink($typeid); | |||
$this->searchArr = $searchArr; | |||
if (!is_array($this->TypeLink->TypeInfos)) { | |||
$this->IsError = true; | |||
} | |||
if (!$this->IsError) { | |||
$this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']); | |||
$this->Fields = $this->TypeLink->TypeInfos; | |||
$this->Fields['id'] = $typeid; | |||
$this->Fields['position'] = $this->TypeLink->GetPositionLink(true); | |||
$this->Fields['title'] = preg_replace("/[<>]/", " / ", $this->TypeLink->GetPositionLink(false)); | |||
//获得附加表和列表字段信息 | |||
$this->AddTable = $this->ChannelUnit->ChannelInfos['addtable']; | |||
$listfield = trim($this->ChannelUnit->ChannelInfos['listfields']); | |||
$this->ListFields = explode(',', $listfield); | |||
//设置一些全局参数的值 | |||
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | |||
$this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | |||
//设置环境变量 | |||
SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | |||
$this->Fields['typeid'] = $this->TypeID; | |||
//获得交叉栏目id | |||
if ($this->TypeLink->TypeInfos['cross'] > 0 && $this->TypeLink->TypeInfos['ispart'] == 0) { | |||
$selquery = ''; | |||
if ($this->TypeLink->TypeInfos['cross'] == 1) { | |||
$selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$this->Fields['typename']}' AND id<>'{$this->TypeID}' AND topid<>'{$this->TypeID}' "; | |||
} else { | |||
$this->Fields['crossid'] = preg_replace("/[^0-9,]/", '', trim($this->Fields['crossid'])); | |||
if ($this->Fields['crossid'] != '') { | |||
$selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN({$this->Fields['crossid']}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID} "; | |||
} | |||
} | |||
if ($selquery != '') { | |||
$this->dsql->SetQuery($selquery); | |||
$this->dsql->Execute(); | |||
while ($arr = $this->dsql->GetArray()) { | |||
$this->CrossID .= ($this->CrossID == '' ? $arr['id'] : ','.$arr['id']); | |||
} | |||
} | |||
} | |||
} //!error | |||
} | |||
//php4构造函数 | |||
function SgListView($typeid, $searchArr = array()) | |||
{ | |||
$this->__construct($typeid, $searchArr); | |||
} | |||
//关闭相关资源 | |||
function Close() | |||
{ | |||
} | |||
/** | |||
* 统计列表里的记录 | |||
* | |||
* @access public | |||
* @return void | |||
*/ | |||
function CountRecord() | |||
{ | |||
global $cfg_list_son; | |||
//统计数据库记录 | |||
$this->TotalResult = -1; | |||
if (isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult']; | |||
if (isset($GLOBALS['PageNo'])) $this->PageNo = $GLOBALS['PageNo']; | |||
else $this->PageNo = 1; | |||
$this->addSql = " arc.arcrank > -1 "; | |||
//栏目id条件 | |||
if (!empty($this->TypeID)) { | |||
if ($cfg_list_son == 'N') { | |||
if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid='".$this->TypeID."') "; | |||
else $this->addSql .= " AND (arc.typeid IN({$this->CrossID},{$this->TypeID})) "; | |||
} else { | |||
if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).") ) "; | |||
else $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).",{$this->CrossID}) ) "; | |||
} | |||
} | |||
$naddQuery = ''; | |||
//地区与信息类型条件 | |||
if (count($this->searchArr) > 0) { | |||
if (!empty($this->searchArr['nativeplace'])) { | |||
if ($this->searchArr['nativeplace'] % 500 == 0) { | |||
$naddQuery .= " AND arc.nativeplace >= '{$this->searchArr['nativeplace']}' AND arc.nativeplace < '".($this->searchArr['nativeplace'] + 500)."'"; | |||
} else { | |||
$naddQuery .= "AND arc.nativeplace = '{$this->searchArr['nativeplace']}'"; | |||
} | |||
} | |||
if (!empty($this->searchArr['infotype'])) { | |||
if ($this->searchArr['infotype'] % 500 == 0) { | |||
$naddQuery .= " AND arc.infotype >= '{$this->searchArr['infotype']}' AND arc.infotype < '".($this->searchArr['infotype'] + 500)."'"; | |||
} else { | |||
$naddQuery .= "AND arc.infotype = '{$this->searchArr['infotype']}'"; | |||
} | |||
} | |||
if (!empty($this->searchArr['keyword'])) { | |||
$naddQuery .= "AND arc.title like '%{$this->searchArr['keyword']}%' "; | |||
} | |||
} | |||
if ($naddQuery != '') { | |||
$this->sAddTable = true; | |||
$this->addSql .= $naddQuery; | |||
} | |||
if ($this->TotalResult == -1) { | |||
if ($this->sAddTable) { | |||
$cquery = "SELECT COUNT(*) AS dd FROM `{$this->AddTable}` arc WHERE ".$this->addSql; | |||
} else { | |||
$cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql; | |||
} | |||
$row = $this->dsql->GetOne($cquery); | |||
if (is_array($row)) { | |||
$this->TotalResult = $row['dd']; | |||
} else { | |||
$this->TotalResult = 0; | |||
} | |||
} | |||
//初始化列表模板,并统计页面总数 | |||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||
if (defined('DEDEMOB')) { | |||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||
} | |||
if (!file_exists($tempfile)) { | |||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default_sg.htm"; | |||
if (defined('DEDEMOB')) { | |||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||
} | |||
} | |||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||
echo "主题模板文件不存在,无法发布文档"; | |||
exit(); | |||
} | |||
$this->dtp->LoadTemplate($tempfile); | |||
$ctag = $this->dtp->GetTag("page"); | |||
if (!is_object($ctag)) { | |||
$ctag = $this->dtp->GetTag("list"); | |||
} | |||
if (!is_object($ctag)) { | |||
$this->pagesize = 20; | |||
} else { | |||
if ($ctag->GetAtt('pagesize') != '') { | |||
$this->pagesize = $ctag->GetAtt('pagesize'); | |||
} else { | |||
$this->pagesize = 20; | |||
} | |||
} | |||
$this->TotalPage = ceil($this->TotalResult / $this->pagesize); | |||
} | |||
/** | |||
* 列表创建网页 | |||
* | |||
* @access public | |||
* @param string $startpage 开始页面 | |||
* @param string $makepagesize 生成尺寸 | |||
* @return string | |||
*/ | |||
function MakeHtml($startpage = 1, $makepagesize = 0) | |||
{ | |||
if (empty($startpage)) { | |||
$startpage = 1; | |||
} | |||
//创建封面模板文件 | |||
if ($this->TypeLink->TypeInfos['isdefault'] == -1) { | |||
echo '这个是动态栏目'; | |||
return ''; | |||
} | |||
//单独页面 | |||
else if ($this->TypeLink->TypeInfos['ispart'] > 0) { | |||
$reurl = $this->MakePartTemplets(); | |||
return $reurl; | |||
} | |||
if (empty($this->TotalResult)) $this->CountRecord(); | |||
//初步给固定值的标记赋值 | |||
$this->ParseTempletsFirst(); | |||
$totalpage = ceil($this->TotalResult / $this->pagesize); | |||
if ($totalpage == 0) { | |||
$totalpage = 1; | |||
} | |||
CreateDir(MfTypedir($this->Fields['typedir'])); | |||
$murl = ''; | |||
if ($makepagesize > 0) { | |||
$endpage = $startpage + $makepagesize; | |||
} else { | |||
$endpage = ($totalpage + 1); | |||
} | |||
if ($endpage >= $totalpage + 1) { | |||
$endpage = $totalpage + 1; | |||
} | |||
if ($endpage == 1) { | |||
$endpage = 2; | |||
} | |||
for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) { | |||
$this->ParseDMFields($this->PageNo, 1); | |||
$makeFile = $this->GetMakeFileRule($this->Fields['id'], 'list', $this->Fields['typedir'], '', $this->Fields['namerule2']); | |||
$makeFile = str_replace("{page}", $this->PageNo, $makeFile); | |||
$murl = $makeFile; | |||
if (!preg_match("/^\//", $makeFile)) { | |||
$makeFile = "/".$makeFile; | |||
} | |||
$makeFile = $this->GetTruePath().$makeFile; | |||
$makeFile = preg_replace("/\/{1,}/", "/", $makeFile); | |||
$murl = $this->GetTrueUrl($murl); | |||
$this->dtp->SaveTo($makeFile); | |||
if (PHP_SAPI === 'cli') { | |||
DedeCli::showProgress(ceil(($this->PageNo / $endpage) * 100), 100); | |||
} | |||
} | |||
if ($startpage == 1) { | |||
//如果列表启用封面文件,复制这个文件第一页 | |||
if ( | |||
$this->TypeLink->TypeInfos['isdefault'] == 1 | |||
&& $this->TypeLink->TypeInfos['ispart'] == 0 | |||
) { | |||
$onlyrule = $this->GetMakeFileRule($this->Fields['id'], "list", $this->Fields['typedir'], '', $this->Fields['namerule2']); | |||
$onlyrule = str_replace("{page}", "1", $onlyrule); | |||
$list_1 = $this->GetTruePath().$onlyrule; | |||
$murl = MfTypedir($this->Fields['typedir']).'/'.$this->Fields['defaultname']; | |||
$indexname = $this->GetTruePath().$murl; | |||
copy($list_1, $indexname); | |||
} | |||
} | |||
return $murl; | |||
} | |||
/** | |||
* 显示列表 | |||
* | |||
* @access public | |||
* @return void | |||
*/ | |||
function Display() | |||
{ | |||
if ($this->TypeLink->TypeInfos['ispart'] > 0 && count($this->searchArr) == 0) { | |||
$this->DisplayPartTemplets(); | |||
return; | |||
} | |||
$this->CountRecord(); | |||
$this->ParseTempletsFirst(); | |||
$this->ParseDMFields($this->PageNo, 0); | |||
$this->dtp->Display(); | |||
} | |||
/** | |||
* 创建单独模板页面 | |||
* | |||
* @access public | |||
* @return string | |||
*/ | |||
function MakePartTemplets() | |||
{ | |||
$this->PartView = new PartView($this->TypeID, false); | |||
$this->PartView->SetTypeLink($this->TypeLink); | |||
$nmfa = 0; | |||
$tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']; | |||
if ($this->Fields['ispart'] == 1) { | |||
$tempfile = str_replace("{tid}", $this->TypeID, $this->Fields['tempindex']); | |||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||
$tempfile = $tmpdir."/".$tempfile; | |||
if (defined('DEDEMOB')) { | |||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||
} | |||
if (!file_exists($tempfile)) { | |||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default_sg.htm"; | |||
if (defined('DEDEMOB')) { | |||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||
} | |||
} | |||
$this->PartView->SetTemplet($tempfile); | |||
} else if ($this->Fields['ispart'] == 2) { | |||
//跳转网址 | |||
return $this->Fields['typedir']; | |||
} | |||
CreateDir(MfTypedir($this->Fields['typedir'])); | |||
$makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']); | |||
$makeUrl = preg_replace("/\/{1,}/", "/", $makeUrl); | |||
$makeFile = $this->GetTruePath().$makeUrl; | |||
if ($nmfa == 0) { | |||
$this->PartView->SaveToHtml($makeFile); | |||
} else { | |||
if (!file_exists($makeFile)) { | |||
$this->PartView->SaveToHtml($makeFile); | |||
} | |||
} | |||
return $this->GetTrueUrl($makeUrl); | |||
} | |||
/** | |||
* 显示单独模板页面 | |||
* | |||
* @access public | |||
* @return void | |||
*/ | |||
function DisplayPartTemplets() | |||
{ | |||
$this->PartView = new PartView($this->TypeID, false); | |||
$this->PartView->SetTypeLink($this->TypeLink); | |||
$nmfa = 0; | |||
$tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']; | |||
if ($this->Fields['ispart'] == 1) { | |||
//封面模板 | |||
$tempfile = str_replace("{tid}", $this->TypeID, $this->Fields['tempindex']); | |||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||
$tempfile = $tmpdir."/".$tempfile; | |||
if (!file_exists($tempfile)) { | |||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default_sg.htm"; | |||
} | |||
$this->PartView->SetTemplet($tempfile); | |||
} else if ($this->Fields['ispart'] == 2) { | |||
//跳转网址 | |||
$gotourl = $this->Fields['typedir']; | |||
header("Location:$gotourl"); | |||
exit(); | |||
} | |||
CreateDir(MfTypedir($this->Fields['typedir'])); | |||
$makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']); | |||
$makeFile = $this->GetTruePath().$makeUrl; | |||
if ($nmfa == 0) { | |||
$this->PartView->Display(); | |||
} else { | |||
if (!file_exists($makeFile)) { | |||
$this->PartView->Display(); | |||
} else { | |||
include($makeFile); | |||
} | |||
} | |||
} | |||
/** | |||
* 获得站点的真实根路径 | |||
* | |||
* @access public | |||
* @return string | |||
*/ | |||
function GetTruePath() | |||
{ | |||
$truepath = $GLOBALS["cfg_basedir"]; | |||
return $truepath; | |||
} | |||
/** | |||
* 获得真实连接路径 | |||
* | |||
* @access public | |||
* @param string $nurl 连接地址 | |||
* @return string | |||
*/ | |||
function GetTrueUrl($nurl) | |||
{ | |||
if (preg_match("/^http[s]?:\/\//", $nurl)) return $nurl; | |||
if ($this->Fields['moresite'] == 1) { | |||
if ($this->Fields['sitepath'] != '') { | |||
$nurl = preg_replace("/^".$this->Fields['sitepath']."/", '', $nurl); | |||
} | |||
$nurl = $this->Fields['siteurl'].$nurl; | |||
} | |||
return $nurl; | |||
} | |||
/** | |||
* 解析模板,对固定的标记进行初始给值 | |||
* | |||
* @access private | |||
* @return void | |||
*/ | |||
function ParseTempletsFirst() | |||
{ | |||
if (isset($this->TypeLink->TypeInfos['reid'])) { | |||
$GLOBALS['envs']['reid'] = $this->TypeLink->TypeInfos['reid']; | |||
} | |||
$GLOBALS['envs']['channelid'] = $this->TypeLink->TypeInfos['channeltype']; | |||
$GLOBALS['envs']['typeid'] = $this->TypeID; | |||
$GLOBALS['envs']['cross'] = 1; | |||
MakeOneTag($this->dtp, $this); | |||
} | |||
/** | |||
* 解析模板,对文档里的变动进行赋值 | |||
* | |||
* @access public | |||
* @param int $PageNo 页码 | |||
* @param int $ismake 是否编译 | |||
* @return void | |||
*/ | |||
function ParseDMFields($PageNo, $ismake = 1) | |||
{ | |||
//替换第二页后的文档 | |||
if (($PageNo > 1 || strlen($this->Fields['content']) < 10) && !$this->IsReplace) { | |||
$this->dtp->SourceString = str_replace('[cmsreplace]', 'display:none', $this->dtp->SourceString); | |||
$this->IsReplace = true; | |||
} | |||
foreach ($this->dtp->CTags as $tagid => $ctag) { | |||
if ($ctag->GetName() == "list") { | |||
$limitstart = ($this->PageNo - 1) * $this->pagesize; | |||
$row = $this->pagesize; | |||
if (trim($ctag->GetInnerText()) == "") { | |||
$InnerText = GetSysTemplets("list_fulllist.htm"); | |||
} else { | |||
$InnerText = trim($ctag->GetInnerText()); | |||
} | |||
$this->dtp->Assign( | |||
$tagid, | |||
$this->GetArcList( | |||
$limitstart, | |||
$row, | |||
$ctag->GetAtt("col"), | |||
$ctag->GetAtt("titlelen"), | |||
$ctag->GetAtt("listtype"), | |||
$ctag->GetAtt("orderby"), | |||
$InnerText, | |||
$ctag->GetAtt("tablewidth"), | |||
$ismake, | |||
$ctag->GetAtt("orderway") | |||
) | |||
); | |||
} else if ($ctag->GetName() == "pagelist") { | |||
$list_len = trim($ctag->GetAtt("listsize")); | |||
$ctag->GetAtt("listitem") == "" ? $listitem = "index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem"); | |||
if ($list_len == "") { | |||
$list_len = 3; | |||
} | |||
if ($ismake == 0) { | |||
$this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem)); | |||
} else { | |||
$this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem)); | |||
} | |||
} else if ($PageNo != 1 && $ctag->GetName() == 'field' && $ctag->GetAtt('display') != '') { | |||
$this->dtp->Assign($tagid, ''); | |||
} | |||
} | |||
} | |||
/** | |||
* 获得要创建的文件名称规则 | |||
* | |||
* @access public | |||
* @param string $typeid 栏目id | |||
* @param string $wname | |||
* @param string $typedir 栏目目录 | |||
* @param string $defaultname 默认名称 | |||
* @param string $namerule2 名称规则 | |||
* @return string | |||
*/ | |||
function GetMakeFileRule($typeid, $wname, $typedir, $defaultname, $namerule2) | |||
{ | |||
$typedir = MfTypedir($typedir); | |||
if ($wname == 'index') { | |||
return $typedir.'/'.$defaultname; | |||
} else { | |||
$namerule2 = str_replace('{tid}', $typeid, $namerule2); | |||
$namerule2 = str_replace('{typedir}', $typedir, $namerule2); | |||
return $namerule2; | |||
} | |||
} | |||
/** | |||
* 获得一个单列的文档列表 | |||
* | |||
* @access public | |||
* @param int $limitstart 限制开始 | |||
* @param int $row 行数 | |||
* @param int $col 列数 | |||
* @param int $titlelen 标题长度 | |||
* @param int $infolen 描述长度 | |||
* @param int $imgwidth 图片宽度 | |||
* @param int $imgheight 图片高度 | |||
* @param string $listtype 列表类型 | |||
* @param string $orderby 排列顺序 | |||
* @param string $innertext 底层模板 | |||
* @param string $tablewidth 表格宽度 | |||
* @param string $ismake 是否编译 | |||
* @param string $orderWay 排序方式 | |||
* @return string | |||
*/ | |||
function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc') | |||
{ | |||
global $cfg_list_son; | |||
$typeid = $this->TypeID; | |||
if ($row == '') $row = 10; | |||
if ($limitstart == '') $limitstart = 0; | |||
if ($titlelen == '') $titlelen = 100; | |||
if ($listtype == '') $listtype = "all"; | |||
if ($orderby == '') $orderby = 'id'; | |||
else $orderby = strtolower($orderby); | |||
if ($orderWay == '') $orderWay = 'desc'; | |||
$tablewidth = str_replace("%", "", $tablewidth); | |||
if ($tablewidth == '') $tablewidth = 100; | |||
if ($col == '') $col = 1; | |||
$colWidth = ceil(100 / $col); | |||
$tablewidth = $tablewidth."%"; | |||
$colWidth = $colWidth."%"; | |||
$innertext = trim($innertext); | |||
if ($innertext == '') $innertext = GetSysTemplets('list_sglist.htm'); | |||
//排序方式 | |||
$ordersql = ''; | |||
if ($orderby == 'senddate' || $orderby == 'id') { | |||
$ordersql = " ORDER BY arc.aid $orderWay"; | |||
} else if ($orderby == 'hot' || $orderby == 'click') { | |||
$ordersql = " ORDER BY arc.click $orderWay"; | |||
} else { | |||
$ordersql = " ORDER BY arc.aid $orderWay"; | |||
} | |||
$addField = 'arc.'.join(',arc.', $this->ListFields); | |||
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 | |||
if (preg_match('/hot|click/', $orderby) || $this->sAddTable) { | |||
$query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row"; | |||
} | |||
//普通情况先从arctiny表查出id,然后按id查询速度非常快 | |||
else { | |||
$t1 = ExecTime(); | |||
$ids = array(); | |||
$nordersql = str_replace('.aid', '.id', $ordersql); | |||
$query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} $nordersql LIMIT $limitstart,$row"; | |||
$this->dsql->SetQuery($query); | |||
$this->dsql->Execute(); | |||
while ($arr = $this->dsql->GetArray()) { | |||
$ids[] = $arr['id']; | |||
} | |||
$idstr = join(',', $ids); | |||
if ($idstr == '') { | |||
return ''; | |||
} else { | |||
$query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.aid IN($idstr) AND arc.arcrank >-1 $ordersql"; | |||
} | |||
$t2 = ExecTime(); | |||
} | |||
$this->dsql->SetQuery($query); | |||
$this->dsql->Execute('al'); | |||
$t2 = ExecTime(); | |||
$artlist = ''; | |||
$this->dtp2->LoadSource($innertext); | |||
$GLOBALS['autoindex'] = 0; | |||
for ($i = 0; $i < $row; $i++) { | |||
if ($col > 1) { | |||
$artlist .= "<div>\r\n"; | |||
} | |||
for ($j = 0; $j < $col; $j++) { | |||
if ($row = $this->dsql->GetArray("al")) { | |||
$GLOBALS['autoindex']++; | |||
$ids[$row['aid']] = $row['id'] = $row['aid']; | |||
//处理一些特殊字段 | |||
$row['ismake'] = 1; | |||
$row['money'] = 0; | |||
$row['arcrank'] = 0; | |||
$row['filename'] = ''; | |||
$row['filename'] = $row['arcurl'] = GetFileUrl( | |||
$row['id'], | |||
$row['typeid'], | |||
$row['senddate'], | |||
$row['title'], | |||
$row['ismake'], | |||
$row['arcrank'], | |||
$row['namerule'], | |||
$row['typedir'], | |||
$row['money'], | |||
$row['filename'], | |||
$row['moresite'], | |||
$row['siteurl'], | |||
$row['sitepath'] | |||
); | |||
$row['typeurl'] = GetTypeUrl( | |||
$row['typeid'], | |||
MfTypedir($row['typedir']), | |||
$row['isdefault'], | |||
$row['defaultname'], | |||
$row['ispart'], | |||
$row['namerule2'], | |||
$row['moresite'], | |||
$row['siteurl'], | |||
$row['sitepath'] | |||
); | |||
if ($row['litpic'] == '-' || $row['litpic'] == '') { | |||
$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']; | |||
} | |||
$row['picname'] = $row['litpic']; | |||
$row['pubdate'] = $row['senddate']; | |||
$row['stime'] = GetDateMK($row['pubdate']); | |||
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>"; | |||
$row['fulltitle'] = $row['title']; | |||
$row['title'] = cn_substr($row['title'], $titlelen); | |||
if (preg_match('/b/', $row['flag'])) { | |||
$row['title'] = "".$row['title'].""; | |||
} | |||
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>"; | |||
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl']; | |||
$row['memberurl'] = $GLOBALS['cfg_memberurl']; | |||
$row['templeturl'] = $GLOBALS['cfg_templeturl']; | |||
//编译附加表里的数据 | |||
foreach ($row as $k => $v) $row[strtolower($k)] = $v; | |||
foreach ($this->ChannelUnit->ChannelFields as $k => $arr) { | |||
if (isset($row[$k])) { | |||
$row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]); | |||
} | |||
} | |||
if (is_array($this->dtp2->CTags)) { | |||
foreach ($this->dtp2->CTags as $k => $ctag) { | |||
if ($ctag->GetName() == 'array') { | |||
//传递整个数组,在runphp模式中有特殊作用 | |||
$this->dtp2->Assign($k, $row); | |||
} else { | |||
if (isset($row[$ctag->GetName()])) { | |||
$this->dtp2->Assign($k, $row[$ctag->GetName()]); | |||
} else { | |||
$this->dtp2->Assign($k, ''); | |||
} | |||
} | |||
} | |||
} | |||
$artlist .= $this->dtp2->GetResult(); | |||
} //if hasRow | |||
}//Loop Col | |||
if ($col > 1) { | |||
$i += $col - 1; | |||
$artlist .= "</div>\r\n"; | |||
} | |||
}//Loop Line | |||
$t3 = ExecTime(); | |||
$this->dsql->FreeResult('al'); | |||
return $artlist; | |||
} | |||
/** | |||
* 获取静态的分页列表 | |||
* | |||
* @access public | |||
* @param int $list_len 列表宽度 | |||
* @param string $listitem 列表样式 | |||
* @return string | |||
*/ | |||
function GetPageListST($list_len, $listitem = "index,end,pre,next,pageno") | |||
{ | |||
$prepage = ""; | |||
$nextpage = ""; | |||
$prepagenum = $this->PageNo - 1; | |||
$nextpagenum = $this->PageNo + 1; | |||
if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) { | |||
$list_len = 3; | |||
} | |||
$totalpage = ceil($this->TotalResult / $this->pagesize); | |||
if ($totalpage <= 1 && $this->TotalResult > 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>"; | |||
} | |||
if ($this->TotalResult == 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>"; | |||
} | |||
$purl = $this->GetCurUrl(); | |||
$maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>"; | |||
$tnamerule = $this->GetMakeFileRule($this->Fields['id'], "list", $this->Fields['typedir'], $this->Fields['defaultname'], $this->Fields['namerule2']); | |||
$tnamerule = preg_replace("/^(.*)\//", '', $tnamerule); | |||
//获得上一页和首页的链接 | |||
if ($this->PageNo != 1) { | |||
$prepage .= "<li class='page-item'><a class='page-link' href='".str_replace("{page}", $prepagenum, $tnamerule)."'>上一页</a></li>\r\n"; | |||
$indexpage = "<li class='page-item'><a class='page-link' href='".str_replace("{page}", 1, $tnamerule)."'>首页</a></li>\r\n"; | |||
} else { | |||
$indexpage = "<li class='page-item'>首页</li>\r\n"; | |||
} | |||
//下一页和未页的链接 | |||
if ($this->PageNo != $totalpage && $totalpage > 1) { | |||
$nextpage .= "<li class='page-item'><a class='page-link' href='".str_replace("{page}", $nextpagenum, $tnamerule)."'>下一页</a></li>\r\n"; | |||
$endpage = "<li class='page-item'><a class='page-link' href='".str_replace("{page}", $totalpage, $tnamerule)."'>末页</a></li>\r\n"; | |||
} else { | |||
$endpage = "<li class='page-item'><a class='page-link'>末页</a></li>"; | |||
} | |||
//option链接 | |||
$optionlist = ""; | |||
//获得数字链接 | |||
$listdd = ""; | |||
$total_list = $list_len * 2 + 1; | |||
if ($this->PageNo >= $total_list) { | |||
$j = $this->PageNo - $list_len; | |||
$total_list = $this->PageNo + $list_len; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} else { | |||
$j = 1; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} | |||
for ($j; $j <= $total_list; $j++) { | |||
if ($j == $this->PageNo) { | |||
$listdd .= "<li class='page-item active'><a class='page-link'>$j</a></li>\r\n"; | |||
} else { | |||
$listdd .= "<li class='page-item'><a class='page-link' href='".str_replace("{page}", $j, $tnamerule)."'>".$j."</a></li>\r\n"; | |||
} | |||
} | |||
$plist = ""; | |||
if (preg_match('/info/i', $listitem)) { | |||
$plist .= $maininfo.' '; | |||
} | |||
if (preg_match('/index/i', $listitem)) { | |||
$plist .= $indexpage.' '; | |||
} | |||
if (preg_match('/pre/i', $listitem)) { | |||
$plist .= $prepage.' '; | |||
} | |||
if (preg_match('/pageno/i', $listitem)) { | |||
$plist .= $listdd.' '; | |||
} | |||
if (preg_match('/next/i', $listitem)) { | |||
$plist .= $nextpage.' '; | |||
} | |||
if (preg_match('/end/i', $listitem)) { | |||
$plist .= $endpage.' '; | |||
} | |||
if (preg_match('/option/i', $listitem)) { | |||
$plist .= $optionlist; | |||
} | |||
return $plist; | |||
} | |||
/** | |||
* 获取动态的分页列表 | |||
* | |||
* @access public | |||
* @param int $list_len 列表宽度 | |||
* @param string $listitem 列表样式 | |||
* @return string | |||
*/ | |||
function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno") | |||
{ | |||
global $nativeplace, $infotype, $keyword; | |||
if (empty($nativeplace)) $nativeplace = 0; | |||
if (empty($infotype)) $infotype = 0; | |||
if (empty($keyword)) $keyword = ''; | |||
$prepage = $nextpage = ''; | |||
$prepagenum = $this->PageNo - 1; | |||
$nextpagenum = $this->PageNo + 1; | |||
if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) { | |||
$list_len = 3; | |||
} | |||
$totalpage = ceil($this->TotalResult / $this->pagesize); | |||
if ($totalpage <= 1 && $this->TotalResult > 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>"; | |||
} | |||
if ($this->TotalResult == 0) { | |||
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>"; | |||
} | |||
$purl = $this->GetCurUrl(); | |||
$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&"; | |||
$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />\r\n"; | |||
$hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />\r\n"; | |||
$hidenform = "<input type='hidden' name='infotype' value='$infotype' />\r\n"; | |||
$hidenform = "<input type='hidden' name='keyword' value='$keyword' />\r\n"; | |||
$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />\r\n"; | |||
$purl .= "?".$geturl; | |||
//获得上一页和下一页的链接 | |||
if ($this->PageNo != 1) { | |||
$prepage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; | |||
$indexpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=1'>首页</a></li>\r\n"; | |||
} else { | |||
$indexpage = "<li class='page-item disabled'><a class='page-link'>首页</a></li>\r\n"; | |||
} | |||
if ($this->PageNo != $totalpage && $totalpage > 1) { | |||
$nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; | |||
$endpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; | |||
} else { | |||
$endpage = "<li class='page-item disabled'><a class='page-link'>末页</a></li>"; | |||
} | |||
//获得数字链接 | |||
$listdd = ""; | |||
$total_list = $list_len * 2 + 1; | |||
if ($this->PageNo >= $total_list) { | |||
$j = $this->PageNo - $list_len; | |||
$total_list = $this->PageNo + $list_len; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} else { | |||
$j = 1; | |||
if ($total_list > $totalpage) { | |||
$total_list = $totalpage; | |||
} | |||
} | |||
for ($j; $j <= $total_list; $j++) { | |||
if ($j == $this->PageNo) { | |||
$listdd .= "<li class='page-item active'><a class='page-link'>$j</a></li>\r\n"; | |||
} else { | |||
$listdd .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; | |||
} | |||
} | |||
$plist = $indexpage.$prepage.$listdd.$nextpage.$endpage; | |||
return $plist; | |||
} | |||
/** | |||
* 获得当前的页面文件链接 | |||
* | |||
* @access private | |||
* @return string | |||
*/ | |||
function GetCurUrl() | |||
{ | |||
if (!empty($_SERVER["REQUEST_URI"])) { | |||
$nowurl = $_SERVER["REQUEST_URI"]; | |||
$nowurls = explode("?", $nowurl); | |||
$nowurl = $nowurls[0]; | |||
} else { | |||
$nowurl = $_SERVER["PHP_SELF"]; | |||
} | |||
return $nowurl; | |||
} | |||
}//End Class | |||
?> |