Example #1
0
$prevRanks = $mdb->findDoc('ranksProgress', ['cacheTime' => 36000, 'type' => $statType, 'id' => (int) $id], ['date' => 1]);
if ($prevRanks != null && isset($prevRanks['date']->sec)) {
    $prevRanks['date'] = date('Y-m-d', $prevRanks['date']->sec);
    $statistics['prevRanks'] = $prevRanks;
}
$groups = @$statistics['groups'];
if (is_array($groups) and sizeof($groups) > 0) {
    Info::addInfo($groups);
    $g = [];
    foreach ($groups as $group) {
        $g[$group['groupName']] = $group;
    }
    ksort($g);
    // Divide the stats into 4 columns...
    $chunkSize = ceil(sizeof($g) / 4);
    $statistics['groups'] = array_chunk($g, $chunkSize);
} else {
    $statistics['groups'] = null;
}
$months = @$statistics['months'];
// Ensure the months are sorted in descending order
if (is_array($months) && sizeof($months) > 0) {
    krsort($months);
    $statistics['months'] = array_values($months);
} else {
    $statistics['months'] = null;
}
// Collect active PVP stats
$activePvP = Stats::getActivePvpStats($parameters);
$renderParams = array('pageName' => $pageName, 'kills' => $kills, 'losses' => $losses, 'detail' => $detail, 'page' => $page, 'topKills' => $topKills, 'mixed' => $mixedKills, 'key' => $key, 'id' => $id, 'pageType' => $pageType, 'solo' => $solo, 'topLists' => $topLists, 'corps' => $corpList, 'corpStats' => $corpStats, 'summaryTable' => $stats, 'pager' => sizeof($kills) + sizeof($losses) >= $limit, 'datepicker' => true, 'nextApiCheck' => $nextApiCheck, 'apiVerified' => $apiVerified, 'prevID' => $prevID, 'nextID' => $nextID, 'extra' => $extra, 'statistics' => $statistics, 'activePvP' => $activePvP);
$app->render('overview.html', $renderParams);
Example #2
0
<?php

global $mdb;
try {
    $parameters = Util::convertUriToParameters();
    $array = $mdb->findDoc('statistics', ['type' => $type, 'id' => (int) $id]);
    unset($array['_id']);
    $array['activepvp'] = Stats::getActivePvpStats($parameters);
    $array['info'] = $mdb->findDoc('information', ['type' => $type, 'id' => (int) $id]);
    unset($array['info']['_id']);
    //Stats::getSupers($array, $type, $id);
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET');
    if (isset($_GET['callback']) && Util::isValidCallback($_GET['callback'])) {
        $app->contentType('application/javascript; charset=utf-8');
        header('X-JSONP: true');
        echo $_GET['callback'] . '(' . json_encode($array) . ')';
    } else {
        $app->contentType('application/json; charset=utf-8');
        if (isset($parameters['pretty'])) {
            echo json_encode($array, JSON_PRETTY_PRINT);
        } else {
            echo json_encode($array);
        }
    }
} catch (Exception $ex) {
    header('HTTP/1.0 503 Server error.');
    die;
}