当前位置: 首页>>代码示例>>PHP>>正文


PHP CacheHandler::exists方法代码示例

本文整理汇总了PHP中CacheHandler::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheHandler::exists方法的具体用法?PHP CacheHandler::exists怎么用?PHP CacheHandler::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheHandler的用法示例。


在下文中一共展示了CacheHandler::exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
     }
 }
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:28,代码来源:shipImage.php

示例2: getPortraitURL

 /**
  * Return the URL for the alliance's portrait. If the alliance has a
  * portrait in the board's img/alliances directory, that portrait will be
  * used
  *
  * @param integer $size The desired portrait size.
  * @return string URL for a portrait.
  */
 function getPortraitURL($size = 128)
 {
     if (isset($this->imgurl[$size])) {
         return $this->imgurl[$size];
     }
     if (file_exists("img/alliances/" . $this->getUnique() . ".png")) {
         if ($size == 128) {
             $this->imgurl[$size] = IMG_HOST . "/img/alliances/" . $this->getUnique() . ".png";
         } else {
             if (CacheHandler::exists($this->getUnique() . "_{$size}.png", 'img')) {
                 $this->imgurl[$size] = KB_HOST . "/" . CacheHandler::getExternal($this->getUnique() . "_{$size}.png", 'img');
             } else {
                 $this->imgurl[$size] = KB_HOST . '/?a=thumb&type=alliance&id=' . $this->getUnique() . '&size=' . $size;
             }
         }
         $this->putCache();
     } else {
         if ($this->getExternalID()) {
             $this->imgurl[$size] = imageURL::getURL('Alliance', $this->getExternalID(), $size);
             $this->putCache();
         } else {
             $this->imgurl[$size] = imageURL::getURL('Alliance', 1, $size);
         }
     }
     return $this->imgurl[$size];
 }
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:34,代码来源:class.alliance.php

示例3: errorPic

