• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> PHP 开发 >> PHP精通 >> 详细内容
 

推荐文章

  • PHP 程序加速探索
  • 用封装类来合理的设计PHP项目--谈PHP项目中类的封装
 
 

热点文章

  • 30分钟学会用PHP写带数据库的简单通讯录
  • 结合AJAX进行PHP开发之入门
  • 最强的PHP字符串截取函数
  • 汉字编码问题
  • PHP向脚本提交POST数据
  • 中文字符集与字符编码的基础知识
  • PHP实现验证码一法
  • php模板smarty
  • php如何隐藏图片的真实地址
  • PHP 程序加速探索
  • php防盗链的方法
  • 用封装类来合理的设计PHP项目--谈PHP项目中类的封装
 
 

相关文章

  • PHP使用zlib扩展实现页面GZIP压缩输出
  • 为什么PHP令人不爽(对于大型系统)
  • php中的stdClass
  • php中ADODB类使用
  • php自动post数据--百度贴吧灌水机器人代码实例
  • Linux/FreeBSD下用C语言开发PHP的so扩展模块例解
  • php取不到session的常见原因
  • 使用php的zlib压缩和解压缩swf文件
  • php 做服务器端程序
  • PHP5.2下function和class性能对比
  • PHP用mkdir()新建立目录无写的权限的问题
  • mysql的bigint类型与php的mysql_insert_id函数造成的b..
 
 

百度搜索

 
 

PHP大型Web应用入门(九)

  • 阅览次数:
  • 文章来源: http://goodlinuxer.bokee.com/
  • 原文作者: 静水人生
  • 整理日期: 2008-07-28
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

functionparse($file)
{
global
$page_time,$page_time_start;

$tplfile=$this->tpl_dir.$file.'.'.$this->tpl_file_ext;
$objfile=$this->tpl_cache_root_dir.'/'.$this->tpl_name.'_'.$file.'.tpl.'.$this->tpl_cache_file_ext;

if(!
file_exists($tplfile)){
$tplfile=$this->tpl_root_dir.'/'.$this->default_tpl_name.'/'.$file.'.'.$this->tpl_file_ext;
$objfile=$this->tpl_cache_root_dir.'/'.$this->default_tpl_name.'_'.$file.'.tpl.'.$this->tpl_cache_file_ext;
}

if((@
filemtime($tplfile)>@filemtime($objfile))||(!@file_exists($objfile))){
//$this->parse_template($tplfile,$objfile);
if(!@$fp=fopen($objfile,'w')){
die(
"Directory'".$this->tpl_root.'/'.$this->tpl_cache_root."'notfoundorhavenoaccess!");
}

flock($fp,3);
fwrite($fp,$this->parse_template($tplfile,$objfile));
fclose($fp);
}
list(
$usec,$sec)=explode("",microtime());
$page_time_end=$usec+$sec;
$page_time=sprintf("%0.6f",$page_time_end-$page_time_start);

return
$objfile;
}

function
set_tpl_db_handle($dh)
{
$this->defalt_db_handle='$'.$dh;
}

function
set_tpl_name($name)
{
$tpl_dir=$this->tpl_root_dir.'/'.$name.'/';
if(
$name!=''&&is_dir($tpl_dir)){
$this->tpl_name=$name;
$this->tpl_dir=str_replace('//','/',$tpl_dir);
}
else{
$this->tpl_name=$this->default_tpl_name;
$this->tpl_dir=str_replace('//','/',$this->tpl_root_dir.'/'.$this->tpl_name.'/');
}

}

function
set_language($langMeta)
{
$langFile=$this->tpl_dir.$langMeta.'.lang';
clearstatcache();

if(@
is_readable($langFile)){
return
$langFile;
}

elseif(@
is_readable($this->tpl_dir.$this->default_lang.'.'.$this->tpl_lang_file_ext)){
$langFile=$this->tpl_dir.$this->default_lang.'.'.$this->tpl_lang_file_ext;
$langMeta=$this->default_lang;
return
$langFile;
}

elseif(@
is_readable($this->tpl_root_dir.'/'.$this->default_tpl_name.'/'.$langMeta.'.lang')){
$langFile=$this->tpl_root_dir.'/'.$this->default_tpl_name.'/'.$langMeta.'.lang';
return
$langFile;
}

elseif(@
is_readable($this->tpl_root_dir.'/'.$this->default_tpl_name.'/'.$this->default_lang.'.'.$this->tpl_lang_file_ext)){
$langFile=$this->tpl_root_dir.'/'.$this->default_tpl_name.'/'.$this->default_lang.'.'.$this->tpl_lang_file_ext;
$langMeta=$this->default_lang;
return
$langFile;
}

else
die(
'AcceptLangfile:'.$langFile.'didnotexistorhasnoaccess!');
}

function
dsp()
{
global
$mSession;
if(
$mSession['do_gzip']){
$gzip_contents=ob_get_contents();
ob_end_clean();

$gzip_size=strlen($gzip_contents);
$gzip_crc=crc32($gzip_contents);

$gzip_contents=gzcompress($gzip_contents,9);
$gzip_contents=substr($gzip_contents,0,strlen($gzip_contents)-4);

echo
"x1fx8bx08x00x00x00x00x00";
echo
$gzip_contents;
echo
pack('V',$gzip_crc);
echo
pack('V',$gzip_size);
}
else
ob_end_flush();
}

function
get_static_html($file)
{
//JustforTest...

$static_file='../../data/static/'.$file.'.'.$this->tpl_static_file_ext;
if(@
$fp=fopen($static_file,'wb')){
fwrite($fp,ob_get_contents());
fclose($fp);
}

ob_end_clean();
return;
}
}

function
addquote($var)
{
return
str_replace("\\"",""",preg_replace("/[([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*)]/s","['\1']",$var));
}

function
stripvtags($expr,$statement)
{
$expr=str_replace("\\"",""",preg_replace("/<?=(\$[a-zA-Z_x7f-xff][a-zA-Z0-9_[]\"'x7f-xff]*)?>/s","\1",$expr));
$statement=str_replace("\\"",""",$statement);
return
$expr.$statement;
}

?>

后面附了一个简单的获取静态页的方法,其实也没什么用,大家都有更好的方法来生成静态页。

上一篇:PHP使用zlib扩展实现页面GZIP压缩输出
下一篇:构建支持Master/Slave读写分离的数据库操作类
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号