public function __construct($id) { $myDB = new DBFactory(); $this->sql = $myDB->getMysqlConnexionWithPDO(); $this->classes = $this->getClasses(); $this->id = $id; }
function getRole($role) { $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT id, login, role FROM users WHERE role = :role AND login != :me"); $query->execute(array('role' => $role, 'me' => $_SESSION['user'])); return $query->fetchAll(); }
function getCharacters() { $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT chars.*, class.name AS className, spec1.role_name AS role1, spec2.role_name AS role2 FROM chars, specs AS spec1, specs AS spec2, class WHERE chars.spec1 = spec1.id AND chars.spec2 = spec2.id AND spec1.class_id = class.id"); $query->execute(); return $query->fetchAll(); }
/** * Wrapper to do all to work. Updates the items table based on the cached or live data. */ function ec_update_value($item_id) { $query = DBFactory::getDBQuery(); // Don't try if we can't open URLs with fopen. // Do to! // if (1 != function_exists('curl_init')) { // return; // } // Don't try if the item id isn't an integer. if (!is_numeric($item_id)) { return; } // Verify we have a sync table to use. verify_sync_table(); // The destroyed items etc feed in the -internal- killboard item ID. // EVE Central needs the external ID if we have it. $query->execute("SELECT typeID FROM kb3_invtypes WHERE typeID={$item_id}"); $data = $query->getRow(); $e_item_id = $data['typeID']; // Don't try if the item id isn't an integer or it's 0. if (!is_numeric($e_item_id) or 0 == $e_item_id) { return; } file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "Request for {$item_id} -> {$e_item_id}\n", FILE_APPEND); $value = ec_get_value($e_item_id); if (-99 != $value) { $query->execute("update kb3_item_price set price='{$value}' WHERE typeID={$item_id}"); return true; } else { file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "Failed to find it.\n", FILE_APPEND); } return false; }
public static function getInstance() { if (!DBFactory::$_instance instanceof MysqliDb) { DBFactory::$_instance = new MysqliDB(); } return DBFactory::$_instance; }
/** * 取得数据库信息 * * @access public * @return mixed */ public static function getDbInfo() { if (self::$dbinfo == null) { self::$dbinfo = Tiny::app()->db; } return self::$dbinfo; }
private function updateChars() { if (empty($this->chars)) { return $this->chars; } foreach ($this->chars as $char) { // check if chars eveid exists in kb $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $char['Name'] . '"'; $qry = DBFactory::getDBQuery(); $qry->execute($sql); if ($qry->recordCount() != 0) { // pilot is in kb db, check he has his char id $row = $qry->getRow(); $pilot_id = $row['plt_id']; $pilot_external_id = $row['plt_externalid']; if ($pilot_external_id == 0 && $pilot_id != 0) { // update DB with ID $qry->execute("UPDATE kb3_pilots SET plt_externalid = " . intval($char['charID']) . "\n WHERE plt_id = " . $pilot_id); } } else { // pilot is not in DB // Set Corp $pilotscorp = Corporation::lookup($char['corpName']); // Check Corp was set, if not, add the Corp if (!$pilotscorp->getID()) { $ialliance = Alliance::add('None'); $pilotscorp = Corporation::add($char['corpName'], $ialliance, gmdate("Y-m-d H:i:s")); } Pilot::add($char['Name'], $pilotscorp, gmdate("Y-m-d H:i:s"), intval($char['charID'])); } } return; }
function update014() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "014") { if (is_null(config::get('014updatestatus'))) { config::set('014updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('014updatestatus') < 1) { // Add killmail summary. time, hash, trust. $sql = 'CREATE TABLE IF NOT EXISTS `kb3_mails` ( `kll_id` int(11) NOT NULL auto_increment, `kll_timestamp` datetime NOT NULL default "0000-00-00 00:00:00", `kll_external_id` int(8) default NULL, `kll_hash` BINARY(16) NOT NULL, `kll_trust` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (`kll_id`), UNIQUE KEY `external_id` (`kll_external_id`), UNIQUE KEY `time_hash` (`kll_timestamp`,`kll_hash`) ) Engine=InnoDB'; $qry->execute($sql); } killCache(); config::set("DBUpdate", "014"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '014' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '014'"); config::del("014updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 014 completed."); $smarty->display('update.tpl'); die; } }
public function getLanguage() { if (!$this->language instanceof Language && is_numeric($this->language)) { $this->language = DBFactory::get('languages')->get($this->language); } return $this->language; }
/** * @return Database Handler */ public static function getDBHandler() { global $db_i; $dbenv = $db_i[$db_i['env']]; switch ($dbenv['dbdriver']) { case DB_PDO_MYSQL: if ( !isset(self::$dbh) ) { $ret = new DBPdoMysql($dbenv); self::$dbh = $ret->getDBHandler(); return self::$dbh; } return self::$dbh; case DB_PDO_SQLITE: if ( !isset(self::$dbh) ) { $ret = new DBPdoSqlite($dbenv); self::$dbh = $ret->getDBHandler(); return self::$dbh; } return self::$dbh; } return null; }
/** * @package EDK */ function update016() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "016") { $qry = DBFactory::getDBQuery(true); $sql = "ALTER TABLE `kb3_mails` ADD `kll_modified_time` DATETIME NOT NULL "; $qry->execute("SHOW COLUMNS FROM kb3_mails LIKE 'kll_modified_time'"); if (!$qry->recordCount()) { $qry->execute($sql); } $sql = "ALTER TABLE `kb3_mails` ADD INDEX ( `kll_modified_time` ) "; $qry->execute("SHOW INDEXES FROM kb3_mails"); $indexexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'kll_modified_time') { $indexexists = true; } } if (!$indexexists) { $qry->execute($sql); } config::set("DBUpdate", "016"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '016' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '016'"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 016 completed."); $smarty->display('update.tpl'); die; } }
/** * 构造方法 * * @access public * @param mixed $name * @return mixed */ public function __construct($name) { $dbinfo = DBFactory::getDbInfo(); $this->tablePre = $dbinfo['tablePre']; $this->table = $name; $this->dbo = DBFactory::getInstance(); }
/** * @package EDK */ function update034() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "034") { if (is_null(config::get('034updatestatus'))) { config::set('034updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('034updatestatus') < 1) { $qry->execute("SHOW COLUMNS FROM kb3_invtypes LIKE 'radius'"); if ($qry->recordCount()) { $sql = "ALTER TABLE `kb3_invtypes` DROP COLUMN `radius` "; $qry->execute($sql); } } config::set("DBUpdate", "034"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '034' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '034'"); config::del("034updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 034 completed."); $smarty->display('update.tpl'); die; } }
public function getAdmin() { if (is_null($this->admin)) { $this->admin = DBFactory::get('admins')->get($this->getSessionParam('admin')); } return $this->admin; }
function execQuery() { $qry = DBFactory::getDBQuery(); $qry->execute("select * from kb3_regions where reg_id = " . $this->id); $row = $qry->getRow(); $this->name = $row['reg_name']; $this->coords = array($row['reg_x'], $row['reg_y'], $row['reg_z']); }
/** * * @param array $itemarray * @param float $price */ function ItemList($itemarray = null, $price = 0) { if (isset($itemarray)) { $this->itemarray = $itemarray; } $this->price = $price; $this->qry = DBFactory::getDBQuery(); }
public static function getShipClassIDByName($shipClassName) { $query = "SELECT scl_id FROM kb3_ship_classes WHERE scl_class = '{$shipClassName}'"; $qry = DBFactory::getDBQuery(); $qry->execute($query); $shipClassId = $qry->getRow(); return $shipClassId["scl_id"]; }
/** * Log a new kill. * * @param integer $killid * @param string $note */ public static function logKill($killid, $note = null) { if (is_null($note)) { $note = "IP:" . logger::getip(); } $qry = DBFactory::getDBQuery(true); $qry->execute("INSERT INTO kb3_log (log_kll_id, log_site," . " log_ip_address, log_timestamp) values(" . $killid . ",'" . KB_SITE . "','" . $qry->escape($note) . "', UTC_TIMESTAMP())"); }
public static function delKill($kill) { $qry = DBFactory::getDBQuery(); $qry->execute("BEGIN"); allianceSummary::delKill($kill); corpSummary::delKill($kill); pilotSummary::delKill($kill); $qry->execute("COMMIT"); }
public function __construct() { $this->db = DBFactory::getInstance(); $this->resultModel = new Model("result"); $this->resultListModel = new Model("result_list"); $this->examineResultModel = new Model("examine_result"); $config = Config::getInstance(); $this->jkf = $config->get('jkf'); }
function update022() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "022") { if (is_null(config::get('022updatestatus'))) { config::set('022updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('022updatestatus') < 1) { $qry->execute("DELETE FROM `kb3_ships` WHERE `shp_externalid` = 0 AND `shp_name` NOT LIKE '%Unknown%'"); $qry->execute("DELETE FROM `kb3_ships` WHERE `shp_id` IN (206, 497, 348, 349,352, 354, 606)"); config::set('022updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "22. Delete unused and duplicated ships from ships table."); $smarty->display('update.tpl'); die; } if (config::get('022updatestatus') < 2) { // Add timestamp column to kb3_inv_detail $qry->execute("SHOW INDEX FROM `kb3_ships`"); $indextexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'shp_externalid') { $indextexists = true; } } if (!$indextexists) { $qry->execute("ALTER TABLE `kb3_ships` ADD UNIQUE `shp_externalid` ( `shp_externalid` ) "); config::set('022updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "22. Ships table added unique index for external IDs."); $smarty->display('update.tpl'); die; } } if (config::get('022updatestatus') < 3) { //not too happy about this one but it does force the ships to use *my* IDs, as it would be if i dumped it - FRK $qry->execute("INSERT IGNORE INTO `kb3_ships` (`shp_id` ,`shp_name` ,`shp_class` ,`shp_externalid` ,`shp_rce_id` ,`shp_baseprice` ,`shp_techlevel` ,`shp_isfaction`) VALUES (704 , 'Guristas Shuttle', '11', '21628', '1', '10000000', '1', '1');"); $qry->execute("INSERT IGNORE INTO `kb3_ships` (`shp_id` ,`shp_name` ,`shp_class` ,`shp_externalid` ,`shp_rce_id` ,`shp_baseprice` ,`shp_techlevel` ,`shp_isfaction`) VALUES (705 , 'Civilian Gallente Shuttle', '11', '27303', '8', '0', '1', '0');"); config::set('022updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "22. Insert missing shuttles."); $smarty->display('update.tpl'); die; } killCache(); config::set("DBUpdate", "022"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '022' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '022'"); config::del("022updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 022 completed."); $smarty->display('update.tpl'); die; } }
function stats() { global $smarty; $qry = DBFactory::getDBQuery(); $qry->execute("SELECT COUNT(*) AS cnt FROM kb3_kills"); $row = $qry->getRow(); $kills = $row['cnt']; $smarty->assign('kills', $kills); return $smarty->fetch(get_tpl("about_stats")); }
public static function hasCampaigns($active = false) { $qry = DBFactory::getDBQuery(); $sql = "select ctr_id\n from kb3_contracts\n\t where ctr_site = '" . KB_SITE . "'"; if ($active) { $sql .= " and ( ctr_ended is null or now() <= ctr_ended ) limit 1"; } $qry->execute($sql); return $qry->recordCount() > 0; }
function update021() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "021") { $qry = DBFactory::getDBQuery(true); if (is_null(config::get('021updatestatus'))) { config::set('021updatestatus', 0); } if (config::get('021updatestatus') < 1) { // Add timestamp column to kb3_inv_detail $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_isfaction'"); if (!$qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_ships` ADD `shp_isfaction` TINYINT(1) DEFAULT '0' AFTER `shp_techlevel`;"); config::set('021updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "21. kb3_ships shp_isfaction column added"); $smarty->display('update.tpl'); die; } } if (config::get('021updatestatus') < 3) { $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 3628;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17715;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17718;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17720;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17722;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17736;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17738;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17740;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17918;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17920;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17922;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17924;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17926;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17928;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17930;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17932;"); $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 32207;"); config::set('021updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "21. faction tags added"); $smarty->display('update.tpl'); die; } killCache(); config::set("DBUpdate", "021"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '021' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '021'"); config::del("021updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 021 completed."); $smarty->display('update.tpl'); die; } }
public function setUp() { $this->test_table = PREFIX . 'test_table'; $connection = DBFactory::get_db_connection(); $sql_querier = DBFactory::new_sql_querier($connection); $this->dbms_utils = new MySQLDBMSUtils($sql_querier); $this->querier = new DBQuerier($sql_querier); $this->drop_test_table(); $this->create_test_table(); $this->populate_test_table(); }
/** * @package EDK */ function update039() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "039") { if (is_null(config::get('039updatestatus'))) { config::set('039updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('039updatestatus') < 1) { $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 11194 WHERE ind_shp_id = 206"); // Kitsune $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22428 WHERE ind_shp_id = 348"); // Redeemer $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22430 WHERE ind_shp_id = 349"); // Sin $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22436 WHERE ind_shp_id = 352"); // Widow $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22440 WHERE ind_shp_id = 354"); // Panther config::set('039updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "39. Update kb3_inv_detail."); $smarty->display('update.tpl'); die; } if (config::get('039updatestatus') < 2) { $qry->execute("UPDATE kb3_kills SET kll_ship_id = 11194 WHERE kll_ship_id = 206"); // Kitsune $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22428 WHERE kll_ship_id = 348"); // Redeemer $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22430 WHERE kll_ship_id = 349"); // Sin $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22436 WHERE kll_ship_id = 352"); // Widow $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22440 WHERE kll_ship_id = 354"); // Panther config::set('039updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "39. Update kb3_kills."); $smarty->display('update.tpl'); die; } killCache(); config::set("DBUpdate", "039"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '039' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '039'"); config::del("039updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 039 completed."); $smarty->display('update.tpl'); die; } }
public static function getMoonName($id) { if ($id != 0) { $qry = DBFactory::getDBQuery(); $sql = 'select moo_name FROM kb3_moons WHERE moo_id = ' . $id; $qry->execute($sql); $row = $qry->getRow(); return $row['moo_name']; } else { return false; } }
/** * Gibt das Singleton Datenbankobjekt zurück. */ public static function getInstance() { if (!isset(self::$db)) { // Datenbankverbindung aufbauen self::$db = @new MySQLi(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE); // Prüfen, ob die Verindung aufgebaut werden konnte if (mysqli_connect_errno()) { throw new Exception("MySQLi konnte sich nicht verbinden: " . mysqli_connect_error()); } } return self::$db; }
public function updateAction() { if (empty($_GET['id']) || !($language = DBFactory::get($this->module)->get($_GET['id'])) instanceof Language) { Header::location(UrlFactory::module($this->module)); } $this->valid($language, $_POST); $view = $this->getView('Form'); $view->language = $language; $layout = $this->getLayout('Default', $view); $layout->addBreadcrumbsLink(new Link(Translator::get('module_languages'), UrlFactory::module($this->module))); $layout->addBreadcrumbsLink(new Link($language->name, UrlFactory::update($this->module, $language))); $layout->addBreadcrumbsLink(new Link(Translator::get('module_update'))); }
/** * * @return string HTML string for toplists */ function topLists($filterArguments = array()) { if (empty($filterArguments)) { $whereSql = ""; } else { $whereSql = "WHERE " . implode(" AND ", $filterArguments); } $sql = "SELECT COUNT( bop.battle_id ) AS cnt, bop.plt_id\n FROM kb3_battles_owner_pilots bop\n INNER JOIN kb3_pilots plt ON ( plt.plt_id = bop.plt_id ) \n INNER JOIN kb3_battles_cache bc ON bc.battle_id = bop.battle_id\n INNER JOIN kb3_systems sys ON sys.sys_name = bc.system\n INNER JOIN kb3_constellations con ON con.con_id = sys.sys_con_id\n INNER JOIN kb3_regions reg ON reg.reg_id = con.con_reg_id\n {$whereSql}\n GROUP BY bop.plt_id ORDER BY 1 DESC LIMIT 15"; $query = DBFactory::getDBQuery(); $query->execute($sql); $tkbox = new AwardBoxLong($query, "Top Fleet Attendees", "Fleet attendances", "fleets", "eagle", $query->recordCount()); return $html = $tkbox->generate(); }