<?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. Java中终止线程的三种方法

    终止线程一般建议采用的方法是让线程自行结束,进入Dead(死亡)状态,就是执行完run()方法.即如果想要停止一个线程的执行,就要提供某种方式让线程能够自动结束run()方法的执行.比如设置一个标志来 ...

  2. How to reconfigure installed dpkg package (tzdata, locales)

    1 List the installed dpkg package $ sudo dpkg --list 2 Reconfigure the package $ sudo dpkg-reconfigu ...

  3. c++11 多线程依次打印ABC

    并发 练习代码 #include <thread> #include <vector> #include <mutex> #include <iostream ...

  4. Partition Array Into Three Parts With Equal Sum LT1013

    Given an array A of integers, return true if and only if we can partition the array into three non-e ...

  5. android模拟器不能上网设置

    进行sdk目录中的platform-tools目录: adb devices 系统会罗列出所有设置 adb -s emulator- shell 最后设置网关 setprop net.dns1 192 ...

  6. windows 下设置nginx负载均衡

    #user nobody; worker_processes ; #error_log logs/error.log; #error_log logs/error.log notice; #error ...

  7. CentOS7安装ms8可能出现的错误

    参照<在Centos上安装MS8.0的详细过程>:http://muchong.com/html/201507/9145663.html 安装过程中如果库文件不全,会异常终止.报错情况如下 ...

  8. 2017/2/6:在oracle中varchar与varchar2的区别与增删改查

    1.varchar2把所有字符都占两字节处理(一般情况下),varchar只对汉字和全角等字符占两字节,数字,英文字符等都是一个字节:2.VARCHAR2把空串等同于null处理,而varchar仍按 ...

  9. Python之入门篇1

    一.安装python解释器 官网: https://www.python.org/downloads/windows/ 自行下载安装,添加环境变量 #测试安装是否成功 windows --> 运 ...

  10. substr()和substring()函数

    区别:主要是两者的参数不同 功能:相似. substr :返回一个从指定位置开始的指定长度的子字符串 substring :返回位于 String 对象中指定位置的子字符串. 用法: stringva ...