Example #1
1
 /**
  * Returns json of the kill
  *
  * @param $killID the ID of the kill
  * @return string
  */
 public static function getJson($killID)
 {
     $jsonRaw = Db::queryField("SELECT kill_json FROM zz_killmails WHERE killID = :killID", "kill_json", array(":killID" => $killID));
     $decoded = json_decode($jsonRaw, true);
     $killarray = Info::addInfo($decoded);
     return json_encode($killarray);
 }
Example #2
1
 /**
  * @param string $groupByColumn
  */
 public static function getTop($groupByColumn, $parameters = array())
 {
     global $mdb, $debug, $longQueryMS;
     $hashKey = "Stats::getTop:{$groupByColumn}:" . serialize($parameters);
     $result = RedisCache::get($hashKey);
     if ($result != null) {
         return $result;
     }
     if (isset($parameters['pastSeconds'])) {
         $killmails = $mdb->getCollection('oneWeek');
         if ($parameters['pastSeconds'] >= 604800) {
             unset($parameters['pastSeconds']);
         }
     } else {
         $killmails = $mdb->getCollection('killmails');
     }
     $query = MongoFilter::buildQuery($parameters);
     if (!$mdb->exists('killmails', $query)) {
         return [];
     }
     $andQuery = MongoFilter::buildQuery($parameters, false);
     if ($groupByColumn == 'solarSystemID' || $groupByColumn == 'regionID') {
         $keyField = "system.{$groupByColumn}";
     } else {
         $keyField = "involved.{$groupByColumn}";
     }
     $id = $type = null;
     if ($groupByColumn != 'solarSystemID' && $groupByColumn != 'regionID') {
         foreach ($parameters as $k => $v) {
             if (strpos($k, 'ID') === false) {
                 continue;
             }
             if (!is_array($v) || sizeof($v) < 1) {
                 continue;
             }
             $id = $v[0];
             if ($k != 'solarSystemID' && $k != 'regionID') {
                 $type = "involved.{$k}";
             } else {
                 $type = "system.{$k}";
             }
         }
     }
     $timer = new Timer();
     $pipeline = [];
     $pipeline[] = ['$match' => $query];
     if ($groupByColumn != 'solarSystemID' && $groupByColumn != 'regionID') {
         $pipeline[] = ['$unwind' => '$involved'];
     }
     if ($type != null && $id != null) {
         $pipeline[] = ['$match' => [$type => $id, 'involved.isVictim' => false]];
     }
     $pipeline[] = ['$match' => [$keyField => ['$ne' => null]]];
     $pipeline[] = ['$match' => $andQuery];
     $pipeline[] = ['$group' => ['_id' => ['killID' => '$killID', $groupByColumn => '$' . $keyField]]];
     $pipeline[] = ['$group' => ['_id' => '$_id.' . $groupByColumn, 'kills' => ['$sum' => 1]]];
     $pipeline[] = ['$sort' => ['kills' => -1]];
     if (!isset($parameters['nolimit'])) {
         $pipeline[] = ['$limit' => 10];
     }
     $pipeline[] = ['$project' => [$groupByColumn => '$_id', 'kills' => 1, '_id' => 0]];
     if (!$debug) {
         MongoCursor::$timeout = -1;
     }
     $result = $killmails->aggregateCursor($pipeline);
     $result = iterator_to_array($result);
     $time = $timer->stop();
     if ($time > $longQueryMS) {
         Log::log("Aggregate Long query ({$time}ms): {$hashKey}");
     }
     Info::addInfo($result);
     RedisCache::set($hashKey, $result, 3600);
     return $result;
 }
 public function execute($parameters, $db)
 {
     $db->execute("delete from zz_social where insertTime < date_sub(now(), interval 23 hour)");
     $minPilots = 100;
     $minWrecks = 100;
     $result = $db->query("select * from (select solarSystemID, count(distinct characterID) count, count(distinct killID) kills from zz_participants where characterID != 0 and killID > 0 and dttm > date_sub(now(), interval 1 hour) group by 1 order by 2 desc) f where count >= {$minPilots} and kills > {$minWrecks}");
     foreach ($result as $row) {
         $systemID = $row["solarSystemID"];
         $key = $row["solarSystemID"] * 100 + date("H");
         $key2 = $row["solarSystemID"] * 100 + date("H", time() + 3600);
         // Have we already reported this battle to the masses?
         $socialCount = $db->queryField("select count(*) count from zz_social where killID = :killID", "count", array(":killID" => $key), 0);
         $db->execute("insert ignore into zz_social (killID) values (:k1), (:k2)", array(":k1" => $key, ":k2" => $key2));
         Info::addInfo($row);
         $wrecks = number_format($row['kills'], 0);
         $involved = number_format($row['count'], 0);
         $system = $row["solarSystemName"];
         $date = date("YmdH00");
         $link = "https://zkillboard.com/related/{$systemID}/{$date}/";
         // Insert into (or update) zz_battles
         $db->execute("REPLACE INTO zz_battles (solarSystemID, solarSystemName, timestamp, involved, kills) VALUES (:solarSystemID, :solarSystemName, :timestamp, :involved, :kills)", array(":solarSystemID" => $systemID, ":solarSystemName" => $system, ":timestamp" => $date, ":involved" => $involved, ":kills" => $wrecks));
         if ($socialCount != 0) {
             $message = "Battle detected in |g|{$system}|n| with |g|{$involved}|n| involved and |g|{$wrecks}|n| wrecks.";
             Log::irc($message . " |g|{$link}");
             $isgd = Twit::shortenURL($link);
             $message = Log::stripIRCColors($message . " {$isgd} #tweetfleet #eveonline");
             $tweet = Twit::sendMessage($message);
             $twitID = $tweet->id;
             Log::irc("Message was also tweeted: https://twitter.com/eve_kill/status/{$twitID}");
         }
     }
 }
