# 帝国CMS自动刷新首页自定义列表的方法

*Published:* 2024-03-26
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2024年3月26日，已超过 180天没有更新



实现方法如下

在首页模板中加入下面代码,尽量放在底部.

代码如下：

```
<script language=”javascript” type=”text/javascript” src=”/e/htmlindex/index_html.php”></script>
```

在 /e/ 建立文件夹 htmlindex 并设置 777权限,将下面代码保存在 /e/htmlindex/index\_html.php

代码如下：

```
<?php

require("../class/connect.php");
include("../class/db_sql.php");
include("../config/config.php");
include("../class/functions.php");
include("../class/t_functions.php");
require LoadLang("pub/fun.php");
require("../data/dbcache/class.php");
require("../data/dbcache/MemberLevel.php");
include("../class/chtmlfun.php");
$link=db_connect();
$empire=new mysqlquery();
//更新首页
$indextemp=GetIndextemp();//取得模板
NewsBq($classid,$indextemp,1,0);
insert_dolog("");//操作日志
//跟新自定义列表
$b=0;
$sql=$empire->query("select listid,pagetitle,filepath,filetype,totalsql,listsql,maxnum,lencord,listtempid,pagekeywords,pagedescription from {$dbtbpre}enewsuserlist where listid>0 order by listid limit ".$public_r['reuserlistnum']);
while($r=$empire->fetch($sql))
{
    $b=1;
    $newstart=$r[listid];
    ReUserlist($r,"");
}
echo '更新首页，自定义列表页成功';
db_close();

?>
```

[![](https://www.xarjtc.com/wp-content/uploads/2024/03/2d713712f5cd6f9.webp)](https://www.xarjtc.com/wp-content/uploads/2024/03/2d713712f5cd6f9.webp)

然后在宝塔的计划任务中设置好定时访问这个连接即可。