Example #1
0
function updateInfo($killID)
{
    global $mdb, $debug;
    $killmail = $mdb->findDoc('rawmails', ['killID' => $killID]);
    $system = $killmail['solarSystem'];
    $id = (int) $system['id'];
    if ($id == 0) {
        return;
    }
    if ($mdb->count('information', ['type' => 'solarSystemID', 'id' => $id]) == 0) {
        // system doesn't exist in our database yet
        $name = $system['name'];
        $crestSystem = CrestTools::getJSON($system['href']);
        if ($crestSystem == '') {
            exit("no system \\o/ {$killID} {$id}" . $system['href']);
        }
        $ex = explode('/', $crestSystem['constellation']['href']);
        $constID = (int) $ex[4];
        if (!$mdb->exists('information', ['type' => 'constellationID', 'id' => $constID])) {
            $crestConst = CrestTools::getJSON($crestSystem['constellation']['href']);
            if ($crestConst == '') {
                exit;
            }
            $constName = $crestConst['name'];
            $regionURL = $crestConst['region']['href'];
            $ex = explode('/', $regionURL);
            $regionID = (int) $ex[4];
            $mdb->insertUpdate('information', ['type' => 'constellationID', 'id' => $constID], ['name' => $constName, 'regionID' => $regionID]);
            if ($debug) {
                Util::out("Added constellation: {$constName}");
            }
        }
        $constellation = $mdb->findDoc('information', ['type' => 'constellationID', 'id' => $constID]);
        $regionID = (int) $constellation['regionID'];
        if (!$mdb->exists('information', ['type' => 'regionID', 'id' => $regionID])) {
            $regionURL = "https://public-crest.eveonline.com/regions/{$regionID}/";
            $crestRegion = CrestTools::getJSON($regionURL);
            if ($crestRegion == '') {
                exit;
            }
            $regionName = $crestRegion['name'];
            $mdb->insertUpdate('information', ['type' => 'regionID', 'id' => $regionID], ['name' => $regionName]);
            if ($debug) {
                Util::out("Added region: {$regionName}");
            }
        }
        $mdb->insertUpdate('information', ['type' => 'solarSystemID', 'id' => $id], ['name' => $name, 'regionID' => $regionID, 'secStatus' => (double) $crestSystem['securityStatus'], 'secClass' => $crestSystem['securityClass']]);
        Util::out("Added system: {$name}");
    }
    updateItems($killID, $killmail['killTime'], @$killmail['victim']['items']);
    updateEntity($killID, $killmail['victim']);
    foreach ($killmail['attackers'] as $entity) {
        updateEntity($killID, $entity);
    }
}
Example #2
0
<?php

require_once "../init.php";
if (date('i') != 45) {
    exit;
}
$assign = ['capacity', 'name', 'portionSize', 'mass', 'volume', 'description', 'radius', 'published'];
$rows = $mdb->getCollection("information")->find(['type' => 'typeID']);
foreach ($rows as $row) {
    $typeID = (int) $row['id'];
    $lastCrestUpdate = @$row['lastCrestUpdate'];
    if ($lastCrestUpdate != null && $lastCrestUpdate->sec > time() - 86400) {
        continue;
    }
    $crest = CrestTools::getJSON("https://public-crest.eveonline.com/types/{$typeID}/");
    foreach ($assign as $key) {
        if (isset($crest[$key])) {
            $row[$key] = $crest[$key];
        }
    }
    $row['lastCrestUpdate'] = $mdb->now();
    $mdb->save("information", $row);
}
Example #3
0
 $war['id'] = $id;
 $war['finished'] = false;
 $mdb->insertUpdate('information', ['type' => 'warID', 'id' => $id], $war);
 $prevKills = @$warRow['agrShipsKilled'] + @$warRow['dfdShipsKilled'];
 $currKills = $war['aggressor']['shipsKilled'] + $war['defender']['shipsKilled'];
 // Don't fetch killmail api for wars with no kill count change
 if ($prevKills != $currKills) {
     $kmHref = $war['killmails'];
     $page = floor($mdb->count('warmails', ['warID' => $id]) / 2000);
     if ($page == 0) {
         $page = 1;
     } elseif ($page > 1) {
         $kmHref .= "?page={$page}";
     }
     while ($kmHref != null) {
         $killmails = CrestTools::getJSON($kmHref);
         foreach ($killmails['items'] as $kill) {
             $href = $kill['href'];
             $exploded = explode('/', $href);
             $killID = (int) $exploded[4];
             $hash = $exploded[5];
             $mdb->insertUpdate('warmails', ['warID' => $id, 'killID' => $killID]);
             if (!$mdb->exists('crestmails', ['killID' => $killID, 'hash' => $hash])) {
                 $mdb->insert('crestmails', ['killID' => (int) $killID, 'hash' => $hash], ['processed' => false]);
                 Util::out("New WARmail {$killID}");
             }
         }
         $next = @$killmails['next']['href'];
         if ($next != $kmHref) {
             $kmHref = $next;
         } else {
Example #4
0
             exit;
         }
         $constName = $crestConst['name'];
         $regionURL = $crestConst['region']['href'];
         $ex = explode('/', $regionURL);
         $regionID = (int) $ex[4];
         $mdb->insertUpdate('information', ['type' => 'constellationID', 'id' => $constID], ['name' => $constName, 'regionID' => $regionID]);
         if ($debug) {
             Util::out("Added constellation: {$constName}");
         }
     }
     $constellation = $mdb->findDoc('information', ['type' => 'constellationID', 'id' => $constID]);
     $regionID = (int) $constellation['regionID'];
     if (!$mdb->exists('information', ['type' => 'regionID', 'id' => $regionID])) {
         $regionURL = "https://public-crest.eveonline.com/regions/{$regionID}/";
         $crestRegion = CrestTools::getJSON($regionURL);
         if ($crestRegion == '') {
             exit;
         }
         $regionName = $crestRegion['name'];
         $mdb->insertUpdate('information', ['type' => 'regionID', 'id' => $regionID], ['name' => $regionName]);
         if ($debug) {
             Util::out("Added region: {$regionName}");
         }
     }
     $mdb->insertUpdate('information', ['type' => 'solarSystemID', 'id' => (int) $mail['solarSystem']['id']], ['name' => $name, 'regionID' => $regionID, 'secStatus' => (double) $crestSystem['securityStatus'], 'secClass' => $crestSystem['securityClass']]);
     Util::out("Added system: {$name}");
     $system = $mdb->findDoc('information', ['type' => 'solarSystemID', 'id' => (int) $mail['solarSystem']['id']]);
 }
 $solarSystem = array();
 $solarSystem['solarSystemID'] = (int) $mail['solarSystem']['id'];
