python更新织梦网站_怎么让dedecms织梦网站首页自动更新

展开全部

首页自62616964757a686964616fe4b893e5b19e31333363386130动更新用到js和php:

在/plus目录下新建autoupdate.php文件

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

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

include( $fpath );

if(empty($last_time)){

$last_time = 0;

}

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

{

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

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

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

$templet = "default/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 );

}

?>

在首页引入以下js:

以上就可以刷新首页了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值