Example #1
0
 /**
  * Fetches information for a wormhole system.
  *
  * @param int $systemID
  *
  * @return array
  */
 public static function getWormholeSystemInfo($systemID)
 {
     if ($systemID < 3100000) {
         return;
     }
     return Db::queryRow('select * from ccp_zwormhole_info where solarSystemID = :systemID', array(':systemID' => $systemID), 3600);
 }
Example #2
0
 /**
  * Adds a key to the database.
  *
  * @static
  * @param int $keyID
  * @param string $vCode
  * @param null|string $label
  * @return string
  */
 public static function addKey($keyID, $vCode, $label = null)
 {
     $userID = User::getUserID();
     if ($userID == null) {
         $userID = 0;
     }
     $exists = Db::queryRow("SELECT userID, keyID, vCode FROM zz_api WHERE keyID = :keyID AND vCode = :vCode", array(":keyID" => $keyID, ":vCode" => $vCode), 0);
     if ($exists == null) {
         // Insert the api key
         Db::execute("replace into zz_api (userID, keyID, vCode, label) VALUES (:userID, :keyID, :vCode, :label)", array(":userID" => $userID, ":keyID" => $keyID, ":vCode" => $vCode, ":label" => $label));
     } else {
         if ($exists["userID"] == 0) {
             // Someone already gave us this key anonymously, give it to this user
             Db::execute("UPDATE zz_api SET userID = :userID, label = :label WHERE keyID = :keyID", array(":userID" => $userID, ":label" => $label, ":keyID" => $keyID));
             return "keyID {$keyID} previously existed in our database but has now been assigned to you.";
         } else {
             return "keyID {$keyID} is already in the database...";
         }
     }
     $pheal = Util::getPheal($keyID, $vCode);
     $result = $pheal->accountScope->APIKeyInfo();
     $key = $result->key;
     $keyType = $key->type;
     if ($keyType == "Account") {
         $keyType = "Character";
     }
     $ip = IP::get();
     Log::log("API: {$keyID} has been added.  Type: {$keyType} ({$ip})");
     return "Success, your {$keyType} key has been added.";
 }
Example #3
0
 public static function calculatePoints($killID, $tempTables = false)
 {
     $temp = $tempTables ? "_temporary" : "";
     $victim = Db::queryRow("select * from zz_participants{$temp} where killID = :killID and isVictim = 1", array(":killID" => $killID), 0);
     $kill = $victim;
     $involved = Db::query("select * from zz_participants{$temp} where killID = :killID and isVictim = 0", array(":killID" => $killID), 0);
     $vicpoints = self::getPoints($victim["groupID"]);
     $vicpoints += $kill["total_price"] / 10000000;
     $maxpoints = round($vicpoints * 1.2);
     $invpoints = 0;
     foreach ($involved as $inv) {
         $invpoints += self::getPoints($inv["groupID"]);
     }
     if ($vicpoints + $invpoints == 0) {
         return 0;
     }
     $gankfactor = $vicpoints / ($vicpoints + $invpoints);
     $points = ceil($vicpoints * ($gankfactor / 0.75));
     if ($points > $maxpoints) {
         $points = $maxpoints;
     }
     $points = round($points, 0);
     return max(1, $points);
     // a kill is always worth at least one point
 }