Example #5
0
<?php

require_once '../init.php';
$minute = (int) date('i');
$hour = (int) date('H');
if ($hour != 13) {
    exit;
}
if ($minute != 15) {
    exit;
}
$json = CrestTools::getJSON('https://public-crest.eveonline.com/inventory/categories/7/');
foreach ($json['groups'] as $group) {
    $href = $group['href'];
    $types = CrestTools::getJSON($href);
    if ($types != null && $types['types'] != null) {
        foreach ($types['types'] as $type) {
            $typeID = getTypeID($type['href']);
            $mdb->set('information', ['type' => 'typeID', 'id' => $typeID], ['fittable' => true]);
        }
    }
    sleep(1);
}
function getTypeID($href)
{
    $ex = explode('/', $href);
    return (int) $ex[4];
}
            foreach ($types['types'] as $type) {
                $typeID = (int) getTypeID($type['href']);
                $name = $type['name'];
                $exists = $mdb->count('information', ['type' => 'typeID', 'id' => $typeID]);
                if ($exists > 0) {
                    continue;
                }
                Util::out("Discovered item: {$name}");
                ++$newItems;
                $mdb->insertUpdate('information', ['type' => 'typeID', 'id' => $typeID], ['name' => $name, 'groupID' => $groupID, 'lastCrestUpdate' => new MongoDate(1)]);
            }
        }
    }
    $next = @$groups['next']['href'];
    if ($next != null) {
        $groups = CrestTools::getJSON($next);
    }
} while ($next != null);
$mdb->insertUpdate('storage', ['locker' => 'groupsPopulated'], ['contents' => true]);
if ($newGroups > 0) {
    Log::irc("Added {$newGroups} new groupIDs");
}
if ($newItems > 0) {
    Log::irc("Added {$newItems} new typeIDs");
}
function getTypeID($href)
{
    $ex = explode('/', $href);
    return $ex[4];
}
function getGroupID($href)
Example #7
0
while (!Util::exitNow() && $timer->stop() < 115000) {
    $unprocessed = $crestmails->find(array('processed' => false))->sort(['killID' => -1])->limit(10);
    if (!$unprocessed->hasNext()) {
        sleep(1);
    }
    foreach ($unprocessed as $crestmail) {
        if (Util::exitNow()) {
            break;
        }
        $id = $crestmail['killID'];
        $hash = $crestmail['hash'];
        if ($mdb->exists('killmails', ['killID' => $id])) {
            $crestmails->update($crestmail, array('$set' => array('processed' => true)));
            continue;
        }
        $killmail = CrestTools::fetch($id, $hash);
        if ($killmail == null || $killmail == '' || !isset($killmail['attackers'])) {
            if ($killmail == 403) {
                $mdb->remove('crestmails', $crestmail);
            } else {
                $crestmails->update($crestmail, array('$set' => array('processed' => null)));
            }
            continue;
        }
        if ($killmail == 415 || $killmail == 500 || $killmail == 403) {
            $crestmails->update($crestmail, array('$set' => array('processed' => true, 'errorCode' => $killmail)));
            continue;
        }
        unset($crestmail['npcOnly']);
        unset($killmail['zkb']);
        unset($killmail['_id']);
Example #8
0
<?php

require_once '../init.php';
$root = CrestTools::getJSON('https://public-crest.eveonline.com/');
$serverStatus = @$root['serviceStatus']['eve'];
if ($serverStatus == null) {
    $serverStatus = 'OFFLINE';
} else {
    $serverStatus = strtoupper($serverStatus);
}
$loggedIn = (int) @$root['userCounts']['eve'];
if ($loggedIn == 0) {
    $loggedIn = $serverStatus;
} else {
    $loggedIn = number_format($loggedIn, 0);
}
$redis->set('tqStatus', $serverStatus);
$redis->set('tqCount', $loggedIn);
Example #9
0
<?php

require_once '../init.php';
// Run once an hour
$minute = (int) date('i');
//if ($minute != 0) exit();
$page = ceil($mdb->count('information', ['type' => 'warID']) / 2000);
if ($page == 0) {
    $page = 1;
}
$next = "https://public-crest.eveonline.com/wars/?page={$page}";
do {
    $wars = CrestTools::getJSON($next);
    if ($wars == null) {
        exit;
    }
    $next = @$wars['next']['href'];
    foreach ($wars['items'] as $war) {
        $warID = (int) $war['id'];
        //echo "$warID\n";
        if (!$mdb->exists('information', ['type' => 'warID', 'id' => $warID])) {
            $mdb->save('information', ['type' => 'warID', 'id' => $warID, 'lastCrestUpdate' => new MongoDate(2)]);
        }
    }
    sleep(5);
} while ($next != null);
Example #10
0
<?php

require_once "../init.php";
$date = date('Ymd', time() - 7200);
$yesterday = date('Y-m-d', time() - 7200 - 86400);
$key = "tq:pricesChecked:{$date}";
if ($redis->get($key) == true) {
    exit;
}
$crestPrices = CrestTools::getJson("https://public-crest.eveonline.com/market/prices/");
if (!isset($crestPrices['items'])) {
    exit;
}
foreach ($crestPrices['items'] as $item) {
    $typeID = $item['type']['id'];
    $price = Price::getItemPrice($typeID, $date, true);
    $marketHistory = $mdb->findDoc("prices", ['typeID' => $typeID]);
    if ($marketHistory === null) {
        $marketHistory = ['typeID' => $typeID];
        $mdb->save("prices", $marketHistory);
    }
    if (!isset($marketHistory[$yesterday]) && isset($item['averagePrice'])) {
        $avgPrice = $item['averagePrice'];
        $mdb->set("prices", ['typeID' => $typeID], [$yesterday => $avgPrice]);
    }
}
$redis->set($key, true);
Example #11
0
    $allis = $mdb->find('information', ['type' => 'allianceID']);
    foreach ($allis as $alli) {
        $queueAllis->add($alli['id']);
    }
}
while ($timer->stop() <= 55000) {
    sleep(1);
    $id = (int) $queueAllis->next(false);
    if ($id == null) {
        exit;
    }
    $alliance = $mdb->findDoc('information', ['type' => 'allianceID', 'id' => $id]);
    $id = $alliance['id'];
    $name = $alliance['name'];
    $currentInfo = $mdb->findDoc('information', ['type' => 'alliance', 'id' => $id]);
    $alliCrest = CrestTools::getJSON("https://public-crest.eveonline.com/alliances/{$id}/");
    if ($alliCrest == null || !isset($alliCrest['name'])) {
        $mdb->set('information', ['type' => 'alliance', 'id' => $id], ['lastApiUpdate' => $mdb->now()]);
        continue;
    }
    $update = [];
    $update['lastApiUpdate'] = $mdb->now();
    $update['corpCount'] = (int) $alliCrest['corporationsCount'];
    $update['executorCorpID'] = (int) @$alliCrest['executorCorporation']['id'];
    addCorp($update['executorCorpID']);
    $memberCount = 0;
    $update['deleted'] = $alliCrest['deleted'];
    $mdb->set('information', ['type' => 'corporationID', 'allianceID' => $id], ['allianceID' => 0]);
    if ($alliCrest['corporations']) {
        foreach ($alliCrest['corporations'] as $corp) {
            $corpID = (int) $corp['id'];
Example #12
0
 protected static function getCrestPrices($typeID)
 {
     global $mdb, $debug;
     $marketHistory = $mdb->findDoc("prices", ['typeID' => $typeID]);
     if ($marketHistory === null) {
         $marketHistory = ['typeID' => $typeID];
         $mdb->save("prices", $marketHistory);
     }
     $url = "https://public-crest.eveonline.com/market/10000002/types/{$typeID}/history/";
     $json = CrestTools::getJSON($url);
     if (is_array($json["items"])) {
         foreach ($json["items"] as $row) {
             $avgPrice = $row['avgPrice'];
             $date = substr($row['date'], 0, 10);
             if (isset($marketHistory[$date])) {
                 continue;
             }
             $mdb->set("prices", ['typeID' => $typeID], [$date => $avgPrice]);
         }
     }
 }