Exemple #1
0
 /**
  * @param $userID
  * @param $serverID
  * @return int|string
  */
 public function get($userID, $serverID)
 {
     foreach ($this->config->get("admins", "permissions") as $adminID) {
         if ($adminID == $userID) {
             return 2;
         }
     }
     return $this->db->queryField("SELECT permission FROM permissions WHERE userID = :userID AND serverID = :serverID", "permission", [":userID" => $userID, ":serverID" => $serverID]);
 }
Exemple #2
0
 protected static function doPopulatePrice($typeID, $date)
 {
     global $redis;
     $todaysLookup = 'CREST-Market:' . date('Ymd');
     $todaysLookupTypeID = $todaysLookup . ":{$typeID}";
     $isDone = $redis->get($todaysLookupTypeID) == 'true';
     if ($typeID != 2233 && $isDone) {
         return;
     }
     static::doPopulateRareItemPrices($todaysLookup);
     // Populate rare items and today's lookup and do some cleanup
     if ($typeID == 2233) {
         $gantry = self::getItemPrice(3962, $date, true);
         $nodes = self::getItemPrice(2867, $date, true);
         $modules = self::getItemPrice(2871, $date, true);
         $mainframes = self::getItemPrice(2876, $date, true);
         $cores = self::getItemPrice(2872, $date, true);
         $total = $gantry + ($nodes + $modules + $mainframes + $cores) * 8;
         Db::execute('replace into zz_item_price_lookup (typeID, priceDate, lowPrice, avgPrice, highPrice) values (:typeID, :date, :low, :avg, :high)', array(':typeID' => $typeID, ':date' => $date, ':low' => $total, ':avg' => $total, ':high' => $total));
         $redis->setex($todaysLookupTypeID, 86400, 'true');
         return $total;
     }
     $url = "https://public-crest.eveonline.com/market/10000002/types/{$typeID}/history/";
     $raw = Util::getData($url, 0);
     $json = json_decode($raw, true);
     if (isset($json['items'])) {
         foreach ($json['items'] as $row) {
             $hasRow = Db::queryField('select count(1) count from zz_item_price_lookup where typeID = :typeID and priceDate = :date', 'count', array(':typeID' => $typeID, ':date' => $row['date']));
             if ($hasRow == 0) {
                 Db::execute('insert ignore into zz_item_price_lookup (typeID, priceDate, lowPrice, avgPrice, highPrice) values (:typeID, :date, :low, :avg, :high)', array(':typeID' => $typeID, ':date' => $row['date'], ':low' => $row['lowPrice'], ':avg' => $row['avgPrice'], ':high' => $row['highPrice']));
             }
         }
     }
     $redis->setex($todaysLookupTypeID, 86400, 'true');
 }
Exemple #3
0
function irc_log($nick, $uhost, $command, $params)
{
    $id = Db::queryField("SELECT id FROM zz_irc_access WHERE name = :nick AND host = :uhost", "id", array(":nick" => $nick, ":uhost" => $uhost));
    if ($id == null) {
        $id = 0;
    }
    Db::execute("INSERT INTO zz_irc_log (id, nick, command, parameters) VALUES (:id, :nick, :command, :params)", array(":nick" => $nick, ":id" => $id, ":command" => $command, ":params" => implode(" ", $params)));
}
Exemple #4
0
 /**
  * @static
  * @param	$typeID int
  * @return null
  */
 protected static function getItemBasePrice($typeID)
 {
     // Market failed, faction pricing failed, do we have a basePrice in the database?
     $price = Db::queryField("select basePrice from ccp_invTypes where typeID = :typeID", "basePrice", array(":typeID" => $typeID));
     self::storeItemPrice($typeID, $price);
     if ($price != null) {
         return $price;
     }
 }
Exemple #5
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}");
     }
 }
