本文整理匯總了PHP中httpCache::file方法的典型用法代碼示例。如果您正苦於以下問題:PHP httpCache::file方法的具體用法?PHP httpCache::file怎麽用?PHP httpCache::file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類httpCache
的用法示例。
在下文中一共展示了httpCache::file方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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");
}
示例2: 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");
}
示例3: 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}");
}