本文整理汇总了PHP中httpCache类的典型用法代码示例。如果您正苦于以下问题:PHP httpCache类的具体用法?PHP httpCache怎么用?PHP httpCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了httpCache类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minify
public function minify($cacheFile = null, $dir = null)
{
if ($dir === null) {
$dir = dirname($_SERVER['SCRIPT_FILENAME']);
}
// MODIFICATION TIME FILES
$mtFiles = array(__FILE__, $_SERVER['SCRIPT_FILENAME'], "conf/config.php");
// GET SOURCE CODE FILES
$files = dir::content($dir, array('types' => "file", 'pattern' => '/^.*\\.' . $this->type . '$/'));
// GET NEWEST MODIFICATION TIME
$mtime = 0;
foreach (array_merge($mtFiles, $files) as $file) {
$fmtime = filemtime($file);
if ($fmtime > $mtime) {
$mtime = $fmtime;
}
}
$header = "Content-Type: {$this->mime[$this->type]}";
// GET SOURCE CODE FROM CLIENT HTTP CACHE IF EXISTS
httpCache::checkMTime($mtime, $header);
// OUTPUT SOURCE CODE
header($header);
// GET SOURCE CODE FROM SERVER-SIDE CACHE
if ($cacheFile !== null && file_exists($cacheFile) && (filemtime($cacheFile) >= $mtime || !is_writable($cacheFile))) {
// with its distribution content
readfile($cacheFile);
die;
}
// MINIFY AND JOIN SOURCE CODE
$source = "";
foreach ($files as $file) {
if (strlen($this->minCmd) && substr($file, 4, 1) != "_") {
$cmd = str_replace("{file}", $file, $this->minCmd);
$source .= `{$cmd}`;
} else {
$source .= file_get_contents($file);
}
}
// UPDATE SERVER-SIDE CACHE
if ($cacheFile !== null && (is_writable($cacheFile) || !file_exists($cacheFile) && dir::isWritable(dirname($cacheFile)))) {
file_put_contents($cacheFile, $source);
touch($cacheFile, $mtime);
}
// OUTPUT SOURCE CODE
echo $source;
}
示例2: header
* @author Pavel Tzonkov <sunhater@sunhater.com>
* @copyright 2010-2014 KCFinder Project
* @license http://opensource.org/licenses/GPL-3.0 GPLv3
* @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
* @link http://kcfinder.sunhater.com
*/
namespace kcfinder;
require "core/autoload.php";
if (!isset($_GET['lng']) || $_GET['lng'] == 'en' || $_GET['lng'] != basename($_GET['lng']) || !is_file("lang/" . $_GET['lng'] . ".php")) {
header("Content-Type: text/javascript");
die;
}
$file = "lang/" . $_GET['lng'] . ".php";
$mtime = @filemtime($file);
if ($mtime) {
httpCache::checkMTime($mtime, "Content-Type: text/javascript");
}
require $file;
header("Content-Type: text/javascript");
echo "_.labels={";
$i = 0;
foreach ($lang as $english => $native) {
if (substr($english, 0, 1) != "_") {
echo "'" . text::jsValue($english) . "':\"" . text::jsValue($native) . "\"";
if (++$i < count($lang)) {
echo ",";
}
}
}
echo "}";
示例3: act_thumb
protected function act_thumb()
{
$this->getDir($this->get['dir'], true);
if (!isset($this->get['file']) || !isset($this->get['dir'])) {
$this->sendDefaultThumb();
}
$file = $this->get['file'];
if (basename($file) != $file) {
$this->sendDefaultThumb();
}
$file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
if (!is_file($file) || !is_readable($file)) {
$file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
if (!is_file($file) || !is_readable($file)) {
$this->sendDefaultThumb($file);
}
$image = new gd($file);
if ($image->init_error) {
$this->sendDefaultThumb($file);
}
$browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
if (in_array($image->type, $browsable) && $image->get_width() <= $this->config['thumbWidth'] && $image->get_height() <= $this->config['thumbHeight']) {
$type = $image->type == IMAGETYPE_GIF ? "gif" : ($image->type == IMAGETYPE_PNG ? "png" : "jpeg");
$type = "image/{$type}";
httpCache::file($file, $type);
} else {
$this->sendDefaultThumb($file);
}
}
httpCache::file($file, "image/jpeg");
}
示例4: browser
/** This file is part of KCFinder project
*
* @desc Base CSS definitions
* @package KCFinder
* @version 2.21
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
* @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
* @link http://kcfinder.sunhater.com
*/
require "core/autoload.php";
$mtime = @filemtime(__FILE__);
if ($mtime) {
httpCache::checkMTime($mtime);
}
$browser = new browser();
$config = $browser->config;
ob_start();
?>
html, body {
overflow: hidden;
}
body, form, th, td {
margin: 0;
padding: 0;
}
a {
示例5: act_thumb
protected function act_thumb()
{
$this->getDir($this->get['dir'], true);
if (!isset($this->get['file']) || !isset($this->get['dir'])) {
$this->sendDefaultThumb();
}
$file = $this->get['file'];
if (basename($file) != $file) {
$this->sendDefaultThumb();
}
$file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
if (!is_file($file) || !is_readable($file)) {
$file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
if (!is_file($file) || !is_readable($file)) {
$this->sendDefaultThumb($file);
}
$image = image::factory($this->imageDriver, $file);
if ($image->initError) {
$this->sendDefaultThumb($file);
}
list($tmp, $tmp, $type) = getimagesize($file);
if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
$mime = $type == IMAGETYPE_GIF ? "gif" : ($type == IMAGETYPE_PNG ? "png" : "jpeg");
$mime = "image/{$mime}";
httpCache::file($file, $mime);
} else {
$this->sendDefaultThumb($file);
}
}
httpCache::file($file, "image/jpeg");
}
示例6: act_thumb
protected function act_thumb()
{
if (!isset($_GET['file']) || !isset($_GET['dir']) || !$this->checkFilename($_GET['file'])) {
$this->sendDefaultThumb();
}
$dir = $this->getDir();
$file = "{$this->thumbsTypeDir}/{$_GET['dir']}/{$_GET['file']}";
// Create thumbnail
if (!is_file($file) || !is_readable($file)) {
$file = "{$dir}/{$_GET['file']}";
if (!is_file($file) || !is_readable($file)) {
$this->sendDefaultThumb($file);
}
$image = image::factory($this->imageDriver, $file);
if ($image->initError) {
$this->sendDefaultThumb($file);
}
$img = new fastImage($file);
$type = $img->getType();
$img->close();
if (in_array($type, array("gif", "jpeg", "png")) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
$mime = "image/{$type}";
httpCache::file($file, $mime);
} else {
$this->sendDefaultThumb($file);
}
// Get type from already-existing thumbnail
} else {
$img = new fastImage($file);
$type = $img->getType();
$img->close();
}
httpCache::file($file, "image/{$type}");
}
示例7: glob
<?php
/** This file is part of KCFinder project
*
* @desc Join all JavaScript files in current directory
* @package KCFinder
* @version {version}
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
* @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
* @link http://kcfinder.sunhater.com
*/
require "../../lib/helper_httpCache.php";
$files = glob("*.js");
foreach ($files as $file) {
$fmtime = filemtime($file);
if (!isset($mtime) || $fmtime > $mtime) {
$mtime = $fmtime;
}
}
httpCache::checkMTime($mtime);
header("Content-Type: text/javascript");
ob_start();
foreach ($files as $file) {
require $file;
}
httpCache::content(ob_get_clean(), $mtime);