织梦模板DEDECMS如何实现自动更新主页功能的代码

叶子小小的,碧绿碧绿的,花儿小小的,好可爱。紫红色的玫瑰花在风中翩翩起舞,玫瑰花树枝上还有调皮又可爱的小刺,你可要当心哦!你看,那个大仙人球旁围着8个小仙人球,好像一家人聚在一起,多欢快呀!
<?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'"); 
} 
?> 

到此这篇关于织梦模板DEDECMS如何实现自动更新主页功能的代码就介绍到这了。内心强大比什么都重要你要照顾好自己;承认自己的平凡,但是努力向好的方向发展;可以平静面对生活,安然的听从自己内心的感受,不受其他影响,你可以,请不要虚度。更多相关织梦模板DEDECMS如何实现自动更新主页功能的代码内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: 自动更新