phpcms2008 首页index.php浅析
来源:互联网 发布:蔡晨数据 编辑:程序博客网 时间:2024/06/01 07:25
phpcms2008 首页index.php浅析
<?php
require dirname(__FILE__).'/include/common.inc.php'; //加载公共函数
$head['title'] = $PHPCMS['sitename']; //调用公共变量站名
$head['keywords'] = $PHPCMS['meta_keywords']; //调用公共变量设置的关键字
$head['description'] = $PHPCMS['meta_description']; //调用公共变量设置的网站内容描述文字
header('Last-Modified: '.gmdate('D, d M Y H:i:s', TIME).' GMT'); //设置网页在服务器上修改的修改时间
header('Expires: '.gmdate('D, d M Y H:i:s', TIME+CACHE_PAGE_INDEX_TTL).' GMT'); //设置服务器的访问响应超时时间
header('Cache-Control: max-age='.CACHE_PAGE_INDEX_TTL.', must-revalidate'); //设置最在page的cache缓存时间
include template('phpcms', 'index'); //调用模板
cache_page(CACHE_PAGE_INDEX_TTL); //缓存默认生命周期
?>
//缓存配置如下
define('CACHE_STORAGE', 'files'); //Cache 存储方式(files, mysql, apc, eaccelerator, memcache, shmop)
define('CACHE_PATH', PHPCMS_ROOT.'data/cache/'); //缓存默认存储路径
define('CACHE_MODEL_PATH', PHPCMS_ROOT.'data/cache_model/'); //模型缓存存储路径
//页面缓存配置
define('CACHE_PAGE', 0); //是否开启PHP页面自动缓存功能
define('CACHE_PAGE_PATH', PHPCMS_ROOT.'data/cache_page/'); //缓存存储路径
define('CACHE_PAGE_TTL', 3600); //秒,缓存默认生命周期
define('CACHE_PAGE_INDEX_TTL', 300); //秒,缓存默认生命周期
define('CACHE_PAGE_CATEGORY_TTL', 600); //秒,缓存默认生命周期
define('CACHE_PAGE_LIST_TTL', 900); //秒,缓存默认生命周期
define('CACHE_PAGE_CONTENT_TTL', 14400); //秒,缓存默认生命周期
//所用到的函数
function cache_page($ttl = CACHE_PAGE_TTL, $isjs = 0)
{
if($ttl == 0 || !defined('CACHE_PAGE_FILE')) return false;
$contents = ob_get_contents(); //将ob生成的内容取出来
if($isjs) $contents = format_js($contents); //判断是否为js,如果为,则格式化写入
dir_create(CACHE_PAGE_DIR); //创建cahce的目录
$contents = "<!--expiretime:".(TIME + $ttl)."-->/n".$contents; //设置文件最后的修改时间,以防同样的访问,再次生成cahce
file_put_contents(CACHE_PAGE_FILE, $contents); //将内容写入,原来生生的cahce_file_name 中 cache file名的生成在 // cache_page_start()这个函数中
@chmod(CACHE_PAGE_FILE, 0777); //设置cahe目录的可读性,
}
function cache_page_start()
{
define('CACHE_PAGE_ID', md5(RELATE_URL));
define('CACHE_PAGE_DIR', CACHE_PAGE_PATH.substr(CACHE_PAGE_ID, 0, 2).'/');
define('CACHE_PAGE_FILE', CACHE_PAGE_DIR.CACHE_PAGE_ID.'.html');
$contents = @file_get_contents(CACHE_PAGE_FILE);
if($contents && intval(substr($contents, 15, 25)) > TIME)
{
echo substr($contents, 29);
exit;
}
return true;
}
function template($module = 'phpcms', $template = 'index', $istag = 0)
{
$compiledtplfile = TPL_CACHEPATH.$module.'_'.$template.'.tpl.php'; //加载我们平时做的模版目录中的数据生成页面,会放置它的引擎变量里以至后面我们加载html代码后,一同跑出来,的页面,这种模式为MVC模式
if(TPL_REFRESH && (!file_exists($compiledtplfile) || @filemtime(TPL_ROOT.TPL_NAME.'/'.$module.'/'.$template.'.html') > @filemtime//加载模版文件hmtl部分,
($compiledtplfile) || @filemtime(TPL_ROOT.TPL_NAME.'/tag.inc.php') > @filemtime($compiledtplfile))) //加载不同栏目的tag,然后成生页面
{
require_once PHPCMS_ROOT.'include/template.func.php';
template_compile($module, $template, $istag);
}
return $compiledtplfile;
}
php CMS所有的模块就是如此结构, 先看是事原来有缓存,无则生成数据,和cahce 然后将数据刷入模板,然后展示出来.....
- phpcms2008 首页index.php浅析
- phpcms2008 首页index.php浅析
- PHPCMS2008源码浅析-index.php PHPCMS20008二次开发
- phpcms2008 代码简介:index.php
- 日记本首页(index.php)
- PHPCMS2008源码浅析-common.inc.php PHPCMS20008二次开发
- PHPCMS2008源码浅析-cache.func.php PHPCMS20008二次开发
- PHPCMS2008源码浅析-cache.func.php PHPCMS20008二次开发
- PHP PDO ACCESS 留言板-首页index.php
- phpcms2008的栏目首页分类
- 稻壳首页模板index.php的建立
- Apache:设置首页运行index.html index.php的顺序
- 稻壳首页index.php添加站点名和搜索代码
- UCHome 网站首页index.php页面代码分析
- phpcms2008 代码简介:admin.php
- index 首页页面跳转
- 梳理index首页
- index首页布局
- 分页基于Struts
- 智力题解题报告No.15 杯子放硬币
- 嵌入式linux启动信息完全注释(转)
- JSP页面的五种跳转方法
- ASP.NET安全问题--ASP.NET生命周期中的验证以及身份验证模块
- phpcms2008 首页index.php浅析
- 数据库表操作总结
- 【搜索】【RQNOJ】智慧杯
- PL在项目控制中必要的3个手段
- Eclipse 中的 Adapters
- protues 中 虚拟串口的设置与实例
- qemu安装
- 什么是软阀值?什么是硬阀值?
- ASP.NET中的HTTP模块和处理程序