Example #4
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}");
     }
 }
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     if (Util::isMaintenanceMode()) {
         irc_error("|r|Cannot reprice while in maintenance mode");
     }
     @($killID = (int) $parameters[0]);
     if ($killID == 0) {
         irc_error("|r|Please provide a valid killID.");
     }
     $count = Db::queryField("select count(*) count from zz_participants where killID = :killID", "count", array(":killID" => $killID));
     if ($count == 0) {
         irc_error("|r|KillID {$killID} does not exist!");
     }
     Stats::calcStats($killID, false);
     Db::execute("update zz_killmails set processed = 0 where killID = :killID", array(":killID" => $killID));
     do {
         sleep(1);
         $processed = Db::queryField("select processed from zz_killmails where killID = :killID", "processed", array(":killID" => $killID), 0);
     } while ($processed == 0);
     $kill = Db::queryRow("select * from zz_participants where isVictim = 1 and killID = :killID", array(":killID" => $killID), 0);
     $total = $kill["total_price"];
     $points = $kill["points"];
     irc_out("|g|{$killID}|n| repriced to|g| " . number_format($total, 2) . "|n| ISK and |g|" . number_format($points, 0) . "|n| points");
 }
 * This program is free software: you can redistribute it and/or modify
 * 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/>.
 */
