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; }
/** * @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; }
} $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) {
if (!$exists) { try { $mdb->getCollection('crestmails')->save(['killID' => (int) $killID, 'hash' => $hash, 'processed' => false, 'source' => 'api', 'added' => $mdb->now()]); ++$killsAdded; } catch (MongoDuplicateKeyException $ex) { // ignore it *sigh* } } if (!$exists && $debug) { Util::out("Added {$killID} from API"); } } // helpful info for output if needed $info = $mdb->findDoc('information', ['type' => 'characterID', 'id' => $charID], [], ['name' => 1, 'corporationID' => 1]); $corpInfo = $mdb->findDoc('information', ['type' => 'corporationID', 'id' => @$info['corporationID']], [], ['name' => 1]); $apiVerifiedSet = new RedisTtlSortedSet('ttlss:apiVerified', 86400); $apiVerifiedSet->add(time(), $type == 'Corporation' ? @$info['corporationID'] : $charID); if ($newMaxKillID == 0) { $tqApiChars->setTime($row, time() + rand(72000, 86400)); } // If we got new kills tell the log about it if ($killsAdded > 0) { if ($type == 'Corporation') { $name = 'corp ' . @$corpInfo['name']; } else { $name = 'char ' . @$info['name']; } while (strlen("{$killsAdded}") < 3) { $killsAdded = ' ' . $killsAdded; } Util::out("{$killsAdded} kills added by {$name}");
public function registerListener($queueID) { $allQueues = new RedisTtlSortedSet('redisQ:allQueues'); $allQueues->add(time(), $queueID); }
<?php namespace RedisQ; require_once "../init.php"; $allQueues = new RedisTtlSortedSet('redisQ:allQueues'); $objectQueues = new RedisTtlSortedSet('objectQueues'); $listeners = number_format($allQueues->count(), 0); $objects = number_format($objectQueues->count(), 0); header("Content-type: text/text"); echo "{$listeners} Listeners\n"; echo "{$objects} Objects\n";