Example #4
0
 public static function getRanks($type, $rankType, $recent)
 {
     $table = $recent == true ? 'zz_ranks' : 'zz_ranks_recent';
     switch ($rankType) {
         case 'shipsDestroyed':
             $valueColumn = 'shipsDestroyed';
             $rankColumn = 'sdRank';
             break;
         case 'pointsDestroyed':
             $valueColumn = 'pointsDestroyed';
             $rankColumn = 'pdRank';
             break;
         case 'iskDestroyed':
             $valueColumn = 'iskDestroyed';
             $rankColumn = 'idRank';
             break;
         case 'overallRank':
             $valueColumn = 'overallRank';
             $rankColumn = 'overallRank';
             break;
         default:
             throw new Exception("Unknown rankType passed to getRanks: {$rankType}");
     }
     switch ($type) {
         case 'pilot':
             $idColumn = 'characterID';
             break;
         case 'corp':
             $idColumn = 'corporationID';
             break;
         case 'alli':
             $idColumn = 'allianceID';
             break;
         case 'faction':
             $idColumn = 'factionID';
             break;
         case 'ship':
             $idColumn = 'shipTypeID';
             break;
         case 'group':
             $idColumn = 'groupID';
             break;
         case 'system':
             $idColumn = 'solarSystemID';
             break;
         case 'region':
             $idColumn = 'regionID';
             break;
         default:
             throw new Exception("Unknown type passed to getRanks: {$type}");
     }
     $result = Db::query("select typeID {$idColumn}, {$rankColumn} rank, {$valueColumn} kills from {$table} where type = '{$type}' order by {$rankColumn} limit 10");
     Info::addInfo($result);
     return $result;
 }
Example #5
0
 public static function getRanks($type, $rankType, $recent)
 {
     $table = $recent == true ? "zz_ranks" : "zz_ranks_recent";
     switch ($rankType) {
         case "shipsDestroyed":
             $valueColumn = "shipsDestroyed";
             $rankColumn = "sdRank";
             break;
         case "pointsDestroyed":
             $valueColumn = "pointsDestroyed";
             $rankColumn = "pdRank";
             break;
         case "iskDestroyed":
             $valueColumn = "iskDestroyed";
             $rankColumn = "idRank";
             break;
         case "overallRank":
             $valueColumn = "overallRank";
             $rankColumn = "overallRank";
             break;
         default:
             throw new Exception("Unknown rankType passed to getRanks: {$rankType}");
     }
     switch ($type) {
         case "pilot":
             $idColumn = "characterID";
             break;
         case "corp":
             $idColumn = "corporationID";
             break;
         case "alli":
             $idColumn = "allianceID";
             break;
         case "faction":
             $idColumn = "factionID";
             break;
         case "ship":
             $idColumn = "shipTypeID";
             break;
         case "group":
             $idColumn = "groupID";
             break;
         case "system":
             $idColumn = "solarSystemID";
             break;
         case "region":
             $idColumn = "regionID";
             break;
         default:
             throw new Exception("Unknown type passed to getRanks: {$type}");
     }
     $result = Db::query("select typeID {$idColumn}, {$rankColumn} rank, {$valueColumn} kills from {$table} where type = '{$type}' order by {$rankColumn} limit 10");
     Info::addInfo($result);
     return $result;
 }
