织梦如何实现自动更新主页功能

织梦如何实现自动更新主页功能?

推荐学习:织梦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'] GetOne("Select * From cmsxx_homepageset"); 
$dsql-&gt;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-&gt;SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet); 
$pv-&gt;SaveToHtml($homeFile); 
} 
function autonew($no=''){ 
  global $dsql; 
    $sql = "SELECT id FROM `cmsxx_archives` where arcrank '0'  limit $no ;"; 
    $dsql-&gt;SetQuery($sql); 
    $dsql-&gt;Execute(); 
    while($row = $dsql-&gt;GetArray()){ 
        $id = $row['id']; 
        $time = time() - rand(0,$interval * 10); 
        $dsql-&gt;ExecuteNoneQuery("Update `cmsxx_arctiny` set `arcrank`='0', `sortrank`='$time' where id = '$id';"); 
        $dsql-&gt;ExecuteNoneQuery("Update `cmsxx_archives` set `arcrank`='0', `sortrank`='$time', `pubdate`='$time' where id = '$id';"); 
    } 
    machom($no); 
    $dsql-&gt;ExecuteNoneQuery("Update `cmsxx_arccache` set  `uptime`=".time()." where md5hash = 'autonew'"); 
} 
?&gt;
登录后复制

以上就是织梦如何实现自动更新主页功能的详细内容,更多请关注慧达AI工具网其它相关文章!

转载请说明出处 内容投诉内容投诉
慧达seo-站长工具-seo工具-采集-发布-AI文章生成发布工具 » 织梦如何实现自动更新主页功能

慧达AI专注站群seo管理工具

查看演示 官网购买