+ 收藏我们

网站模板

网站模板搜索
404模板 营销型模板 外贸网站模板 单页模板 双语模板 标签大全

注册

织梦dedecms定时自动更新首页的方法

AB模板网 / 2021-09-18
dedecms织梦模板定时自动更新首页的方法如下:
 
1、在 根目录/plus 目录下新建一个php文件,命名为:autoindex.php
 
2、将以下代码复制到 autoindex.php 文件

 <?php

function sp_input( $text )

{

$text = trim( $text );

$text = htmlspecialchars( $text );

if (!get_magic_quotes_gpc())

return addslashes( $text );

else

return $text;

}

$autotime = 3600;//自动更新时间,单位为秒,这里我设为一小时,大家可以自行更改。

$fpath = "../data/last_time.inc";//记录更新时间文件,如果不能达到目的,请检查是否有读取权限。

include( $fpath );

if( empty($last_time))

$last_time = 0;

if( sp_input($_GET['renew'])=="now")

$last_time = 0;

if((time()-$last_time)>=$autotime )

{

define('DEDEADMIN', ereg_replace("[/\\]{1,}",'/',dirname(__FILE__) ) );

require_once(DEDEADMIN."/../include/common.inc.php");

require_once(DEDEINC."/arc.partview.class.php");

/*

$row = $dsql->GetOne("Select * From dede_homepageset");

$dsql->Close();

$templet=$row['templet'];

$position=$row['position'];

*/

$templet = “tnbjh/index.htm”;//这里是首页模板位置,当前是dede默认首面位置。

$position = "../index.html";

$homeFile = dirname(__FILE__)."/".$position;

$homeFile = str_replace("\\", "/", $homeFile );

$homeFile = str_replace( "//", "/", $homeFile );

$pv = new PartView();

$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet );

$pv -> SaveToHtml( $homeFile );

$pv -> Close();

$file = fopen( $fpath, "w");

fwrite( $file, "<?php\n");

fwrite( $file,"\$last_time=".time().";\n");

fwrite( $file, '?>' );

fclose( $file );

}

?>
3、在首页模板的<head></head>标签中加入如下代码
 
<script src="/plus/autoindex.php" language="javascript"></script>
 
以上就是本文章的内容,希望对大家有所帮助
文章搜集与网络,如有侵权请联系本站,转载请说明出处:https://www.adminbuy.cn/dedecmsjc/9351.html

有问题可以加入网站技术QQ群一起交流学习

本站vip会员 请加入AB模板网 VIP群(577645397) PS:加入时备注用户名或昵称

普通注册会员或访客 请加入AB模板网 技术交流群(818577662)

客服微信号:wwwadminbuycn

☉首先声明,只要是我们的vip会员全站所有资源均可以免费下载,不做任何限制(了解更多)

☉本站的源码不会像其它下载站一样植入大量的广告。

☉本站提供的网站源码,都是做好测试好发布的,均可放心使用。

☉本站提供的网站源码,均带数据及演示地址。可以在任一源码详情页查看演示地址。

☉为了vip利益的最大化,我们还提供了vip赠品(了解更多

☉如有其他问题,请加网站客服QQ(9490489)进行交流。

首页 pbootcms模板 html模板 会员中心
 
QQ在线咨询

推荐添加下面的微信客服

添加微信客服