织梦实现自动更新主页功能的方法?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!
织梦如何实现自动更新主页功能?
推荐学习:织梦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'");
}
?>
感谢各位的阅读!看完上述内容,你们对织梦实现自动更新主页功能的方法大概了解了吗?希望文章内容对大家有所帮助。如果想了解更多相关文章内容,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。