<?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 详情页静态化的更多相关文章

  1. Freemarker商品详情页静态化服务调用处理

    --------------------------------------------------------------------------------------------- [版权申明: ...

  2. FreeMarker-网页静态化

    网页静态化解决方案在实际开发中运用比较多,例如新闻网站,门户网站中的新闻频道或者是文章类的频道. 网页静态化技术和缓存技术的共同点都是为了减轻数据库的访问压力,但是具体的应用场景不同,缓存比较适合小规 ...

  3. 阶段5 3.微服务项目【学成在线】_day09 课程预览 Eureka Feign_09-课程详情页面静态化-静态页面测试

    4 课程详情页面静态化 4.1 静态页面测试 4.1.1 页面内容组成 我们在编写一个页面时需要知道哪些信息是静态信息,哪些信息为动态信息,下图是页面的设计图: 打开静态页面,观察每部分的内容. 红色 ...

  4. Phpcms 详情页显示所属栏目的同级栏目

    Phpcms详情页是不显示所属栏目的同级栏目的,如果按下面的方式 {loop subcat($parentid) $v} <li{if $v[catid]==$catid} class=&quo ...

  5. Day13_商品详情及静态化

    学于黑马和传智播客联合做的教学项目 感谢 黑马官网 传智播客官网 微信搜索"艺术行者",关注并回复关键词"乐优商城"获取视频和教程资料! b站在线视频 0.学习 ...

  6. jeecms 单页静态化方法

    在论坛上去搜,都说可以需要在模型中配置增加字段,看了云里雾里,调试源代码发现原因,方法如下: 步骤一:改模型 模型管理->"单页“栏目模型->添加: channelStatic( ...

  7. TP-网页静态化

    首先放上一张某手册中的一段代码: 我们要想在TP框架中执行网页静态化,在这段代码的基础上稍加添加就可以了: 在TP5框架中,为了方便寻找模板文件与生成的静态文件,我们将模板文件以及生成的静态文件放在p ...

  8. DJANGO-天天生鲜项目从0到1-007-首页静态化与缓存

    本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...

  9. jeecms 2012 源码分析(2) 前台栏目页静态化分析

    还是要说到web.xml文件 <welcome-file-list> <welcome-file>index.html</welcome-file> <wel ...

随机推荐

  1. 比较好的前端方法库及一些vue如何引入静态文件

    https://select2.github.io/examples.html   select2 自动搜索带select选择 ## 表单提交 https://github.com/marioizqu ...

  2. javascript客户端时间线

    1.创建document对象,解析解析web页面,此时document.readyState=“loading” 2.下载脚本并执行,同时解析文档. 3.文档解析完成,document.readySt ...

  3. springMVC注解及优化

    1. 新建web project 2. 添加jar 3. 改写web.xml, 注意spring-servlet.xml的名字 <?xml version="1.0" enc ...

  4. DHCP配置部分

    1.DHCP工作过程 dhcp discover \\客户端请求服务器器提供地址 dhcp offer \\服务器提供ip地址 dhcp request \\客户端租用ip地址 dhcp ack \\ ...

  5. input限定文件上传类型:Microsoft Office MIME types

    <input id = " " name = " " type = " file " accept=" ? ? ? &quo ...

  6. Windows Azure Table Storage 解决 Guid 查询问题

    在使用 Windows Azure Table Storage 的 CloudTableClient 对Azure 进行数据查询时,会发现在自定义类的Guid类型始终无法去成功查询出数据,对比发现 G ...

  7. package。。

    如果在源代码内没有加上 package ... 是无法以下面的方式访问到主类的. D:\lab_>java timer.LambdaTest 加载时会返回 "错误: 找不到或无法加载主 ...

  8. (简单) POJ 3076 Sudoku , DLX+精确覆盖。

    Description A Sudoku grid is a 16x16 grid of cells grouped in sixteen 4x4 squares, where some cells ...

  9. oracle查看表空间物理文件的名称,路径及大小

    select tablespace_name, file_id,file_name,round(bytes/(1024*1024),0) total_space from dba_data_files ...

  10. VSC#2010打开视图编辑器假死/卡死

    最近写项目代码的时候写C#,VSC#2010刚配置好,打开之前同学写的项目的设计界面结果...我擦,卡死了,重复几次都是这样. 于是上网搜发现是VS一个bug,打一个VSSP1补丁就好了~ http: ...