Example #1
0
            $killsLastHour->add($id);
            $rawmails->save($killmail);
        }
        if (!validKill($killmail)) {
            $crestmail['npcOnly'] = true;
            $crestmail['processed'] = true;
            $crestmails->save($crestmail);
            continue;
        }
        $killID = @$killmail['killID'];
        if ($killID != 0) {
            $crestmail['processed'] = true;
            $crestmails->save($crestmail);
            $queueProcess->push($killID);
            ++$counter;
            $queueShare->push($killID);
        } else {
            $crestmails->update($crestmail, array('$set' => array('processed' => null)));
        }
    }
}
if ($debug && $counter > 0) {
    Util::out('Added ' . number_format($counter, 0) . ' Kills.');
}
function validKill(&$kill)
{
    // Show all pod kills
    $victimShipID = $kill['victim']['shipType']['id'];
    if ($victimShipID == 670 || $victimShipID == 33328) {
        return true;
    }
Example #2
0
        if (isset($kill['locationID'])) {
            $zkb['locationID'] = $kill['locationID'];
        }
        $zkb['hash'] = $crestmail['hash'];
        $zkb['totalValue'] = (double) $totalValue;
        $zkb['points'] = (int) Points::getKillPoints($kill, $zkb['totalValue']);
        $kill['zkb'] = $zkb;
        $exists = $killmails->count(['killID' => $killID]);
        if ($exists == 0) {
            $killmails->save($kill);
        }
        $oneWeekExists = $mdb->exists('oneWeek', ['killID' => $killID]);
        if (!$oneWeekExists) {
            $mdb->getCollection('oneWeek')->save($kill);
        }
        $queueInfo->push($killID);
        $redis->incr("zkb:totalKills");
        ++$counter;
    }
}
if ($debug && $counter > 0) {
    Util::out('Processed ' . number_format($counter, 0) . ' Kills.');
}
function createInvolved($data)
{
    global $mdb;
    $dataArray = array('character', 'corporation', 'alliance', 'faction', 'shipType');
    $array = array();
    foreach ($dataArray as $index) {
        if (isset($data[$index]['id']) && $data[$index]['id'] != 0) {
            $array["{$index}ID"] = (int) $data[$index]['id'];
Example #3
0
<?php

require_once '../init.php';
$queueInfo = new RedisQueue('queueInfo');
$queueSocial = new RedisQueue('queueSocial');
$queueStats = new RedisQueue('queueStats');
$killmails = $mdb->getCollection('killmails');
$rawmails = $mdb->getCollection('rawmails');
$information = $mdb->getCollection('information');
$statArray = ['characterID', 'corporationID', 'allianceID', 'factionID', 'shipTypeID', 'groupID'];
while (!Util::exitNow()) {
    $killID = $queueInfo->pop();
    if ($killID !== null) {
        updateInfo($killID);
        updateStatsQueue($killID);
        $queueSocial->push($killID);
    }
}
function updateStatsQueue($killID)
{
    global $killmails, $statArray, $queueStats;
    $kill = $killmails->findOne(['killID' => $killID]);
    $involved = $kill['involved'];
    $sequence = $kill['sequence'];
    // solar system
    addToStatsQueue('solarSystemID', $kill['system']['solarSystemID'], $sequence);
    addToStatsQueue('regionID', $kill['system']['regionID'], $sequence);
    foreach ($involved as $inv) {
        foreach ($statArray as $stat) {
            if (isset($inv[$stat])) {
                addToStatsQueue($stat, $inv[$stat], $sequence);
Example #4
0
    while ($row = $iter->next()) {
        if ($row['type'] == 'characterID') {
            continue;
        }
        $allTimeSum = (int) @$row['allTimeSum'];
        $currentSum = (int) @$row['shipsDestroyed'];
        if ($currentSum == 0) {
            continue;
        }
        if ($currentSum == $allTimeSum) {
            continue;
        }
        if ($currentSum - $allTimeSum < $allTimeSum * 0.01) {
            continue;
        }
        $queueTopAlltime->push($row['_id']);
    }
}
$redis->setex($redisKey, 86400, true);
if ($redis->llen('queueStats') > 100) {
    exit;
}
while ($id = $queueTopAlltime->pop()) {
    $row = $mdb->findDoc('statistics', ['_id' => $id]);
    calcTop($row);
    if ($redis->llen('queueStats') > 100) {
        exit;
    }
}
function calcTop($row)
{
Example #5
0
require_once '../init.php';
$queueInfo = new RedisQueue('queueInfo');
$queueSocial = new RedisQueue('queueSocial');
$queueStats = new RedisQueue('queueStats');
$queueRedisQ = new RedisQueue('queueRedisQ');
$killmails = $mdb->getCollection('killmails');
$rawmails = $mdb->getCollection('rawmails');
$information = $mdb->getCollection('information');
$statArray = ['characterID', 'corporationID', 'allianceID', 'factionID', 'shipTypeID', 'groupID'];
while (!Util::exitNow()) {
    $killID = $queueInfo->pop();
    if ($killID !== null) {
        updateInfo($killID);
        updateStatsQueue($killID);
        $queueSocial->push($killID);
        $queueRedisQ->push($killID);
    }
}
function updateStatsQueue($killID)
{
    global $killmails, $statArray, $queueStats;
    $kill = $killmails->findOne(['killID' => $killID]);
    $involved = $kill['involved'];
    $sequence = $kill['sequence'];
    // solar system
    addToStatsQueue('solarSystemID', $kill['system']['solarSystemID'], $sequence);
    addToStatsQueue('regionID', $kill['system']['regionID'], $sequence);
    if (isset($kill['locationID'])) {
        addToStatsQueue('locationID', $kill['locationID'], $sequence);
    }
    foreach ($involved as $inv) {
Example #6
0
$load = getLoad();
// Check if the user has autologin turned on
if ($load < 20 && !User::isLoggedIn()) {
    User::autoLogin();
}
if ($load >= 20) {
    $uri = @$_SERVER['REQUEST_URI'];
    if ($uri != '') {
        $contents = $redis->get("cache:{$uri}");
        if ($contents !== false) {
            echo $contents;
            exit;
        }
        $_SERVER['requestDttm'] = $mdb->now();
        $qServer = new RedisQueue('queueServer');
        $qServer->push($_SERVER);
    }
}
// Theme
if (User::isLoggedIn()) {
    $theme = UserConfig::get('theme');
}
$app->config(array('templates.path' => $baseDir . 'templates/'));
// Error handling
$app->error(function (\Exception $e) use($app) {
    include 'view/error.php';
});
// Load the routes - always keep at the bottom of the require list ;)
include 'routes.php';
// Load twig stuff
include 'twig.php';
Example #7
0
            if ($killmail == null) {
                Util::out("saving null killmail? id is {$id}");
            }
            $rawmails->save($killmail);
        }
        if (!validKill($killmail)) {
            $crestmail['npcOnly'] = true;
            $crestmail['processed'] = true;
            $crestmails->save($crestmail);
            continue;
        }
        $killID = @$killmail['killID'];
        if ($killID != 0) {
            $crestmail['processed'] = true;
            $crestmails->save($crestmail);
            $queueProcess->push($killID);
            ++$counter;
            if ($queueShare != null) {
                $queueShare->push($killID);
            }
        } else {
            $crestmails->update($crestmail, array('$set' => array('processed' => false)));
        }
    }
}
if ($debug && $counter > 0) {
    Util::out('Added ' . number_format($counter, 0) . ' Kills.');
}
function validKill(&$kill)
{
    // Show all pod kills