当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::out方法代码示例

本文整理汇总了PHP中Util::out方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::out方法的具体用法?PHP Util::out怎么用?PHP Util::out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util::out方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doFetch

function doFetch($type, $id)
{
    global $redis, $debug;
    $key = "zkb:zkbFeed:{$type}:{$id}";
    $fetched = $redis->get($key);
    if ($fetched == true) {
        return;
    }
    if ($debug) {
        Util::out("Fetching {$type} {$id}");
    }
    $lastFetchedID = (int) $redis->get("zkb:lastFetchedID:{$type}:{$id}");
    do {
        $url = "https://zkillboard.com/api/{$type}ID/{$id}/orderDirection/asc/afterKillID/{$lastFetchedID}/no-items/no-attackers/";
        $raw = Util::getData($url);
        $json = json_decode($raw, true);
        foreach ($json as $kill) {
            $killID = (int) $kill['killID'];
            $hash = $kill['zkb']['hash'];
            $lastFetchedID = max($lastFetchedID, $killID);
            saveKill($killID, $hash);
        }
        $newKills = sizeof($json);
    } while ($newKills > 0);
    $redis->set("zkb:lastFetchedID:{$type}:{$id}", $lastFetchedID);
    $redis->setex($key, 3601, true);
}
开发者ID:hybrid1969,项目名称:zKillboard,代码行数:27,代码来源:1.zkbFeed.php

示例2: getCSV

function getCSV($url, $method)
{
    global $mdb, $redis;
    $file = $redis->get("RC:{$url}");
    if ($file == null) {
        $file = file_get_contents($url);
        $redis->setex("RC:{$url}", 900, $file);
    }
    $csv = bzdecompress($file);
    Util::out("Parsing {$url}");
    parseCSV($csv, $method);
}
开发者ID:esnoeijs,项目名称:zKillboard,代码行数:12,代码来源:9.sdeUpdate.php

示例3: calcStats

function calcStats($row)
{
    global $mdb, $debug;
    $type = $row['type'];
    $id = $row['id'];
    $newSequence = $row['sequence'];
    $key = ['type' => $type, 'id' => $id];
    $stats = $mdb->findDoc('statistics', $key);
    if ($stats === null) {
        $stats = [];
        $stats['type'] = $type;
        $stats['id'] = $id;
    }
    $oldSequence = (int) @$stats['sequence'];
    if ($newSequence <= $oldSequence) {
        return;
    }
    for ($i = 0; $i <= 1; ++$i) {
        $isVictim = $i == 0;
        if (($type == 'locationID' || $type == 'regionID' || $type == 'solarSystemID') && $isVictim == true) {
            continue;
        }
        // build the query
        $query = [$row['type'] => $row['id'], 'isVictim' => $isVictim];
        $query = MongoFilter::buildQuery($query);
        // set the proper sequence values
        $query = ['$and' => [['sequence' => ['$gt' => $oldSequence]], ['sequence' => ['$lte' => $newSequence]], $query]];
        $allTime = $mdb->group('killmails', [], $query, 'killID', ['zkb.points', 'zkb.totalValue']);
        mergeAllTime($stats, $allTime, $isVictim);
        $groups = $mdb->group('killmails', 'vGroupID', $query, 'killID', ['zkb.points', 'zkb.totalValue'], ['vGroupID' => 1]);
        mergeGroups($stats, $groups, $isVictim);
        $months = $mdb->group('killmails', ['year' => 'dttm', 'month' => 'dttm'], $query, 'killID', ['zkb.points', 'zkb.totalValue'], ['year' => 1, 'month' => 1]);
        mergeMonths($stats, $months, $isVictim);
    }
    // Update the sequence
    $stats['sequence'] = $newSequence;
    // save it
    $mdb->getCollection('statistics')->save($stats);
    $r = $mdb->getDb()->command(['getLastError' => 1]);
    if ($r['ok'] != 1) {
        die('stats update failure');
    }
    if ($debug) {
        Util::out("Stats completed for: {$type} {$id} {$newSequence}");
    }
}
开发者ID:a-tal,项目名称:zKillboard,代码行数:46,代码来源:6.queueStats.php

示例4: createInvolved

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'];
        }
    }
    if (isset($array['shipTypeID']) && Info::getGroupID($array['shipTypeID']) == -1) {
        $mdb->getCollection('information')->update(['type' => 'group'], ['$set' => ['lastCrestUpdate' => new MongoDate(1)]]);
        Util::out('Bailing on processing a kill, unable to find groupID for ' . $array['shipTypeID']);
        exit;
    }
    if (isset($array['shipTypeID'])) {
        $array['groupID'] = (int) Info::getGroupID($array['shipTypeID']);
    }
    if (isset($data['finalBlow']) && $data['finalBlow'] == true) {
        $array['finalBlow'] = true;
    }
    return $array;
}
开发者ID:hybrid1969,项目名称:zKillboard,代码行数:23,代码来源:3.queueProcess.php

示例5: foreach

        $name = $group['name'];
        $exists = $mdb->count('information', ['type' => 'groupID', 'id' => $groupID]);
        if ($exists == 0) {
            ++$newGroups;
        }
        $mdb->insertUpdate('information', ['type' => 'groupID', 'id' => $groupID], ['name' => $name, 'lastCrestUpdate' => $mdb->now(-86400)]);
        $types = CrestTools::getJSON($href);
        if (@$types['types'] != null) {
            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) {
开发者ID:nasimnabavi,项目名称:zKillboard,代码行数:31,代码来源:9.updateGroups.php

示例6: array

            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;
    }
    $npcOnly = true;
    foreach ($kill['attackers'] as $attacker) {
        if (isset($attacker['shipType']['id'])) {
            $attackerGroupID = Info::getGroupID($attacker['shipType']['id']);
            if ($attackerGroupID == 365) {
                return true;
            }
开发者ID:nasimnabavi,项目名称:zKillboard,代码行数:31,代码来源:2.crest_fetch.php

示例7: file_get_contents

<?php

require_once "../init.php";
$raw = file_get_contents("{$baseDir}/setup/items.json");
$json = json_decode($raw, true);
foreach ($json as $row) {
    $doc = $mdb->find("information", ['type' => 'typeID', 'id' => (int) $row['typeID']]);
    if ($doc === null || is_array($doc) && sizeof($doc) == 0) {
        Util::out("Adding " . $row['name']);
        $row['id'] = $row['typeID'];
        unset($row['typeID']);
        $row['type'] = 'typeID';
        $mdb->save("information", $row);
    }
    $row = null;
}
$redis->set("tq:itemsPopulated", true);
开发者ID:hybrid1969,项目名称:zKillboard,代码行数:17,代码来源:addItems.php

示例8: foreach

<?php

require_once '../init.php';
if (date('Hi') != '0001') {
    exit;
}
$types = ['allianceID', 'corporationID', 'factionID', 'shipTypeID', 'groupID', 'solarSystemID', 'regionID'];
foreach ($types as $type) {
    Util::out($type);
    $entities = $mdb->find('statistics', ['type' => $type]);
    foreach ($entities as $row) {
        calcTop($row);
    }
}
function calcTop($row)
{
    global $mdb;
    if (date('d') != '01' && isset($row['topAllTime'])) {
        return;
    }
    $parameters = [$row['type'] => $row['id']];
    $parameters['limit'] = 10;
    $parameters['kills'] = true;
    $topLists[] = array('type' => 'character', 'data' => Stats::getTop('characterID', $parameters));
    $topLists[] = array('type' => 'corporation', 'data' => Stats::getTop('corporationID', $parameters, true));
    $topLists[] = array('type' => 'alliance', 'data' => Stats::getTop('allianceID', $parameters, true));
    $topLists[] = array('type' => 'faction', 'data' => Stats::getTop('factionID', $parameters, true));
    $topLists[] = array('type' => 'ship', 'data' => Stats::getTop('shipTypeID', $parameters, true));
    $topLists[] = array('type' => 'system', 'data' => Stats::getTop('solarSystemID', $parameters, true));
    do {
        $r = $mdb->set('statistics', $row, ['topAllTime' => $topLists]);
开发者ID:WreckerWorld,项目名称:zKillboard,代码行数:31,代码来源:9.topAllTime.php

示例9: floor

    // 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 {
                $kmHref = null;
            }
        }
    }
}
开发者ID:nasimnabavi,项目名称:zKillboard,代码行数:31,代码来源:1.warConsumer.php

示例10: Stomp

    $stomp = new Stomp($stompServer, $stompUser, $stompPassword);
} catch (Exception $ex) {
    Util::out("Stomp error: " . $ex->getMessage());
    exit;
}
$stomp->setReadTimeout(1);
foreach ($topics as $topic) {
    $stomp->subscribe($topic, array('id' => 'zkb-' . $baseAddr, 'persistent' => 'true', 'ack' => 'client', 'prefetch-count' => 1));
}
$stompCount = 0;
$timer = new Timer();
while ($timer->stop() <= 59000) {
    $frame = $stomp->readFrame();
    if (!empty($frame)) {
        $killdata = json_decode($frame->body, true);
        $killID = (int) $killdata['killID'];
        if ($killID == 0) {
            continue;
        }
        $hash = $hash = Killmail::getCrestHash($killID, $killdata);
        $killdata['killID'] = (int) $killID;
        if (!$mdb->exists('crestmails', ['killID' => $killID, 'hash' => $hash])) {
            ++$stompCount;
            $i = $mdb->getCollection('crestmails')->insert(['killID' => $killID, 'hash' => $hash, 'processed' => false, 'source' => 'stomp', 'added' => $mdb->now()]);
        }
        $stomp->ack($frame->headers['message-id']);
    }
}
if ($stompCount > 0) {
    Util::out("New kills from STOMP: {$stompCount}");
}
开发者ID:hybrid1969,项目名称:zKillboard,代码行数:31,代码来源:1.stompListen.php

示例11: foreach

<?php

