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; } }
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 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; } }
/** * @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; } }
function update025() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "025") { $qry = DBFactory::getDBQuery(true); $qry->execute("INSERT IGNORE INTO `kb3_item_locations` (" . "`itl_id` , `itl_location`)" . " VALUES ('8', 'Implant');"); killCache(); config::set("DBUpdate", "025"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '025' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '025'"); $smarty->assign('refresh', 1); $smarty->assign('content', "25. kb3_item_locations updated."); $smarty->display('update.tpl'); die; } }
function update008() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "008") { if (is_null(config::get('008updatestatus'))) { config::set('008updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('008updatestatus') < 1) { // Add pilot, corp and alliance index to kb3_inv_detail // Incomplete in update007 $qry->execute("SHOW INDEXES FROM kb3_inv_detail"); $indexcexists = false; $indexaexists = false; $indexpexists = false; $indexkexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'ind_kll_id' && $testresult['Seq_in_index'] == 1) { $indexkexists = true; } if ($testresult['Column_name'] == 'ind_crp_id' && $testresult['Seq_in_index'] == 1) { $indexcexists = true; } if ($testresult['Column_name'] == 'ind_all_id' && $testresult['Seq_in_index'] == 1) { $indexaexists = true; } if ($testresult['Column_name'] == 'ind_plt_id' && $testresult['Seq_in_index'] == 1) { $indexpexists = true; } } if (!$indexkexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_kll_id`, `ind_order` ) "); $smarty->assign('refresh', 1); $smarty->assign('content', "8. kb3_inv_detail index id_order added"); $smarty->display('update.tpl'); die; } if (!$indexcexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_crp_id` ) "); $smarty->assign('refresh', 1); $smarty->assign('content', "8. kb3_inv_detail index id_order added"); $smarty->display('update.tpl'); die; } if (!$indexaexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_all_id` ) "); $smarty->assign('refresh', 1); $smarty->assign('content', "8. kb3_inv_detail index id_order added"); $smarty->display('update.tpl'); die; } if (!$indexpexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_plt_id` ) "); $smarty->assign('refresh', 1); $smarty->assign('content', "8. kb3_inv_detail index id_order added"); $smarty->display('update.tpl'); die; } config::set('008updatestatus', 1); } $qry->execute("SHOW INDEXES FROM kb3_corps"); $indexaexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'crp_name' && $testresult['Non_unique'] == 0) { $indexcexists = true; } } if (!$indexcexists) { $qry->rewind(); $indexexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Key_name'] == 'UPGRADE8_crp_name') { $indexexists = true; } } if (!$indexexists) { $qry->execute("ALTER TABLE `kb3_corps` ADD INDEX `UPGRADE8_crp_name` ( `crp_name` ) "); } $sqlcrp = 'select a.crp_id as newid, b.crp_id as oldid from kb3_corps a, kb3_corps b where a.crp_name = b.crp_name and a.crp_id < b.crp_id'; if (config::get('008updatestatus') < 2) { $qry->execute('update kb3_inv_detail join (' . $sqlcrp . ') c on c.oldid = ind_crp_id set ind_crp_id = c.newid'); config::set('008updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique corp names: updated kb3_inv_detail"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 3) { $qry->execute('update kb3_pilots join (' . $sqlcrp . ') c on (c.oldid = plt_crp_id) set plt_crp_id = c.newid'); config::set('008updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique corp names: updated kb3_pilots"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 4) { $qry->execute('update kb3_kills join (' . $sqlcrp . ') c on (c.oldid = kll_crp_id) set kll_crp_id = c.newid'); config::set('008updatestatus', 4); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique corp names: updated kb3_kills"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 6) { $qry->execute('delete b from kb3_corps a, kb3_corps b where a.crp_name = b.crp_name and a.crp_id < b.crp_id'); config::set('008updatestatus', 6); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique corp names: updated kb3_corps"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 7) { $qry->execute("ALTER TABLE `kb3_corps` DROP INDEX `UPGRADE8_crp_name`"); $qry->execute("SHOW INDEXES FROM kb3_corps"); $indexcexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'crp_name' && $testresult['Seq_in_index'] == 1) { $indexcname = $testresult['Key_name']; $indexcexists = true; } elseif ($testresult['Key_name'] == $indexcname && $testresult['Seq_in_index'] == 2) { $indexcexists = false; } } if ($indexcexists) { $qry->execute("ALTER TABLE `kb3_corps` DROP INDEX `" . $indexcname . "`"); } $qry->execute("ALTER TABLE `kb3_corps` ADD UNIQUE INDEX ( `crp_name` ) "); config::set('008updatestatus', 7); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique corp names: unique index added to kb3_corps"); $smarty->display('update.tpl'); die; } } // Make kb3_alliances.all_name unique without losing kills $qry->execute("SHOW INDEXES FROM kb3_alliances"); $indexaexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'all_name' && $testresult['Non_unique'] == 0) { $indexaexists = true; } } if (!$indexaexists) { $qry->rewind(); $indexexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Key_name'] == 'UPGRADE8_all_name') { $indexexists = true; } } if (!$indexexists) { $qry->execute("ALTER TABLE `kb3_alliances` ADD INDEX `UPGRADE8_all_name` ( `all_name` ) "); } $sqlall = 'select a.all_id as newid, b.all_id as oldid from kb3_alliances a, kb3_alliances b where a.all_name = b.all_name and a.all_id < b.all_id'; if (config::get('008updatestatus') < 8) { $qry->execute('update kb3_inv_detail join (' . $sqlall . ') c on c.oldid = ind_all_id set ind_all_id = c.newid'); config::set('008updatestatus', 8); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique all names: updated kb3_inv_detail"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 9) { $qry->execute('update kb3_corps join (' . $sqlall . ') c on (c.oldid = crp_all_id) set crp_all_id = c.newid'); config::set('008updatestatus', 9); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique all names: updated kb3_corps"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 10) { $qry->execute('update kb3_kills join (' . $sqlall . ') c on (c.oldid = kll_all_id) set kll_all_id = c.newid'); config::set('008updatestatus', 10); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique all names: updated kb3_kills"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 12) { $qry->execute('delete b from kb3_alliances a, kb3_alliances b where a.all_name = b.all_name and a.all_id < b.all_id'); config::set('008updatestatus', 12); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique all names: updated kb3_alliances"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 13) { $qry->execute("ALTER TABLE `kb3_alliances` DROP INDEX `UPGRADE8_all_name`"); $qry->execute("SHOW INDEXES FROM kb3_alliances"); $indexaexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'all_name' && $testresult['Seq_in_index'] == 1) { $indexaname = $testresult['Key_name']; $indexaexists = true; } elseif ($testresult['Key_name'] == $indexaname && $testresult['Seq_in_index'] == 2) { $indexaexists = false; } } if ($indexaexists) { $qry->execute("ALTER TABLE `kb3_alliances` DROP INDEX `" . $indexaname . "`"); } $qry->execute("ALTER TABLE `kb3_alliances` ADD UNIQUE INDEX ( `all_name` ) "); config::set('008updatestatus', 13); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique all names: unique index applied to kb3_alliances"); $smarty->display('update.tpl'); die; } } // Make kb3_pilots.plt_name unique without losing kills $qry->execute("SHOW INDEXES FROM kb3_pilots"); $indexaexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'plt_name' && $testresult['Non_unique'] == 0) { $indexaexists = true; } } if (!$indexaexists) { $qry->rewind(); $indexexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Key_name'] == 'UPGRADE8_plt_name') { $indexexists = true; } } if (!$indexexists) { $qry->execute("ALTER TABLE `kb3_pilots` ADD INDEX `UPGRADE8_plt_name` ( `plt_name` ) "); } $sqlplt = 'select a.plt_id as newid, b.plt_id as oldid from kb3_pilots a, kb3_pilots b where a.plt_name = b.plt_name and a.plt_id < b.plt_id'; if (config::get('008updatestatus') < 14) { $qry->execute('update kb3_inv_detail join (' . $sqlplt . ') c on c.oldid = ind_plt_id set ind_plt_id = c.newid'); config::set('008updatestatus', 14); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique plt names: updated kb3_inv_detail"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 15) { $qry->execute('update kb3_kills join (' . $sqlplt . ') c on (c.oldid = kll_victim_id) set kll_victim_id = c.newid'); config::set('008updatestatus', 15); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique plt names: updated kb3_kills victim"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 16) { $qry->execute('update kb3_kills join (' . $sqlplt . ') c on (c.oldid = kll_fb_plt_id) set kll_fb_plt_id = c.newid'); config::set('008updatestatus', 16); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique plt names: updated kb3_kills killer"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 17) { $qry->execute('delete b from kb3_pilots a, kb3_pilots b where a.plt_name = b.plt_name and a.plt_id < b.plt_id'); config::set('008updatestatus', 17); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique plt names: updated kb3_pilots"); $smarty->display('update.tpl'); die; } if (config::get('008updatestatus') < 18) { $qry->execute("ALTER TABLE `kb3_pilots` DROP INDEX `UPGRADE8_plt_name`"); $qry->execute("SHOW INDEXES FROM kb3_pilots"); $indexpexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'plt_name' && $testresult['Seq_in_index'] == 1) { $indexpname = $testresult['Key_name']; $indexpexists = true; } elseif ($testresult['Key_name'] == $indexpname && $testresult['Seq_in_index'] == 2) { $indexpexists = false; } } if ($indexpexists) { $qry->execute("ALTER TABLE `kb3_pilots` DROP INDEX `" . $indexpname . "`"); } $qry->execute("ALTER TABLE `kb3_pilots` ADD UNIQUE INDEX ( `plt_name` ) "); config::set('008updatestatus', 18); $smarty->assign('refresh', 1); $smarty->assign('content', "8. Unique plt names: unique index applied to kb3_pilots."); $smarty->display('update.tpl'); die; } } config::set('cache_update', '*'); config::set('cache_time', '10'); killCache(); config::set("DBUpdate", "008"); $qry->execute("UPDATE kb3_config SET cfg_value = '008' WHERE cfg_key = 'DBUpdate'"); config::del("008updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 008 completed."); $smarty->display('update.tpl'); die; } }
function updateDB() { // if update nesseary run updates killCache(); removeOld(0, 'cache/templates_c', false); chdir('update'); $dir = opendir('.'); $updatedirs = array(); while ($file = readdir($dir)) { if ($file[0] == '.' || !is_dir($file)) { continue; } else { $updatedirs[] = $file; } } asort($updatedirs); foreach ($updatedirs as $curdir) { if (!preg_match("/[0-9]+/", $curdir)) { continue; } if (CURRENT_DB_UPDATE >= $curdir) { continue; } require_once $curdir . '/update.php'; $func = 'update' . $curdir; $func(); } }
function update012() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "012") { if (is_null(config::get('012updatestatus'))) { config::set('012updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('012updatestatus') < 1) { // Add timestamp column to kb3_inv_detail $qry->execute("SHOW COLUMNS FROM kb3_inv_detail LIKE 'ind_timestamp'"); if (!$qry->recordCount()) { $qry->execute("ALTER TABLE kb3_inv_detail ADD ind_timestamp\r\n\t\t\t\t\tDATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER ind_kll_id"); config::set('012updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_detail timestamp column added"); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 2) { // Add timestamp column to kb3_inv_detail $qry->execute("SHOW INDEX FROM kb3_inv_detail"); $indextexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'ind_timestamp') { $indextexists = true; } } if (!$indextexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_timestamp` ) "); config::set('012updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_detail timestamp index added"); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 3) { // Add pilot,timestamp index to kb3_inv_detail $qry->execute("SHOW INDEX FROM kb3_inv_detail"); $indexpexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Key_name'] == 'ind_plt_time') { $indexpexists = true; } } if (!$indexpexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ind_plt_time ( `ind_plt_id`,`ind_timestamp` ) "); config::set('012updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_detail pilot index added"); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 4) { $qry->execute("SHOW TABLES LIKE 'kb3_inv_all'"); if ($qry->recordCount()) { $qry->execute("DROP TABLE kb3_inv_all"); } $qry->execute("SHOW TABLES LIKE 'kb3_inv_crp'"); if ($qry->recordCount()) { $qry->execute("DROP TABLE kb3_inv_crp"); } $qry->execute("SHOW TABLES LIKE 'kb3_inv_plt'"); if ($qry->recordCount()) { $qry->execute("DROP TABLE kb3_inv_plt"); } // kb3_inv_all (kll_id, all_id, timestamp) $sql = "CREATE TABLE IF NOT EXISTS `kb3_inv_all` (\r\n\t\t\t\t `ina_kll_id` int(6) NOT NULL DEFAULT '0',\r\n\t\t\t\t `ina_all_id` int(3) NOT NULL DEFAULT '0',\r\n\t\t\t\t `ina_timestamp` datetime NOT NULL,\r\n\t\t\t\t PRIMARY KEY (`ina_kll_id`,`ina_all_id`),\r\n\t\t\t\t KEY `ina_all_time` (`ina_all_id`,`ina_timestamp`)\r\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $qry->execute($sql); // kb3_inv_crp (kll_id, crp_id, timestamp) $sql = "CREATE TABLE IF NOT EXISTS `kb3_inv_crp` (\r\n\t\t\t\t `inc_kll_id` int(6) NOT NULL DEFAULT '0',\r\n\t\t\t\t `inc_crp_id` int(3) NOT NULL DEFAULT '0',\r\n\t\t\t\t `inc_timestamp` datetime NOT NULL,\r\n\t\t\t\t PRIMARY KEY (`inc_kll_id`,`inc_crp_id`),\r\n\t\t\t\t KEY `inc_crp_time` (`inc_crp_id`,`inc_timestamp`)\r\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $qry->execute($sql); config::set('012updatestatus', 4); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_all and kb3_inv_crp created."); $smarty->display('update.tpl'); die; } if (config::get('012updatestatus') < 5) { $step = 10000; //$qry->execute("SELECT MAX(kll_id) as cnt FROM kb3_kills"); //$result = $qry->getRow(); //$max = $result['cnt']; if (!config::get('012_5_status')) { config::set('012_5_status', '0'); } // add times to kb3_inv_detail. $qry->execute("UPDATE kb3_inv_detail join kb3_kills on ind_kll_id = kll_id\r\n\t\t\t\tSET ind_timestamp = kll_timestamp\r\n\t\t\t\tWHERE ind_timestamp < '0001-01-01'\r\n\t\t\t\tAND kll_id >= " . config::get('012_5_status') . "\r\n\t\t\t\tAND kll_id < " . (config::get('012_5_status') + $step)); $qry->execute("SELECT MIN(kll_id) as next FROM kb3_kills WHERE kll_id >= " . (config::get('012_5_status') + $step)); $row = $qry->getRow(); if (!isset($row['next']) || $row['next'] == null) { config::set('012updatestatus', 5); config::del('012_5_status'); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_detail timestamp added."); $smarty->display('update.tpl'); die; } else { config::set('012_5_status', $row['next']); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_detail timestamp updated rows " . (config::get('012_5_status') - $step) . " - " . config::get('012_5_status')); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 6) { $step = 10000; //$qry->execute("SELECT MAX(kll_id) as cnt FROM kb3_kills"); //$result = $qry->getRow(); //$max = $result['cnt']; if (!config::get('012_6_status')) { config::set('012_6_status', '0'); } // add times to kb3_inv_detail. $qry->execute("INSERT IGNORE INTO kb3_inv_all\r\n\t\t\t\tSELECT ind_kll_id, ind_all_id, ind_timestamp\r\n\t\t\t\tFROM kb3_inv_detail\r\n\t\t\t\tWHERE ind_kll_id >= " . config::get('012_6_status') . "\r\n\t\t\t\t\tAND ind_kll_id < " . (config::get('012_6_status') + $step) . "\r\n\t\t\t\tGROUP BY ind_kll_id, ind_all_id"); $qry->execute("SELECT MIN(kll_id) as next FROM kb3_kills WHERE kll_id >= " . (config::get('012_6_status') + $step)); $row = $qry->getRow(); if (!isset($row['next']) || $row['next'] == null) { config::del('012_6_status'); config::set('012updatestatus', 6); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_all filled."); $smarty->display('update.tpl'); die; } else { config::set('012_6_status', $row['next']); $smarty->assign('refresh', 1); $out = "12. kb3_inv_all rows " . (config::get('012_6_status') - $step); $out .= " - " . config::get('012_6_status') . " added."; $smarty->assign('content', $out); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 7) { $step = 10000; // add times to kb3_inv_detail. //$qry->execute("SELECT MAX(kll_id) as cnt FROM kb3_kills"); //$result = $qry->getRow(); //$max = $result['cnt']; if (!config::get('012_7_status')) { config::set('012_7_status', '0'); } $qry->execute("INSERT IGNORE INTO kb3_inv_crp\r\n\t\t\t\tSELECT ind_kll_id, ind_crp_id, ind_timestamp\r\n\t\t\t\tFROM kb3_inv_detail\r\n\t\t\t\tWHERE ind_kll_id >= " . config::get('012_7_status') . "\r\n\t\t\t\t\tAND ind_kll_id < " . (config::get('012_7_status') + $step) . "\r\n\t\t\t\tGROUP BY ind_kll_id, ind_crp_id"); $qry->execute("SELECT MIN(kll_id) as next FROM kb3_kills WHERE kll_id >= " . (config::get('012_7_status') + $step)); $row = $qry->getRow(); if (!isset($row['next']) || $row['next'] == null) { config::del('012_7_status'); config::set('012updatestatus', 7); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_inv_crp filled."); $smarty->display('update.tpl'); die; } else { config::set('012_7_status', $row['next']); $smarty->assign('refresh', 1); $out = "12. kb3_inv_crp rows " . (config::get('012_7_status') - $step); $out .= " - " . config::get('012_7_status') . " added."; $smarty->assign('content', $out); $smarty->display('update.tpl'); die; } } if (config::get('012updatestatus') < 8) { // add times to kb3_inv_detail. $qry->execute("ALTER TABLE `kb3_log` CHANGE `log_ip_address` `log_ip_address` VARCHAR( 100 ) NOT NULL"); config::set('012updatestatus', 8); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_log expanded."); $smarty->display('update.tpl'); die; } if (config::get('012updatestatus') < 9) { // add times to kb3_inv_detail. $qry->execute("SHOW COLUMNS FROM kb3_comments LIKE 'ip'"); if (!$qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_comments` ADD `ip` VARBINARY( 39 ) NOT NULL DEFAULT '0:0:0:0'"); } config::set('012updatestatus', 9); $smarty->assign('refresh', 1); $smarty->assign('content', "12. kb3_comments ip field added."); $smarty->display('update.tpl'); die; } if (config::get('012updatestatus') < 10) { $qry->execute("UPDATE kb3_config SET cfg_value = 'default' where cfg_key = 'style_name'"); $qry->execute("INSERT IGNORE INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'theme_name', 'default' FROM kb3_config GROUP BY cfg_site"); config::set('012updatestatus', 10); $smarty->assign('refresh', 1); $smarty->assign('content', "12. theme set to default."); $smarty->display('update.tpl'); die; } if (config::get('012updatestatus') < 11) { $qry->execute("UPDATE `kb3_navigation` SET url = '?a=self_detail' WHERE descr = 'Stats';"); $qry->execute("DELETE FROM `kb3_navigation` WHERE url = '?a=losses';"); $qry->execute("DELETE FROM `kb3_navigation` WHERE url = '?a=kills';"); config::set('012updatestatus', 11); $smarty->assign('refresh', 1); $smarty->assign('content', "12. Navigation updated."); $smarty->display('update.tpl'); die; } killCache(); config::set("DBUpdate", "012"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '012' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '012'"); config::del("012updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 012 completed."); $smarty->display('update.tpl'); die; } }
function update013() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "013") { if (is_null(config::get('013updatestatus'))) { config::set('013updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('013updatestatus') < 1) { // Add timestamp column to kb3_inv_detail $qry->execute("SHOW COLUMNS FROM kb3_comments LIKE 'site'"); if (!$qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_comments` ADD `site` CHAR( 16 ) DEFAULT NULL AFTER `id`"); config::set('013updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "13. kb3_comments site column added"); $smarty->display('update.tpl'); die; } } if (config::get('013updatestatus') < 3) { // Add site column to kb3_comments $qry->execute("SHOW INDEX FROM kb3_comments"); $indexkexists = false; $indexsexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Key_name'] == 'kll_id') { $indexkexists = true; } if ($testresult['Key_name'] == 'kll_site_id') { $indexsexists = true; } } if ($indexkexists) { $qry->execute("ALTER TABLE kb3_comments DROP INDEX kll_id"); config::set('013updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "13. kb3_comments kll_id index dropped"); $smarty->display('update.tpl'); die; } if (!$indexsexists) { $qry->execute("ALTER TABLE `kb3_comments` ADD INDEX `kll_site_id` ( `kll_id`, `site` ) "); config::set('013updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "13. kb3_comments kll_site_id index added"); $smarty->display('update.tpl'); die; } } killCache(); config::set("DBUpdate", "013"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '013' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '013'"); config::del("013updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 013 completed."); $smarty->display('update.tpl'); die; } }
function update024() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "024") { if (is_null(config::get('024updatestatus'))) { config::set('024updatestatus', 0); } $qry = DBFactory::getDBQuery(true); if (config::get('024updatestatus') < 1) { $qry->execute("SHOW COLUMNS FROM kb3_systems LIKE 'sys_eve_id'"); if ($qry->recordCount()) { $qry->execute("SELECT min(sys_eve_id) as min FROM kb3_systems"); $row = $qry->getRow(); $min = $row['min']; $qry->execute("UPDATE kb3_kills\n\t\t\t\t\tJOIN kb3_systems on sys_id = kll_system_id\n\t\t\t\t\tSET kll_system_id = sys_eve_id\n\t\t\t\t\tWHERE kll_system_id < {$min}"); } config::set('024updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "24. Updated kb3_kills systems."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 2) { $qry->execute("SHOW COLUMNS FROM kb3_systems LIKE 'sys_eve_id'"); if ($qry->recordCount()) { $qry->execute("SELECT min(sys_eve_id) as min FROM kb3_systems"); $row = $qry->getRow(); $min = $row['min']; $qry->execute("UPDATE kb3_contract_details\n\t\t\t\t\tJOIN kb3_systems on sys_id = ctd_sys_id\n\t\t\t\t\tSET ctd_sys_id = sys_eve_id\n\t\t\t\t\tWHERE ctd_sys_id < {$min}"); } config::set('024updatestatus', 2); $smarty->assign('refresh', 1); $smarty->assign('content', "24. Updated kb3_contract_details."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 3) { $qry->execute("SHOW COLUMNS FROM kb3_systems LIKE 'sys_eve_id'"); if ($qry->recordCount()) { $qry->execute("UPDATE kb3_systems SET sys_id = sys_eve_id"); } config::set('024updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_systems is updated."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 4) { $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_externalid'"); if ($qry->recordCount()) { $qry->execute("UPDATE kb3_kills JOIN kb3_ships ON kll_ship_id =" . " shp_id SET kll_ship_id = shp_externalid"); } config::set('024updatestatus', 4); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_kills ships are updated."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 5) { $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_externalid'"); if ($qry->recordCount()) { $qry->execute("UPDATE kb3_inv_detail JOIN kb3_ships ON ind_shp_id =" . " shp_id SET ind_shp_id = shp_externalid"); } config::set('024updatestatus', 5); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_inv_detail ships are updated."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 6) { $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_externalid'"); if ($qry->recordCount()) { $qry->execute("UPDATE kb3_ships SET shp_id = shp_id+100000"); $qry->execute("UPDATE kb3_ships SET shp_id = shp_externalid"); } config::set('024updatestatus', 6); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_ships is updated."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 7) { $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_externalid'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_ships`" . " DROP `shp_name`," . " DROP `shp_externalid`," . " DROP `shp_rce_id`," . " DROP `shp_baseprice`," . " DROP `shp_techlevel`," . " DROP `shp_isfaction`"); } config::set('024updatestatus', 7); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_ships shrunk."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 8) { $qry->execute("SHOW TABLES LIKE 'kb3_ships_values'"); if ($qry->recordCount()) { $qry->execute("DROP TABLE kb3_ships_values"); } config::set('024updatestatus', 8); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_ships_values removed."); $smarty->display('update.tpl'); die; } if (config::get('024updatestatus') < 9) { $qry->execute("SHOW COLUMNS FROM kb3_systems LIKE 'sys_eve_id'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_systems` DROP `sys_eve_id`"); } config::set('024updatestatus', 9); $smarty->assign('refresh', 1); $smarty->assign('content', "24. kb3_systems shrunk."); $smarty->display('update.tpl'); die; } killCache(); config::set("DBUpdate", "024"); $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '024' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '024'"); config::del("024updatestatus"); $smarty->assign('refresh', 1); $smarty->assign('content', "Update 024 completed."); $smarty->display('update.tpl'); die; } }
/** * @package EDK */ function update007() { global $url, $smarty; //Checking if this Update already done if (CURRENT_DB_UPDATE < "007") { $qry = DBFactory::getDBQuery(true); if (is_null(config::get('007updatestatus'))) { config::set('007updatestatus', 0); } if (config::get('007updatestatus') < 1) { // Add columns for external ids. $qry->execute("SHOW COLUMNS FROM kb3_alliances LIKE 'all_external_id'"); if (!$qry->recordCount()) { $sql = "ALTER TABLE `kb3_alliances` " . "ADD `all_external_id` INT( 11 ) UNSIGNED NULL " . "DEFAULT NULL , ADD UNIQUE ( all_external_id )"; $qry->execute($sql); } $qry->execute("SHOW COLUMNS FROM kb3_corps LIKE 'crp_external_id'"); if (!$qry->recordCount()) { $sql = "ALTER TABLE `kb3_corps` " . "ADD `crp_external_id` INT( 11 ) UNSIGNED NULL " . "DEFAULT NULL , ADD UNIQUE ( crp_external_id )"; $qry->execute($sql); } $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_external_id'"); if (!$qry->recordCount()) { $sql = "ALTER TABLE `kb3_kills` " . "ADD `kll_external_id` INT( 11 ) UNSIGNED NULL " . "DEFAULT NULL , ADD UNIQUE ( kll_external_id )"; $qry->execute($sql); } config::set('007updatestatus', 1); $smarty->assign('refresh', 1); $smarty->assign('content', "7. External ID columns added"); $smarty->display('update.tpl'); die; } // Add isk loss column to kb3_kills if (config::get('007updatestatus') < 8) { // Update price with items destroyed and ship value, excluding // blueprints since default cost is for BPO and BPC looks identical if (config::get('007updatestatus') < 2) { $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_ship` (\r\n\t\t\t\t `kll_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t\t `value` float NOT NULL DEFAULT '0',\r\n\t\t\t\t PRIMARY KEY (`kll_id`)\r\n\t\t\t\t) ENGINE=MyISAM"; $qry->execute($sql); $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_destroyed` (\r\n\t\t\t\t `kll_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t\t `value` float NOT NULL DEFAULT '0',\r\n\t\t\t\t PRIMARY KEY (`kll_id`)\r\n\t\t\t\t) ENGINE=MyISAM"; $qry->execute($sql); $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_dropped` (\r\n\t\t\t\t `kll_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t\t\t `value` float NOT NULL DEFAULT '0',\r\n\t\t\t\t PRIMARY KEY (`kll_id`)\r\n\t\t\t\t) ENGINE=MyISAM"; $qry->execute($sql); config::set('007updatestatus', 2); } $qry->execute("LOCK TABLES tmp_price_ship WRITE, tmp_price_destroyed WRITE,\r\n\t\t\t\ttmp_price_dropped WRITE, kb3_kills WRITE, kb3_ships WRITE,\r\n\t\t\t\tkb3_ships_values WRITE, kb3_items_destroyed WRITE, kb3_items_dropped WRITE,\r\n\t\t\t\tkb3_invtypes WRITE, kb3_item_price WRITE, kb3_config WRITE"); if (config::get('007updatestatus') < 3) { $qry->execute("INSERT IGNORE INTO tmp_price_ship select\r\n\t\t\t\t\tkll_id,if(isnull(shp_value),shp_baseprice,shp_value) FROM kb3_kills\r\n\t\t\t\t\tINNER JOIN kb3_ships ON kb3_ships.shp_id = kll_ship_id\r\n\t\t\t\t\tLEFT JOIN kb3_ships_values ON kb3_ships_values.shp_id = kll_ship_id"); $qry->execute($sql); config::set('007updatestatus', 3); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: Ship prices calculated"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 4) { $sql = "INSERT IGNORE INTO tmp_price_destroyed\r\n\t\t\t\t\tSELECT itd_kll_id,\r\n\t\t\t\t\tsum(if(typeName LIKE '%Blueprint%',0,if(isnull(itd_quantity),\r\n\t\t\t\t\t0,itd_quantity * if(price = 0 OR isnull(price),basePrice,price))))\r\n\t\t\t\t\tFROM kb3_items_destroyed\r\n\t\t\t\t\tLEFT JOIN kb3_item_price ON kb3_item_price.typeID = itd_itm_id\r\n\t\t\t\t\tLEFT JOIN kb3_invtypes ON itd_itm_id = kb3_invtypes.typeID\r\n\t\t\t\t\tGROUP BY itd_kll_id"; $qry->execute($sql); config::set('007updatestatus', 4); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: Destroyed item prices calculated"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 5) { if (config::get('kd_droptototal')) { $action = "calculated"; $sql = "INSERT INTO tmp_price_dropped\r\n\t\t\t\t\t\tSELECT itd_kll_id,\r\n\t\t\t\t\t\tsum(if(typeName LIKE '%Blueprint%',0,if(isnull(itd_quantity),\r\n\t\t\t\t\t\t0,itd_quantity * if(price = 0 OR isnull(price),basePrice,price))))\r\n\t\t\t\t\t\tFROM kb3_items_dropped\r\n\t\t\t\t\t\tLEFT JOIN kb3_item_price ON kb3_item_price.typeID = itd_itm_id\r\n\t\t\t\t\t\tLEFT JOIN kb3_invtypes ON itd_itm_id = kb3_invtypes.typeID\r\n\t\t\t\t\t\tGROUP BY itd_kll_id"; $qry->execute($sql); } else { $action = "ignored"; } config::set('007updatestatus', 5); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: Dropped item prices {$action}"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 7) { $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_isk_loss'"); if (!$qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_kills` ADD `kll_isk_loss` FLOAT NOT NULL DEFAULT '0'"); config::set('007updatestatus', 7); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: ISK column created"); $smarty->display('update.tpl'); die; } config::set('007updatestatus', 7); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: ISK column already exists."); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 8) { // default step size $step = 8192; if (!config::get('007.8status')) { config::set('007.8status', 0); config::set('007.8step', $step); } // If we had to restart then halve the step size up to 4 times. if (config::get('007.8status') > 0 && config::get('007.8step') >= $step / 2 ^ 4) { config::set('007.8step', config::get('007.8step') / 2); } $qry->execute("SELECT max(kll_id) as max FROM kb3_kills"); $row = $qry->getRow(); $count = $row['max']; while (config::get('007.8status') < $count) { $sql = 'UPDATE kb3_kills natural join tmp_price_ship left join tmp_price_destroyed on kb3_kills.kll_id = tmp_price_destroyed.kll_id '; if (config::get('kd_droptototal')) { $sql .= ' left join tmp_price_dropped on kb3_kills.kll_id = tmp_price_dropped.kll_id '; } $sql .= 'SET kb3_kills.kll_isk_loss = tmp_price_ship.value + ifnull(tmp_price_destroyed.value,0) '; if (config::get('kd_droptototal')) { $sql .= ' + ifnull(tmp_price_dropped.value,0) '; } $sql .= ' WHERE kb3_kills.kll_id >= ' . config::get('007.8status') . ' AND kb3_kills.kll_id < ' . (intval(config::get('007.8status')) + intval(config::get('007.8step'))); $qry->execute($sql); config::set('007.8status', intval(config::get('007.8status')) + intval(config::get('007.8step'))); } config::del('007.8status'); config::del('007.8step'); $qry->execute("UNLOCK TABLES"); $qry->execute('DROP TABLE tmp_price_ship'); $qry->execute('DROP TABLE tmp_price_destroyed'); $qry->execute('DROP TABLE tmp_price_dropped'); config::set('007updatestatus', 8); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Kill values: Totals updated"); $smarty->display('update.tpl'); die; } } if (config::get('007updatestatus') < 9) { $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_fb_crp_id'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_kills` DROP `kll_fb_crp_id`"); } config::set('007updatestatus', 9); $smarty->assign('refresh', 1); $smarty->assign('content', "7. kll_fb_crp_id column dropped"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 10) { $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_fb_all_id'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE `kb3_kills` DROP `kll_fb_all_id`"); } config::set('007updatestatus', 10); $smarty->assign('refresh', 1); $smarty->assign('content', "7. kll_fb_all_id column dropped"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 11) { // Drop unused columns $qry->execute("SHOW COLUMNS FROM kb3_corps LIKE 'crp_trial'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE kb3_corps DROP crp_trial"); } $qry->execute("SHOW COLUMNS FROM kb3_pilots LIKE 'plt_killpoints'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE kb3_pilots DROP plt_killpoints"); } $qry->execute("SHOW COLUMNS FROM kb3_pilots LIKE 'plt_losspoints'"); if ($qry->recordCount()) { $qry->execute("ALTER TABLE kb3_pilots DROP plt_losspoints"); } config::set('007updatestatus', 11); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Unused crp and plt columns dropped"); $smarty->display('update.tpl'); die; } // Add corp and alliance index to kb3_inv_detail $qry->execute("SHOW INDEX FROM kb3_inv_detail"); $indexcexists = false; $indexaexists = false; while ($testresult = $qry->getRow()) { if ($testresult['Column_name'] == 'ind_crp_id') { $indexcexists = true; } elseif ($testresult['Column_name'] == 'ind_all_id') { $indexaexists = true; } } if (config::get('007updatestatus') < 12) { if (!$indexcexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_crp_id` ) "); } config::set('007updatestatus', 12); $smarty->assign('refresh', 1); $smarty->assign('content', "7. kb3_inv_detail ind_crp_id index added"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 13) { if (!$indexaexists) { $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_all_id` ) "); } config::set('007updatestatus', 13); $smarty->assign('refresh', 1); $smarty->assign('content', "7. kb3_inv_detail ind_all_id index added"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 14) { // Add table for api cache $sql = "CREATE TABLE IF NOT EXISTS `kb3_apicache` (\r\n\t\t\t\t `cfg_site` varchar(16) NOT NULL default '',\r\n\t\t\t\t `cfg_key` varchar(32) NOT NULL default '',\r\n\t\t\t\t `cfg_value` text NOT NULL,\r\n\t\t\t\t PRIMARY KEY (`cfg_site`,`cfg_key`)\r\n\t\t\t\t )"; $qry->execute($sql); $qry->execute("CREATE TABLE IF NOT EXISTS `kb3_apilog` (\r\n\t\t\t\t`log_site` VARCHAR( 20 ) NOT NULL ,\r\n\t\t\t\t`log_keyname` VARCHAR( 20 ) NOT NULL ,\r\n\t\t\t\t`log_posted` INT NOT NULL ,\r\n\t\t\t\t`log_errors` INT NOT NULL ,\r\n\t\t\t\t`log_ignored` INT NOT NULL ,\r\n\t\t\t\t`log_verified` INT NOT NULL ,\r\n\t\t\t\t`log_totalmails` INT NOT NULL ,\r\n\t\t\t\t`log_source` VARCHAR( 20 ) NOT NULL ,\r\n\t\t\t\t`log_type` VARCHAR( 20 ) NOT NULL ,\r\n\t\t\t\t`log_timestamp` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'\r\n\t\t\t\t) ENGINE = MYISAM "); // set API update complete config::set('API_DBUpdate', '1'); config::set('007updatestatus', 14); $smarty->assign('refresh', 1); $smarty->assign('content', "7. API tables added"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 15) { // Add subsystem slot $qry->execute("SELECT 1 FROM kb3_item_locations WHERE itl_id = 7"); if (!$qry->recordCount()) { $qry->execute("INSERT INTO `kb3_item_locations` (`itl_id`, `itl_location`) VALUES(7, 'Subsystem Slot')"); $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 954 LIMIT 1"); $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 955 LIMIT 1"); $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 956 LIMIT 1"); $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 957 LIMIT 1"); $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 958 LIMIT 1"); } config::set('007updatestatus', 15); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Subsystem slots added"); $smarty->display('update.tpl'); die; } if (config::get('007updatestatus') < 16) { $qry->execute('SHOW TABLES'); $qry2 = DBFactory::getDBQuery(true); while ($row = $qry->getRow()) { $tablename = implode($row); if ($tablename == 'kb3_inv_all') { $qry2->execute("TRUNCATE kb3_inv_all"); } if ($tablename == 'kb3_inv_crp') { $qry2->execute("TRUNCATE kb3_inv_crp"); } if ($tablename == 'kb3_inv_plt') { $qry2->execute("TRUNCATE kb3_inv_plt"); } } killCache(); config::set("DBUpdate", "007"); $qry->execute("UPDATE kb3_config SET cfg_value = '007' WHERE cfg_key = 'DBUpdate'"); config::del('007updatestatus'); $smarty->assign('refresh', 1); $smarty->assign('content', "7. Empty tables truncated.<br>Update 007 completed."); $smarty->display('update.tpl'); die; } } }