// If we still don't have an external ID then just use the internal for names.
if (!$plt_ext_id) {
    $plt_ext_id = $plt_id;
}
if (!$pilot->exists()) {
    errorPic('That pilot doesnt exist.');
}
$corp = $pilot->getCorp();
$alliance = $corp->getAlliance();
// we dont generate pictures for non-members
if (array_search($alliance->getID(), config::get('cfg_allianceid')) === false && !array_search($corp->getID(), config::get('cfg_corpid')) === false && !array_search($pilot->getID(), config::get('cfg_pilotid')) === false) {
    errorPic('Invalid pilot');
}
$id = abs(crc32($sig_name));
// check for cached version
if (file_exists(CacheHandler::exists("{$plt_ext_id}_sig_{$id}.jpg", 'img'))) {
    // cache files for 120 minutes
    if (time() - CacheHandler::age("{$plt_ext_id}_sig_{$id}.jpg", 'img') < 120 * 60 || lastKill($plt_id) > 120 * 60) {
        if (isset($_SERVER['HTTP_IF_NONE_MATCH']) || isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            header($_SERVER["SERVER_PROTOCOL"] . " 304 Not Modified");
            die;
        } 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);
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:31,代码来源:sig.php

示例4: killListToXML

 /**
  *
  * @param KillList $killList
  * @return string KillList as XML
  */
 public static function killListToXML($killList)
 {
     global $idfeedversion;
     $qry = DBFactory::getDBQuery();
     $date = gmdate('Y-m-d H:i:s');
     $xml = "<?xml version='1.0' encoding='UTF-8'?>\n\t\t<eveapi version='2' edkapi='" . $idfeedversion . "'>\n\t\t</eveapi>";
     $sxe = new SimpleXMLElement($xml);
     // Let's start making the xml.
     $sxe->addChild('currentTime', $date);
     $result = $sxe->addChild('result');
     $kills = $result->addChild('rowset');
     $kills->addAttribute('name', 'kills');
     $kills->addAttribute('key', 'killID');
     $kills->addAttribute('columns', 'killID,solarSystemID,killTime,moonID,hash,trust');
     $count = 0;
     $timing = '';
     while ($kill = $killList->getKill()) {
         if (config::get('km_cache_enabled') && CacheHandler::exists($kill->getID() . ".xml", 'mails')) {
             $cachedRow = new SimpleXMLElement(CacheHandler::get($kill->getID() . ".xml", 'mails'));
             IDFeed::addXMLElement($kills, $cachedRow);
             continue;
         }
         $count++;
         if ($kill->isClassified()) {
             continue;
         }
         //$kill = Kill::getByID($kill->getID());
         $row = $kills->addChild('row');
         $row->addAttribute('killID', intval($kill->getExternalID()));
         $row->addAttribute('killInternalID', intval($kill->getID()));
         $row->addAttribute('solarSystemID', $kill->getSystem()->getExternalID());
         $row->addAttribute('killTime', $kill->getTimeStamp());
         $row->addAttribute('moonID', '0');
         $row->addAttribute('hash', bin2hex(IDFeed::getHash($kill, true)));
         $row->addAttribute('trust', 3);
         $victim = Pilot::getByID($kill->getVictimID());
         $victimCorp = Corporation::getByID($kill->getVictimCorpID());
         $victimAlliance = Alliance::getByID($kill->getVictimAllianceID());
         $victimrow = $row->addChild('victim');
         if ($victim->getName() == $kill->getVictimShipName()) {
             $victimrow->addAttribute('characterID', "0");
             $victimrow->addAttribute('characterName', "");
         } else {
             $victimrow->addAttribute('characterID', $victim->getExternalID());
             $victimrow->addAttribute('characterName', $victim->getName());
         }
         $victimrow->addAttribute('corporationID', $victimCorp->getExternalID());
         $victimrow->addAttribute('corporationName', $victimCorp->getName());
         if ($victimAlliance->isFaction()) {
             $victimrow->addAttribute('allianceID', 0);
             $victimrow->addAttribute('allianceName', '');
             $victimrow->addAttribute('factionID', $victimAlliance->getFactionID());
             $victimrow->addAttribute('factionName', $victimAlliance->getName());
         } else {
             $victimrow->addAttribute('allianceID', $victimAlliance->getExternalID());
             $victimrow->addAttribute('allianceName', $victimAlliance->getName());
             $victimrow->addAttribute('factionID', 0);
             $victimrow->addAttribute('factionName', '');
         }
         $victimrow->addAttribute('damageTaken', $kill->getDamageTaken());
         $victimrow->addAttribute('shipTypeID', $kill->getVictimShipExternalID());
         $involved = $row->addChild('rowset');
         $involved->addAttribute('name', 'attackers');
         $involved->addAttribute('columns', 'characterID,characterName,corporationID,corporationName,allianceID,allianceName,factionID,factionName,securityStatus,damageDone,finalBlow,weaponTypeID,shipTypeID');
         $sql = "SELECT ind_sec_status, ind_all_id, ind_crp_id,\n\t\t\t\tind_shp_id, ind_wep_id, ind_order, ind_dmgdone, plt_id, plt_name,\n\t\t\t\tplt_externalid, crp_name, crp_external_id,\n\t\t\t\twtype.typeName AS wep_name FROM kb3_inv_detail\n\t\t\t\tJOIN kb3_pilots ON (plt_id = ind_plt_id)\n\t\t\t\tJOIN kb3_corps ON (crp_id = ind_crp_id)\n\t\t\t\tJOIN kb3_invtypes wtype ON (ind_wep_id = wtype.typeID)\n\t\t\t\tWHERE ind_kll_id = " . $kill->getID() . " ORDER BY ind_order ASC";
         $qry->execute($sql);
         while ($inv = $qry->getRow()) {
             $invrow = $involved->addChild('row');
             if (strpos($inv['plt_name'], '- ') !== false) {
                 $inv['plt_name'] = substr($inv['plt_name'], strpos($inv['plt_name'], '- ') + 2);
             } else {
                 if (strpos($inv['plt_name'], '#') !== false) {
                     $name = explode("#", $inv['plt_name']);
                     $inv['plt_name'] = $name[3];
                 }
             }
             if ($inv['plt_name'] == $inv['wep_name']) {
                 $invrow->addAttribute('characterID', 0);
                 $invrow->addAttribute('characterName', "");
                 $invrow->addAttribute('weaponTypeID', 0);
                 $invrow->addAttribute('shipTypeID', $inv['ind_wep_id']);
             } else {
                 $invrow->addAttribute('characterID', $inv['plt_externalid']);
                 $invrow->addAttribute('characterName', $inv['plt_name']);
                 $invrow->addAttribute('weaponTypeID', $inv['ind_wep_id']);
                 $invrow->addAttribute('shipTypeID', $inv['ind_shp_id']);
             }
             $invrow->addAttribute('corporationID', $inv['crp_external_id']);
             $invrow->addAttribute('corporationName', $inv['crp_name']);
             $invAlliance = Alliance::getByID($inv['ind_all_id']);
             if ($invAlliance->isFaction()) {
                 $invrow->addAttribute('allianceID', 0);
                 $invrow->addAttribute('allianceName', '');
                 $invrow->addAttribute('factionID', $invAlliance->getFactionID());
                 $invrow->addAttribute('factionName', $invAlliance->getName());
//.........这里部分代码省略.........
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:101,代码来源:class.idfeed.php

示例5: 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;
}
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:53,代码来源:thumb.php

示例6: genCorp

 function genCorp()
 {
     $source = 'img/corps/' . $this->id . '.png';
     // id matches an npc image.
     if (file_exists($source)) {
         $img = imagecreatefrompng($source);
     } else {
         if (CacheHandler::exists($this->id . '_128.png', $this->thumbDir)) {
             $img = imagecreatefrompng(CacheHandler::getInternal($this->id . '_128.png', $this->thumbDir));
         } else {
             $img = $this->fetchImage('Corporation', 128);
             if ($this->size == 128 && $img) {
                 return true;
             }
         }
     }
     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);
         $this->thumb = CacheHandler::getInternal($this->id . '_' . $this->size . '.png', $this->thumbDir);
         imagepng($newimg, $this->thumb);
     } else {
         return false;
     }
     return true;
 }
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:31,代码来源:class.thumb.php


注:本文中的CacheHandler::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。