コード例 #1
0
        $vCode = $api['vCode'];
        $userID = $api['userID'];
        $value = ['keyID' => $keyID, 'vCode' => $vCode, 'userID' => $userID];
        $errorCode = (int) @$api['errorCode'];
        if (in_array($errorCode, [0, 18, 106, 503, 522, 901, 902, 904])) {
            $tqApis->add($value);
        }
    }
}
if ($pid != 0) {
    exit;
}
$timer = new Timer();
$requestNum = 0;
while ($timer->stop() <= 58000) {
    $row = $tqApis->next();
    if ($row !== null) {
        $keyID = $row['keyID'];
        $vCode = $row['vCode'];
        $userID = $row['userID'];
        if (!isset($row['characters'])) {
            $row['characters'] = [];
        }
        $errorCode = (int) @$row['errorCode'];
        if ($errorCode == 0 || $errorCode == 221) {
            \Pheal\Core\Config::getInstance()->http_user_agent = "API Fetcher for https://{$baseAddr}";
            \Pheal\Core\Config::getInstance()->http_post = false;
            \Pheal\Core\Config::getInstance()->http_keepalive = true;
            // default 15 seconds
            \Pheal\Core\Config::getInstance()->http_keepalive = 10;
            // KeepAliveTimeout in seconds
コード例 #2
0
<?php

require_once '../init.php';
$counter = 0;
$information = $mdb->getCollection('information');
$queueCharacters = new RedisTimeQueue('tqCharacters', 86400);
$timer = new Timer();
$counter = 0;
while ($timer->stop() < 59000) {
    $ids = [];
    for ($i = 0; $i < 100; ++$i) {
        $id = $queueCharacters->next(false);
        if ($id != null) {
            $ids[] = $id;
        }
    }
    if (sizeof($ids) == 0) {
        exit;
    }
    $stringIDs = implode(',', $ids);
    $href = "https://api.eveonline.com/eve/CharacterAffiliation.xml.aspx?ids={$stringIDs}";
    $raw = file_get_contents($href);
    if ($raw == '') {
        exit;
    }
    $xml = @simplexml_load_string($raw);
    foreach ($xml->result->rowset->row as $info) {
        $id = (int) $info['characterID'];
        $row = $mdb->findDoc('information', ['type' => 'characterID', 'id' => $id]);
        if (isset($info['characterName'])) {
            ++$counter;
コード例 #3
0
$queueWars = new RedisTimeQueue('tqWars', 9600);
$minute = date('i');
if ($minute == 30) {
    $allWars = $mdb->getCollection('information')->find(['type' => 'warID'], ['id' => 1]);
    foreach ($allWars as $war) {
        if (@$war['finished'] == 1) {
            $queueWars->remove($war['id']);
        } else {
            $queueWars->add($war['id']);
        }
    }
}
$added = 0;
while ($timer->stop() < 58000) {
    sleep(1);
    $id = $queueWars->next();
    if ($id == null) {
        exit;
    }
    $warRow = $mdb->findDoc('information', ['type' => 'warID', 'id' => $id]);
    if (@$warRow['timeFinished'] != null) {
        $threeDays = date('Y-m-d', time() - 86400 * 3);
        $warFinished = substr($warRow['timeFinished'], 0, 10);
        if ($warFinished <= $threeDays) {
            $mdb->set('information', ['type' => 'warID', 'id' => $id], ['finished' => true]);
            continue;
        }
    }
    $href = "https://public-crest.eveonline.com/wars/{$id}/";
    $war = CrestTools::getJSON($href);
    if (!isset($warRow['agrShipsKilled']) || !isset($warRow['dfdShipsKilled'])) {
コード例 #4
0
ファイル: 1.apiConsumer.php プロジェクト: a-tal/zKillboard
        break;
    }
}
if ($pid != 0) {
    exit;
}
require_once '../init.php';
$timer = new Timer();
$tqApiChars = new RedisTimeQueue('tqApiChars', 3600);
$numApis = $tqApiChars->size();
if ($i >= $numApis / 100 + 1) {
    exit;
}
$count = 0;
while ($timer->stop() <= 59000) {
    $row = $tqApiChars->next();
    if ($row !== null) {
        $charID = $row['characterID'];
        $keyID = $row['keyID'];
        $vCode = $row['vCode'];
        $type = $row['type'];
        $userID = $row['userID'];
        if ($userID != 0) {
            $multi = $redis->multi();
            $multi->hSet("userID:api:{$userID}", $charID, true);
            $multi->expire("userID:api:{$userID}", 86400);
            $multi->setex("userID:api:{$userID}:{$charID}", 86400, serialize(['charID' => $charID, 'keyID' => $keyID, 'time' => time(), 'type' => $type]));
            $multi->exec();
        }
        $charCorp = $type == 'Corporation' ? 'corp' : 'char';
        $killsAdded = 0;
コード例 #5
0
    }
}
require_once '../init.php';
$apis = $mdb->getCollection('apis');
$information = $mdb->getCollection('information');
$tqApis = new RedisTimeQueue('tqApis', 9600);
$tqApiChars = new RedisTimeQueue('tqApiChars');
$timer = new Timer();
$requestNum = 0;
$numApis = $tqApis->size();
if ($i >= $numApis / 100 + 1) {
    exit;
}
$noApiCount = 0;
while ($timer->stop() <= 58000) {
    $id = $tqApis->next();
    if ($id !== null) {
        $row = $mdb->findDoc('apis', ['_id' => $id]);
        $keyID = $row['keyID'];
        $vCode = $row['vCode'];
        $userID = $row['userID'];
        $errorCode = (int) @$row['errorCode'];
        \Pheal\Core\Config::getInstance()->http_user_agent = "API Fetcher for https://{$baseAddr}";
        \Pheal\Core\Config::getInstance()->http_post = false;
        \Pheal\Core\Config::getInstance()->http_keepalive = true;
        // default 15 seconds
        \Pheal\Core\Config::getInstance()->http_keepalive = 10;
        // KeepAliveTimeout in seconds
        \Pheal\Core\Config::getInstance()->http_timeout = 30;
        \Pheal\Core\Config::getInstance()->api_customkeys = true;
        $pheal = new \Pheal\Pheal($keyID, $vCode);
コード例 #6
0
require_once '../init.php';
$counter = 0;
$information = $mdb->getCollection('information');
$timer = new Timer();
$queueCorps = new RedisTimeQueue('tqCorporations', 86400);
$i = date('i');
if ($i == 30) {
    $corps = $information->find(['type' => 'corporationID']);
    foreach ($corps as $corp) {
        $queueCorps->add($corp['id']);
    }
}
while ($timer->stop() < 55000) {
    sleep(1);
    $id = $queueCorps->next(false);
    if ($id == null) {
        continue;
    }
    $row = $mdb->findDoc('information', ['type' => 'corporationID', 'id' => (int) $id]);
    $updates = [];
    if (!isset($row['memberCount']) || isset($row['memberCount']) && $row['memberCount'] != 0) {
        $id = (int) $row['id'];
        $raw = @file_get_contents("https://api.eveonline.com/corp/CorporationSheet.xml.aspx?corporationID={$id}");
        if ($raw != '') {
            ++$counter;
            $xml = @simplexml_load_string($raw);
            if ($xml != null) {
                $corpInfo = $xml->result;
                if (isset($corpInfo->ticker)) {
                    $ceoID = (int) $corpInfo->ceoID;
コード例 #7
0
ファイル: 9.alliances.php プロジェクト: hybrid1969/zKillboard
require_once '../init.php';
$mdb = new Mdb();
$old = $mdb->now(3600 * 3);
// 8 hours
$timer = new Timer();
$queueAllis = new RedisTimeQueue('tqAlliances', 9600);
$i = date('i');
if ($i == 45) {
    $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'];