📄 html.php
字号:
$Files = new Files;
if ($this->in[mode] == '') {
$string = $this->in['CateID'] . ',' . $this->in['refresh_index'] . ',' . $this->in['refresh_content'] . ',' . $this->in['include_sub'] . ',' . $this->in['content_num'] . ',';
if ($this->in['include_sub'] != '0') {
if ($this->in['CateID'] == '0') {
$keys = '';
foreach($Cate as $v) {
$keys .= $v[CateID] . '|';
}
} else {
$keys = $this->in[CateID] . '|';
$keys .= $this->getSub($this->in[CateID], '|');
}
} else $keys = $this->in[CateID];
$this->cache();
$this->Files->write(DIR_CACHE . '/task.txt', $string . $keys);
echo md5($string . $keys);
} elseif ($this->in[mode] = 'running') {
$t = $this->Files->read(DIR_CACHE . '/task.txt');
$tt = explode(',', $t);
if ($tt[1] == '1' && empty($this->in[refreshContent])&&$tt[3]) {
$c = explode('|', $tt[5]);
$this->CateID = $this->in[CateID] != '0'?$c[0]:$this->in[CateID];
$page = $this->index();
if (!$page) {
array_shift($c);
$N_id = $c[0];
if (empty($N_id) && $tt[2]) {
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshContent=1&TaskID='.$this->in[TaskID] ;
if ($tt[3] != '0') {
if ($tt[0] == '0') {
$keys = '';
foreach($Cate as $v) {
$keys .= $v[CateID] . '|';
}
} else {
$keys = $tt[0] . '|';
$keys .= $this->getSub($tt[0], '|');
}
} else $keys = $tt[0];
$tt[5] = $keys;
$t = implode(',', $tt);
$this->Files->write(DIR_CACHE . '/task.txt', $t);
$EndThread='1';
} elseif (!empty($N_id)) {
$tt[5] = implode('|', $c);
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshIndex=1&CateID=' . $N_id.'&TaskID='.$this->in[TaskID] ;
$t = implode(',', $tt);
$this->Files->write(DIR_CACHE . '/task.txt', $t);
$EndThread='1';
} else {
@unlink(DIR_CACHE . '/task.txt');
$EndThread='1';
echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating site finish </script>";
}
} else {
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshIndex=1&CateID=' . $this->CateID . '&page=' . $page.'&TaskID='.$this->in[TaskID];
}
// $Thread=$url;
$ThreadName = $this->in[TaskID];
}elseif($tt[1] == '1' && empty($this->in[refreshContent])&&$tt[3]=='0'){//不刷新子频道时
$ThreadName='refreshindex';
$this->CateID=$tt[5];
$page = $this->index();
if($page){
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshIndex=1&CateID=' . $tt[5] . '&page=' . $page.'&TaskID='.$this->in[TaskID];
}elseif($tt[2]){//刷新内容时
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshContent=1&TaskID='.$this->in[TaskID];
$EndThread='1';
}else $EndThread='1';
} elseif ($this->in[refreshContent]&&$tt[3]) {//刷新紫频道时
$ThreadName='refreshcontent';
$c = explode('|', $tt[5]);
$this->CateID = $c[0];
$this->content_num = $tt[4];
$page = $this->CateRefresh();
if (!$page) {
array_shift($c);
$N_id = $c[0];
$tt[5] = implode("|", $c);
if ($N_id == '') {
$url = '';
@unlink(DIR_CACHE . '/task.txt');
$EndThread='1';
} else {
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshContent=1&CateID=' . $N_id .'&TaskID='.$this->in[TaskID];
$this->Files->write(DIR_CACHE . '/task.txt', implode(',', $tt));
}
} else {
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshContent=1&CateID=' . $this->CateID . '&page=' . $page.'&TaskID='.$this->in[TaskID];
}
}elseif($this->in[refreshContent]&&$tt[3]=='0') {//不刷新子频道时
$ThreadName='refreshcontent';
$this->CateID = $tt[5];
$this->content_num = $t[4];
$page = $this->CateRefresh();
$ThreadName='refeshcontent';
if($page){
$url = 'index.php?module=html&act=refreshSite&mode=running&refreshContent=1&CateID=' . $tt[5] . '&page=' . $page.'&TaskID='.$this->in[TaskID];
}else{
@unlink(DIR_CACHE . '/task.txt');
$EndThread='1';
echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating site finish </script>";
}
}
if ($Thread != '')echo "<script language='JavaScript'>top.CrawlerTaskFrame.addThread(\"" . $Thread . "\" , \"" . $ThreadName . "\");</script>";
if($EndThread)echo"<script language='JavaScript'>endThread('".$ThreadName."')</script>";
$this->tpl->assign("url", $url);
$this->tpl->assign("Msg", $this->app->getSysMsg('jump', $url));
$this->tpl->display("admin/msg.html");
}
}
function cache()
{
include DIR_CACHE . 'cache_Cate.inc.php';
foreach($Cate as $tmp) {
$tmp[SubCate] = $this->getSub($tmp[CateID], ',');
$tmp[Nav] = $this->getNav($tmp[ParentList]);
$tmp[Navigation] = $this->getNavigation($tmp[ParentList]);
$tmp[URL] = getUrl($tmp[ResourceURL]);
$filename = DIR_CACHE . 'CateInfo/' . $tmp[CateID] . '.php';
$tmpfile = "<?php" . PHP_NEXTLINE . "//SSCMS cache file, DO NOT modify me!" . PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$CateInfo=" . var_export($tmp, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE . PHP_CLOSE_TAG;
$this->Files->write($filename, $tmpfile);
}
}
function getSub($CID, $sq = ',')
{
include DIR_CACHE . 'cache_Cate.inc.php';
$subcate = $CID;
foreach($Cate as $tmp) {
if ($tmp[ParentID] == $CID) {
$subcate .= $sq . $this->getSub($tmp[CateID], $sq);
}
}
return $subcate;
}
function getNav($list)
{
include DIR_CACHE . 'cache_Cate.inc.php';
$n = explode(',', $list);
$i = 0;
foreach($n as $nav) {
if ($nav != '-1') {
$i++;
$v[$i][CateID] = $Cate[$nav][CateID];
$v[$i][Title] = $Cate[$nav][Title];
}
}
return serialize($v);
}
function getNavigation($list)
{
include DIR_CACHE . 'cache_Cate.inc.php';
$n = explode(',', $list);
$i = 0;
krsort($n);
foreach($n as $nav) {
if ($nav != '-1') {
$v[$i][CateID] = $Cate[$nav][CateID];
$v[$i][Title] = $Cate[$nav][Title];
$v[$i][URL] = getUrl($Cate[$nav][ResourceURL]);
$i++;
}
}
return $v;
}
function MakeNavigation($id)
{
include DIR_CACHE . 'CateInfo/' . $id . '.php';
foreach($CateInfo[Navigation] as $key => $var) {
if ($key == 0) {
$Navigation = "<a href='{$var[URL]}' >{$var[Title]}</a>";
} else {
$Navigation .= " > <a href='{$var[URL]}' >{$var[Title]}</a>";
}
}
return $Navigation;
}
function index()
{
$where = $this->CateID == '0'?'':" WHERE CateID=" . $this->CateID;
$this->CateID = $this->CateID == '0'?'1':$this->CateID;
include DIR_CACHE . 'CateInfo/' . $this->CateID . '.php';
include DIR_CACHE . 'cache_PSN.inc.php';
$perpage = empty($CateInfo[PerPage])?'30':$CateInfo[PerPage];
$CateInfo[ListFileName] = empty($CateInfo[ListFileName])?'index.html':$CateInfo[ListFileName];
$apos = strpos($CateInfo[ListFileName], ".");
if (!$apos) {
$filename = $CateInfo[ListFileName];
$ext = ".html";
} else {
$filename = substr($CateInfo[ListFileName], 0, $apos);
$ext = substr($CateInfo[ListFileName], $apos + 1);
}
$this->in[page] = empty($this->in[page])?'1':$this->in[page];
$this->objDataSet->html = '1';
$this->objDataSet->filename = $filename;
$this->objDataSet->ext = $ext;
$this->objDataSet->pagenum = $this->in[page];
$query = "select * from " . $this->content_index . $where;
$data = $this->objDataSet->getList($query, $perpage);
$this->tpl->assign('CateInfo', $CateInfo);
$this->tpl->assign("total", $data->total());
$this->tpl->assign("fromto", $data->fromto());
$data->navchar = array($this->app->getSysMsg('firstpage'), '[<]', '[>]', $this->app->getSysMsg('endpage'));
$this->tpl->assign("navbar", $data->navbar(10));
$IndexTpl=empty($CateInfo[IndexTpl])?'default/index.html':$CateInfo[IndexTpl];
$string = $this->tpl->display($IndexTpl, '1');
preg_match("/{PSN:(\d)}(.*)/is", $CateInfo[ResourcePSN], $p);
$RPSN = $PSN_cache[$p[1]]['PSN'];
$RPSN = ltrim(rtrim(str_replace("Local::", "", $RPSN)));
$RPSN .= $p[2];
$RPSN .= "/";
if ($this->in[page] == '0' || $this->in[page] == '1') {
$target = $RPSN . $CateInfo[ListFileName];
} else
$target = $RPSN . $filename . '_' . $this->in[page] . '.' . $ext;
if (!empty($string))$this->Files->write($target, $string);
$this->in[page]?$page = $this->in[page]:$page = '1';
$page++;
echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating content " . $this->CateID . "index_" . $this->in[page] . ".html', 'refreshlist" . $this->CateID . "')</script>";
if ($page <= $data->totalpage) {
return $page;
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -