加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_汕头站长网 (https://www.0754zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > 网站设计 > 教程 > 正文

帝国cms中实现用户访问页面自动生成html

发布时间:2022-06-28 14:11:45 所属栏目:教程 来源:互联网
导读:原因:帝国cms在批量生成文件的时候非常慢,更改了一次模板,往往要更新半天. 思路:删除所有html-利用nginx匹配未生成的html-php生成html,如果nginx 检测html已经生成,则直接展示,不跳转到php. 实现代码如下: location /{ alias /home/web/xxx.com/; if (!-e
  原因:帝国cms在批量生成文件的时候非常慢,更改了一次模板,往往要更新半天.
 
  思路:删除所有html->利用nginx匹配未生成的html->php生成html,如果nginx 检测html已经生成,则直接展示,不跳转到php.
 
  实现代码如下:
 
  location /{
  alias /home/web/xxx.com/;
  if (!-e $request_filename) {
  rewrite /(.*)/(.*).html$ /chtml.php?classid=1&id=$2&ssid=$2&check=checkcode;
  }
  }  
  以上配置,用户访问不存在的html的时候会自动展示chtml.php里面的内容,网址不会跳转,相当于是在当前URL下.
 
  3.php生成:

  文件1修改:functions.php GetHtml 方法尾部新增一下代码,用于直接显示生成后的html:
 
  /* 直接展示html 2014-5-8    */
      $s_aid = $_GET['ssid'];
      $s_play = (int)$_GET['play'];
      $s_check = $_GET['check'];
      if($s_check=="checkcode"){
          if($s_aid && strstr($s_aid,"_play")){
              echo file_get_contents($file_p);
          }else{
              echo file_get_contents($file);
          }
      }
      /* 直接展示html 2014-5-8    */。
 
  文件2:chtml.php代码如下:
 
  <?php
  $check= stripslashes($_GET['check']);
  
  require('./class/connect.php');        //引入数据库配置文件和公共函数文件
  require('./class/db_sql.php');        //引入数据库操作文件
  require("./class/functions.php");
  require("./class/t_functions.php");
  require("./data/dbcache/class.php");
  require("./data/dbcache/MemberLevel.php");
  require('./class/chtmlfun.php');  
  $link=db_connect();                //连接MYSQL
  $empire=new mysqlquery();        //声明数据库操作类
  
  if($check=="checkcode"){//checkcode 对应nginx配置的 checkcode
  //开源软件:phpfensi.com
  ReSingleInfo('userid','username');//你的帝国后台 id 和 用户名
  }
     
  db_close();   //关闭MYSQL链接
  $empire=null;  //注消操作类变量
      
  ?>  
  文件3修改:
 
  e/class/chtmlfun.php
 
  找到ReSingleInfo方法,在下面之前:
 
  $sql=$empire->query(“select * from {$dbtbpre}ecms_”.$class_r[$classid][tbname].” where “.$add);  
  新增:如下代码:
 
  /* 前台生成单个文件 2014-5-8 shanmao*/
  $s_aid = (int)$_GET['ssid'];
  if($s_aid>0){
      $add="id=$s_aid";
      $classid=58;//你的栏目id
  }
  /* 前台生成单个文件 */。

(编辑:云计算网_汕头站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!