require_once "../init.php";
if ($redis->get("tq:itemsPopulated") != true) {
    Util::out("Waiting for items to be populated...");
    exit;
}
if (date('i') != 45) {
    exit;
}
$assign = ['capacity', 'name', 'portionSize', 'mass', 'volume', 'description', 'radius', 'published'];
$rows = $mdb->find("information", ['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);
}
开发者ID:a-tal,项目名称:zKillboard,代码行数:27,代码来源:9.updateItems.php

示例12: foreach

    if ($rank !== false) {
        $rank = 1 + $rank;
        $mdb->set("statistics", $row, ['recentOverallRank' => $rank]);
        $redis->hSet("tq:ranks:{$type}:recent:{$today}", $rank, $id);
    }
}
$keys = $redis->keys("tq:ranks:recent:*");
foreach ($keys as $key) {
    $redis->del($key);
}
$keys = $redis->keys("tq:ranks:*:recent:*");
foreach ($keys as $key) {
    $redis->expire($key, 14 * 86400);
}
$redis->setex($todaysKey, 87000, true);
Util::out("Recent rankings complete");
function getValue(&$array, $index)
{
    $index = ucwords($index);
    $value = @$array["recent{$index}"];
    return $value;
}
function getRecent($type, $id, $isVictim, $ninetyDayKillID)
{
    global $mdb;
    // build the query
    $query = [$type => $id, 'isVictim' => $isVictim];
    $query = MongoFilter::buildQuery($query);
    // set the proper sequence values
    $query = ['$and' => [['killID' => ['$gte' => $ninetyDayKillID]], $query]];
    $result = $mdb->group('killmails', [], $query, 'killID', ['zkb.points', 'zkb.totalValue']);
开发者ID:esnoeijs,项目名称:zKillboard,代码行数:31,代码来源:9.ranksRecent.php

示例13: moveAndExpire

    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:shipsDestroyed");
    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:shipsLost");
    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:iskDestroyed");
    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:iskLost");
    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:pointsDestroyed");
    moveAndExpire($multi, $today, "tq:ranks:weekly:{$type}:{$today}:pointsLost");
    $multi->exec();
}
function moveAndExpire(&$multi, $today, $key)
{
    $newKey = str_replace(":{$today}", "", $key);
    $multi->rename($key, $newKey);
    $multi->expire($newKey, 3600);
}
$redis->setex($todaysKey, 9000, true);
Util::out("Weekly rankings complete");
function zAdd(&$multi, $key, $value, $id)
{
    $value = max(1, (int) $value);
    $multi->zAdd($key, $value, $id);
    $multi->expire($key, 9000);
}
function rankCheck($max, $rank)
{
    return $rank === false ? $max : $rank + 1;
}
function getWeekly($type, $id, $isVictim, $ninetyDayKillID)
{
    global $mdb;
    // build the query
    $query = [$type => $id, 'isVictim' => $isVictim];
开发者ID:a-tal,项目名称:zKillboard,代码行数:31,代码来源:9.ranksWeekly.php

示例14: catch

                } catch (MongoDuplicateKeyException $ex) {
                    // ignore it *sigh*
                }
            }
            if (!$exists && $debug) {
                Util::out("Added {$killID} from API");
            }
        }
        // helpful info for output if needed
        $info = $mdb->findDoc('information', ['type' => 'characterID', 'id' => $charID], [], ['name' => 1, 'corporationID' => 1]);
        $corpInfo = $mdb->findDoc('information', ['type' => 'corporationID', 'id' => @$info['corporationID']], [], ['name' => 1]);
        $apiVerifiedSet = new RedisTtlSortedSet('ttlss:apiVerified', 86400);
        $apiVerifiedSet->add(time(), $type == 'Corporation' ? @$info['corporationID'] : $charID);
        if ($newMaxKillID == 0) {
            $tqApiChars->setTime($row, time() + rand(72000, 86400));
        }
        // If we got new kills tell the log about it
        if ($killsAdded > 0) {
            if ($type == 'Corporation') {
                $name = 'corp ' . @$corpInfo['name'];
            } else {
                $name = 'char ' . @$info['name'];
            }
            while (strlen("{$killsAdded}") < 3) {
                $killsAdded = ' ' . $killsAdded;
            }
            Util::out("{$killsAdded} kills added by {$name}");
        }
    }
    sleep(1);
}
开发者ID:a-tal,项目名称:zKillboard,代码行数:31,代码来源:1.apiConsumer.php

示例15: updateEntity

function updateEntity($killID, $entity)
{
    global $information, $mdb, $debug;
    $types = ['character', 'corporation', 'alliance', 'faction'];
    for ($index = 0; $index < 4; ++$index) {
        $type = $types[$index];
        if (!isset($entity[$type]['id'])) {
            continue;
        }
        $id = $entity[$type]['id'];
        $name = $entity[$type]['name'];
        // Look for the current entry
        $query = ['type' => $type . 'ID', 'id' => $id, 'killID' => ['$gte' => $killID]];
        if ($mdb->exists('information', $query)) {
            continue;
        }
        unset($query['killID']);
        $row = $mdb->findDoc('information', $query);
        $new = $row == null;
        if (!isset($row['killID'])) {
            $row['killID'] = 0;
        }
        if ($row != null && $killID <= $row['killID']) {
            echo "continuing..\n";
        }
        if ($row != null && $killID <= $row['killID']) {
            continue;
        }
        $updates = [];
        $updates['name'] = $name;
        $updates['killID'] = $killID;
        for ($subIndex = $index + 1; $subIndex < 4; ++$subIndex) {
            $subType = $types[$subIndex];
            $updates["{$subType}ID"] = (int) @$entity[$subType]['id'];
        }
        $mdb->insertUpdate('information', $query, $updates);
        if ($new && $debug) {
            Util::out("Added {$type}: {$name}");
        }
    }
}
开发者ID:WreckerWorld,项目名称:zKillboard,代码行数:41,代码来源:4.queueInfo.php


注:本文中的Util::out方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。