function execute() { $results = Db::q(' SELECT `lpStore`.* , `invTypes`.`typeName`, `lpOffers`.*, ( SELECT linkid FROM graphMarket WHERE latch = 2 AND origid = 1 AND seq = 1 AND destid = `invTypes`.`marketGroupID` ) AS marketRoot FROM lpStore NATURAL JOIN lpOffers NATURAL JOIN invTypes WHERE `lpStore`.`corporationID` = :corpID ORDER BY `lpOffers`.`lpCost`, `lpOffers`.iskCost, `invTypes`.`typeName`', array(':corpID' => $this->corpID)); foreach ($results as &$result) { // $result['icon'] = EveIcon::getIcon($result['typeID']); } return $results; }
function performQuery() { $result = Db::q(' SELECT a.materialTypeID as typeID, b.typeName, a.quantity as runQty, a.quantity*:bpcRuns AS totQty FROM industryActivityMaterials a JOIN invTypes b on (a.materialTypeID = b.typeID) WHERE a.typeID=:typeID', array(':typeID' => $this->typeID, ':bpcRuns' => $this->qty)); return $result; }
function execute() { $result = Db::q(' SELECT a.corporationID, b.itemName AS corpName FROM lpStore a INNER JOIN invUniqueNames b ON (a.corporationID = b.itemID AND b.groupID = 2) WHERE b.itemName LIKE :query GROUP BY a.corporationID', array(':query' => $this->search)); return $result; }
function execute() { $result = Db::q(' SELECT `lpOffers`.*, `invTypes`.`typeName` FROM `lpOffers` NATURAL JOIN `lpStore` NATURAL JOIN `invTypes` WHERE `typeID` = :typeID GROUP BY `offerID`', array(':typeID' => $this->typeID)); return $result; }
function execute() { $result = Db::q(' SELECT s.*, u.`itemName` FROM `lpStore` s INNER JOIN `invUniqueNames` u ON (u.`itemID` = s.`corporationID`) WHERE `offerID` = :offerID ORDER BY `itemName` ASC', array(':offerID' => $this->offerID)); return $result; }
public function calc() { try { if ($this->offerDetails === null) { $this->offerDetails = Db::q(Sql::oDetails, array($this->offerID))[0]; } if (empty($this->offerDetails)) { throw Exception('No offer details available.'); } if ($this->reqDetails === null) { $this->reqDetails = Db::q(Sql::rDetails, array($this->offerID)); } if (strstr($this->offerDetails['typeName'], " Blueprint")) { # If this is a bpc, set the flag and run bpc function $this->bpc = true; $this->bpcCalc(); } else { # if this is not a blueprint, go ahead and set price via given known typeID try { $price = new Price(Emdr::get($this->offerDetails['typeID'])); $this->cached = true; $this->price = $price->{Prefs::get('marketOffer')}[0]; $this->totVolume = $price->{Prefs::get('marketOffer')}[1]; $this->timeDiff = (time() - $price->generatedAt) / 60 / 60; # time difference in hours } catch (Exception $e) { array_push($this->noCache, $this->offerDetails['typeName']); } } foreach ($this->reqDetails as &$reqItem) { try { $price = new Price(Emdr::get($reqItem['typeID'])); $reqItem['price'] = $price->{Prefs::get('marketReq')}[0]; $reqItem['totPrice'] = $reqItem['price'] * $reqItem['quantity']; } catch (Exception $e) { array_push($this->noCache, $reqItem['typeName']); } } # calculate total cost $this->totalCost = $this->offerDetails['iskCost']; foreach ($this->reqDetails as &$reqItem) { $this->totalCost += $reqItem['quantity'] * $reqItem['price']; } foreach ($this->manDetails as &$manItem) { $this->totalCost += $manItem['totQty'] * $manItem['price']; } # calculate profits / isk/lp $this->profit = $this->price * $this->offerDetails['quantity']; $this->margin = $this->profit - $this->totalCost; $this->lp2isk = $this->margin / $this->offerDetails['lpCost']; } catch (Exception $e) { die($e); } return $this; }
function execute() { $result = Db::q(' SELECT b.factionID, f.itemName AS factionName FROM `lpStore` a INNER JOIN crpNPCCorporations b ON (b.corporationID = a.corporationID) INNER JOIN invUniqueNames f ON (b.factionID = f.itemID) GROUP BY b.factionID ORDER BY b.factionID ASC'); return $result; }
private function fetch() { self::$short = mysql_escape_string(trim($_GET['upload'], "/")); $query = "SELECT * FROM `" . Config::$db_table . "` WHERE `short`='" . self::$short . "' LIMIT 1"; $result = Db::q($query); if ($row = mysql_fetch_assoc($result)) { self::$found = true; self::$name = $row['name']; self::$long = $row['long']; self::$type = $row['type']; self::$date = date("m/d/y", strtotime($row['ts'])); } }
function execute() { $container = array(); $result = Db::q(' SELECT a.typeID, a.quantity, b.typeName, a.offerID FROM lpOfferRequirements a NATURAL JOIN invTypes b NATURAL JOIN lpStore c WHERE c.corporationID = :corpID ORDER BY a.quantity ASC', array(':corpID' => $this->corpID)); # @todo: add icon path for items foreach ($result as $item) { $container[$item['offerID']][] = $item; } return $container; }
function execute() { $result = Db::q("\n SELECT a.`stationName`, a.`stationID`, b.`security`, b.`solarSystemID`, c.`regionName`,\n (\n SELECT seq \n FROM graphJumps\n WHERE latch = 2\n AND origid = :origin\n AND destid = b.`solarSystemID`\n ORDER BY seq DESC\n LIMIT 0,1\n ) AS jumps\n FROM `staStations` a \n INNER JOIN `mapSolarSystems` b ON (b.`solarSystemID` = a.`solarSystemID`)\n INNER JOIN `mapRegions` c ON (a.`regionID` = c.`regionID`)\n WHERE a.`corporationID` = :corpID\n ORDER BY a.`stationName` ASC", array(':corpID' => $this->corpID, ':origin' => $this->system)); return $result; }
public static function listTransactions($start_ts, $end_ts) { return Db::q(' SELECT id, remoteBankCode, remoteAccountNumber, remoteIban, remoteBic, remoteName, value_value, purpose, date FROM `transaction` '); }
public function save() { $params = array('keys' => array('`short`', '`long`', '`type`', '`name`'), 'values' => array(mysql_escape_string($this->short), mysql_escape_string($this->long), $this->type, $this->name)); $query = "INSERT INTO `" . Config::$db_table . "` (" . implode(',', $params['keys']) . ") VALUES ('" . implode("','", $params['values']) . "')"; return Db::q($query); }
function execute() { $result = Db::q("\n SELECT solarSystemID, solarSystemName\n FROM mapSolarSystems\n WHERE solarSystemName LIKE :query\n ORDER BY solarSystemName ASC\n LIMIT 0,30", array(':query' => $this->search)); return $result; }
} if (isset($_SESSION['playerid'])) { $thisPlayerID = $_SESSION['playerid']; } else { $thisPlayerID = null; } /* ========================================== AJAX - Load game|level ========================================== */ if (Tools::isSubmit('getLevels')) { //Init variables $data = null; $html = null; $img = null; $position = null; //L'utente non ha effettuato l'accesso //Visualizza il messaggio if ($thisPlayerID == null) { print 1; exit; } $data = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'saves LEFT JOIN ' . _DB_PREFIX_ . 'maps ON g_saves.level = g_maps.mapIndex WHERE id_player = ' . $thisPlayerID . ''); if (!$data[0]) { print 1; exit; } print stripslashes(json_encode($data)); exit; }
function signIn($POSTdata) { //Init variables $unick = trim($POSTdata['playernick']); $upass = trim($POSTdata['playerpassword']); $umail = trim($POSTdata['playermail']); $data = array(); $output = array(); //Check password copy if ($upass != $POSTdata['playerpasswordcpy']) { print 1; exit; } $check = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'users WHERE playermail = "' . mysql_escape_string($umail) . '" LIMIT 1'); if (sizeof($check) >= 1) { print 2; die; } $error = array(); if (!Validate::isName($unick)) { $error[] = 'Invalid nickname'; } if (!Validate::isPasswd($upass)) { $error[] = 'Invalid password'; } if (!Validate::isEmail($umail)) { $error[] = 'Invalid email'; } //Validate if (sizeof($error)) { print 0; die; } /* ========================== 2° step : save data =========================== */ Db::q('INSERT INTO ' . _DB_PREFIX_ . 'users (playernick, playermail, playerpassword) VALUES("' . mysql_real_escape_string($unick) . '", "' . mysql_real_escape_string($umail) . '", "' . md5($upass) . '")'); $check = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'users WHERE playermail = "' . mysql_real_escape_string($umail) . '"'); if (!sizeof($check)) { print 0; die; } Db::q('INSERT INTO ' . _DB_PREFIX_ . 'points (id_player, points) VALUES("' . $check[0]['id'] . '", "0")'); //Initialize saves data Db::q('INSERT INTO ' . _DB_PREFIX_ . 'saves (id_player, points, level, health, inventary) VALUES("' . $check[0]['id'] . '", "0", "1", "100", 0)'); print 3; die; }
function execute() { $result = Db::q("\n SELECT a.typeID, b.typeName\n FROM lpOffers a \n INNER JOIN invTypes b ON (a.typeID = b.typeID) \n WHERE typeName LIKE :query\n GROUP BY typeID\n LIMIT 0,30", array(':query' => $this->search)); return $result; }
<?php include "../lib/sns.php"; SnS::init(); $db_table = Config::$db_table; $query = "CREATE TABLE IF NOT EXISTS `{$db_table}` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `type` tinyint(4) NOT NULL,\n `short` varchar(55) NOT NULL DEFAULT '',\n `long` varchar(255) NOT NULL DEFAULT '',\n `name` varchar(255) DEFAULT NULL,\n `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `short` (`short`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; try { Db::q($query); Response::redirect('complete.php'); } catch (Exception $e) { Response::redirect('error.php'); }
========================================== */ if (Tools::isSubmit('saveInventary')) { $inventary = $_POST['inventary']; $weapons = $_POST['weapons']; $level = $_POST['level']; $health = $_POST['health']; if (!$level || !$health) { die; } $already = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'saves WHERE id_player = ' . (int) $thisPlayerID . ' AND level = ' . (int) $level . ' LIMIT 1'); if (!sizeof($already)) { //Insert new save Db::q('INSERT INTO ' . _DB_PREFIX_ . 'saves (id_player, level, health, inventary, weapons) VALUES(' . (int) $thisPlayerID . ', ' . (int) $level . ', ' . (int) $health . ', "' . mysql_real_escape_string($inventary) . '", "' . mysql_real_escape_string($weapons) . '")'); print 1; die; } else { //Update save Db::q('UPDATE ' . _DB_PREFIX_ . 'saves SET inventary = "' . mysql_real_escape_string($inventary) . '", weapons = "' . mysql_real_escape_string($weapons) . '", health = ' . (int) $health . ' WHERE id_player = ' . (int) $thisPlayerID . ' AND level = ' . (int) $level . ' LIMIT 1'); print 2; die; } }
if (isset($_SESSION['playernick'])) { $thisPlayer = $_SESSION['playernick']; } else { $thisPlayer = null; } if (isset($_SESSION['playerid'])) { $thisPlayerID = $_SESSION['playerid']; } else { $thisPlayerID = null; } if (Tools::isSubmit('getAccount')) { $data = array(); $jsonData = array(); $output = 1; if ($thisPlayer != null && $thisPlayerID != null) { $data = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'users LEFT JOIN ' . _DB_PREFIX_ . 'points ON ' . _DB_PREFIX_ . 'points.id_player = ' . _DB_PREFIX_ . 'users.id LIMIT 1'); } else { print 0; exit; } $jsonData['email'] = $data[0]['playermail']; $jsonData['nick'] = $thisPlayer; $jsonData['signindate'] = $data[0]['date']; $jsonData['id'] = $data[0]['id']; $jsonData['spoints'] = $data[0]['points']; //Load picture if ($_SESSION['ltype'] === 'facebook') { $jsonData['imgsrc'] = 'http://graph.facebook.com/1542713425/picture'; } else { if (file_exists('images/phs/us_' . $thisPlayerID . '-big.png')) { $jsonData['imgsrc'] = 'serverSide/images/phs/us_' . $thisPlayerID . '-big.png';
} else { $thisPlayer = null; } /* ========================================== AJAX - GET RANKS ========================================== */ if (Tools::isSubmit('getRank')) { //Init variables $data = null; $html = null; $img = null; $position = null; //Get users points | info $data = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'points ORDER BY points DESC'); if ($data == NULL) { print '<div style="margin:15px; font-size:11px; color:white;">No data</div>'; exit; } //Format data $html .= '<table><tr style="background:white; color:black;"><td>Nickname</td><td>Points</td><td>Map</td><td>when</td></tr>'; foreach ($data as $key => $value) { if ($thisPlayer != null) { if ($value['playernick'] === $thisPlayer) { $position = $key + 1; $points = $value['points']; } } //Check photo if (file_exists('images/phs/us_' . $value['id'] . '-mini.png')) {
========================================== */ if (isset($_SESSION['playernick'])) { $thisPlayer = $_SESSION['playernick']; } else { $thisPlayer = null; } if (isset($_SESSION['playerid'])) { $thisPlayerID = $_SESSION['playerid']; } else { $thisPlayerID = null; } /* ========================================== Save points ========================================== */ if (Tools::isSubmit('savePoints')) { $points = (int) $_POST['points']; $name = $_POST['name']; $mapTitle = $_POST['mapTitle']; if ($points == null || $mapTitle == null) { die; } $thisMapTitle = Db::q('SELECT * FROM ' . _DB_PREFIX_ . 'maps WHERE mapIndex = "' . $mapTitle . '" LIMIT 1'); $thisMapTitle = $thisMapTitle[0]['name']; $date = date('Y-m-d H:i:s'); Db::q('INSERT INTO ' . _DB_PREFIX_ . 'points (points, mapTitle, id_player, date) VALUES(' . $points . ', "' . $thisMapTitle . '", "' . mysql_real_escape_string($name) . '", "' . $date . '")'); print 1; die; }
<?php require_once 'config.php'; $factionID = filter_input(INPUT_GET, 'factionID', FILTER_VALIDATE_INT); $tpl->factionName = Db::qColumn("SELECT `itemName` FROM `invUniqueNames` WHERE `itemID` = ?", array($factionID)); $tpl->corps = Db::q("\n SELECT a.corporationID, b.factionID, c.itemName AS corpName, d.itemName AS facName, count(*) AS num\n FROM `lpStore` a \n INNER JOIN crpNPCCorporations b ON (b.corporationID = a.corporationID) \n INNER JOIN invUniqueNames c ON (a.corporationID = c.itemID AND c.groupID = 2)\n INNER JOIN invUniqueNames d ON (b.factionID = d.itemID)\n WHERE b.factionID = ?\n GROUP BY a.corporationID \n ORDER BY c.itemName ASC", array($factionID)); $tpl->display('faction.html');
public function getRowWhere($row = 'id', $whereCl = '', $limit = 1) { if (empty($whereCl) or !is_string($whereCl) or !self::isUnsignedInt($limit) or !self::isDbColName($row)) { return false; } $limit >= 1 ? $res = $this->q('SELECT ' . $row . ' FROM ' . $this->table . ' ' . $whereCl . ' LIMIT ' . $limit . '') : ($res = Db::q('SELECT ' . $row . ' FROM ' . $this->table . ' ' . $whereCl . '')); //$res[0...][$key] return $res; }
<?php require_once 'config.php'; # @todo migrate SQL to Query subclass $typeID = filter_input(INPUT_GET, 'typeID', FILTER_VALIDATE_INT); $tpl->typeName = Db::qColumn("SELECT `typeName` FROM `invTypes` WHERE `typeID` = ?", array($typeID)); $offers = Db::q("\n SELECT offerID\n FROM lpOffers\n WHERE typeID LIKE :typeID", array(':typeID' => $typeID)); // If there is only one offer, no need to list it, go directly to offer page if (count($offers) === 1) { header('Location: ' . BASE_PATH . 'offer/' . $offers[0]['offerID'] . '/'); die; } foreach ($offers as $id => $data) { $offers[$id] = (new LpOffer($data['offerID']))->calc(); } $tpl->offers = $offers; $tpl->display('item.html');
if (isset($_SESSION['playerid'])) { $thisPlayerID = $_SESSION['playerid']; } else { $thisPlayerID = null; } $gmq = get_magic_quotes_gpc(); $test = false; if ($test) { $_POST['mapIndex'] = 1; } if (Tools::isSubmit('requestMap') || $test) { $mapIndex = $_POST['mapIndex'] == null ? 1 : $_POST['mapIndex']; $jsonData = array(); $output = array(); //Get map data $data = Db::q('SELECT data FROM ' . _DB_PREFIX_ . 'maps WHERE mapIndex = "' . $mapIndex . '" LIMIT 1'); if (sizeof($data[0]['data'])) { $val = $data[0]['data']; //removePar $val = str_replace('(', '', $val); $val = str_replace(')', '', $val); $val = str_replace('printBlock', '', $val); $val = str_replace(' ', '', $val); //Get single data string $mDataArray = preg_split('/\\s*?\\;\\s*?/', $val, -1, PREG_SPLIT_NO_EMPTY); foreach ($mDataArray as $k => $val) { if (empty($val)) { continue; } $mValArray = preg_split("/[,]+/", str_replace('\'', '', $val)); $output[$k] = array();