<?php
/**
*
*/
class Output
{ function __construct()
{
$this->_zlib_oc = @ini_get('zlib.output_compression');
if(file_exists($mimes))
{
include $mimes;
}
} function _display($output = '')
{
global $BM, $CFG; if(extension_loaded('zlib'))
{
if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
{
ob_start('ob_gzhandler');
} if(preg_match("|</body>.*?</html>|is", $output))
{
$output = preg_replace("|</body>.*?</html>|is", '', $output); $output .= '</body></html>';
}
} function _write_cache($output)
{
$CI = &get_instance();
$path = 'cache/';
$cache_path = $path; if (is_dir($cache_path) OR !is_writable($cache_path))
{
$cache_path .= md5($uri); if(!$fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
{
return;
} $expire = time()+($expire*60); if(flock($fp, LOCK_EX))
{
fwrite($fp, $expire, 'TS--->'.$output);
flock($fp, LOCK_UN);
}
else
{
return;
}
fclose($fp);
@chmod($cache_path, FILE_WRITE_MODE);
}
}
} function _display_cache(&$CFG, &$URI)
{
$cache_path = 'cache/'; $uri = $this->uri_string; $filepath = $cache_path.md5($uri); if(!@file_exists($filepath))
{
return false;
} if(!$fp = @fopen($filepath, FOPEN_READ))
{
return FALSE;
} flock($fp, LOCK_SH); $cache = '';
if(filesize($filepath) > 0)
{
$cache = fread($fp, filesize($filepath));
} flock($fp, LOCK_UN);
fclose($fp); if(!preg_match("/(\d+TS---->)/", $cache, $match))
{
return FALSE;
} if(time()>=trim(str_replace('TS---->', '', $match[1])))
{
if(is_writable($cache_path))
{
@unlink($filepath);
return FALSE;
}
}
$this->_display(str_replace($match[0], '', $cache));
return TRUE;
}
}

output.php的更多相关文章

  1. SubSonic3.0使用存储过程查询时,不能使用output参数返回值的问题修改

    有个群友问SubSonic3.0执行存储过程时能不能使用output参数返回值,说测试过后获取不到返回值,早上有些时间所以就尝试修改了一下 首先在数据库中创建一个存储过程 CREATE PROCEDU ...

  2. OutPut子句的使用限制

    Output子句很方便,多数情况下可以省略了更新后插入或者删除后插入操作表,将2个语句变成1个语句操作.不管从语句美观还是效率上都是有不错的提升, 但是对于Output自身,也是有一些限制的. 从文档 ...

  3. 在output 子句和 scope_identity() 混合使用的时候的注意事项

    无意睹到一篇旧文档 SR0008:考虑使用 SCOPE_IDENTITY 代替 @@IDENTITY :https://msdn.microsoft.com/zh-cn/library/dd17212 ...

  4. Compiler Error Message: CS0016: Could not write to output file 回绝访问

    Compiler Error Message: CS0016: Could not write to output file 'c:\Windows...dll' 拒绝访问 C:\Windows\Te ...

  5. Visual Studio将std::cout输出到Output窗口

    在debug的时候,输出到Output需要使用OutputDebugString函数,但部分库的log是采用std::cout输出的,需要用控制台(黑窗)程序来查看输出.有没有一种使用GUI和Outp ...

  6. sql 存储过程 output参数的使用

    /*嵌套存储过程中需要输出来的参数*/output 就是这个存储过程返回的值 也可以说输出的值--创建存储过程 求最大值CREATE PROCEDURE [dbo].[P_Max]@a int, -- ...

  7. Qt Disable QDebug And Warning Output

    如何禁止qDebug的输出 在项目开发的过程中,为了开发方便,我们常常在Qt的Application Output中输出一些内容,慢慢的. 有些qDebug就会被我们遗忘再角落里. 虽然对整个程序影响 ...

  8. Data Flow的Error Output

    一,在Data Flow Task中,对于Error Row的处理通过Error Output Tab配置的. 1,操作失败的类型:Error(Conversion) 和 Truncation. 2, ...

  9. C#调用SQL中的存储过程中有output参数,存储过程执行过程中返回信息

      C#调用SQL中的存储过程中有output参数,类型是字符型的时候一定要指定参数的长度.不然获取到的结果总是只有第一字符.本人就是由于这个原因,折腾了很久.在此记录一下,供大家以后参考! 例如: ...

  10. insert into output使用

    declare @t table (logId int,customerId int,amount int) insert into log( customerId,amount) output in ...

随机推荐

  1. 时间处理:计算下一天日期,如输入"2004/12/31"(注释2014年12月31日),则输出"2005/1/1".

    /* ============================================================================ Name : Exercise.c Au ...

  2. mybatis入门--初识mybatis

    初识mybatis 今天,一起来说说mybits这个框架吧.这是一个持久层的框架.之前叫做ibatis.所以,在它的代码中出现ibatis这个词的时候,不要感到惊讶.不是写错了,它确实就是这个样子的. ...

  3. hdu 5129 (枚举) The E-pang Palace

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5128. 给你n个点,问能否组成两个不相交的与坐标轴平行的矩形,能就输出两矩形的面积和,不能就输出一个字符串 ...

  4. jquery源码学习

    1,"use strict"; //16行   用在代码开始处,表示之后的代码将按照严格模式执行

  5. java中 this 关键字的三种用法

    Java中this的三种用法 调用属性 (1)this可以调用本类中的任何成员变量 调用方法(可省略) (2)this调用本类中的成员方法(在main方法里面没有办法通过this调用) 调用构造方法 ...

  6. 12. pt-index-usage

    pt-index-usage h=192.168.100.101,P=3306,u=admin,p=admin /data/mysql3306/data/slow.log 根据slow log来判断i ...

  7. Lazarus的二维码解决方案

    不解释,直接上图

  8. 链接PDO

    header('Content-type:text/html;Charset=utf-8'); /** * 实例化PDO对象 */ // 1, 设置相关的参数 // 1.1 确定数据源 $dbms = ...

  9. 轻博客类Web原型制作分享——Tumblr

    Tumblr(汤博乐)成立于2007年,是目前全球最大的轻博客网站,也是轻博客网站的始祖. Tumblr是一种介于传统博客和微博之间的全新媒体形态,既注重表达,又注重社交,而且注重个性化设置,成为当前 ...

  10. openssl RSA基本加密解密

    #include <stdio.h> #include <string.h> #include <stdlib.h> #include <openssl/bn ...