您现在的位置是:首页 > 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怎么样,好用吗
相关教程
图文教程
phpcmsv9可以在php7运行吗
phpcmsv9作为国内主流的cms目前新版本“9.6.0适配php5.5php5.6php7”(phpcms官方升级更新说明原话),所以支持php7的。
phpcms找不到临时文件的解决方法
phpcms找不到临时文件的解决办法:首先找到并打开“php.ini”文件;然后找到内容“;upload_tmp_dir =”;接着输入临时文件夹的路径;最后删除该内容前面的分号
PHPCMSV9静态化HTML生成设置及URL规则优化方法
最近有客户在进行网站优化的时候,具体问道Phpcms V9怎么样静态化、伪静态的问题,之前有分享过“Phpcms自定义URL规则技巧”,不过那只是原理,今天在这里
常用phpcmsv9模版调用代码整理
网上收集下来的,常用标签基本都用的到的!当然二次开发肯定不包括在内,供我这种小白使用:首页调用栏目调用二级栏目判断当前栏目是否存在子栏目
相关源码
-
(PC+WAP)蓝色公司注册财务会计公证律师网站源码下载本模板基于PbootCMS内核开发,为财务会计事务所、律师公证机构等专业服务机构打造。采用自适应设计,确保在各类设备上都能呈现专业视觉效果,帮助机构建立值得信赖的线上形象。查看源码 -
(PC+WAP)五金机械设备营销型模板下载带在线留言为机械设备制造商设计的营销型模板,集成产品参数对比系统、产品展示模块和询价管理功能。采用PbootCMS开发内核,PHP7+运行环境。手工编写语义化HTML5结构,CSS3动画优化交互体验。查看源码 -
帝国cms7.5文库范文/付费下载/复制付费/带支付源码免费下载本模板为文库、文档分享、知识付费类平台设计,提供完整的内容变现解决方案。系统支持多种内容展示与付费模式,满足不同场景下的内容价值转化需求,帮助平台实现内容资源的有效管理和商业化运营。查看源码 -
pbootcms响应式蓝色旅游旅行社pbootcms网站源码下载为旅游公司、旅行社定制的响应式网站模板,聚焦旅游线路展示、景点推荐及预约服务场景。采用PbootCMS内核开发,自适应技术确保PC与手机端数据实时同步查看源码 -
(自适应响应式)pbootcms食品零食店日化用品网站源码下载基于PbootCMS内核开发的响应式模板,为食品零食、日化用品等行业量身定制。该模板通过可视化设计展现产品特色,帮助企业快速搭建专业官网查看源码 -
(自适应)WordPress二次元博客主题SakurairoSakurairo主题为二次元内容创作者设计,提供丰富的动漫风格元素和个性化的展示效果。该主题在原有Sakura主题基础上进行了功能增强,支持多种自定义设置,满足动漫爱好者建立个人博客的需求。查看源码
| 分享笔记 (共有 篇笔记) |
