本文整理汇总了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;
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:46,代码来源:minifier.php
示例2: header
* @author Pavel Tzonkov <[email protected]>
* @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 "}";
开发者ID:christianallred,项目名称:fluent_univ,代码行数:31,代码来源:js_localize.php
示例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");
}
开发者ID:kinghinds,项目名称:kingtest2,代码行数:31,代码来源:browser.php
示例4: browser
/** This file is part of KCFinder project
*
* @desc Base CSS definitions
* @package KCFinder
* @version 2.21
* @author Pavel Tzonkov <[email protected]>
* @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 {
开发者ID:alejandrozepeda,项目名称:gvm,代码行数:30,代码来源:css.php
示例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");
}
开发者ID:Fess7,项目名称:evolution,代码行数:31,代码来源:browser.php
示例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}");
}
开发者ID:Radius17,项目名称:kcfinder,代码行数:34,代码来源:browser.php
示例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 <[email protected]>
* @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);
开发者ID:r-kitaev,项目名称:limb,代码行数:28,代码来源:index.php
注:本文中的httpCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论