示例#1
0
 public static function getCharacterKeys($userID)
 {
     global $mdb, $redis;
     $apiVerifiedSet = new RedisTtlSortedSet('ttlss:apiVerified', 86400);
     $characterIDs = $redis->hGetAll("userID:api:{$userID}");
     if ($characterIDs == null) {
         $characterIDs = [];
     }
     $charIDs = [];
     foreach ($characterIDs as $charID => $value) {
         $raw = $redis->get("userID:api:{$userID}:{$charID}");
         $row = unserialize($raw);
         if (!isset($charIDs["{$charID}"])) {
             $charIDs["{$charID}"] = [];
         }
         $charIDs["{$charID}"]['characterID'] = $charID;
         if ($row['time'] > @$charIDs["{$charID}"]['time']) {
             $charIDs["{$charID}"]['time'] = $row['time'];
         }
         $charIDs["{$charID}"]['lastChecked'] = date('Y-m-d H:i', (int) @$charIDs["{$charID}"]['time']);
         $charIDs["{$charID}"]['keyID'] = $row['keyID'];
         $charIDs["{$charID}"]['keyType'] = @$row['type'];
         $charIDs["{$charID}"]['corporationID'] = $mdb->findField('information', 'corporationID', ['cacheTime' => 3600, 'type' => 'characterID', 'id' => $charID]);
         $apiVerified = $apiVerifiedSet->getTime((int) $charID);
         if ($apiVerified != null) {
             $charIDs["{$charID}"]['cachedUntilTime'] = date('Y-m-d H:i', $apiVerified + 3600);
         }
     }
     Info::addInfo($charIDs);
     return $charIDs;
 }
示例#2
0
 /**
  * @param int $allianceID
  *
  * @return array
  */
 public static function getCorps($allianceID)
 {
     global $mdb;
     $corpList = $mdb->find('information', ['type' => 'corporationID', 'memberCount' => ['$gt' => 0], 'allianceID' => (int) $allianceID], ['name' => 1]);
     $retList = array();
     foreach ($corpList as $corp) {
         $corp['corporationName'] = $corp['name'];
         $corp['corporationID'] = $corp['id'];
         $apiVerifiedSet = new RedisTtlSortedSet('ttlss:apiVerified', 86400);
         $count = $apiVerifiedSet->getTime((int) $corp['corporationID']);
         if ($count) {
             $corp['cachedUntilTime'] = date('Y-m-d H:i', $count);
             $corp['apiVerified'] = 1;
         }
         self::addInfo($corp);
         $retList[] = $corp;
     }
     return $retList;
 }
示例#3
0
$onlyHistory = array('character', 'corporation', 'alliance');
if ($pageType == 'stats' && in_array($key, $onlyHistory)) {
    $months = $mdb->findField('statistics', 'months', ['type' => $key . 'ID', 'id' => (int) $id]);
    if ($months != null) {
        krsort($months);
    }
    $detail['history'] = $months == null ? [] : $months;
} else {
    $detail['history'] = array();
}
// Figure out if the character or corporation has any API keys in the database
$apiVerified = false;
$nextApiCheck = null;
if (in_array($key, array('character', 'corporation'))) {
    $apiVerifiedSet = new RedisTtlSortedSet('ttlss:apiVerified', 86400);
    $apiVerified = $apiVerifiedSet->getTime((int) $id);
    if ($apiVerified == null) {
        $apiVerified = $apiVerifiedSet->getTime((int) @$detail['corporationID']);
    }
    if ($apiVerified != null) {
        $nextApiCheck = date('H:i', $apiVerified + 3600);
    }
}
$cnt = 0;
$cnid = 0;
$stats = array();
$totalcount = ceil(count($detail['stats']) / 4);
if ($detail['stats'] != null) {
    foreach ($detail['stats'] as $q) {
        if ($cnt == $totalcount) {
            ++$cnid;