- 浏览: 592238 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
kangh:
转载的也拿出来 都不试一下 完全错误
Nginx+ffmpeg的HLS开源服务器搭建配置及开发详解 -
wangtxlz:
#cd builders/cmake#cmake .系统提示命 ...
crtmpserver流媒体服务器的介绍与搭建 -
hnraysir:
支持支持支持
手机Android音视频采集与直播推送,实现单兵、移动监控类应用 -
wuent:
把web服务器和php框架绑定到一起?真不建议这样。。。
Swoole(PHP高级Web开发框架) -
wuent:
有更详细的性能比较吗?php,python,java
PHP中的(伪)多线程与多进程
require require_once include等都是php里面常规的文件调用函数,具体的区别和用法通常都是.
require_once filename;
filename要求引入的文件的相对路径.
而discuz x在文件调用方面引入了另外的filename获取方法.这个是本文主要讨论的内容.
如:根目录下portal.php中有这么一句.
1. require_once libfile('portal/'.$_GET['mod'], 'module');
在/source/function/function_core.php中找到函数原型:
function libfile($libname, $folder = '') {
$libpath = DISCUZ_ROOT.'/source/'.$folder;
if(strstr($libname, '/')) {
list($pre, $name) = explode('/', $libname);
return realpath("{$libpath}/{$pre}/{$pre}_{$name}.php");
} else {
return realpath("{$libpath}/{$libname}.php");
}
}
$libpath = DISCUZ_ROOT.'/source/'.$folder;
if(strstr($libname, '/')) {
list($pre, $name) = explode('/', $libname);
return realpath("{$libpath}/{$pre}/{$pre}_{$name}.php");
} else {
return realpath("{$libpath}/{$libname}.php");
}
}
包含2个参数:$libname 和 $folder
该函数读取source目录下的$folder子目录作为基础部分.
另外当$libname中包含/的时候,把$libname分为前后两部分.前面部分为子目录.
规则为:/source/$folder/$libname_pre/$libname_pre_$libname_end.php
不包含/的调用规则为: /source/$folder/$libname.php
require_once libfile('portal/'.$_GET['mod'], 'module');
调用的实际为:
require_once /source/module/portal/portal_$_get['mod'].php
($get[mod]是浏览器环境的提供的)
2. include_once template('diy:portal/index');
调用位置: \source\module\portal\portal_index.php
函数位置:/source/function/function_core.php
函数原型:
function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0) {
global $_G;
if(strexists($file, ':')) {
list($templateid, $file, $clonefile) = explode(':', $file);
//用分号来分开参数的file,对于topic模板来说
//$templateid = DIY 等
//$file = portal/portal_topic_content
//$clonefile 为 topicid
$oldfile = $file;
///如果$clonefile不为空,那么$file加上$clonefile编号
$file = empty($clonefile) ? $file : $file.'_'.$clonefile;
///DIY类型的模板
if($templateid == 'diy') { ///看摸板是否存在
if(file_exists(DISCUZ_ROOT.'./data/diy/'.$file.'.htm')) {
$tpldir = 'data/diy';
!$gettplfile && $_G['style']['tplsavemod'] = 1;
} elseif(file_exists(DISCUZ_ROOT.'./data/diy/'.$oldfile.'.htm')) {
///摸板不存在,如果 默认摸板存在
$file = $oldfile;
$tpldir = 'data/diy';
!$gettplfile && $_G['style']['tplsavemod'] = 0;
} else {
$file = $oldfile;
}
///摸板是否刷新的模式
$tplrefresh = $_G['config']['output']['tplrefresh'];
///如果符合摸板刷新的机制,那么来更新摸板
if(($tplrefresh ==1 || ($tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh))) && @filemtime(DISCUZ_ROOT.'./data/diy/'.$file.'.htm') &&
@filemtime(DISCUZ_ROOT.'./data/diy/'.$file.'.htm') < @filemtime(DISCUZ_ROOT.TPLDIR.'/'.$oldfile.'.htm')) {
updatediytemplate($file);
}
} else { ////非DIY类型模板放置
$tpldir = './source/plugin/'.$templateid.'/template';
}
}
if (!$gettplfile && empty($_G['style']['tplfile'])) $_G['style']['tplfile'] = empty($clonefile) ? $file : $oldfile.':'.$clonefile;
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$tplfile = ($tpldir ? $tpldir.'/' : './template/').$file.'.htm';
$filebak = $file;
$file == 'common/header' && defined('CURMODULE') && CURMODULE && $file = 'common/header_'.CURMODULE;
$cachefile = './data/template/'.(defined('STYLEID') ? STYLEID.'_' : '_').$templateid.'_'.str_replace('/', '_', $file).'.tpl.php';
////如果tplfile的文件不存在的时候,去/template/default/对应目录里面获取
if($templateid != 1 && !file_exists(DISCUZ_ROOT.$tplfile)) {
$tplfile = './template/default/'.$filebak.'.htm';
}
if($gettplfile) {
return $tplfile;
}
////根据摸板文件及缓存返回读取的文件
checktplrefresh($tplfile, $tplfile, @filemtime($cachefile), $templateid, $cachefile, $tpldir, $file);
return $cachefile;
}
global $_G;
if(strexists($file, ':')) {
list($templateid, $file, $clonefile) = explode(':', $file);
//用分号来分开参数的file,对于topic模板来说
//$templateid = DIY 等
//$file = portal/portal_topic_content
//$clonefile 为 topicid
$oldfile = $file;
///如果$clonefile不为空,那么$file加上$clonefile编号
$file = empty($clonefile) ? $file : $file.'_'.$clonefile;
///DIY类型的模板
if($templateid == 'diy') { ///看摸板是否存在
if(file_exists(DISCUZ_ROOT.'./data/diy/'.$file.'.htm')) {
$tpldir = 'data/diy';
!$gettplfile && $_G['style']['tplsavemod'] = 1;
} elseif(file_exists(DISCUZ_ROOT.'./data/diy/'.$oldfile.'.htm')) {
///摸板不存在,如果 默认摸板存在
$file = $oldfile;
$tpldir = 'data/diy';
!$gettplfile && $_G['style']['tplsavemod'] = 0;
} else {
$file = $oldfile;
}
///摸板是否刷新的模式
$tplrefresh = $_G['config']['output']['tplrefresh'];
///如果符合摸板刷新的机制,那么来更新摸板
if(($tplrefresh ==1 || ($tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh))) && @filemtime(DISCUZ_ROOT.'./data/diy/'.$file.'.htm') &&
@filemtime(DISCUZ_ROOT.'./data/diy/'.$file.'.htm') < @filemtime(DISCUZ_ROOT.TPLDIR.'/'.$oldfile.'.htm')) {
updatediytemplate($file);
}
} else { ////非DIY类型模板放置
$tpldir = './source/plugin/'.$templateid.'/template';
}
}
if (!$gettplfile && empty($_G['style']['tplfile'])) $_G['style']['tplfile'] = empty($clonefile) ? $file : $oldfile.':'.$clonefile;
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$tplfile = ($tpldir ? $tpldir.'/' : './template/').$file.'.htm';
$filebak = $file;
$file == 'common/header' && defined('CURMODULE') && CURMODULE && $file = 'common/header_'.CURMODULE;
$cachefile = './data/template/'.(defined('STYLEID') ? STYLEID.'_' : '_').$templateid.'_'.str_replace('/', '_', $file).'.tpl.php';
////如果tplfile的文件不存在的时候,去/template/default/对应目录里面获取
if($templateid != 1 && !file_exists(DISCUZ_ROOT.$tplfile)) {
$tplfile = './template/default/'.$filebak.'.htm';
}
if($gettplfile) {
return $tplfile;
}
////根据摸板文件及缓存返回读取的文件
checktplrefresh($tplfile, $tplfile, @filemtime($cachefile), $templateid, $cachefile, $tpldir, $file);
return $cachefile;
}
发表评论
-
nginx、php-fpm默认配置与性能–TCP socket还是unix domain socket
2015-04-02 11:14 1418前几天看到一篇博客,提到php所在服务器在大并发情况下,频 ... -
使用socket方式连接Nginx优化php-fpm性能
2015-04-01 13:49 0Nginx连接fastcgi的方式有 ... -
PHP中include和require的区别详解
2015-04-01 08:32 01、概要 require()语句的性能与includ ... -
PHP 中cookie 和 session 的分析
2015-03-31 12:33 0HP 中cookie 和session 的分析 ... -
php 经典的算法题你懂的
2015-03-31 12:31 0有5个人偷了一堆苹果,准备在第二天分赃。晚上,有一人遛出来, ... -
PHP最常用的2种设计模式工厂模式和单例模式介绍
2015-03-31 12:26 0简单来说,PHP单例模式就是一个功能用一个类来实现,并且在整 ... -
PHP 数据类型
2015-03-31 12:23 0PHP 数据类型 PHP 支持八种原始类型(type)。 ... -
PHP mcrypt启用、加密以及解密过程详解
2015-03-30 11:32 1422Mcrypt扩展库可以实现加密解密功能,就是既能将明文加密, ... -
PHP扩展实现类扩展
2015-03-27 14:08 536在第一篇文章中,我们所开发的扩展是单个函数,本篇文章看一下 ... -
PHP高级工程师的面试题
2015-03-06 10:35 01. 基本知识点 HTTP协议中几个状态码的含义:1x ... -
PHP面试中常见的面试试题与算法例子
2015-03-05 14:14 0下面是四道比较常见的题目,主要考察的是对字符串函数以及文件操 ... -
PHP实现四种常用的排序算法
2015-03-05 14:09 0插入排序(Insertion Sort),选择排序(Sele ... -
用swagger-php/ui做API测试
2015-02-13 09:46 3607功能: 1 swagger-php根据自定义的规则生成API ... -
app后端设计(0)--总目录
2015-01-23 18:03 0做了3年app相关的系统架构,api设计,先后在3个创业公司中 ... -
PHP中eAccelerator、memcached、xcache、APC 4个加速、缓存扩展的区别
2015-01-23 10:26 876这篇文章主要介绍了PHP ... -
PHP内核探索:zend_parse_parameters函数
2015-01-16 14:14 908最简单的获取函数调用者传递过来的参数便是使用zend_pars ... -
实战:用C写php扩展(二)
2015-01-16 11:05 946一、前言 在我的上一篇文章“实战:用C写php扩展(一)”里介 ... -
实战:用C写php扩展(一)
2015-01-16 11:04 9811、 前言 首先,确保你的机器安装了apache和php。假 ... -
JavaScript or PHP 来检测移动设备
2014-09-22 10:04 593iPhone & iPod Detection T ... -
YII Framework学习教程-YII的Modules(模块化)
2014-08-27 11:04 711一个相对来说大的项目。如果按照yii生成的 ...
相关推荐
深黑经典模板Discuz模板是一款用于社区 黑色 论坛 交流的模板,适用于discuz! x2.5版本。
Discuz! x2.5安卓风格模板
质感金属模板Discuz模板是一款用于社区 黑色 论坛 交流的模板,适用于discuz! x2.5版本。
X1.5 圣诞节模板,蓝黑色,附PSD源文件,本风格是基于DiscuzX1.5 GBK (2010-11-25)版本,并且只修改了部分文件,未修改之文件,调用默认模板包的文件。如果出现变形,请下载最新程序,使用最新的默认模板覆盖你目前的...
Discuz! x2.5中秋节模板
Discuz! x2.5秋意时尚模板
Discuz! x2.5黑大气模板.rar
回首经典模板Discuz模板是一款用于社区 蓝色 论坛 交流的模板,适用于discuz0 x2.5版本。
模版介绍:价值400大洋的Discuz!商业模版,该模板包含门户和论坛页面,整体色彩采用大自然的绿色,带DIY数据,模版兼容主流浏览器,页面结构和CSS均已优化适合搜索引擎收录。该模版风格大气,不仅可用于旅游类站点,...
详解Discuz!X1.5 showmessage函数详解Discuz!X1.5 showmessage函数
Discuz!X3.4模板转码专用工具1.0.zipDiscuz!X3.4模板转码专用工具1.0.zipDiscuz!X3.4模板转码专用工具1.0.zipDiscuz!X3.4模板转码专用工具1.0.zip
质感灰黑模板Discuz模板是一款用于社区 灰色 论坛 交流的模板,适用于discuz! x2.5版本。
Discuz!X3.1穷游网模板UTF8
博客风格模板Discuz模板是一款用于社区 白色 博客 论坛 交流的模板,适用于discuz! x2.5版本。
蓝色小清新模板Discuz模板是一款用于社区 蓝色 论坛 交流的模板,适用于discuz! x2.5版本。
论坛风格模板Discuz模板是一款用于社区 蓝色 论坛 交流的模板,适用于discuz! x2.5版本。
紫黑风格模板Discuz模板是一款用于社区 黑色 论坛 交流的模板,适用于discuz! x2.5版本。
泼墨江山模板Discuz模板是一款用于社区 黄色 论坛 交流的模板,适用于discuz! x2.5版本。
浪蓝色大气模板Discuz模板是一款用于社区 绿色 论坛 交流的模板,适用于discuz! x2.5版本。
Discuz!x目录文件列表结构及模板文件结构详解(加精中文版)