织梦如何实现自动更新主页功能
<?php
require_once (dirname(__FILE__) . "/../include/common.inc.php");
$row = $dsql->GetOne("Select uptime From `cmsxx_arccache` where md5hash = 'autonew';");
if(!is_array($row)) exit(autonew(5));
$interval=60; //时间 秒
if(time() - $row['uptime'] < $interval ) exit();
autonew($no);
function machom($no=''){
define('DEDEADMIN', ereg_replace("[/\\]{1,}",'/',dirname(__FILE__) ) );
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(dirname(__FILE__)."/../include/arc.partview.class.php");
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select * From cmsxx_homepageset");
$dsql->Close();
$templet=$row['templet'];
$position=$row['position'];
$homeFile = DEDEADMIN."/".$position;
$homeFile = str_replace("\\","/",$homeFile);
$homeFile = str_replace("//","/",$homeFile);
$templet = str_replace("{style}",$cfg_df_style,$templet);
$pv = new PartView();
$GLOBALS['_arclistEnv'] = 'index';
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
$pv->SaveToHtml($homeFile);
}
function autonew($no=''){
global $dsql;
$sql = "SELECT id FROM `cmsxx_archives` where arcrank <>'0' limit $no ;";
$dsql->SetQuery($sql);
$dsql->Execute();
while($row = $dsql->GetArray()){
$id = $row['id'];
$time = time() - rand(0,$interval * 10);
$dsql->ExecuteNoneQuery("Update `cmsxx_arctiny` set `arcrank`='0', `sortrank`='$time' where id = '$id';");
$dsql->ExecuteNoneQuery("Update `cmsxx_archives` set `arcrank`='0', `sortrank`='$time', `pubdate`='$time' where id = '$id';");
}
machom($no);
$dsql->ExecuteNoneQuery("Update `cmsxx_arccache` set `uptime`=".time()." where md5hash = 'autonew'");
}
?>

扫码添加技术【解决问题】
专注企业网站建设、网站安全16年。
承接:企业网站建设、网站修改、网站改版、BUG修复、问题处理、二次开发、PSD转HTML、网站被黑、网站漏洞修复等。
专业解决各种疑难杂症,您有任何网站问题都可联系我们技术人员。
本文来自博客园,作者:黄文Rex,转载请注明原文链接:https://www.cnblogs.com/hwrex/p/18351639

浙公网安备 33010602011771号