不会吧,原来高手们都是半夜上网的啊,学习中。。。。
忘记说了,小弟已在帝国CMS的4.6和5.0、5.1版下测试使用正常。现已有如下网站正在使用该功能: www.krong.net www.jiedu.org www.shoukang.org
代码贴出来算了: 创建MEMORY表的代码,文件名e/autoRehtml/install.php 运行一次即可。
<?php // Version: 2009-2-14 // Author: wongkelly@163.com
require("../class/connect.php"); include("../class/db_sql.php"); include("../class/config.php"); include("../class/class.php"); include("../class/functions.php"); include("../class/t_functions.php");
$link=db_connect(); $empire=new mysqlquery();
$empire->query("CREATE TABLE IF NOT EXISTS `phome_auto_rehtml` (". "`classid` smallint(6) NOT NULL DEFAULT '0',". "`update_time` int(11) DEFAULT NULL,". "PRIMARY KEY (`classid`)". ") ENGINE=MEMORY;");
db_close(); $empire=null;
echo "数据库建立成功!"; ?>
自动刷新的代码,文件名e/autoRehtml/index.php 用js方式调用,根据classid刷新指定栏目,如无classid则刷新首页
<?php // Version: 2009-2-14 // Author: wongkelly@163.com
require("../class/connect.php"); include("../class/db_sql.php"); include("../class/config.php"); include("../class/class.php"); include("../class/functions.php"); include("../class/t_functions.php");
// -------------- <config> -------------
//重新刷新首页间隔秒数 $auto_reIndex_interval=600;
//重新刷新栏目页间隔秒数 $auto_reList_interval=600;
// -------------- </config> -------------
$link=db_connect(); $empire=new mysqlquery();
$classid=(int)$_GET['classid'];
// check first $r=$empire->fetch1("select count(*) from {$dbtbpre}auto_rehtml where classid=$classid"); if ($r[0]==0) $empire->query1("insert into {$dbtbpre}auto_rehtml (classid, update_time) values($classid, 0)");
// check interval $r=$empire->fetch1("select unix_timestamp()-update_time from {$dbtbpre}auto_rehtml where classid=$classid"); echo "//".$r[0];
$update_time_sql="update {$dbtbpre}auto_rehtml set update_time=unix_timestamp() where classid=$classid"; if ($classid==0) //reIndex { if ($r[0]>$auto_reIndex_interval) { echo "reIndex"; $empire->query1($update_time_sql); ReIndex(); } } else //reList { if ($r[0]>$auto_reList_interval) { echo "reList"; $empire->query1($update_time_sql); ReListHtml($classid, 0); } } db_close(); $empire=null; ?>
|