Example #6
0
 public static function beSocial($killID)
 {
     if ($killID < 0) {
         return;
     }
     $ircMin = 5000000000;
     $twitMin = 10000000000;
     // This is an array of characters we like to laugh at :)
     $laugh = array(1633218082, 924610627, 619471207, 268946627, 179004085, 428663616);
     $count = Db::queryField("select count(*) count from zz_social where killID = :killID", "count", array(":killID" => $killID), 0);
     if ($count != 0) {
         return;
     }
     // Get victim info
     $victimInfo = Db::queryRow("select * from zz_participants where killID = :killID and isVictim = 1", array(":killID" => $killID));
     if ($victimInfo == null) {
         return;
     }
     $totalPrice = $victimInfo["total_price"];
     if (!in_array($victimInfo["characterID"], $laugh)) {
         // If in laugh array, skip the checks
         // Check the minimums, min. price and happened in last 12 hours
         if ($totalPrice < $ircMin) {
             return;
         }
     }
     Info::addInfo($victimInfo);
     $url = "https://zkillboard.com/detail/{$killID}/";
     if ($totalPrice >= $twitMin) {
         $url = Twit::shortenUrl($url);
     }
     $message = "|g|" . $victimInfo["shipName"] . "|n| worth |r|" . Util::formatIsk($totalPrice) . " ISK|n| was destroyed! {$url}";
     if (!isset($victimInfo["characterName"])) {
         $victimInfo["characterName"] = $victimInfo["corporationName"];
     }
     if (strlen($victimInfo["characterName"]) < 25) {
         $name = $victimInfo["characterName"];
         if (Util::endsWith($name, "s")) {
             $name .= "'";
         } else {
             $name .= "'s";
         }
         $message = "{$name} {$message}";
     }
     Db::execute("insert into zz_social (killID) values (:killID)", array(":killID" => $killID));
     Log::irc("{$message}");
     $message = Log::stripIRCColors($message);
     if ($totalPrice >= $twitMin) {
         $message .= " #tweetfleet #eveonline";
         $return = Twit::sendMessage($message);
         $twit = "https://twitter.com/eve_kill/status/" . $return->id;
         Log::irc("Message was also tweeted: |g|{$twit}");
     }
 }
Example #7
0
 public static function getSupers($key, $id)
 {
     $data = array();
     $parameters = [$key => (int) $id, 'groupID' => 30, 'isVictim' => false, 'pastSeconds' => 86400 * 90, 'nolimit' => true];
     $data['titans']['data'] = Stats::getTop('characterID', $parameters);
     $data['titans']['title'] = 'Titans';
     $parameters = [$key => (int) $id, 'groupID' => 659, 'isVictim' => false, 'pastSeconds' => 86400 * 90, 'nolimit' => true];
     $data['supercarriers']['data'] = Stats::getTop('characterID', $parameters);
     $data['supercarriers']['title'] = 'Supercarriers';
     Info::addInfo($data);
     return $data;
 }
Example #8
0
        if ($status == 0) {
            $app->redirect('/tickets/');
        } else {
            $app->redirect('.');
        }
        exit;
    }
    if ($reply !== null && $ticket['status'] != 0) {
        $charID = User::getUserId();
        $name = $info['username'];
        $moderator = @$info['moderator'] == true;
        $mdb->insert("tickets", ['parentID' => $id, 'content' => $reply, 'characterID' => $charID, 'dttm' => time(), 'moderator' => $moderator]);
        $mdb->getCollection("tickets")->update(['_id' => new MongoID($id)], ['$set' => ['dttmUpdate' => time()]]);
        $mdb->getCollection("tickets")->update(['_id' => new MongoID($id)], ['$inc' => ['replies' => 1]]);
        if (!$moderator) {
            Log::irc("|g|Ticket response from {$name}|n|: {$fullAddr}/tickets/view/{$id}/");
        }
        if ($moderator && isset($ticket['email']) && strlen($ticket['email']) > 0) {
            Email::send($ticket['email'], "zKillboard Ticket Response", "You have received a response to a ticket you submitted. To view the response, please click {$fullAddr}/tickets/view/{$id}/");
        }
        $app->redirect(".");
        exit;
    } else {
        $message = array('status' => 'error', 'message' => 'No...');
    }
}
$replies = $mdb->find("tickets", ['parentID' => $id], ['dttm' => 1]);
Info::addInfo($ticket);
Info::addInfo($replies);
array_unshift($replies, $ticket);
$app->render('tickets_view.html', array('page' => $id, 'message' => $message, 'ticket' => $ticket, 'replies' => $replies, 'user' => $info));
Example #9
0
<?php

global $mdb;
$battles = $mdb->find("battles", [], ['battleID' => -1], 50);
Info::addInfo($battles);
$app->render('battles.html', ['battles' => $battles]);
Example #10
0
 /**
  * @param array $array
  * @param array $killHash
  * @return array
  */
 private static function addInfo($array, $killHash)
 {
     $results = array();
     foreach ($array as $hash => $kill) {
         $split = explode("|", $hash);
         $row = array();
         $row["shipTypeID"] = $split[0];
         $row["corporationID"] = $split[1];
         $row["characterID"] = $split[2];
         $row["allianceID"] = $split[3];
         $row["destroyed"] = in_array($hash, array_keys($killHash)) ? $killHash[$hash]["kill"]["victim"]["killID"] : 0;
         $podHash = "670|" . $row["corporationID"] . "|" . $row["characterID"] . "|" . $row["allianceID"];
         $row["podded"] = in_array($podHash, $killHash) ? 1 : 0;
         Info::addInfo($row);
         $results[] = $row;
     }
     return $results;
 }
