本文整理汇总了PHP中CacheHandler::getInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheHandler::getInternal方法的具体用法?PHP CacheHandler::getInternal怎么用?PHP CacheHandler::getInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheHandler
的用法示例。
在下文中一共展示了CacheHandler::getInternal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get an image.
*
* Returns an image resource or false on failure. Fetches the image from
* CCP if needed.
* @param integer $id
* @param integer $size
* @return resource Image resource or false on failure.
*/
static function get($id, $size = 64)
{
$id = (int) $id;
$size = (int) $size;
if ($size != 32 && $size != 64) {
return false;
}
if (!$id) {
return imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
}
// If it's in the cache then read it from there.
if (CacheHandler::exists("{$id}_{$size}.png", "img")) {
return imagecreatefrompng(CacheHandler::getInternal("{$id}_{$size}.png", "img"));
} else {
$img = self::fetchImage($id, $size);
imagepng($img, CacheHandler::getInternal("{$id}_{$size}.png", "img"));
return $img ? $img : imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
}
}
示例2: getPortraitPath
/**
* Return the file path for the pilot's portrait.
*
* The portrait is not generated by this function. If the portrait does
* not exist then the path it would use is returned.
* @param integer $size The desired portrait size.
* @param integer $id The pilot ID to use. If not given and this is instantiated
* use the ID for this pilot.
* @return string path for a portrait.
*/
public function getPortraitPath($size = 64, $id = 0)
{
$size = intval($size);
$id = intval($id);
if (!$id) {
$id = $this->getExternalID();
}
return CacheHandler::getInternal($id . "_" . $size . ".jpg", "img");
}
示例3: header
} else {
header('Content-Type: image/jpeg');
readfile(CacheHandler::get("{$plt_ext_id}_sig_{$id}.jpg", 'img'));
die;
}
}
}
$pid = $pilot->getExternalID();
$cachePath = $pilot->getPortraitPath(256);
$thumb = new thumb($pid, 256);
if (!$thumb->isCached()) {
$thumb->genCache();
}
// check template
if (!is_dir(dirname(__FILE__) . '/signatures/' . $sig_name)) {
errorPic('Template not found.');
}
// let the template do the work, we just output $im
require dirname(__FILE__) . '/signatures/' . $sig_name . '/' . $sig_name . '.php';
if (headers_sent()) {
trigger_error('An error occured. Headers have already been sent.<br/>', E_USER_ERROR);
}
if (ob_get_contents()) {
trigger_error('An error occured. Content has already been sent.<br/>', E_USER_ERROR);
} else {
header('Content-Type: image/jpeg');
imagejpeg($im, CacheHandler::getInternal("{$plt_ext_id}_sig_{$id}.jpg", 'img'), 90);
readfile(CacheHandler::getInternal("{$plt_ext_id}_sig_{$id}.jpg", 'img'));
}
ob_end_flush();
die;
示例4: goType
function goType($type, $id, $size = 64, $imghost = "")
{
if ($size != 32 && $size != 64 && $size != 24 && $size != 48 && !($type == "ship" && ($size == 256 || ($size = 512)))) {
show404();
}
if ($id == 0) {
if ($size == 32 || $size == 64 || $size == 128 || $size == 256) {
header("Location: {$imghost}img/portrait_0_{$size}.jpg");
} else {
header("Location: {$imghost}img/portrait_0_64.jpg");
}
die;
}
define('KB_CACHEDIR', 'cache');
require_once "common/includes/class.cachehandler.php";
// If it's in the cache then read it from there.
if (CacheHandler::exists("{$id}_{$size}.png", "img")) {
expiryHeaders("png", CacheHandler::getInternal("{$id}_{$size}.png", "img"));
readfile(CacheHandler::getInternal("{$id}_{$size}.png", "img"));
die;
}
//TODO: add an optional memcache backed by the filecache
//Ships are available at 256 and 512
if ($type == 'ship' && $size > 64) {
$img = fetchImage($id, "Render", $size, "png");
} else {
if ($size > 32) {
if (CacheHandler::exists("{$id}_64.png", "img")) {
$img = imagecreatefrompng(CacheHandler::getInternal("{$id}_64.png", "img"));
} else {
$img = fetchImage($id, "InventoryType", 64, "png");
}
if ($img && $size != 64) {
resize($size, 64, $img, CacheHandler::getInternal("{$id}_{$size}.png", "img"));
}
} else {
if (CacheHandler::exists("{$id}_32.png", "img")) {
$img = imagecreatefrompng(CacheHandler::getInternal("{$id}_32.png", "img"));
} else {
$img = fetchImage($id, "InventoryType", 32, "png");
}
if ($img && $size != 32) {
resize($size, 32, $img, CacheHandler::getInternal("{$id}_{$size}.png", "img"));
}
}
}
if (!$img) {
show404();
}
expiryHeaders("png", CacheHandler::getInternal("{$id}_{$size}.png", "img"));
readfile(CacheHandler::getInternal("{$id}_{$size}.png", "img"));
die;
}
示例5: genNPC
function genNPC()
{
$source = 'img/corps/' . $this->id . '.png';
if (!file_exists($source)) {
$this->id = 0;
$source = 'img/corps/0.png';
$this->thumb = CacheHandler::getInternal($this->id . '_' . $this->size . '.png', $this->thumbDir);
}
$img = imagecreatefrompng($source);
if ($img) {
$newimg = imagecreatetruecolor($this->size, $this->size);
$color = imagecolortransparent($newimg, imagecolorallocatealpha($newimg, 0, 0, 0, 127));
imagefill($newimg, 0, 0, $color);
imagesavealpha($newimg, true);
$oldx = imagesx($img);
$oldy = imagesy($img);
imagecopyresampled($newimg, $img, 0, 0, 0, 0, $this->size, $this->size, $oldx, $oldy);
// Check the cache directories have been created.
CacheHandler::getInternal($this->id . '_' . $this->size . '.png', $this->thumbDir);
return imagepng($newimg, $this->thumb);
}
return false;
}