曹操读书--知行合一,化于无形

删除html后,如何让帝国cms怎么实现访客访问页面自动生成html

作者 :会员投稿 2021-04-09 08:52:19 审稿人 : admin 围观 : 评论

本文实例讲述了帝国cms实现用户访问页面自动生成html的方法。分享给大家供大家参考。具体分析如下:syt曹操读书网

原因:对于服务器资源有限但是数据量非常庞大的网站来说,使用帝国cms在批量生成全部文件的时候速度比较慢,更改了一次模板,往往要更新很久.syt曹操读书网

思路:删除所有html->利用nginx匹配未生成的html->php生成html,如果nginx 检测html已经生成,则直接展示,不跳转到php.syt曹操读书网

实现代码如下:syt曹操读书网
 syt曹操读书网

复制代码syt曹操读书网
代码如下:syt曹操读书网
location /{syt曹操读书网
alias /home/web/xxx.com/;syt曹操读书网
if (!-e $request_filename) {syt曹操读书网
rewrite /(.*)/(.*).html$ /chtml.php?classid=1&id=$2&ssid=$2&check=checkcode;syt曹操读书网
}syt曹操读书网
}syt曹操读书网
以上配置,用户访问不存在的html的时候会自动展示chtml.php里面的内容,网址不会跳转,相当于是在当前URL下.

 syt曹操读书网

3.php生成:syt曹操读书网

文件1:chtml.php代码如下:syt曹操读书网
 syt曹操读书网

复制代码syt曹操读书网
代码如下:syt曹操读书网
<?phpsyt曹操读书网
$check= stripslashes($_GET['check']);syt曹操读书网
syt曹操读书网
require('./class/connect.php'); //引入数据库配置文件和公共函数文件syt曹操读书网
require('./class/db_sql.php'); //引入数据库操作文件syt曹操读书网
require("./class/functions.php");syt曹操读书网
require("./class/t_functions.php");syt曹操读书网
require("./data/dbcache/class.php");syt曹操读书网
require("./data/dbcache/MemberLevel.php");syt曹操读书网
require('./class/chtmlfun.php');syt曹操读书网
$link=db_connect(); //连接MYSQLsyt曹操读书网
$empire=new mysqlquery(); //声明数据库操作类syt曹操读书网
syt曹操读书网
if($check=="checkcode"){//checkcode 对应nginx配置的 checkcodesyt曹操读书网
ReSingleInfo('userid','username');//你的帝国后台 id 和 用户名syt曹操读书网
}syt曹操读书网
syt曹操读书网
db_close(); //关闭MYSQL链接syt曹操读书网
$empire=null; //注消操作类变量syt曹操读书网
?>syt曹操读书网
文件2修改:

 syt曹操读书网

e/class/chtmlfun.phpsyt曹操读书网

找到ReSingleInfo方法,在下面之前:syt曹操读书网
 syt曹操读书网

复制代码syt曹操读书网
代码如下:syt曹操读书网
$sql=$empire->query("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add);syt曹操读书网
新增:如下代码:syt曹操读书网
syt曹操读书网
复制代码syt曹操读书网
代码如下:syt曹操读书网
/* 前台生成单个文件 2014-5-8 shanmao*/syt曹操读书网
$s_aid = (int)$_GET['ssid'];syt曹操读书网
if($s_aid>0){syt曹操读书网
$add="id=$s_aid";syt曹操读书网
$classid=58;//你的栏目idsyt曹操读书网
}syt曹操读书网
/* 前台生成单个文件 */syt曹操读书网
文件3修改:functions.php GetHtml 方法尾部新增一下代码,用于直接显示生成后的html:syt曹操读书网
syt曹操读书网
复制代码syt曹操读书网
代码如下:syt曹操读书网
/* 直接展示html 2014-5-8 */syt曹操读书网
$s_aid = $_GET['ssid'];syt曹操读书网
$s_play = (int)$_GET['play'];syt曹操读书网
$s_check = $_GET['check'];syt曹操读书网
if($s_check=="checkcode"){syt曹操读书网
if($s_aid && strstr($s_aid,"_play")){syt曹操读书网
echo file_get_contents($file_p);syt曹操读书网
}else{syt曹操读书网
echo file_get_contents($file);syt曹操读书网
}syt曹操读书网
}syt曹操读书网
/* 直接展示html 2014-5-8 */

 syt曹操读书网

希望本文所述对大家的帝国cms建站有所帮助。syt曹操读书网

相关文章

留言与评论(共有 0 条评论)
   
验证码:
标签列表
    SQL Error: select * from ***_enewstags order by num DESC limit 24