Example #11
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
if (!in_array($pageType, array("recent", "alltime"))) {
    $app->notFound();
}
if (!in_array($subType, array("killers", "losers"))) {
    $app->notFound();
}
$table = $pageType == "recent" ? "zz_ranks_recent" : "zz_ranks";
$pageTitle = $pageType == "recent" ? "Ranks - Recent (Past 90 Days)" : "Alltime Ranks";
$tableTitle = $pageType == "recent" ? "Recent Rank" : "Alltime Rank";
$rankColumns = $subType == "killers" ? "(sdRank <= 10 or pdRank <= 10 or idRank <= 10 or overallRank <= 10)" : "(slRank <= 10 or plRank <= 10 or ilRank <= 10)";
$types = array("pilot" => "characterID", "corp" => "corporationID", "alli" => "allianceID", "faction" => "factionID");
$names = array("character" => "Characters", "corp" => "Corporations", "alli" => "Alliances", "faction" => "Factions");
$ranks = array();
foreach ($types as $type => $column) {
    $result = Db::query("select distinct typeID {$column}, r.* from {$table} r where type = '{$type}' and {$rankColumns} order by overallRank");
    if ($type == "pilot") {
        $type = "character";
    }
    $ranks[] = array("type" => $type, "data" => $result, "name" => $names[$type]);
}
Info::addInfo($ranks);
$app->render("ranks.html", array("ranks" => $ranks, "pageTitle" => $pageTitle, "tableTitle" => $tableTitle, "pageType" => $pageType, "subType" => $subType));
Example #12
0
    $top[] = Info::doMakeCommon('Top Characters', 'characterID', Stats::getTopPilots($p));
    $top[] = $columnName != 'corporationID' ? Info::doMakeCommon('Top Corporations', 'corporationID', Stats::getTopCorps($p)) : array();
    $top[] = $columnName != 'corporationID' && $columnName != 'allianceID' ? Info::doMakeCommon('Top Alliances', 'allianceID', Stats::getTopAllis($p)) : array();
    $top[] = Info::doMakeCommon('Top Ships', 'shipTypeID', Stats::getTopShips($p));
    $top[] = Info::doMakeCommon('Top Systems', 'solarSystemID', Stats::getTopSystems($p));
    $requestUriPager = str_replace('ID', '', $columnName) . "/{$id}/";
    $p['limit'] = 5;
    $topIsk = Stats::getTopIsk($p);
    unset($p['pastSeconds']);
    unset($p['kills']);
    // get latest kills
    $killsLimit = 50;
    $p['limit'] = $killsLimit;
    $kills = Kills::getKills($p);
    $kills = Kills::mergeKillArrays($kills, array(), $killsLimit, $columnName, $id);
    Info::addInfo($p);
    $pageTitle = array();
    foreach ($p as $key => $value) {
        if (strpos($key, 'Name') !== false) {
            $pageTitle[] = $value;
        }
    }
    $pageTitle = implode(',', $pageTitle);
    $pageType = 'subdomain';
} else {
    $topPoints = array();
    $topIsk = Stats::getTopIsk(array('cacheTime' => 15 * 60, 'pastSeconds' => 7 * 86400, 'limit' => 5));
    $topPods = array();
    $top = array();
    $top[] = json_decode(Storage::retrieve('TopChars', [], 900), true);
    $top[] = json_decode(Storage::retrieve('TopCorps', [], 900), true);
Example #13
0
global $baseAddr;
$message = array();
if ($_POST) {
    $email = Util::getPost('email');
    $subject = Util::getPost('subject');
    $ticket = Util::getPost('ticket');
    $info = User::getUserInfo();
    $charID = User::getUserId();
    $name = $info['username'];
    if ($charID > 0 && isset($ticket)) {
        $insert = ['subject' => $subject, 'content' => $ticket, 'dttm' => time(), 'parentID' => null, 'email' => $email, 'characterID' => $charID, 'status' => 1];
        $mdb->insert("tickets", $insert);
        $id = $insert['_id'];
        Log::irc("|g|New ticket from {$name}:|n| https://{$baseAddr}//tickets/view/{$id}/");
        $app->redirect("/tickets/view/{$id}/");
        exit;
    } else {
        $message = array('type' => 'error', 'message' => 'Ticket was not posted, there was an error');
    }
}
$info = User::getUserInfo();
if (@$info['moderator'] == true) {
    $open_tickets = $mdb->find("tickets", ['parentID' => null, 'status' => 1], ['dttm' => -1]);
    $closed_tickets = $mdb->find("tickets", ['parentID' => null, 'status' => ['$ne' => 1]], ['dttm' => -1]);
    $tickets = array_merge($open_tickets, $closed_tickets);
} else {
    $tickets = $mdb->find("tickets", ['$and' => [['characterID' => User::getUserID()], ['parentID' => null]]], ['dttm' => -1]);
}
Info::addInfo($tickets);
$userInfo = User::getUserInfo();
$app->render('tickets.html', array('userInfo' => $userInfo, 'tickets' => $tickets, 'message' => $message));
Example #14
0
function beSocial($killID)
{
    global $beSocial, $mdb;
    if (!isset($beSocial)) {
        $beSocial = false;
    }
    if ($beSocial === false) {
        return;
    }
    if ($killID < 0) {
        return;
    }
    $ircMin = 10000000000.0;
    $twitMin = 10000000000.0;
    $kill = $mdb->findDoc('killmails', ['killID' => $killID]);
    if (@$kill['social'] == true) {
        return;
    }
    $hours24 = time() - 86400;
    if ($kill['dttm']->sec < $hours24) {
        return;
    }
    // Get victim info
    $victimInfo = $kill['involved'][0];
    if ($victimInfo == null) {
        return;
    }
    $totalPrice = $kill['zkb']['totalValue'];
    Info::addInfo($victimInfo);
    // Reduce spam of freighters and jump freighters
    $shipGroupID = $victimInfo['groupID'];
    if (in_array($shipGroupID, array(513, 902))) {
        $shipPrice = Price::getItemPrice($victimInfo['shipTypeID'], date('Ymd'));
        $ircMin += $shipPrice;
        $twitMin += $shipPrice;
    }
    $worthIt = false;
    $worthIt |= $totalPrice >= $ircMin;
    if (!$worthIt) {
        return;
    }
    $tweetIt = false;
    $tweetIt |= $totalPrice >= $twitMin;
    global $fullAddr, $twitterName;
    $url = "{$fullAddr}/kill/{$killID}/";
    if ($url == '') {
        $url = "{$fullAddr}/kill/{$killID}/";
    }
    $message = '|g|' . $victimInfo['shipName'] . '|n| worth |r|' . Util::formatIsk($totalPrice) . " ISK|n| was destroyed! {$url}";
    if (!isset($victimInfo['characterName'])) {
        $victimInfo['characterName'] = $victimInfo['corporationName'];
    }
    if (strlen($victimInfo['characterName']) < 25) {
        $name = $victimInfo['characterName'];
        if (Util::endsWith($name, 's')) {
            $name .= "'";
        } else {
            $name .= "'s";
        }
        $message = "{$name} {$message}";
    }
    $mdb->getCollection('killmails')->update(['killID' => $killID], ['$unset' => ['social' => true]]);
    Log::irc("{$message}");
    $message = Log::stripIRCColors($message);
    $message .= ' #tweetfleet #eveonline';
    if (strlen($message) > 120) {
        $message = str_replace(' worth ', ': ', $message);
    }
    if (strlen($message) > 120) {
        $message = str_replace(' was destroyed!', '', $message);
    }
    if ($tweetIt && strlen($message) <= 120) {
        $return = Twit::sendMessage($message);
        $twit = "https://twitter.com/{$twitterName}/status/" . $return->id;
        Log::irc("Message was also tweeted: |g|{$twit}");
    }
}
Example #15
0
function getTop($title, $type)
{
    global $redis;
    $retVal = [];
    $ids = $redis->zRange("tq:ranks:weekly:{$type}", 0, 10);
    foreach ($ids as $id) {
        $retVal[] = [$type => $id, 'kills' => $redis->zScore("tq:ranks:weekly:{$type}:shipsDestroyed", $id)];
    }
    Info::addInfo($retVal);
    return ['type' => str_replace("ID", "", $type), 'title' => $title, 'values' => $retVal];
}
Example #16
0
 /**
  * Gets details for a kill.
  *
  * @param $killID the killID of the kill you want details for
  *
  * @return array
  */
 public static function getKillDetails($killID)
 {
     global $mdb;
     $killmail = $mdb->findDoc('killmails', ['cacheTime' => 3600, 'killID' => (int) $killID]);
     $rawmail = $mdb->findDoc('rawmails', ['cacheTime' => 3600, 'killID' => (int) $killID]);
     $damage = (int) $rawmail['victim']['damageTaken'];
     $killmail['damage'] = $damage;
     $killmail['dttm'] = date('Y-m-d G:i', $killmail['dttm']->sec);
     Info::addInfo($killmail);
     $victim = $killmail['involved'][0];
     $victim['damage'] = $damage;
     $involved = $killmail['involved'];
     array_shift($involved);
     // remove the victim
     $items = self::getItems($rawmail, $killmail);
     $infoInvolved = array();
     $infoItems = array();
     $rawmailInv = $rawmail['attackers'];
     $attackerCount = sizeof($rawmailInv);
     $killmail['number_involved'] = $attackerCount;
     if (isset($rawmail['victim']['position'])) {
         $location = [];
         $location['itemID'] = (int) $killmail['locationID'];
         $location['itemName'] = $mdb->findField("information", "name", ['cacheTime' => 3600, 'type' => 'locationID', 'id' => (int) $killmail['locationID']]);
         $killmail['location'] = $location;
     }
     for ($index = 0; $index < $attackerCount; ++$index) {
         $rawI = $rawmailInv[$index];
         $i = $involved[$index];
         $i['damage'] = $rawI['damageDone'];
         $i['weaponTypeID'] = @$rawI['weaponType']['id'];
         $infoInvolved[] = Info::addInfo($i);
     }
     unset($involved);
     foreach ($items as $i) {
         $infoItems[] = Info::addInfo($i);
     }
     unset($items);
     return array('info' => $killmail, 'victim' => $victim, 'involved' => $infoInvolved, 'items' => $infoItems);
 }
Example #17
0
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
if (!is_numeric($id)) {
    $id = Info::getItemId($id);
    if ($id > 0) {
        header("Location: /item/{$id}/");
    } else {
        header("Location: /");
    }
    die;
}
$info = Db::queryRow("select typeID, typeName, description from ccp_invTypes where typeID = :id", array(":id" => $id), 3600);
$info["description"] = str_replace("<br>", "\n", $info["description"]);
$info["description"] = strip_tags($info["description"]);
$hasKills = 1 == Db::queryField("select 1 as hasKills from zz_participants where shipTypeID = :id limit 1", "hasKills", array(":id" => $id), 3600);
$buyOrders = Db::query("select * from zz_marketdata where typeID = :typeID and bid = 1 order by price desc limit 10", array(":typeID" => $id));
$sellOrders = Db::query("select * from zz_marketdata where typeID = :typeID and bid = 0 order by price asc limit 10", array(":typeID" => $id));
$info["attributes"] = Db::query("SELECT categoryName, coalesce(displayName, attributeName) attributeName, coalesce(valueint,valuefloat) value  FROM ccp_invTypes JOIN ccp_dgmTypeAttributes ON (ccp_invTypes.typeid = ccp_dgmTypeAttributes.typeid) JOIN ccp_dgmAttributeTypes ON (ccp_dgmTypeAttributes.attributeid = ccp_dgmAttributeTypes.attributeid) LEFT JOIN ccp_dgmAttributeCategories ON (ccp_dgmAttributeTypes.categoryid=ccp_dgmAttributeCategories.categoryid) WHERE ccp_invTypes.typeid = :typeID and ccp_dgmAttributeCategories.categoryid is not null and displayName is not null and ccp_dgmAttributeTypes.categoryID not in (8,9) ORDER BY ccp_dgmAttributeCategories.categoryid,   ccp_dgmAttributeTypes.attributeid", array(":typeID" => $id));
Info::addInfo($buyOrders);
Info::addInfo($sellOrders);
$app->render("item.html", array("info" => $info, "hasKills" => $hasKills, "buyOrders" => $buyOrders, "sellOrders" => $sellOrders));
Example #18
0
 private static function getStatsKillList($killIDs)
 {
     $totalPrice = 0;
     $totalPoints = 0;
     $groupIDs = array();
     $totalShips = 0;
     foreach ($killIDs as $killID) {
         $kill = Kills::getKillDetails($killID);
         $info = $kill['info'];
         $victim = $kill['victim'];
         $totalPrice += $info['zkb']['totalValue'];
         $totalPoints += $info['zkb']['points'];
         $groupID = $victim['groupID'];
         if (!isset($groupIDs[$groupID])) {
             $groupIDs[$groupID] = array();
             $groupIDs[$groupID]['count'] = 0;
             $groupIDs[$groupID]['isk'] = 0;
             $groupIDs[$groupID]['points'] = 0;
         }
         $groupIDs[$groupID]['groupID'] = $groupID;
         ++$groupIDs[$groupID]['count'];
         $groupIDs[$groupID]['isk'] += $info['zkb']['totalValue'];
         $groupIDs[$groupID]['points'] += $info['zkb']['points'];
         ++$totalShips;
     }
     Info::addInfo($groupIDs);
     return array('total_price' => $totalPrice, 'groupIDs' => $groupIDs, 'totalShips' => $totalShips, 'total_points' => $totalPoints);
 }
Example #19
0
global $mdb;
if (!is_numeric($id)) {
    $id = Info::getItemId($id);
    if ($id > 0) {
        header("Location: /item/{$id}/");
    } else {
        header('Location: /');
    }
    die;
}
$info = $mdb->findDoc("information", ['type' => 'typeID', 'id' => (int) $id, 'cacheTime' => 3600]);
$info['typeName'] = $info['name'];
$info['description'] = str_replace('<br>', "\n", @$info['description']);
$info['description'] = strip_tags(@$info['description']);
$info['price'] = Price::getItemPrice($id, date('Ymd'));
global $mdb;
$cursor = $mdb->getCollection('killmails')->find(['involved.shipTypeID' => (int) $id]);
$hasKills = $cursor->hasNext();
$info['attributes'] = array();
$info['market'] = Db::query('select * from zz_item_price_lookup where typeID = :typeID order by priceDate desc limit 30', array(':typeID' => $id));
$kills = $mdb->find('itemmails', ['typeID' => (int) $id], ['killID' => -1], 50);
$victims = [];
foreach ($kills as $row) {
    $kill = $mdb->findDoc('killmails', ['killID' => $row['killID']]);
    $victim = $kill['involved'][0];
    $victim['destroyed'] = $row['killID'];
    $victims[] = $victim;
}
Info::addInfo($victims);
$app->render('item.html', array('info' => $info, 'hasKills' => $hasKills, 'kills' => $victims));
Example #20
0
 /**
  * Returns an array of the characters assigned to this user.
  *
  * @static
  *
  * @param $userID int
  *
  * @return array
  */
 public static function getCharacters($userID)
 {
     $result = self::getCharacterKeys($userID);
     Info::addInfo($result);
     return $result;
 }
Example #21
0
 /**
  * @param \Pheal\Core\Result $data
  * @param mixed $db
  * @return int
  */
 private static function processAPI($data, $db)
 {
     $count = 0;
     foreach ($data->kills as $kill) {
         if ($kill->killID > 0) {
             $killID = $kill->killID;
         } else {
             $killID = $kill->killInternalID * -1;
         }
         if ($killID == 0) {
             continue;
         }
         $killArray = $kill->toArray();
         // Remove all the unwanted crud that EDK sets
         unset($killArray["killInternalID"]);
         unset($killArray["hash"]);
         unset($killArray["trust"]);
         // If the killID is below zero, we'll just replace the killID in the array with the minus one..
         if ($killID < 0) {
             $killArray["killID"] = $killID;
         }
         $json = json_encode($killArray);
         $hash = Util::getKillHash(null, $kill);
         $source = "EDK Feed Fetch";
         $mKillID = $db->queryField("select killID from zz_killmails where killID < 0 and processed = 1 and hash = :hash", "killID", array(":hash" => $hash), 0);
         if ($mKillID) {
             Kills::cleanDupe($mKillID, $killID);
         }
         // If the killID is negative at this point, we need to create a raw mail, and use that to insert it into the zz_manual_mails table, so we can get a manual mail id
         if ($killID < 0) {
             $rawText = Kills::getRawMail(null, Info::addInfo($killArray));
             $db->execute("INSERT IGNORE INTO zz_manual_mails (hash, rawText) VALUES (:hash, :rawText)", array(":hash" => $hash, ":rawText" => $rawText));
             $killID = $db->queryField("SELECT mKillID FROM zz_manual_mails WHERE hash = :hash ORDER BY mKillID DESC LIMIT 1", array(":hash" => $hash), 0);
         }
         $added = $db->execute("insert ignore into zz_killmails (killID, hash, source, kill_json) values (:killID, :hash, :source, :json)", array(":killID" => $killID, ":hash" => $hash, ":source" => $source, ":json" => $json));
         $count += $added;
     }
     return $count;
 }
Example #22
-1
        }
    }
    $ddcombine = Util::getPost("ddcombine");
    if (isset($ddcombine)) {
        UserConfig::set("ddcombine", $ddcombine);
    }
    $ddmonthyear = Util::getPost("ddmonthYear");
    if (isset($ddmonthyear)) {
        UserConfig::set("ddmonthyear", $ddmonthyear);
    }
    $useSummaryAccordion = Util::getPost("useSummaryAccordion");
    if (isset($useSummaryAccordion)) {
        UserConfig::set("useSummaryAccordion", $useSummaryAccordion);
    }
}
$data["entities"] = Account::getUserTrackerData();
$data["themes"] = Util::bootstrapThemes();
$data["viewthemes"] = Util::themesAvailable();
$data["apiKeys"] = Api::getKeys($userID);
$data["apiChars"] = Api::getCharacters($userID);
$charKeys = Api::getCharacterKeys($userID);
$charKeys = Info::addInfo($charKeys);
$data["apiCharKeys"] = $charKeys;
$data["userInfo"] = User::getUserInfo();
$data["currentTheme"] = UserConfig::get("theme", "default");
$data["timeago"] = UserConfig::get("timeago");
$data["ddcombine"] = UserConfig::get("ddcombine");
$data["ddmonthyear"] = UserConfig::get("ddmonthyear");
$data["useSummaryAccordion"] = UserConfig::get("useSummaryAccordion");
$data["sessions"] = User::getSessions($userID);
$app->render("account.html", array("data" => $data, "message" => $error, "key" => $key, "reqid" => $reqid));
Example #23
-1
if ($key == 'system') {
    $statType = 'solarSystemID';
} elseif ($key == 'ship') {
    $statType = 'shipTypeID';
} else {
    $statType = "{$key}ID";
}
$statistics = $mdb->findDoc('statistics', ['type' => $statType, 'id' => (int) $id]);
$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);
Example #24
-2
    $extra['wormhole'] = $data;
    $url = 'https://' . $_SERVER['SERVER_NAME'] . "/detail/{$id}/";
    if ($killdata['victim']['groupID'] == 29) {
        $query = ['$and' => [['involved.characterID' => (int) $killdata['victim']['characterID']], ['killID' => ['$gte' => $id - 200]], ['killID' => ['$lt' => $id]], ['vGroupID' => ['$ne' => 29]]]];
        $relatedKill = $mdb->findDoc('killmails', $query);
        if ($relatedKill) {
            $relatedShip = ['killID' => $relatedKill['killID'], 'shipTypeID' => $relatedKill['involved'][0]['shipTypeID']];
        }
    } else {
        $query = ['$and' => [['involved.characterID' => (int) @$killdata['victim']['characterID']], ['killID' => ['$lte' => $id + 200]], ['killID' => ['$gt' => $id]], ['vGroupID' => 29]]];
        $relatedKill = $mdb->findDoc('killmails', $query);
        if ($relatedKill) {
            $relatedShip = ['killID' => $relatedKill['killID'], 'shipTypeID' => $relatedKill['involved'][0]['shipTypeID']];
        }
    }
    Info::addInfo($relatedShip);
    $killdata['victim']['related'] = $relatedShip;
    $details = array('pageview' => $pageview, 'killdata' => $killdata, 'extra' => $extra, 'message' => $message, 'flags' => Info::$effectToSlot, 'topDamage' => $topDamage, 'finalBlow' => $finalBlow, 'url' => $url);
    RedisCache::set($killKey, $details, 3600);
}
$app->render('detail.html', $details);
function involvedships($array)
{
    $involved = array();
    foreach ($array as $inv) {
        if (isset($involved[@$inv['shipTypeID']]) && isset($inv['shipName'])) {
            $involved[$inv['shipTypeID']] = array('shipName' => $inv['shipName'], 'shipTypeID' => $inv['shipTypeID'], 'count' => $involved[$inv['shipTypeID']]['count'] + 1);
        } elseif (isset($inv['shipTypeID']) && isset($inv['shipName'])) {
            $involved[$inv['shipTypeID']] = array('shipName' => $inv['shipName'], 'shipTypeID' => $inv['shipTypeID'], 'count' => 1);
        } else {
            continue;
Example #25
-2
$entities = array();
if ($_POST) {
    $app->redirect('/search/' . urlencode($_POST['searchbox']) . '/');
}
if ($search) {
    $result = Info::findEntity($search);
    // if there is only one result, we redirect.
    if (count($result) == 1) {
        $type = str_replace('ID', '', $result[0]['type']);
        $values = array_values($result[0]);
        $id = $result[0]['id'];
        $app->redirect("/{$type}/{$id}/");
        die;
    }
    $entities = [];
    foreach ($result as $row) {
        $entity = [];
        $entity['type'] = str_replace('ID', '', $row['type']);
        $entity[$row['type']] = $row['id'];
        $entity[$entity['type'] . 'Name'] = $row['name'];
        if ($entity['type'] == 'type') {
            $entity['type'] = 'item';
        }
        if ($entity['type'] == 'solarSystem') {
            $entity['type'] = 'system';
        }
        $entities[] = $entity;
    }
    Info::addInfo($entities);
}
$app->render('search.html', array('data' => $entities));
Example #26
-2
 /**
  * Returns an array of the characters assigned to this user.
  *
  * @static
  * @param $userID int
  * @return array
  */
 public static function getCharacters($userID)
 {
     $db = Db::query("SELECT characterID FROM zz_api_characters c left join zz_api a on (c.keyID = a.keyID) where userID = :userID", array(":userID" => $userID), 0);
     $results = Info::addInfo($db);
     return $results;
 }