$message = array();
$info = User::getUserInfo();
$ticket = Db::queryRow("SELECT * FROM zz_tickets WHERE id = :id", array(":id" => $id), 0);
if ($ticket == NULL or sizeof($ticket) == 0) {
    $message = array("status" => "error", "message" => "Ticket does not exist.");
} elseif ($ticket["status"] == 0) {
    $message = array("status" => "error", "message" => "Ticket has been closed, you cannot post, only view it");
} elseif ($ticket["userid"] != $info["id"] && $info["moderator"] == 0 && $info["admin"] == 0) {
    $app->notFound();
}
if ($_POST) {
    $reply = Util::getPost("reply");
    if ($reply && $ticket["status"] != 0) {
        $name = $info["username"];
        $moderator = $info["moderator"];
        $check = Db::query("SELECT * FROM zz_tickets_replies WHERE reply = :reply AND userid = :userid AND belongsTo = :id", array(":reply" => $reply, ":userid" => $info["id"], ":id" => $id), 0);
        if (!$check) {
            Db::execute("INSERT INTO zz_tickets_replies (userid, belongsTo, name, reply, moderator) VALUES (:userid, :belongsTo, :name, :reply, :moderator)", array(":userid" => $info["id"], ":belongsTo" => $id, ":name" => $name, ":reply" => $reply, ":moderator" => $moderator));
Example #7
0
function loadFile($file, $table)
{
    if (Util::endsWith($file, ".gz")) {
        $handle = gzopen($file, "r");
    } else {
        $handle = fopen($file, "r");
    }
    if (Db::queryRow("SHOW TABLES LIKE'{$table}'") != null) {
        //Check to see if we are adding new tables
        if (Util::startsWith($table, "ccp_")) {
            Db::execute("drop table {$table}");
        } else {
            Db::execute("alter table {$table} rename old_{$table}");
        }
    }
    $query = "";
    while ($buffer = fgets($handle)) {
        $query .= $buffer;
        if (strpos($query, ";") !== false) {
            $query = str_replace(";", "", $query);
            Db::execute($query);
            $query = "";
        }
    }
    fclose($handle);
    if (Db::queryRow("SHOW TABLES LIKE 'old_{$table}'") != null) {
        // Check again to see if the old_table is there
        if (!Util::startsWith($table, "ccp_")) {
            try {
                Db::execute("insert ignore into {$table} select * from old_{$table}");
                Db::execute("drop table old_{$table}");
            } catch (Exception $ex) {
                Db::execute("drop table {$table}");
                Db::execute("alter table old_{$table} rename {$table}");
                throw $ex;
            }
        }
    }
}
Example #8
0
<?php

global $mdb;
$battleID = (int) $battleID;
//$battle = $mdb->findDoc("battles", ['battleID' => $battleID]);
$battle = Db::queryRow('select * from zz_battle_report where battleID = :id', array(':id' => $battleID));
$battle['battleID'] = (int) $battle['battleID'];
if (!$mdb->exists("battles", ['battleID' => $battleID])) {
    $mdb->save("battles", $battle);
}
$system = @$battle['solarSystemID'];
$time = @$battle['dttm'];
$options = @$battle['options'];
$showBattleOptions = false;
global $baseDir;
require_once $baseDir . '/view/related.php';
die;
Example #9
0
<?php

$numDays = 7;
$campaign = Db::queryRow('select * from zz_campaigns where uri = :uri', array(':uri' => $uri), 1);
if ($campaign == null) {
    $app->redirect('/', 302);
}
$title = 'Campaign: ' . $campaign['title'];
$subTitle = $campaign['subTitle'];
$p = json_decode($campaign['definition'], true);
$summary = Summary::getSummary('system', 'solarSystemID', $p, 30000142, $p, true);
$topPoints = array();
$topPods = array();
$top = array();
$top[] = Info::doMakeCommon('Top Characters', 'characterID', Stats::getTopPilots($p, true));
$top[] = Info::doMakeCommon('Top Corporations', 'corporationID', Stats::getTopCorps($p, true));
$top[] = Info::doMakeCommon('Top Alliances', 'allianceID', Stats::getTopAllis($p, true));
$top[] = Info::doMakeCommon('Top Ships', 'shipTypeID', Stats::getTopShips($p, true));
$top[] = Info::doMakeCommon('Top Systems', 'solarSystemID', Stats::getTopSystems($p, true));
$p['pastSeconds'] = $numDays * 86400;
$p['limit'] = 5;
$topIsk = Stats::getTopIsk($p, true);
$topIsk['title'] = 'Most Valuable Kills';
unset($p['pastSeconds']);
// get latest kills
$killsLimit = 50;
$p['limit'] = $killsLimit;
if (isset($page) && $page > 0 && $page < 100) {
    $p['page'] = $page;
} else {
    $page = 1;
Example #10
0
 public static function addItems(&$itemArray, $items, $killTime, $inContainer = 0, $parentFlag = 0)
 {
     if (is_array($items)) {
         foreach ($items as $item) {
             $typeID = $item["typeID"];
             $priceLookup = Db::queryRow("select * from zz_item_price_lookup where typeID = :typeID and priceDate = date(:date)", array(":typeID" => $typeID, ":date" => $killTime), 3600);
             $item["price"] = $priceLookup["price"];
             $item["inContainer"] = $inContainer;
             if ($inContainer) {
                 $item["flag"] = $parentFlag;
             }
             if ($inContainer && strpos(Info::getItemName($typeID), "Blueprint")) {
                 $item["singleton"] = 2;
             }
             unset($item["_stringValue"]);
             $itemArray[] = $item;
             $subItems = isset($item["items"]) ? $item["items"] : null;
             unset($item["items"]);
             if ($subItems != null) {
                 self::addItems($itemArray, $subItems, $killTime, 1, $item["flag"]);
             }
         }
     }
 }
Example #11
0
            Db::execute('UPDATE zz_users_crest SET userID = :userID WHERE characterID = :characterID', array(':userID' => $userID, ':characterID' => $characterID));
            // Update the characterID on zz_users and set merged to 1
            Db::execute('UPDATE zz_users SET merged = 1 WHERE id = :userID', array(':userID' => $userID));
            Db::execute('UPDATE zz_users SET characterID = :characterID WHERE id = :userID', array(':userID' => $userID, ':characterID' => $characterID));
            // Set the login session headers and whatnot
            $crestData = Db::queryRow('SELECT * FROM zz_users_crest WHERE characterID = :characterID', array(':characterID' => $characterID));
            $_SESSION['loggedin'] = $crestData['characterName'];
            // Redirect to /
            $app->redirect('/');
        } else {
            // The login failed, or the user didn't exist.. Either way, we don't give a f**k..
            // Randomly generate a password
            $password = md5(time() + $cookie_secret);
            // Insert no email address, null@null.com
            $email = '*****@*****.**';
            // Data from zz_user_crest
            $crestData = Db::queryRow('SELECT * FROM zz_users_crest WHERE characterID = :characterID', array(':characterID' => $characterID));
            // Insert the new user to zz_users
            Db::execute('INSERT INTO zz_users (username, password, email, characterID, merged) VALUES (:username, :password, :email, :characterID, :merged)', array(':username' => $crestData['characterName'], ':password' => $password, ':email' => $email, ':characterID' => $crestData['characterID'], ':merged' => 1));
            // Set the userID in zz_users_crest
            $userID = Db::queryField('SELECT id FROM zz_users WHERE username = :username', 'id', array(':username' => $crestData['characterName']));
            Db::execute('UPDATE zz_users_crest SET userID = :userID WHERE characterID = :characterID', array(':userID' => $userID, ':characterID' => $characterID));
            // Set the session headers and whatnot
            $_SESSION['loggedin'] = $crestData['characterName'];
            // Redirect to /
            $app->redirect('/');
        }
    }
} elseif ($exists == 0 || $exists == null) {
    $app->render('merge.html', array('characterID' => $characterID, 'randomString' => $randomString));
}
Example #12
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 #13
0
 /**
  * @param $userID
  * @return array
  */
 public function get($userID)
 {
     return $this->db->queryRow("SELECT * FROM users WHERE userID = :userID", array(":userID" => $userID));
 }
Example #14
0
 /**
  * @param string $type
  * @param string $column
  * @param array $data
  * @param integer $id
  * @param array $parameters
  * @return array
  */
 private static function getSummary($type, $column, &$data, $id, $parameters = array())
 {
     $key = "summary:{$type}:{$column}:{$id}:" . json_encode($parameters);
     $mc = Cache::get($key);
     if ($mc) {
         return $mc;
     }
     $rank = Db::queryRow("select * from zz_ranks where type = :type and typeID = :id", array(":type" => $type, ":id" => $id), 300);
     $recentRank = Db::queryField("select overallRank from zz_ranks_recent where type = :type and typeID = :id", "overallRank", array(":type" => $type, ":id" => $id), 300);
     $idCount = 0;
     foreach ($parameters as $key => $value) {
         if (Util::endsWith($key, "ID")) {
             $idCount++;
         }
     }
     if (false) {
         //isset($parameters["solo"]) || $idCount >= 2) {
         $rank = $recentRank = array();
         $tables = array();
         $whereClauses = array();
         if (!isset($parameters["kills"]) && !isset($parameters["losses"])) {
             $parameters["mixed"] = true;
         }
         Filters::buildFilters($tables, $whereClauses, $whereClauses, $parameters, true);
         $whereStatement = implode(" and ", $whereClauses);
         $query = "select groupID, sum(if(isVictim, 0, 1)) destroyed, sum(if(isVictim, 0, total_price)) iskDestroyed, sum(if(isVictim, 0, points)) pointsDestroyed, sum(if(isVictim, 1, 0)) lost, sum(if(isVictim, total_price, 0)) iskLost, sum(if(isVictim, points, 0)) pointsLost from (select vGroupID groupID, isVictim, total_price, points from zz_participants p where {$whereStatement} group by killID) as foo group by groupID";
         $stats = Db::query($query);
     } else {
         if ($type == "system" || $type == "region") {
             $stats = Db::query("select groupID, lost destroyed, 0 lost, pointsLost pointsDestroyed, 0 pointsLost, iskLost iskDestroyed, 0 iskLost from zz_stats where type='{$type}' and typeID = {$id}", array(":id" => $id), 300);
         } else {
             $stats = Db::query("select groupID, destroyed, lost, pointsDestroyed, pointsLost, iskDestroyed, iskLost from zz_stats where type='{$type}' and typeID = :id", array(":id" => $id), 0);
         }
     }
     $infoStats = array();
     $data["shipsDestroyed"] = 0;
     $data["shipsLost"] = 0;
     $data["pointsDestroyed"] = 0;
     $data["pointsLost"] = 0;
     $data["iskDestroyed"] = 0;
     $data["iskLost"] = 0;
     foreach ($stats as $stat) {
         $infoStat = Info::addInfo($stat);
         if ($infoStat["groupID"] == 0) {
             $infoStat["groupName"] = "Unknown";
         }
         $infoStats[$infoStat["groupName"]] = $infoStat;
         $data["shipsDestroyed"] += $infoStat["destroyed"];
         $data["shipsLost"] += $infoStat["lost"];
         $data["iskDestroyed"] += $infoStat["iskDestroyed"];
         $data["iskLost"] += $infoStat["iskLost"];
         $data["pointsDestroyed"] += $infoStat["pointsDestroyed"];
         $data["pointsLost"] += $infoStat["pointsLost"];
     }
     unset($stats);
     ksort($infoStats);
     $data["stats"] = $infoStats;
     if ($rank != null && $recentRank != null) {
         $rank["recentRank"] = $recentRank;
     }
     if ($rank != null) {
         $data["ranks"] = $rank;
     }
     Cache::set($key, $data, 300);
     return $data;
 }
Example #15
0
 /**
  * [commentID description]
  * @param  int $id
  * @return int
  */
 public static function commentID($id)
 {
     // Find the old killID or EVE-KILL ID
     $checkID = $id;
     if ($checkID < 0) {
         $checkID = -1 * $checkID;
     }
     $okID = Db::queryRow("SELECT mKillID, killID, eveKillID FROM zz_manual_mails WHERE (mKillID = :mKillID OR killID = :killID)", array(":mKillID" => $checkID, ":killID" => $checkID));
     if (isset($okID["eveKillID"])) {
         $commentID = $okID["eveKillID"];
     } elseif (isset($okID["mKillID"])) {
         $commentID = $okID["mKillID"];
     } elseif (isset($okID["killID"])) {
         $commentID = $okID["killID"];
     } else {
         $commentID = $id;
     }
     return $commentID;
 }
Example #16
0
            }
        }
        $corpStatus = Db::queryRow('select adfreeUntil, banner, alias from zz_subdomains where subdomain = :subdomain', array(':subdomain' => $subdomain), 0);
        $domainChar['adfreeUntil'] = @$corpStatus['adfreeUntil'];
        $domainChar['banner'] = @$corpStatus['banner'];
        $domainChar['alias'] = @$corpStatus['alias'];
        $corps[] = $domainChar;
    }
    if (@$domainChar['isExecutorCEO']) {
        $subdomain = modifyTicker($domainChar['alliTicker']) . ".{$baseAddr}";
        if (isset($bannerUpdates[$subdomain])) {
            $banner = $bannerUpdates[$subdomain];
            Db::execute('insert into zz_subdomains (subdomain, banner) values (:subdomain, :banner) on duplicate key update banner = :banner', array(':subdomain' => $subdomain, ':banner' => $banner));
            $error = "Banner updated for {$subdomain}, please wait 2 minutes for the change to take effect.";
        }
        $status = Db::queryRow('select adfreeUntil, banner from zz_subdomains where subdomain = :subdomain', array(':subdomain' => $subdomain), 0);
        $domainChar['adfreeUntil'] = @$status['adfreeUntil'];
        $domainChar['banner'] = @$status['banner'];
        $allis[] = $domainChar;
    }
    $showDisqus = Util::getPost('showDisqus');
    if ($showDisqus) {
        UserConfig::set('showDisqus', $showDisqus == 'true');
        $error = 'Disqus setting updated to ' . ($showDisqus ? ' display.' : ' not display.') . ' The next page load will reflect the change.';
    }
}
$data['domainCorps'] = $corps;
$data['domainAllis'] = $allis;
$data['domainChars'] = $domainChars;
$data['showDisqus'] = UserConfig::get('showDisqus', true);
$app->render('account.html', array('data' => $data, 'message' => $error, 'key' => $key, 'reqid' => $reqid));
Example #17
0
$extra["relatedtime"] = date("YmdH00", strtotime($killdata["info"]["killTime"]));
$extra["fittingwheel"] = eftarray(md5($id), $killdata["items"], $killdata["victim"]["characterID"]);
$extra["involvedships"] = involvedships($killdata["involved"]);
$extra["involvedshipscount"] = count($extra["involvedships"]);
$extra["totalprice"] = usdeurgbp($killdata["info"]["total_price"]);
$extra["destroyedprice"] = usdeurgbp($extra["lostisk"]);
$extra["droppedprice"] = usdeurgbp($extra["droppedisk"]);
$extra["fittedprice"] = usdeurgbp($extra["fittedisk"]);
$extra["efttext"] = Fitting::EFT($extra["fittingwheel"]);
$extra["dnatext"] = Fitting::DNA($killdata["items"], $killdata["info"]["shipTypeID"]);
$extra["edkrawmail"] = Kills::getRawMail($id);
$extra["zkbrawmail"] = Kills::getRawMail($id, array(), false);
$extra["reports"] = Db::queryField("SELECT count(*) as cnt FROM zz_tickets WHERE killID = :killid", "cnt", array(":killid" => $id), 0);
$extra["slotCounts"] = Info::getSlotCounts($killdata["victim"]["shipTypeID"]);
$extra["commentID"] = Info::commentID($id);
$extra["crest"] = Db::queryRow("select killID, hash from zz_crest_killmail where killID = :killID and processed = 1", array(":killID" => $id), 300);
$systemID = $killdata["info"]["solarSystemID"];
$data = Info::getWormholeSystemInfo($systemID);
$extra["wormhole"] = $data;
$url = "https://" . $_SERVER["SERVER_NAME"] . "/detail/{$id}/";
$app->render("detail.html", array("pageview" => $pageview, "killdata" => $killdata, "extra" => $extra, "message" => $message, "flags" => Info::$effectToSlot, "topDamage" => $topDamage, "finalBlow" => $finalBlow, "url" => $url));
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 #18
0
<?php