Exemple #6
0
 public static function retrieve($locker, $default = null)
 {
     if (!isset($locker) || $locker === null) {
         return $default;
     }
     $contents = Db::queryField("select contents from zz_storage where locker = :locker", "contents", array(":locker" => $locker), 1);
     if ($contents === null) {
         return $default;
     }
     return $contents;
 }
 /**
  * @param string $plainTextPassword
  */
 public static function checkPassword($plainTextPassword, $storedPassword = NULL)
 {
     if ($plainTextPassword && $storedPassword) {
         return self::pwCheck($plainTextPassword, $storedPassword);
     } else {
         $userID = user::getUserID();
         if ($userID) {
             $storedPw = Db::queryField("SELECT password FROM zz_users WHERE id = :userID", "password", array(":userID" => $userID), 0);
             return self::pwCheck($plainTextPassword, $storedPw);
         }
     }
 }
Exemple #8
0
 public static function getSubdomainParameters($serverName)
 {
     global $app, $twig, $baseAddr, $fullAddr, $mdb;
     // Are we looking at an aliased subdomain?
     $alias = Db::queryField('select alias from zz_subdomains where subdomain = :serverName', 'alias', array(':serverName' => $serverName), 60);
     if ($alias) {
         header("Location: http://{$alias}");
         exit;
     }
     if ($serverName != $baseAddr && strlen(str_replace(".{$baseAddr}", '', $serverName)) > 5) {
         $serverName = Db::queryField('select subdomain from zz_subdomains where alias = :serverName', 'subdomain', array(':serverName' => $serverName));
         if (strlen($serverName) == 0) {
             header("Location: http://{$baseAddr}");
             exit;
         }
     }
     $adfree = Db::queryField('select count(*) count from zz_subdomains where adfreeUntil >= now() and subdomain = :serverName', 'count', array(':serverName' => $serverName));
     $board = str_replace(".{$baseAddr}", '', $serverName);
     $board = str_replace('_', ' ', $board);
     $board = preg_replace('/^dot\\./i', '.', $board);
     $board = preg_replace('/\\.dot$/i', '.', $board);
     try {
         if ($board == 'www') {
             $app->redirect($fullAddr, 302);
         }
     } catch (Exception $e) {
         return;
     }
     if ($board == $baseAddr) {
         return [];
     }
     $numDays = 7;
     $faction = null;
     //Db::queryRow("select * from ccp_zfactions where ticker = :board", array(":board" => $board), 3600);
     $alli = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'allianceID', 'ticker' => strtoupper($board)], ['memberCount' => -1]);
     $corp = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'corporationID', 'ticker' => strtoupper($board)], ['memberCount' => -1]);
     $columnName = null;
     $id = null;
     if ($faction) {
         $p = array('factionID' => (int) $faction['factionID']);
         $twig->addGlobal('statslink', '/faction/' . $faction['factionID'] . '/');
     } elseif ($alli) {
         $p = array('allianceID' => (int) $alli['id']);
         $twig->addGlobal('statslink', '/alliance/' . $alli['id'] . '/');
     } elseif ($corp) {
         $p = array('corporationID' => (int) $corp['id']);
         $twig->addGlobal('statslink', '/corporation/' . $corp['id'] . '/');
     } else {
         $p = array();
     }
     return $p;
 }
 public function execute($nick, $uhost, $channel, $command, $parameters, $nickAccessLevel)
 {
     $keyIDs = array();
     $entity = implode(" ", $parameters);
     if (sizeof($parameters) == 1 && (int) $parameters[0]) {
         $keyIDs[] = (int) $parameters[0];
     } else {
         // Perform a search
         $chars = array();
         $corps = array();
         $charResult = Db::query("select characterID from zz_characters where name = :s", array(":s" => $entity));
         foreach ($charResult as $char) {
             $chars[] = $char["characterID"];
         }
         foreach ($chars as $charID) {
             $corpID = Db::queryField("select corporationID from zz_participants where characterID = :c order by killID desc limit 1", "corporationID", array(":c" => $charID));
             if ($corpID !== null && $corpID > 0) {
                 $corps[] = $corpID;
             }
         }
         if (sizeof($chars)) {
             $keys = Db::query("select distinct keyID from zz_api_characters where isDirector = 'F' and characterID in (" . implode(",", $chars) . ")");
             foreach ($keys as $key) {
                 $keyIDs[] = $key["keyID"];
             }
         } else {
             $corpID = Db::queryField("select corporationID from zz_corporations where name = :s order by memberCount desc", "corporationID", array(":s" => $entity));
             if ($corpID !== null && $corpID > 0) {
                 $corps[] = $corpID;
             }
         }
         if (sizeof($corps)) {
             $keys = Db::query("select distinct keyID from zz_api_characters where isDirector = 'T' and corporationID in (" . implode(",", $corps) . ")");
             foreach ($keys as $key) {
                 $keyIDs[] = $key["keyID"];
             }
         }
     }
     if (sizeof($keyIDs) == 0) {
         irc_out("|r|Unable to locate any keys associated with {$entity} |n|");
     } else {
         $keyIDs = array_unique($keyIDs);
         sort($keyIDs);
         $key = sizeof($keyIDs) == 1 ? "keyID" : "keyIDs";
         $keys = implode(", ", $keyIDs);
         Db::execute("update zz_api set errorCode = 0, errorCount = 0, lastValidation = 0 where keyID in ({$keys})");
         if (sizeof($keyIDs)) {
             irc_out("Revalidating {$key}: {$keys}");
         }
     }
 }
Exemple #10
0
 public static function get($killID)
 {
     $kill = RedisCache::get("Kill{$killID}");
     if ($kill != null) {
         return $kill;
     }
     $kill = Db::queryField('select kill_json from zz_killmails where killID = :killID', 'kill_json', array(':killID' => $killID));
     if ($kill != '') {
         RedisCache::set("Kill{$killID}", $kill);
         return $kill;
     }
     return;
     // No such kill in database
 }
function applyBalances()
{
    global $walletCharacterID, $baseAddr, $mdb;
    $toBeApplied = Db::query('select * from zz_account_wallet where paymentApplied = 0', array(), 0);
    if ($toBeApplied == null) {
        $toBeApplied = [];
    }
    foreach ($toBeApplied as $row) {
        if ($row['ownerID2'] != $walletCharacterID) {
            continue;
        }
        $userID = null;
        $reason = $row['reason'];
        if (strpos($reason, ".{$baseAddr}") !== false) {
            global $adFreeMonthCost;
            $months = $row['amount'] / $adFreeMonthCost;
            $bonusMonths = floor($months / 6);
            $months += $bonusMonths;
            $subdomain = trim(str_replace('DESC: ', '', $reason));
            $subdomain = str_replace('http://', '', $subdomain);
            $subdomain = str_replace('https://', '', $subdomain);
            $subdomain = str_replace('/', '', $subdomain);
            $aff = Db::execute("insert into zz_subdomains (subdomain, adfreeUntil) values (:subdomain, date_add(now(), interval {$months} month)) on duplicate key update adfreeUntil = date_add(if(adfreeUntil is null, now(), adfreeUntil), interval {$months} month)", array(':subdomain' => $subdomain));
            if ($aff) {
                Db::execute('update zz_account_wallet set paymentApplied = 1 where refID = :refID', array(':refID' => $row['refID']));
            }
            continue;
        }
        if ($reason) {
            $reason = trim(str_replace('DESC: ', '', $reason));
            $userID = Db::queryField('select id from zz_users where username = :reason', 'id', array(':reason' => $reason));
        }
        if ($userID == null) {
            $charID = $row['ownerID1'];
            $keyIDs = $mdb->find('apiCharacters', ['characterID' => (int) $charID]);
            foreach ($keyIDs as $keyIDRow) {
                if ($userID) {
                    continue;
                }
                $keyID = (int) $keyIDRow['keyID'];
                $userID = $mdb->findField('apis', 'userID', ['keyID' => $keyID]);
            }
        }
        if ($userID) {
            Db::execute('insert into zz_account_balance values (:userID, :amount) on duplicate key update balance = balance + :amount', array(':userID' => $userID, ':amount' => $row['amount']));
            Db::execute('update zz_account_wallet set paymentApplied = 1 where refID = :refID', array(':refID' => $row['refID']));
        }
    }
}
Exemple #12
0
 public static function getWars($id, $active = true, $combined = false)
 {
     if (!self::isAlliance($id)) {
         $alliID = Db::queryField('select allianceID from zz_corporations where corporationID = :id', 'allianceID', array(':id' => $id));
         if ($alliID != 0) {
             $id = $alliID;
         }
     }
     $active = $active ? '' : 'not';
     $aggressing = Db::query("select * from zz_wars where aggressor = :id and timeFinished is {$active} null", array(':id' => $id));
     $defending = Db::query("select * from zz_wars where defender = :id and timeFinished is {$active} null", array(':id' => $id));
     if ($combined) {
         return array_merge($aggressing, $defending);
     }
     return array('agr' => $aggressing, 'dfd' => $defending);
 }
 public static function registerUser($username, $password, $email)
 {
     if (strtolower($username) == "evekill" || strtolower($username) == "eve-kill") {
         return array("type" => "error", "message" => "Restrictd user name");
     }
     $check = Db::queryField("SELECT count(*) count FROM zz_users WHERE email = :email OR username = :username", "count", array(":email" => $email, ":username" => $username), 0);
     if ($check == 0) {
         $hashedpassword = Password::genPassword($password);
         Db::execute("INSERT INTO zz_users (username, password, email) VALUES (:username, :password, :email)", array(":username" => $username, ":password" => $hashedpassword, ":email" => $email));
         $subject = "zKillboard Registration";
         $message = "Thank you, {$username}, for registering at zKillboard.com";
         Email::send($email, $subject, $message);
         $message = "You have been registered, you should recieve a confirmation email in a moment, in the mean time you can click login and login!";
         return array("type" => "success", "message" => $message);
     } else {
         $message = "Username / email is already registered";
         return array("type" => "error", "message" => $message);
     }
 }
 public static function registerUser($username, $password, $email)
 {
     global $baseAddr;
     if (strtolower($username) == 'evekill' || strtolower($username) == 'eve-kill') {
         return array('type' => 'error', 'message' => 'Restrictd user name');
     }
     $check = Db::queryField('SELECT count(*) count FROM zz_users WHERE email = :email OR username = :username', 'count', array(':email' => $email, ':username' => $username), 0);
     if ($check == 0) {
         $hashedpassword = Password::genPassword($password);
         Db::execute('INSERT INTO zz_users (username, password, email) VALUES (:username, :password, :email)', array(':username' => $username, ':password' => $hashedpassword, ':email' => $email));
         $subject = "{$baseAddr} Registration";
         $message = "Thank you, {$username}, for registering at {$baseAddr}";
         //Email::send($email, $subject, $message);
         $message = 'You have been registered!';
         return array('type' => 'success', 'message' => $message);
     } else {
         $message = 'Username / email is already registered';
         return array('type' => 'error', 'message' => $message);
     }
 }
Exemple #15
0
 public static function getUserTrackerData()
 {
     $entities = array("character", "corporation", "alliance", "faction", "ship", "item", "system", "region");
     $entlist = array();
     foreach ($entities as $ent) {
         Db::execute("update zz_users_config set locker = 'tracker_{$ent}' where locker = '{$ent}'");
         $result = UserConfig::get("tracker_{$ent}");
         $part = array();
         if ($result != null) {
             foreach ($result as $row) {
                 switch ($ent) {
                     case "system":
                         $row["solarSystemID"] = $row["id"];
                         $row["solarSystemName"] = $row["name"];
                         $sunType = Db::queryField("SELECT sunTypeID FROM ccp_systems WHERE solarSystemID = :id", "sunTypeID", array(":id" => $row["id"]));
                         $row["sunTypeID"] = $sunType;
                         break;
                     case "item":
                         $row["typeID"] = $row["id"];
                         $row["shipName"] = $row["name"];
                         break;
                     case "ship":
                         $row["shipTypeID"] = $row["id"];
                         $row["{$ent}Name"] = $row["name"];
                         break;
                     default:
                         $row["{$ent}ID"] = $row["id"];
                         $row["{$ent}Name"] = $row["name"];
                         break;
                 }
                 $part[] = $row;
             }
         }
         $entlist[$ent] = $part;
     }
     return $entlist;
 }
 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");
 }
Exemple #17
0
 /**
  * Groups the kills together based on specified parameters
  * @static
  * @param array|null $kills
  * @param array $parameters
  * @return array
  */
 public static function getJSON($kills, $parameters)
 {
     if ($kills == null) {
         return array();
     }
     $retValue = array();
     foreach ($kills as $kill) {
         $killID = $kill["killID"];
         $jsonText = Db::queryField("select kill_json from zz_killmails where killID = :killID", "kill_json", array(":killID" => $killID));
         $json = json_decode($jsonText, true);
         if (array_key_exists("no-items", $parameters)) {
             unset($json["items"]);
         }
         if (array_key_exists("finalblow-only", $parameters)) {
             $involved = count($json["attackers"]);
             $json["zkb"]["involved"] = $involved;
             $data = $json["attackers"];
             unset($json["attackers"]);
             foreach ($data as $attacker) {
                 if ($attacker["finalBlow"] == "1") {
                     $json["attackers"][] = $attacker;
                 }
             }
         } elseif (array_key_exists("no-attackers", $parameters)) {
             $involved = count($json["attackers"]);
             $json["zkb"]["involved"] = $involved;
             unset($json["attackers"]);
         }
         $retValue[] = json_encode($json);
     }
     return $retValue;
 }
Exemple #18
0
    }
}
$corps = array();
$allis = array();
foreach ($domainChars as $domainChar) {
    if (@$domainChar['isCEO']) {
        $subdomain = modifyTicker($domainChar['corpTicker']) . ".{$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 = "{$subdomain} has been updated, please wait up to 2 minutes for the changes to take effect.";
        }
        if (isset($aliasUpdates[$subdomain])) {
            $alias = $aliasUpdates[$subdomain];
            // Make sure no one else has the alias
            $count = Db::queryField('select count(*) count from zz_subdomains where alias = :alias and subdomain != :subdomain', 'count', array(':subdomain' => $subdomain, ':alias' => $alias));
            if ($count == 0 || strlen($alias) == 0) {
                Db::execute('insert into zz_subdomains (subdomain, alias) values (:subdomain, :alias) on duplicate key update alias = :alias', array(':subdomain' => $subdomain, ':alias' => $alias));
                $error = "{$subdomain} has been updated, please wait up to 2 minutes for the changes to take effect.";
            } else {
                $error = "Sorry, someone has already taken the subdomain {$alias}";
            }
        }
        $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}";
<?php

/* zKillboard
 * Copyright (C) 2012-2013 EVE-KILL Team and EVSCO.
 *
 * 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/>.
 */
$ek = Db::queryField("SELECT mKillID FROM zz_manual_mails WHERE eveKillID = :id", "mKillID", array(":id" => $id), 0);
if ($ek > 0) {
    $app->redirect("/detail/-{$ek}/", 301);
} else {
    $app->notFound();
}
 */
if ($_POST) {
    $email = Util::getPost("email");
    if (isset($email)) {
        $exists = Db::queryField("SELECT username FROM zz_users WHERE email = :email", "username", array(":email" => $email), 0);
        if ($exists != NULL) {
            $date = date("Y-m-d H:i:s", strtotime("+24 hours"));
            $hash = sha1($date . $email);
            $alreadySent = Db::queryField("SELECT change_hash FROM zz_users WHERE email = :email", "change_hash", array(":email" => $email), 0);
            if ($alreadySent != NULL) {
                $message = "A request to reset the password for this email, has already been sent";
                $messagetype = "error";
                $app->render("forgotpassword.html", array("message" => $message, "messagetype" => $messagetype));
            } else {
                global $baseAddr;
                $username = Db::queryField("SELECT username FROM zz_users WHERE email = :email", "username", array(":email" => $email));
                $subject = "It seems you might have forgotten your password, so here is a link, that'll allow you to reset it: {$baseAddr}/changepassword/{$hash}/ ps, your username is: {$username}";
                $header = "Password change for {$email}";
                Db::execute("UPDATE zz_users SET change_hash = :hash, change_expiration = :expires WHERE email = :email", array(":hash" => $hash, ":expires" => $date, ":email" => $email));
                Email::send($email, $header, $subject);
                $message = "Sending password change email to: {$email}";
                $messagetype = "success";
                $app->render("forgotpassword.html", array("message" => $message, "messagetype" => $messagetype));
            }
        } else {
            $message = "No user with that email exists, try again";
            $messagetype = "error";
            $app->render("forgotpassword.html", array("message" => $message, "messagetype" => $messagetype));
        }
    } else {
        $message = "An error occured..";
Exemple #21
0
if ($password && $password2) {
    $message = '';
    $messagetype = '';
    $password = Util::getPost('password');
    $password2 = Util::getPost('password2');
    if (!$password || !$password2) {
        $message = 'Password missing, try again..';
        $messagetype = 'error';
    } elseif ($password != $password2) {
        $message = 'Password mismatch, try again..';
        $messagetype = 'error';
    } elseif ($password == $password2) {
        $password = Password::genPassword($password);
        Db::execute('UPDATE zz_users SET password = :password WHERE change_hash = :hash', array(':password' => $password, ':hash' => $hash));
        Db::execute('UPDATE zz_users SET change_hash = NULL, change_expiration = NULL WHERE change_hash = :hash', array(':hash' => $hash));
        $message = 'Password updated, click login, and login with your new password';
        $messagetype = 'success';
    }
    $app->render('changepassword.html', array('message' => $message, 'messagetype' => $messagetype));
} else {
    $date = date('Y-m-d H:i:s');
    $allowed = Db::queryField('SELECT change_expiration FROM zz_users WHERE change_hash = :hash', 'change_expiration', array(':hash' => $hash));
    if (isset($allowed) && $allowed > $date) {
        $foruser = Db::queryField('SELECT email FROM zz_users WHERE change_hash = :hash', 'email', array(':hash' => $hash));
        $app->render('changepassword.html', array('email' => $foruser, 'hash' => $hash));
    } else {
        $message = "Either your password change hash doesn't exist, or it has expired";
        $messagetype = 'error';
        $app->render('changepassword.html', array('message' => $message, 'messagetype' => $messagetype));
    }
}
Exemple #22
0
 public static function getBalance($userID)
 {
     $balance = Db::queryField('select balance from zz_account_balance where userID = :userID', 'balance', array(':userID' => $userID), 3600);
     if ($balance == null) {
         $balance = 0;
     }
     return $balance;
 }
Exemple #23
0
 $extra['shipprice'] = Price::getItemPrice($killdata['victim']['shipTypeID'], date('Ymd', strtotime($killdata['info']['dttm'])));
 $extra['lostisk'] = $extra['shipprice'] + destroyedIsk(md5($id), $killdata['items']);
 $extra['fittedisk'] = fittedIsk(md5($id), $killdata['items']);
 $extra['relatedtime'] = date('YmdH00', strtotime($killdata['info']['dttm']));
 $extra['fittingwheel'] = Detail::eftarray(md5($id), $killdata['items'], @$killdata['victim']['characterID']);
 $extra['involvedships'] = involvedships($killdata['involved']);
 $extra['involvedshipscount'] = count($extra['involvedships']);
 $extra['totalprice'] = usdeurgbp($killdata['info']['zkb']['totalValue']);
 $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['victim']['shipTypeID']);
 $extra['edkrawmail'] = 'deprecated - use CREST';
 $extra['zkbrawmail'] = 'deprecated - use CREST';
 $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'] = $id;
 $extra['crest'] = $mdb->findDoc('crestmails', ['killID' => $id, 'processed' => true]);
 $extra['prevKillID'] = $mdb->findField('killmails', 'killID', ['cacheTime' => 300, 'killID' => ['$lt' => $id]], ['killID' => -1]);
 $extra['nextKillID'] = $mdb->findField('killmails', 'killID', ['cacheTime' => 300, 'killID' => ['$gt' => $id]], ['killID' => 1]);
 $extra['warInfo'] = War::getKillIDWarInfo($id);
 //$extra["insertTime"] = Db::queryField("select insertTime from zz_killmails where killID = :killID", "insertTime", array(":killID" => $id), 300);
 $systemID = $killdata['info']['system']['solarSystemID'];
 $data = Info::getWormholeSystemInfo($systemID);
 $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) {
Exemple #24
0
 public static function is904Error()
 {
     $stop904 = Db::queryField("select count(*) count from zz_storage where locker = 'ApiStop904' and contents > now()", 'count', array(), 1);
     return $stop904 > 0;
 }
Exemple #25
0
 public static function eftarray($md5, $items, $victimID = 0)
 {
     $Cache = Cache::get($md5 . 'eftarray');
     if ($Cache) {
         return $Cache;
     }
     // EFT / Fitting Wheel
     $eftarray['high'] = array();
     // high
     $eftarray['mid'] = array();
     // mid
     $eftarray['low'] = array();
     // low
     $eftarray['rig'] = array();
     // rig
     $eftarray['drone'] = array();
     // drone
     $eftarray['sub'] = array();
     // sub
     $eftammo['high'] = array();
     // high ammo
     $eftammo['mid'] = array();
     // mid ammo
     foreach ($items as $itm) {
         if (!isset($itm['inContainer'])) {
             $itm['inContainer'] = 0;
         }
         if ($victimID >= 2100000000 && $victimID <= 2999999999.0) {
             $itm['flagName'] = Info::getGroupName(Info::getGroupID($itm['typeID']));
         } elseif (!isset($itm['flagName'])) {
             $itm['flagName'] = Info::getFlagName($itm['flag']);
         }
         if ($itm['flagName'] == 'Infantry Modules') {
             $itm['flagName'] = 'Mid Slots';
         }
         if ($itm['flagName'] == 'Infantry Weapons') {
             $itm['flagName'] = 'High Slots';
         }
         if ($itm['flagName'] == 'Infantry Equipment') {
             $itm['flagName'] = 'Low Slots';
         }
         if ($itm['flag'] == 89) {
             $slot = Db::queryField('select coalesce(valueInt, valueFloat) slot from ccp_dgmTypeAttributes where typeID = :typeID and attributeID = 331', 'slot', array(':typeID' => $itm['typeID']));
             if ($slot <= 5 && $slot >= 1) {
                 $itm['flagName'] = 'High Slots';
                 $itm['flag'] = 27 + ($slot - 1);
             } elseif ($slot > 5 && $slot <= 10) {
                 $itm['flagName'] = 'Low Slots';
                 $itm['flag'] = 11 + ($slot - 6);
             }
             $itm['fittable'] = 1;
         }
         if (!isset($itm['flag']) || $itm['flag'] == 0) {
             if ($itm['flagName'] == 'High Slots') {
                 $itm['flag'] = 27;
             }
             if ($itm['flagName'] == 'Mid Slots') {
                 $itm['flag'] = 19;
             }
             if ($itm['flagName'] == 'Low Slots') {
                 $itm['flag'] = 11;
             }
         }
         $key = $itm['typeName'] . '|' . $itm['flagName'];
         if (isset($itm['flagName'])) {
             if ($itm['fittable'] && $itm['inContainer'] == 0) {
                 // not ammo or whatever
                 $repeats = @$itm['quantityDropped'] + @$itm['quantityDestroyed'];
                 $i = 0;
                 while ($i < $repeats) {
                     if ($itm['flagName'] == 'High Slots') {
                         high:
                         if (isset($eftarray['high'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto high;
                         }
                         $eftarray['high'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Mid Slots') {
                         mid:
                         if (isset($eftarray['mid'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto mid;
                         }
                         $eftarray['mid'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Low Slots') {
                         low:
                         if (isset($eftarray['low'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto low;
                         }
                         $eftarray['low'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'Rigs') {
                         rigs:
                         if (isset($eftarray['rig'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto rigs;
                         }
                         $eftarray['rig'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     if ($itm['flagName'] == 'SubSystems') {
                         subs:
                         if (isset($eftarray['sub'][$itm['flag']])) {
                             $itm['flag'] = $itm['flag'] + 1;
                             goto subs;
                         }
                         $eftarray['sub'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID']);
                     }
                     ++$i;
                 }
             } else {
                 if ($itm['flagName'] == 'Drone Bay') {
                     $eftarray['drone'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'qty' => @$itm['quantityDropped'] + @$itm['quantityDestroyed']);
                 }
             }
         }
     }
     // Ammo shit
     foreach ($items as $itm) {
         if (!isset($itm['inContainer'])) {
             $itm['inContainer'] = 0;
         }
         if ($itm['inContainer'] == 0 && !$itm['fittable'] && isset($itm['flagName'])) {
             // possibly ammo
             if ($itm['flagName'] == 'High Slots') {
                 // high slot ammo
                 $eftarray['high'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
             if ($itm['flagName'] == 'Mid Slots') {
                 // mid slot ammo
                 $eftarray['mid'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
             if ($itm['flagName'] == 'Low Slots') {
                 // mid slot ammo
                 $eftarray['low'][$itm['flag']][] = array('typeName' => $itm['typeName'], 'typeID' => $itm['typeID'], 'charge' => true);
             }
         }
     }
     foreach ($eftarray as $key => $value) {
         if (sizeof($value)) {
             asort($value);
             $eftarray[$key] = $value;
         } else {
             unset($eftarray[$key]);
         }
     }
     Cache::set($md5 . 'eftarray', $eftarray);
     return $eftarray;
 }
$count = 0;
$killIDs = Db::query("select killID from zz_killid where writ = 0", array(), 0);
foreach ($killIDs as $row) {
    $count++;
    $killID = $row["killID"];
    $id = $killID;
    $botDir = abs($id % 1000);
    while (strlen("{$botDir}") < 3) {
        $botDir = "0" . $botDir;
    }
    $id = (int) $id / 1000;
    $midDir = abs($id % 1000);
    while (strlen("{$midDir}") < 3) {
        $midDir = "0" . $midDir;
    }
    $id = (int) $id / 1000;
    $topDir = $id % 1000;
    @mkdir("{$baseDir}/{$topDir}");
    @mkdir("{$baseDir}/{$topDir}/{$midDir}");
    $file = "{$baseDir}/{$topDir}/{$midDir}/{$killID}.txt.gz";
    //echo "$killID $file\n";
    $json = Db::queryField("select kill_json from zz_killmails where killID = :killID", "kill_json", array(":killID" => $killID), 0);
    $fp = gzopen($file, "w9");
    gzwrite($fp, $json);
    gzclose($fp);
    Db::execute("update zz_killid set writ = 1 where killID = :killID", array(":killID" => $killID));
    if ($count % 1000 == 0) {
        echo ".";
    }
}
echo "\n";
Exemple #27
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));
Exemple #28
0
<?php

/* zKillboard
 * Copyright (C) 2012-2013 EVE-KILL Team and EVSCO.
 *
 * 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/>.
 */
$jsonRaw = Db::queryField("select kill_json from zz_killmails where killID = :id", "kill_json", array(":id" => $id));
header("Content-Type: application/json");
$json = json_decode($jsonRaw, true);
header("Content-Type: text/plain");
print_r($json);
die;
Exemple #29
0
 public static function compareShips($a, $b)
 {
     $aSize = Db::queryField('select mass from ccp_invTypes where typeID = :typeID', 'mass', array(':typeID' => @$a['shipTypeID']));
     $bSize = Db::queryField('select mass from ccp_invTypes where typeID = :typeID', 'mass', array(':typeID' => @$b['shipTypeID']));
     return $aSize < $bSize;
 }
Exemple #30
0
<?php

$sID = $_GET['sID'];
$dttm = $_GET['dttm'];
$options = $_GET['options'];
$battleID = Db::queryField('select battleID from zz_battle_report where solarSystemID = :sID and dttm = :dttm and options = :options limit 1', 'battleID', array(':sID' => $sID, ':dttm' => $dttm, ':options' => $options), 0);
if ($battleID === null) {
    $battleID = Db::execute('insert into zz_battle_report (solarSystemID, dttm, options) values (:sID, :dttm, :options)', array(':sID' => $sID, ':dttm' => $dttm, ':options' => $options));
}
$battleID = Db::queryField('select battleID from zz_battle_report where solarSystemID = :sID and dttm = :dttm and options = :options limit 1', 'battleID', array(':sID' => $sID, ':dttm' => $dttm, ':options' => $options), 0);
$app->redirect("/br/{$battleID}/", 302);