PHPCMS 详情页静态化
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class game extends admin {
public function __construct() {
parent::__construct();
$this->game = pc_base::load_model('game_model');
$this->db = pc_base::load_model('gamedown_model');
$this->html_root = 'D:\wamp\www\record\/html/game/';
}
/**-- 首页的每日推荐 --**/
public function game_list(){
if($_POST['submit']){
$id = $_POST['id'];
if($id){
$this->game->update(array('content'=>$id),array('id'=>1));
showmessage('修改成功');
}
}else{
$arr = $this->game->get_one(array('id'=>1));
$id = $arr['content'];
include $this->admin_tpl('lists');
}
}
/**-- 游戏分类 静态化 --**/
public function static_lists(){
$url = APP_PATH."index.php?m=game&c=index&a=lists";
$path = $this->html_root.'game/single/lists.html';
$this->php_to_html($path,$url);
}
/**-- 越狱专享 静态化 --**/
public function static_yueyu(){
$url = APP_PATH."index.php?m=game&c=index&a=yueyu";
$path = $this->html_root.'game/single/yueyu.html';
$this->php_to_html($path,$url);
}
/**-- 详情页 静态化 --**/
public function static_show(){
if($_GET['submit']){ }else{ include $this->admin_tpl('static');
}
}
/**-- 去检查更新 --**/
function static_now(){
$type = isset($_GET['type']) ? intval($_GET['type']) : $_GET['type'];
$num = isset($_GET['num']) ? intval($_GET['num']) : $_GET['num'];
$page = isset($_GET['page']) ? $_GET['page'] : 0; if(!$type && !$num){
exit('<h1>参数错误!</h1>');
}
// 根据类型 确定要更新的范围
if(isset($type) && $type == 2){ //更新全部
$total = $this->db->count();
$order = 'id';
}else{
$total = $num;
$order = 'id desc';
}
$total_page = ceil($total/10);
$limit = (10*$page).',10';
$data = $this->db->select('','id,catid', $limit,$order);
foreach ($data as $k => $v) {
$path = $this->html_root.$v['catid'].'/'.$v['id'].'.html';
$url = APP_PATH."index.php?m=game&c=index&a=show&catid=".$v['catid']."&id=".$v['id'];
$this->php_to_html($path,$url);
}
if ($total_page > $page) {
showmessage('正在更新'.($page*10).'/'.$total.'<script type="text/javascript">location.href="?m=game&c=game&a=static_now&page='.($page+1).'&num='.$num.'&type='.$type.'&pc_hash='.$_SESSION['pc_hash'].'"</script>', '?m=game&c=game&a=static_now&page='.($page+1).'&total='.$total);
} else {
showmessage("更新完成!");
}
}
/**-- 生成 HTML 静态页面 --**/
private function php_to_html($path,$url){
//D:\wamp\www\record\/html/2014/dongzuogame_0717/109.html
//$path = 'D:\wamp\www\record/html/game/';
$html = file_get_contents($url);
ob_start();
echo $html;
$this->createhtml($path);
}
/**
* 写入文件
* @param $file 文件路径
* @param $copyjs 是否复制js,跨站调用评论时,需要该js
*/
private function createhtml($file, $copyjs = '') {
$data = ob_get_contents();
ob_clean();
$dir = dirname($file);
if(!is_dir($dir)) {
mkdir($dir, 0777,1);
}
if ($copyjs && !file_exists($dir.'/js.html')) {
@copy(PC_PATH.'modules/content/templates/js.html', $dir.'/js.html');
}
$strlen = file_put_contents($file, $data);
@chmod($file,0777);
if(!is_writable($file)) {
$file = str_replace(PHPCMS_PATH,'',$file);
showmessage(L('file').':'.$file.'<br>'.L('not_writable'));
}
return $strlen;
}
}
?>
PHPCMS 详情页静态化的更多相关文章
- Freemarker商品详情页静态化服务调用处理
--------------------------------------------------------------------------------------------- [版权申明: ...
- FreeMarker-网页静态化
网页静态化解决方案在实际开发中运用比较多,例如新闻网站,门户网站中的新闻频道或者是文章类的频道. 网页静态化技术和缓存技术的共同点都是为了减轻数据库的访问压力,但是具体的应用场景不同,缓存比较适合小规 ...
- 阶段5 3.微服务项目【学成在线】_day09 课程预览 Eureka Feign_09-课程详情页面静态化-静态页面测试
4 课程详情页面静态化 4.1 静态页面测试 4.1.1 页面内容组成 我们在编写一个页面时需要知道哪些信息是静态信息,哪些信息为动态信息,下图是页面的设计图: 打开静态页面,观察每部分的内容. 红色 ...
- Phpcms 详情页显示所属栏目的同级栏目
Phpcms详情页是不显示所属栏目的同级栏目的,如果按下面的方式 {loop subcat($parentid) $v} <li{if $v[catid]==$catid} class=&quo ...
- Day13_商品详情及静态化
学于黑马和传智播客联合做的教学项目 感谢 黑马官网 传智播客官网 微信搜索"艺术行者",关注并回复关键词"乐优商城"获取视频和教程资料! b站在线视频 0.学习 ...
- jeecms 单页静态化方法
在论坛上去搜,都说可以需要在模型中配置增加字段,看了云里雾里,调试源代码发现原因,方法如下: 步骤一:改模型 模型管理->"单页“栏目模型->添加: channelStatic( ...
- TP-网页静态化
首先放上一张某手册中的一段代码: 我们要想在TP框架中执行网页静态化,在这段代码的基础上稍加添加就可以了: 在TP5框架中,为了方便寻找模板文件与生成的静态文件,我们将模板文件以及生成的静态文件放在p ...
- DJANGO-天天生鲜项目从0到1-007-首页静态化与缓存
本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...
- jeecms 2012 源码分析(2) 前台栏目页静态化分析
还是要说到web.xml文件 <welcome-file-list> <welcome-file>index.html</welcome-file> <wel ...
随机推荐
- msf常用命令
msf > search -r great -t exploits search命令查找rank为great的exploit msf > setg RHOST 192.168.1.102 ...
- BodyContent揭秘及定制复杂的JSP标签
BodyContent揭秘及定制复杂的JSP标签 标签: jspintegerwrapperclass设计模式 2010-08-30 11:30 4555人阅读 评论(0) 收藏 举报 分类: HT ...
- 初始化Direct3D
1.Direct3D概述 Direct3D是一套底层图形API,借助该API,我们能够利用硬件加速功能来绘制3D场景. 设备制造商将其产品支持的全部功能都实现到HAL中. 1.1 Direct3D提供 ...
- java正则表达式获取指定HTML标签的指定属性值
package com.mmq.regex; import java.util.ArrayList; import java.util.List; import java.util.regex.Mat ...
- 简单三段式状态机实验2-LCD12864
此实验是在“基于I2C EPPRPM(AT24C02B) + LCD12864实验”基础上,把LCD模块里的一段式状态机改成三段式,I2C EPPROM模块暂时未改出来,一步一步来吧,改完后代码下载到 ...
- js 选项卡
<html><head lang="en"> <meta charset="UTF-8"> <title>Tab ...
- IT人常用的网站
一.网页设计类 蓝色理想 http://www.blueidea.com 网页设计师联盟 http://www.68design.net 网页设计大本营 http://www.code-123.com ...
- openstack controller ha测试环境搭建记录(九)——配置nova(计算节点)
编辑所有节点的/etc/hosts:10.0.0.14 controller110.0.0.12 controller210.0.0.13 controller310.0.0.10 myvip10.0 ...
- c# 封装的文件夹操作类之复制文件夹
c# 封装的文件夹操作类之复制文件夹 一.复制文件夹原理: 1.递归遍历文件夹 2.复制文件 二.FolderHelper.cs /// <summary> /// 文件夹操作类 /// ...
- (简单) POJ 3984 迷宫问题,BFS。
Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, ...