$message = array();
$info = User::getUserInfo();
$ticket = Db::queryRow('SELECT * FROM zz_tickets WHERE id = :id', array(':id' => $id), 0);
if ($ticket == null or sizeof($ticket) == 0) {
    $message = array('status' => 'error', 'message' => 'Ticket does not exist.');
} elseif ($ticket['status'] == 0) {
    $message = array('status' => 'error', 'message' => 'Ticket has been closed, you cannot post, only view it');
} elseif ($ticket['userid'] != User::getUserID() && @$info['moderator'] == 0 && @$info['admin'] == 0) {
    $app->notFound();
}
if ($_POST) {
    $reply = Util::getPost('reply');
    if ($reply && $ticket['status'] != 0) {
        $name = $info['username'];
        $moderator = @$info['moderator'] == true;
        $check = Db::query('SELECT * FROM zz_tickets_replies WHERE reply = :reply AND userid = :userid AND belongsTo = :id', array(':reply' => $reply, ':userid' => User::getUserID(), ':id' => User::getUserID()), 0);
        if (!$check) {
            Db::execute('INSERT INTO zz_tickets_replies (userid, belongsTo, name, reply, moderator) VALUES (:userid, :belongsTo, :name, :reply, :moderator)', array(':userid' => User::getUserID(), ':belongsTo' => $id, ':name' => $name, ':reply' => $reply, ':moderator' => $moderator));
            global $baseAddr;
            if (!$moderator) {
                Log::irc("|g|Ticket response from {$name}|n|: https://{$baseAddr}/moderator/tickets/{$id}/");
            }
            $app->redirect("/tickets/view/{$id}/");
            exit;
        }
    } else {
        $message = array('status' => 'error', 'message' => 'No...');
    }
}
Example #19
0
 public static function parseKills()
 {
     if (Util::isMaintenanceMode()) {
         return;
     }
     $timer = new Timer();
     $maxTime = 65 * 1000;
     Db::execute("set session wait_timeout = 120000");
     Db::execute("create temporary table if not exists zz_participants_temporary select * from zz_participants where 1 = 0");
     $numKills = 0;
     while ($timer->stop() < $maxTime) {
         if (Util::isMaintenanceMode()) {
             self::removeTempTables();
             return;
         }
         Db::execute("delete from zz_participants_temporary");
         //Log::log("Fetching kills for processing...");
         $result = Db::query("select * from zz_killmails where processed = 0 order by killID desc limit 100", array(), 0);
         if (sizeof($result) == 0) {
             $currentSecond = (int) date("s");
             $sleepTime = max(1, 15 - $currentSecond % 15);
             sleep($sleepTime);
             continue;
         }
         //Log::log("Processing fetched kills...");
         $processedKills = array();
         $cleanupKills = array();
         foreach ($result as $row) {
             $numKills++;
             $kill = json_decode($row['kill_json'], true);
             if (!isset($kill["killID"])) {
                 Log::log("Problem with kill " . $row["killID"]);
                 Db::execute("update zz_killmails set processed = 2 where killid = :killid", array(":killid" => $row["killID"]));
                 continue;
             }
             $killID = $kill["killID"];
             Db::execute("insert ignore into zz_killid values(:killID, 0)", array(":killID" => $killID));
             // Cleanup if we're reparsing
             $cleanupKills[] = $killID;
             // Do some validation on the kill
             if (!self::validKill($kill)) {
                 Db::execute("update zz_killmails set processed = 3 where killid = :killid", array(":killid" => $row["killID"]));
                 continue;
             }
             $totalCost = 0;
             $itemInsertOrder = 0;
             $totalCost += self::processItems($kill, $killID, $kill["items"], $itemInsertOrder);
             $totalCost += self::processVictim($kill, $killID, $kill["victim"], false);
             foreach ($kill["attackers"] as $attacker) {
                 self::processAttacker($kill, $killID, $attacker, $kill["victim"]["shipTypeID"], $totalCost);
             }
             $points = Points::calculatePoints($killID, true);
             Db::execute("update zz_participants_temporary set points = :points, number_involved = :numI, total_price = :tp where killID = :killID", array(":killID" => $killID, ":points" => $points, ":numI" => sizeof($kill["attackers"]), ":tp" => $totalCost));
             $processedKills[] = $killID;
         }
         if (sizeof($cleanupKills)) {
             Db::execute("delete from zz_participants where killID in (" . implode(",", $cleanupKills) . ")");
         }
         Db::execute("insert into zz_participants select * from zz_participants_temporary");
         if (sizeof($processedKills)) {
             Db::execute("update zz_killmails set processed = 1 where killID in (" . implode(",", $processedKills) . ")");
         }
         foreach ($processedKills as $killID) {
             Stats::calcStats($killID, true);
             // Add points and total value to the json stored in the database
             $raw = Db::queryField("select kill_json from zz_killmails where killID = :killID", "kill_json", array(":killID" => $killID), 0);
             $json = json_decode($raw, true);
             unset($json["_stringValue"]);
             unset($json["zkb"]);
             $stuff = Db::queryRow("select * from zz_participants where killID = :killID and isVictim = 1", array(":killID" => $killID), 0);
             if ($stuff != null) {
                 $zkb = array();
                 $zkb["totalValue"] = $stuff["total_price"];
                 $zkb["points"] = $stuff["points"];
                 $json["zkb"] = $zkb;
             }
             $raw = json_encode($json);
             Db::execute("update zz_killmails set kill_json = :raw where killID = :killID", array(":killID" => $killID, ":raw" => $raw));
         }
     }
     if ($numKills > 0) {
         Log::log("Processed {$numKills} kills");
     }
     self::removeTempTables();
 }