首頁 >CMS教程 >DEDECMS >織夢如何實現自動更新主頁功能

織夢如何實現自動更新主頁功能

藏色散人
藏色散人原創
2020-01-08 09:46:113350瀏覽

織夢如何實現自動更新主頁功能

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

推荐学习:织梦cms

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

<?php 
require_once (dirname(__FILE__) . "/../include/common.inc.php"); 
$row = $dsql->GetOne("Select uptime From `cmsxx_arccache` where md5hash = &#39;autonew&#39;;"); 
if(!is_array($row)) exit(autonew(5)); 
$interval=60;  //时间 秒 
if(time() - $row[&#39;uptime&#39;] < $interval ) exit(); 
autonew($no); 
function machom($no=&#39;&#39;){ 
define(&#39;DEDEADMIN&#39;, ereg_replace("[/\\]{1,}",&#39;/&#39;,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[&#39;templet&#39;]; 
$position=$row[&#39;position&#39;]; 
$homeFile = DEDEADMIN."/".$position; 
$homeFile = str_replace("\\","/",$homeFile); 
$homeFile = str_replace("//","/",$homeFile); 
$templet = str_replace("{style}",$cfg_df_style,$templet); 
$pv = new PartView(); 
$GLOBALS[&#39;_arclistEnv&#39;] = &#39;index&#39;; 
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet); 
$pv->SaveToHtml($homeFile); 
} 
function autonew($no=&#39;&#39;){ 
  global $dsql; 
    $sql = "SELECT id FROM `cmsxx_archives` where arcrank <>&#39;0&#39;  limit $no ;"; 
    $dsql->SetQuery($sql); 
    $dsql->Execute(); 
    while($row = $dsql->GetArray()){ 
        $id = $row[&#39;id&#39;]; 
        $time = time() - rand(0,$interval * 10); 
        $dsql->ExecuteNoneQuery("Update `cmsxx_arctiny` set `arcrank`=&#39;0&#39;, `sortrank`=&#39;$time&#39; where id = &#39;$id&#39;;"); 
        $dsql->ExecuteNoneQuery("Update `cmsxx_archives` set `arcrank`=&#39;0&#39;, `sortrank`=&#39;$time&#39;, `pubdate`=&#39;$time&#39; where id = &#39;$id&#39;;"); 
    } 
    machom($no); 
    $dsql->ExecuteNoneQuery("Update `cmsxx_arccache` set  `uptime`=".time()." where md5hash = &#39;autonew&#39;"); 
} 
?>

以上是織夢如何實現自動更新主頁功能的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn