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 ...
随机推荐
- (转)windows上virtualenv 安装及使用
[注意]要在某个含有空格的目录下面创建virtualenv环境,就要安装 win32api . 原文地址:http://blog.csdn.net/liuchunming033/article/det ...
- 块和内嵌div和span
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- XML简单的增改删操作
XML文件的简单增改删,每一个都可以单独拿出来使用. 新创建XML文件,<?xmlversion="1.0"encoding="utf-8"?> & ...
- Ubuntu 14.04 使用MyEclipse 10.7 闪退解决
http://www.linuxidc.com/Linux/2014-05/101750.htm
- 解决adb command not found以及sdk环境配置
解决adb command not found以及sdk环境配置 分类: mark 2013-10-02 09:41 2975人阅读 评论(0) 收藏 举报 原文地址:http://www.cnblo ...
- 如何把mysql的ID归0?
如何把mysql的ID归0 可以归0的,truncate table + 表名 就行了
- System.InvalidCastException: 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。
报错:System.InvalidCastException: 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接 ...
- python2.7 与 go1.2简单性能比较
过完年刚上班,项目还没有开始,对于即将到来的项目,想尝试是否可以找到一个开发效率接近python,运行效率接近静态语言的编程语言,选择基本就是scala和go,公司的技术组成基本都是c派的,scala ...
- ArcEngine部分工作总结
Arcengine工作总结地物点查询本部分可以在一个窗体中实现,也可以在两个窗体中实现.由于工作要求本人是在两个窗体中实现的:弹出窗体的名称为FormQuery主窗体单机查询时间的代码FormQuer ...
- jquery中:input和input的区别分析
:input表示选择表单中的input,select,textarea,button元素,input仅仅选择input元素. <html> <head> <style&g ...