您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程
PHPCMS详情页静态化实现方法
紫南2025-05-27phpcms教程已有人查阅
导读defined('IN_PHPCMS') or exit('No permission resources.');pc_base::load_app_class('admin','admin',0);class game extends admin {
<?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\ \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\ \record\/html/2014/dongzuogame_0717/109.html
//$path = 'D:\wamp\ \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文章点击量怎么统计
下一篇:PHPCMSV9怎么样,好用吗
相关教程
图文教程
PHPCMS和帝国CMS的会员管理系统有哪些差异
phpcms和帝国cms在会员管理系统上的主要差异在于灵活性和易用性。1. phpcms提供高度灵活性和可扩展性,适合需要复杂会员系统的网站。2. 帝国cms则以简洁和易用性著称
phpcms中增删改查使用方法
一、查1、select($where = '', $data = '*', $limit = '', $order = '', $group = ''
PHPCMS标签内容模块操作说明介绍
{pc:content action="lists"…}…{/pc} 的方式进行调用下面即按照action 的值不同(操作名不同)来分别讲解相关操作:
phpcmsv9搜索功能的实现方法步骤教程
phpcms v9搜索功能怎么做?phpcmsv9 全站搜索功能如何实现给大家分享一下如何运用搜索功能吧,1. 首先, 模块->全站搜索->添加搜索分类,添加搜索分类
相关源码
-
(自适应)绿色LED灯具照明灯饰灯光灯泡pbootcms网站源码下载本模板基于PbootCMS内核开发,为LED照明、灯具制造及相关光电技术企业量身打造。设计充分考虑了照明行业的展示需求,从产品陈列到技术说明,从光源展示到工程案例,每一个细节都体现出专业照明行业的特点。查看源码 -
(自适应响应式)黑色酷炫高端数码摄影pbootcms网站模板源码本模板基于PbootCMS开发,为摄影工作室、个人摄影师及摄影爱好者设计。采用深色系风格,突出摄影作品展示效果,适配各类数码设备浏览。适用于作品集展示查看源码 -
(自适应)大型农业机械设备水稻玉米收割机网站pbootcms源码下载本模板基于PbootCMS内核开发,为农业机械设备制造与销售企业设计,特别适合水稻玉米收割机、拖拉机、播种机等农用机械展示。模板充分考虑了农机行业的特性,从产品展示到技术参数,从作业案例到售后服务查看源码 -
(自适应)蓝色厨卫厨房水龙头阀门水槽设备源码下载基于PbootCMS内核开发,深度适配厨卫设备行业特性。通过精准的产品展示模块与水效标识专区设计,有效呈现五金件工艺细节。响应式布局确保从手机到平板都能展示金属质感与水流动态效果。查看源码 -
(自适应响应式)HTML5电脑手机电子数码产品配件pbootcms模板下载本模板为电脑配件、手机配件及数码周边产品企业设计,基于PbootCMS内核开发。采用现代化响应式布局,适配各类移动设备,能够专业展示各类电子产品配件参数、应用场景和技术特点。模板内置多种产品展示模块,满足不同类型配件企业的展示需求。查看源码 -
(响应式)wordpress模板VieuV4.5主题资讯自媒体博客源码Vieu主题专注于个人博客与企业展示场景,采用响应式设计确保在手机、电脑、平板等多设备上的展示。主题集成会员中心、投稿系统、内容保护等实用功能,满足现代博客网站的建设需求。查看源码
| 分享笔记 (共有 篇笔记) |
