织梦如何实现自动更新主页功能?
推荐学习:织梦cms
织梦dedecms实现自动更新主页功能
<?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'"); } ?>
以上就是织梦如何实现自动更新主页功能的详细内容。