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


PHP CacheHandler::put方法代码示例

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


在下文中一共展示了CacheHandler::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: killListToXML


//.........这里部分代码省略.........
             $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());
             } else {
                 if (strcasecmp($invAlliance->getName(), "None") == 0) {
                     $invrow->addAttribute('allianceID', 0);
                     $invrow->addAttribute('allianceName', "");
                 } else {
                     $invrow->addAttribute('allianceID', $invAlliance->getExternalID());
                     $invrow->addAttribute('allianceName', $invAlliance->getName());
                 }
                 $invrow->addAttribute('factionID', 0);
                 $invrow->addAttribute('factionName', '');
             }
             $invrow->addAttribute('securityStatus', number_format($inv['ind_sec_status'], 1));
             $invrow->addAttribute('damageDone', $inv['ind_dmgdone']);
             if ($inv['plt_id'] == $kill->getFBPilotID()) {
                 $final = 1;
             } else {
                 $final = 0;
             }
             $invrow->addAttribute('finalBlow', $final);
         }
         $sql = "SELECT * FROM kb3_items_destroyed WHERE itd_kll_id = " . $kill->getID();
         $qry->execute($sql);
         $qry2 = DBFactory::getDBQuery();
         $sql = "SELECT * FROM kb3_items_dropped WHERE itd_kll_id = " . $kill->getID();
         $qry2->execute($sql);
         if ($qry->recordCount() || $qry2->recordCount()) {
             $items = $row->addChild('rowset');
             $items->addAttribute('name', 'items');
             $items->addAttribute('columns', 'typeID,flag,qtyDropped,qtyDestroyed, singleton');
             while ($iRow = $qry->getRow()) {
                 $itemRow = $items->addChild('row');
                 $itemRow->addAttribute('typeID', $iRow['itd_itm_id']);
                 $itemRow->addAttribute('flag', $iRow['itd_itl_id']);
                 if ($iRow['itd_itl_id'] == -1) {
                     $itemRow->addAttribute('singleton', 2);
                 } else {
                     $itemRow->addAttribute('singleton', 0);
                 }
                 $itemRow->addAttribute('qtyDropped', 0);
                 $itemRow->addAttribute('qtyDestroyed', $iRow['itd_quantity']);
             }
             while ($iRow = $qry2->getRow()) {
                 $itemRow = $items->addChild('row');
                 $itemRow->addAttribute('typeID', $iRow['itd_itm_id']);
                 $itemRow->addAttribute('flag', $iRow['itd_itl_id']);
                 if ($iRow['itd_itl_id'] == -1) {
                     $itemRow->addAttribute('singleton', 2);
                 } else {
                     $itemRow->addAttribute('singleton', 0);
                 }
                 $itemRow->addAttribute('qtyDropped', $iRow['itd_quantity']);
                 $itemRow->addAttribute('qtyDestroyed', 0);
             }
         }
         if (config::get('km_cache_enabled')) {
             CacheHandler::put($kill->getID() . ".xml", $row->asXML(), 'mails');
         }
         $timing .= $kill->getID() . ": " . (microtime(true) - $starttime) . "<br />";
     }
     $sxe->addChild('cachedUntil', $date);
     return $sxe->asXML();
 }
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:101,代码来源:class.idfeed.php

示例2: fetchImage

function fetchImage($id, $type = 'Character', $size = 128, $ext = "jpg")
{
    include_once 'kbconfig.php';
    require_once 'common/includes/globals.php';
    require_once "common/includes/class.cachehandler.php";
    $url = 'http://' . IMG_SERVER . "/" . $type . "/" . $id . "_" . $size . "." . $ext;
    if (function_exists('curl_init')) {
        // in case of a dead eve server we only want to wait 2 seconds
        @ini_set('default_socket_timeout', 2);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
        // CURLOPT_FOLLOWLOCATION doesn't work if safe mode or open_basedir is set
        // For pilots we should try from oldportraits.eveonline.com if the main server doesn't have them.
        //if($type != 'Character') curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        //curl_setopt($ch, CURLOPT_HEADER, true);
        $file = curl_exec($ch);
        //list($header, $file) = explode("\n\n", $file, 2);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($http_code != 200) {
            if ($type == 'Character') {
                $url = "http://oldportraits.eveonline.com/Character/" . $id . "_" . $size . "." . $ext;
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                $file = curl_exec($ch);
                $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                if ($http_code != 200) {
                    $file = file_get_contents("img/1_{$size}.jpg");
                }
            } else {
                if ($type == 'Alliance') {
                    $file = file_get_contents("img/alliances/default.png");
                } else {
                    if ($type == 'Corporation') {
                        $file = file_get_contents("img/corps/default.png");
                    } else {
                        show404();
                    }
                }
            }
        }
        curl_close($ch);
    } else {
        require_once 'common/includes/class.httprequest.php';
        // in case of a dead eve server we only want to wait 2 seconds
        @ini_set('default_socket_timeout', 2);
        // try alternative access via fsockopen
        // happens if allow_url_fopen wrapper is false
        $http = new http_request($url);
        $file = $http->get_content();
        $http_code = $http->get_http_code();
        if ($http_code != 200) {
            if ($type == 'Character') {
                $url = "http://oldportraits.eveonline.com/Character/" . $id . "_" . $size . "." . $ext;
                $http = new http_request($url);
                $file = $http->get_content();
                $http_code = $http->get_http_code();
                if ($http_code != 200) {
                    $file = file_get_contents("img/1_{$size}.jpg");
                }
            } else {
                if ($type == 'Alliance') {
                    $file = file_get_contents("img/alliances/default.png");
                } else {
                    if ($type == 'Corporation') {
                        $file = file_get_contents("img/corps/default.png");
                    } else {
                        show404();
                    }
                }
            }
        }
    }
    if ($img = @imagecreatefromstring($file)) {
        CacheHandler::put($id . '_' . $size . '.' . $ext, $file, 'img');
    }
    return $img;
}
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:79,代码来源:thumb.php


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