public static function getTopIsk($parameters = array(), $allTime = false) { global $mdb; if (!isset($parameters['limit'])) { $parameters['limit'] = 5; } $parameters['orderBy'] = 'zkb.totalValue'; $hashKey = 'getTopIsk:' . serialize($parameters); $result = RedisCache::get($hashKey); if ($result != null) { return $result; } $result = Kills::getKills($parameters); RedisCache::set($hashKey, $result, 300); return $result; }
/** * Returns kills in json format according to the specified parameters. * * @static * * @param array $parameters * * @return array */ public static function getKills($parameters = array()) { global $debug; $ip = IP::get(); $userAgent = @$_SERVER['HTTP_USER_AGENT']; if ($debug) { Log::log('API Fetch: ' . $_SERVER['REQUEST_URI'] . ' (' . $ip . ' / ' . $userAgent . ')'); } if (isset($parameters['limit']) && $parameters['limit'] > 200) { $parameters['limit'] = 200; } if (isset($parameters['page'])) { $parameters['limit'] = 200; } if (!isset($parameters['limit'])) { $parameters['limit'] = 200; } $kills = Kills::getKills($parameters, true, false); return self::getJSON($kills, $parameters); }
} } $pageTitle = implode(',', $pageTitle); $pageType = 'subdomain'; } else { $topPoints = array(); $topIsk = Stats::getTopIsk(array('cacheTime' => 15 * 60, 'pastSeconds' => 7 * 86400, 'limit' => 5)); $topPods = array(); $top = array(); $top[] = json_decode(Storage::retrieve('TopChars', [], 900), true); $top[] = json_decode(Storage::retrieve('TopCorps', [], 900), true); $top[] = json_decode(Storage::retrieve('TopAllis', [], 900), true); $top[] = json_decode(Storage::retrieve('TopShips', [], 900), true); $top[] = json_decode(Storage::retrieve('TopSystems', [], 900), true); // get latest kills $kills = Kills::getKills(array('cacheTime' => 60, 'limit' => 50)); // Collect active PVP stats $types = ['characterID', 'corporationID', 'allianceID', 'shipTypeID', 'solarSystemID', 'regionID']; $activePvP = []; foreach ($types as $type) { $result = Stats::getDistinctCount($type, []); if ($result <= 1) { continue; } $type = str_replace('ID', '', $type); if ($type == 'shipType') { $type = 'Ship'; } elseif ($type == 'solarSystem') { $type = 'System'; } else { $type = ucfirst($type);
$kills = Kills::getKills(array("groupID" => array(351064, 351210), "limit" => $limit, "cacheTime" => 300, "losses" => true, "page" => $page)); break; case "dust_vehicles": $kills = Kills::getKills(array("groupID" => "351210", "limit" => $limit, "cacheTime" => 300, "losses" => true, "page" => $page)); break; /* case "lowsec": $kills = Kills::getKills(array("lowsec" => true, "page" => $page)); break; case "highsec": $kills = Kills::getKills(array("highsec" => true, "page" => $page)); break; case "nullsec": $kills = Kills::getKills(array("nullsec" => true, "page" => $page)); break;*/ /* case "lowsec": $kills = Kills::getKills(array("lowsec" => true, "page" => $page)); break; case "highsec": $kills = Kills::getKills(array("highsec" => true, "page" => $page)); break; case "nullsec": $kills = Kills::getKills(array("nullsec" => true, "page" => $page)); break;*/ case "w-space": $kills = Kills::getKills(array("w-space" => true, "page" => $page)); break; default: $kills = Kills::getKills(array("combined" => true, "page" => $page)); break; } $app->render("kills.html", array("kills" => $kills, "page" => $page, "pageType" => $type, "pager" => true));
$kills = Kills::getKills(array('groupID' => array(547, 485), 'limit' => $limit, 'cacheTime' => 300, 'losses' => true, 'page' => $page)); break; case 'freighters': $kills = Kills::getKills(array('groupID' => array(513, 902, 941), 'limit' => $limit, 'cacheTime' => 300, 'losses' => true, 'page' => $page)); break; case 'supers': $kills = Kills::getKills(array('groupID' => array(30, 659), 'limit' => $limit, 'cacheTime' => 300, 'losses' => true, 'page' => $page)); break; case 'dust': $kills = Kills::getKills(array('groupID' => array(351064, 351210), 'limit' => $limit, 'cacheTime' => 300, 'losses' => true, 'page' => $page)); break; case 'dust_vehicles': $kills = Kills::getKills(array('groupID' => '351210', 'limit' => $limit, 'cacheTime' => 300, 'losses' => true, 'page' => $page)); break; case 'lowsec': $kills = Kills::getKills(array('lowsec' => true, 'page' => $page)); break; case 'highsec': $kills = Kills::getKills(array('highsec' => true, 'page' => $page)); break; case 'nullsec': $kills = Kills::getKills(array('nullsec' => true, 'page' => $page)); break; case 'w-space': $kills = Kills::getKills(array('w-space' => true, 'page' => $page)); break; default: $kills = Kills::getKills(array('combined' => true, 'page' => $page)); break; } $app->render('kills.html', array('kills' => $kills, 'page' => $page, 'killsType' => $type, 'pager' => true));
die; } $columnName = $map[$key]['column'] . 'ID'; $mixedKills = $pageType == 'overview' && $map[$key]['mixed'] && UserConfig::get('mixKillsWithLosses', true); $mixed = $pageType == 'overview' ? Kills::getKills($parameters) : array(); $kills = $pageType == 'kills' ? Kills::getKills($parameters) : array(); $losses = $pageType == 'losses' ? Kills::getKills($parameters) : array(); if ($pageType != 'solo' || $key == 'faction') { $soloKills = array(); //$soloCount = 0; } else { $soloParams = $parameters; if (!isset($parameters['kills']) || !isset($parameters['losses'])) { $soloParams['mixed'] = true; } $soloKills = Kills::getKills($soloParams); } //$soloPages = ceil($soloCount / $limit); $solo = Kills::mergeKillArrays($soloKills, array(), $limit, $columnName, $id); $validAllTimePages = array('character', 'corporation', 'alliance', 'faction'); $topLists = array(); $topKills = array(); if ($pageType == 'top' || $pageType == 'topalltime') { $topParameters = $parameters; // array("limit" => 10, "kills" => true, "$columnName" => $id); $topParameters['limit'] = 10; if ($pageType == 'topalltime' && $key != 'character') { $useType = $key; if ($useType == 'ship') { $useType = 'shipType'; } elseif ($useType == 'system') {
<?php require_once '../init.php'; $i = date('i'); if ($i % 15 != 0) { exit; } $p = array(); $numDays = 7; $p['limit'] = 10; $p['pastSeconds'] = $numDays * 86400; $p['kills'] = true; Storage::store('Kills5b+', json_encode(Kills::getKills(array('iskValue' => 5000000000), true, false))); Storage::store('Kills10b+', json_encode(Kills::getKills(array('iskValue' => 10000000000), true, false))); Storage::store('TopChars', json_encode(Info::doMakeCommon('Top Characters', 'characterID', getStats('characterID')))); Storage::store('TopCorps', json_encode(Info::doMakeCommon('Top Corporations', 'corporationID', getStats('corporationID')))); Storage::store('TopAllis', json_encode(Info::doMakeCommon('Top Alliances', 'allianceID', getStats('allianceID')))); Storage::store('TopShips', json_encode(Info::doMakeCommon('Top Ships', 'shipTypeID', getStats('shipTypeID')))); Storage::store('TopSystems', json_encode(Info::doMakeCommon('Top Systems', 'solarSystemID', getStats('solarSystemID')))); Storage::store('TopIsk', json_encode(Stats::getTopIsk(array('pastSeconds' => $numDays * 86400, 'limit' => 5)))); // Cleanup old sessions Db::execute('delete from zz_users_sessions where validTill < now()'); // Keep the account balance table clean Db::execute('delete from zz_account_balance where balance = 0'); // Cleanup subdomain stuff Db::execute('update zz_subdomains set adfreeUntil = null where adfreeUntil < now()'); Db::execute("update zz_subdomains set banner = null where banner = ''"); Db::execute("delete from zz_subdomains where adfreeUntil is null and banner is null and (alias is null or alias = '')"); // Expire change expirations Db::execute('update zz_users set change_expiration = null, change_hash = null where change_expiration < date_sub(now(), interval 3 day)'); function getStats($column)
$app->redirect($url, 302); die; } $systemInfo = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'solarSystemID', 'id' => $systemID]); $systemName = $systemInfo['name']; $regionInfo = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'regionID', 'id' => $systemInfo['regionID']]); $regionName = $regionInfo['name']; $unixTime = strtotime($relatedTime); $time = date('Y-m-d H:i', $unixTime); $exHours = 1; if ((int) $exHours < 1 || (int) $exHours > 12) { $exHours = 1; } $key = md5("br:{$systemID}:{$relatedTime}:{$exHours}:" . json_encode($json_options) . (isset($battleID) ? ":{$battleID}" : "")); $mc = RedisCache::get($key); if ($mc == null) { $parameters = array('solarSystemID' => $systemID, 'relatedTime' => $relatedTime, 'exHours' => $exHours, 'nolimit' => true); $kills = Kills::getKills($parameters); $summary = Related::buildSummary($kills, $json_options); $mc = array('summary' => $summary, 'systemName' => $systemName, 'regionName' => $regionName, 'time' => $time, 'exHours' => $exHours, 'solarSystemID' => $systemID, 'relatedTime' => $relatedTime, 'options' => json_encode($json_options)); if (isset($battleID) && $battleID > 0) { $teamA = $summary['teamA']['totals']; $teamB = $summary['teamB']['totals']; unset($teamA['groupIDs']); unset($teamB['groupIDs']); $mdb->set("battles", ['battleID' => $battleID], ['teamA' => $teamA]); $mdb->set("battles", ['battleID' => $battleID], ['teamB' => $teamB]); } RedisCache::set($key, $mc, 300); } $app->render('related.html', $mc);
$campaign = Db::queryRow('select * from zz_campaigns where uri = :uri', array(':uri' => $uri), 1); if ($campaign == null) { $app->redirect('/', 302); } $title = 'Campaign: ' . $campaign['title']; $subTitle = $campaign['subTitle']; $p = json_decode($campaign['definition'], true); $summary = Summary::getSummary('system', 'solarSystemID', $p, 30000142, $p, true); $topPoints = array(); $topPods = array(); $top = array(); $top[] = Info::doMakeCommon('Top Characters', 'characterID', Stats::getTopPilots($p, true)); $top[] = Info::doMakeCommon('Top Corporations', 'corporationID', Stats::getTopCorps($p, true)); $top[] = Info::doMakeCommon('Top Alliances', 'allianceID', Stats::getTopAllis($p, true)); $top[] = Info::doMakeCommon('Top Ships', 'shipTypeID', Stats::getTopShips($p, true)); $top[] = Info::doMakeCommon('Top Systems', 'solarSystemID', Stats::getTopSystems($p, true)); $p['pastSeconds'] = $numDays * 86400; $p['limit'] = 5; $topIsk = Stats::getTopIsk($p, true); $topIsk['title'] = 'Most Valuable Kills'; unset($p['pastSeconds']); // get latest kills $killsLimit = 50; $p['limit'] = $killsLimit; if (isset($page) && $page > 0 && $page < 100) { $p['page'] = $page; } else { $page = 1; } $kills = Kills::getKills($p); $app->render('campaign.html', array('topPods' => $topPods, 'topIsk' => $topIsk, 'topPoints' => $topPoints, 'topKillers' => $top, 'kills' => $kills, 'page' => 1, 'pageType' => 'kills', 'pager' => true, 'requesturi' => '/campaign/burnjita3/', 'page' => $page, 'detail' => $summary, 'pageTitle' => $title, 'subTitle' => $subTitle));
if (!$warFinished) { $p['pastSeconds'] = 7 * 86400; } $top = array(); $top[] = Info::doMakeCommon('Top Characters', 'characterID', Stats::getTop('characterID', $p)); $top[] = Info::doMakeCommon('Top Corporations', 'corporationID', Stats::getTop('corporationID', $p)); $top[] = Info::doMakeCommon('Top Alliances', 'allianceID', Stats::getTop('allianceID', $p)); $top[] = Info::doMakeCommon('Top Ships', 'shipTypeID', Stats::getTop('shipTypeID', $p)); $top[] = Info::doMakeCommon('Top Systems', 'solarSystemID', Stats::getTop('solarSystemID', $p)); $p['limit'] = 5; $topIsk = array(); //Stats::getTopIsk($p); unset($p['pastSeconds']); unset($p['kills']); // get latest kills $killsLimit = 50; $p['limit'] = $killsLimit; $preKills = Kills::getKills($p); $kills = array(); $agrID = $warData['aggressor']['id']; $dfdID = $warData['defender']['id']; foreach ($preKills as $kill) { $victim = $kill['victim']; if (@$victim['corporationID'] == $dfdID || @$victim['allianceID'] == $dfdID) { $kill['displayAsKill'] = true; } else { $kill['displayAsLoss'] = true; } $kills[] = $kill; } $app->render('index.html', array('war' => $warData, 'wars' => array($warData), 'topPods' => $topPods, 'topIsk' => $topIsk, 'topPoints' => $topPoints, 'topKillers' => $top, 'kills' => $kills, 'page' => $page, 'pageType' => 'war', 'pager' => false, 'pageTitle' => $pageTitle));
* it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ $topPoints = array(); $topIsk = json_decode(Storage::retrieve("TopIsk"), true); $topPods = json_decode(Storage::retrieve("TopPods"), true); $topPointList = json_decode(Storage::retrieve("TopPoints"), true); if (is_array($topPointList)) { $topPoints = Kills::getKillsDetails($topPointList); } $p = array(); $p["limit"] = 5; $p["pastSeconds"] = 3 * 86400; $p["kills"] = true; $top = array(); $top[] = json_decode(Storage::retrieve("Top3dayChars"), true); $top[] = json_decode(Storage::retrieve("Top3dayCorps"), true); $top[] = json_decode(Storage::retrieve("Top3dayAlli"), true); // get latest kills $killsLimit = 50; $kills = Kills::getKills(array("limit" => $killsLimit)); $app->render("index.html", array("topPods" => $topPods, "topIsk" => $topIsk, "topPoints" => $topPoints, "topKillers" => $top, "kills" => $kills, "page" => 1, "pageType" => "kills", "pager" => true));
<?php require_once '../init.php'; global $redis; $key = "zkb:everyFiften"; if ($redis->get($key) === true) { exit; } $p = array(); $numDays = 7; $p['limit'] = 10; $p['pastSeconds'] = $numDays * 86400; $p['kills'] = true; $redis->setex('RC:Kills5b+', 3600, json_encode(Kills::getKills(array('iskValue' => 5000000000), true, false))); $redis->setex('RC:Kills10b+', 3600, json_encode(Kills::getKills(array('iskValue' => 10000000000), true, false))); $redis->setex('RC:TopIsk', 3600, json_encode(Stats::getTopIsk(array('pastSeconds' => $numDays * 86400, 'limit' => 5)))); function getStats($column) { $result = Stats::getTop($column, ['isVictim' => false, 'pastSeconds' => 604800]); return $result; } $redis->keys('*'); // Helps purge expired ttl's $redis->setex($key, 54000, true);