1 | <?php |
---|
2 | define('DB_HALTONERROR', true); |
---|
3 | |
---|
4 | require_once('kbconfig.php'); |
---|
5 | require_once('common/includes/db.php'); |
---|
6 | require_once('common/includes/class.config.php'); |
---|
7 | require_once('common/includes/class.session.php'); |
---|
8 | |
---|
9 | $config = new Config(KB_SITE); |
---|
10 | session::init(); |
---|
11 | $url=$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; |
---|
12 | |
---|
13 | |
---|
14 | if (!session::isAdmin()) |
---|
15 | { |
---|
16 | if (crypt($_POST['usrpass'],ADMIN_PASSWORD) == ADMIN_PASSWORD || $_POST['usrpass'] == ADMIN_PASSWORD) |
---|
17 | { |
---|
18 | session::create(true); |
---|
19 | |
---|
20 | header('Location: http://'.$url); |
---|
21 | die; |
---|
22 | } |
---|
23 | else |
---|
24 | { ?> |
---|
25 | <html><head><title>Upgrade admin login</title></head><body> |
---|
26 | <form method="post" action="http://<?php echo $url; ?>"> |
---|
27 | <table class="kb-subtable"> |
---|
28 | <tr> |
---|
29 | <td width="160"><b>Admin Password:</b></td> |
---|
30 | <td><input type="password" name="usrpass" maxlength="32"></td> |
---|
31 | </tr> |
---|
32 | <tr> |
---|
33 | <td width="160"> </td> |
---|
34 | <td><input type="submit" name="submit" value="Login"></td> |
---|
35 | </tr> |
---|
36 | </table></form></body> |
---|
37 | |
---|
38 | <?php |
---|
39 | die; |
---|
40 | } |
---|
41 | } |
---|
42 | $qry=new DBQuery(true); |
---|
43 | define(CURRENT_DB_UPDATE,config::get("DBUpdate")); |
---|
44 | //Update version of this autoupgrade.php |
---|
45 | // Moved to index.php |
---|
46 | define(LASTEST_DB_UPDATE,"010"); |
---|
47 | updateDB(); |
---|
48 | touch ('install/install.lock'); |
---|
49 | echo "<html><head>"; |
---|
50 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
51 | echo"</head><body>Upgrade complete.<br><a href='".config::get('cfg_kbhost')."'>Return to your board</a></body>"; |
---|
52 | die(); |
---|
53 | |
---|
54 | function updateDB(){ |
---|
55 | // if update nesseary run updates |
---|
56 | if (CURRENT_DB_UPDATE < LASTEST_DB_UPDATE ){ |
---|
57 | update001(); |
---|
58 | update002(); |
---|
59 | update003(); |
---|
60 | update004(); |
---|
61 | update005(); |
---|
62 | |
---|
63 | //Start visual updates |
---|
64 | update007(); |
---|
65 | update008(); |
---|
66 | update009(); |
---|
67 | update010(); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | /* |
---|
72 | * Too much has changed between update005 and current status for a clean |
---|
73 | * update006. Restarting from update007 in the hope that the differences |
---|
74 | * between 5 and 7 are worked out and an update006 implemented |
---|
75 | */ |
---|
76 | |
---|
77 | function update001(){ |
---|
78 | //Checking if this Update already done |
---|
79 | if (CURRENT_DB_UPDATE < "001" ) |
---|
80 | { |
---|
81 | require_once("common/includes/class.item.php"); |
---|
82 | // Changing ShieldBooster Slot from None to Mid Slot |
---|
83 | $ShieldBoosterGroup = item::get_group_id("Small Shield Booster I"); |
---|
84 | update_slot_of_group($ShieldBoosterGroup,0,2); |
---|
85 | |
---|
86 | // Changing Tracking Scripts Slot from None to Mid Slot |
---|
87 | $ScriptGroupID1 = item::get_group_id("Optimal Range"); |
---|
88 | update_slot_of_group($ScriptGroupID1,0,2); |
---|
89 | |
---|
90 | // Changing Warp Disruption Scripts Slot from None to Mid Slot |
---|
91 | $ScriptGroupID2 = item::get_group_id("Focused Warp Disruption"); |
---|
92 | update_slot_of_group($ScriptGroupID2,0,2); |
---|
93 | |
---|
94 | // Changing Tracking Disruption Scripts Slot from None to Mid Slot |
---|
95 | $ScriptGroupID3 = item::get_group_id("Optimal Range Disruption"); |
---|
96 | update_slot_of_group($ScriptGroupID3,0,2); |
---|
97 | |
---|
98 | // Changing Sensor Booster Scripts Slot from None to Mid Slot |
---|
99 | $ScriptGroupID4 = item::get_group_id("Targeting Range"); |
---|
100 | update_slot_of_group($ScriptGroupID4,0,2); |
---|
101 | |
---|
102 | // Changing Sensor Dampener Scripts Slot from None to Mid Slot |
---|
103 | $ScriptGroupID5 = item::get_group_id("Scan Resolution Dampening"); |
---|
104 | update_slot_of_group($ScriptGroupID5,0,2); |
---|
105 | |
---|
106 | // Changing Energy Weapon Slot from None to High Slot |
---|
107 | $EnergyWeaponGroup = item::get_group_id("Gatling Pulse Laser I"); |
---|
108 | update_slot_of_group($EnergyWeaponGroup,0,1); |
---|
109 | |
---|
110 | // Changing Group of Salvager I to same as Small Tractor Beam I |
---|
111 | $item = new Item(); |
---|
112 | $item->lookup("Salvager I"); |
---|
113 | $SalvagerTypeId = $item->getId(); |
---|
114 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
115 | $TractorBeam = item::get_group_id("Small Tractor Beam I"); |
---|
116 | move_item_to_group($SalvagerTypeId,$SalvagerGroup ,$TractorBeam); |
---|
117 | |
---|
118 | //writing Update Status into ConfigDB |
---|
119 | config::set("DBUpdate","001"); |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | function update002(){ |
---|
124 | // to correct the already existing Salvager in med slots. |
---|
125 | // missed it in update001 |
---|
126 | if (CURRENT_DB_UPDATE < "002" ) |
---|
127 | { |
---|
128 | require_once("common/includes/class.item.php"); |
---|
129 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
130 | update_slot_of_group($SalvagerGroup,2,1); |
---|
131 | config::set("DBUpdate","002"); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | function update003(){ |
---|
136 | // Warefare Links and Command Prozessor were midslot items in install file, should be high slot |
---|
137 | if (CURRENT_DB_UPDATE < "003" ) |
---|
138 | { |
---|
139 | require_once("common/includes/class.item.php"); |
---|
140 | $WarfareLinkGroup = item::get_group_id("Skirmish Warfare Link - Rapid Deployment"); |
---|
141 | update_slot_of_group($WarfareLinkGroup,2,1); |
---|
142 | config::set("DBUpdate","003"); |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | function update004(){ |
---|
147 | // new trinity ships are wrong saved as T1 shipes |
---|
148 | if (CURRENT_DB_UPDATE < "004" ) |
---|
149 | { |
---|
150 | $qry = new DBQuery(); |
---|
151 | |
---|
152 | $query = "UPDATE kb3_ships |
---|
153 | INNER JOIN kb3_ship_classes ON scl_id = shp_class |
---|
154 | SET shp_techlevel = 2 |
---|
155 | WHERE scl_class IN ('Electronic Attack Ship','Heavy Interdictor','Black Ops','Marauder','Heavy Interdictor','Jump Freighter') |
---|
156 | AND shp_techlevel = 1;"; |
---|
157 | $qry->execute($query); |
---|
158 | config::set("DBUpdate","004"); |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | function update005(){ |
---|
163 | // Blueprints and small fixes |
---|
164 | if (CURRENT_DB_UPDATE < "005" ) |
---|
165 | { |
---|
166 | $qry = new DBQuery(); |
---|
167 | $query = <<<EOF |
---|
168 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29249, 105, 'Magnate Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
169 | |
---|
170 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29267, 111, 'Apotheosis Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
171 | |
---|
172 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29338, 106, 'Omen Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
173 | |
---|
174 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29339, 106, 'Scythe Fleet Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
175 | |
---|
176 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29341, 106, 'Osprey Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
177 | |
---|
178 | INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29345, 106, 'Exequror Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0); |
---|
179 | |
---|
180 | INSERT INTO `kb3_dgmtypeattributes` (`typeID`, `attributeID`, `value`) VALUES ('29249', '422', '1'); |
---|
181 | |
---|
182 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='180'; |
---|
183 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='181'; |
---|
184 | |
---|
185 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='182'; |
---|
186 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='183'; |
---|
187 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='184'; |
---|
188 | |
---|
189 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='228'; |
---|
190 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='229'; |
---|
191 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='230'; |
---|
192 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='231'; |
---|
193 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='232'; |
---|
194 | |
---|
195 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='277'; |
---|
196 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='278'; |
---|
197 | UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='279'; |
---|
198 | |
---|
199 | UPDATE `kb3_dgmattributetypes` SET `icon` = '04_12' WHERE `attributeID`='193'; |
---|
200 | UPDATE `kb3_dgmattributetypes` SET `icon` = '04_12' WHERE `attributeID`='235'; |
---|
201 | |
---|
202 | UPDATE `kb3_dgmattributetypes` SET `icon` = '22_14' WHERE `attributeID`='108'; |
---|
203 | UPDATE `kb3_dgmattributetypes` SET `icon` = '22_14' WHERE `attributeID`='197'; |
---|
204 | |
---|
205 | UPDATE `kb3_dgmattributetypes` SET `icon` = '07_15' WHERE `attributeID`='137'; |
---|
206 | |
---|
207 | UPDATE `kb3_dgmattributetypes` SET `icon` = '24_01' WHERE `attributeID`='77'; |
---|
208 | |
---|
209 | UPDATE `kb3_dgmattributetypes` SET `icon` = '22_08' WHERE `attributeID`='153'; |
---|
210 | |
---|
211 | UPDATE `kb3_dgmattributetypes` SET `icon` = '07_15' WHERE `attributeID`='484'; |
---|
212 | EOF; |
---|
213 | |
---|
214 | $qry->execute($query); |
---|
215 | config::set("DBUpdate","005"); |
---|
216 | |
---|
217 | } |
---|
218 | } |
---|
219 | |
---|
220 | function update007() |
---|
221 | { |
---|
222 | //Checking if this Update already done |
---|
223 | if (CURRENT_DB_UPDATE < "007" ) |
---|
224 | { |
---|
225 | $qry = new DBQuery(true); |
---|
226 | if(!config::get('007updatestatus')) |
---|
227 | { |
---|
228 | config::set('007updatestatus',0); |
---|
229 | // Add columns for external ids. |
---|
230 | $qry->execute("SHOW COLUMNS FROM kb3_alliances LIKE 'all_external_id'"); |
---|
231 | if(!$qry->recordCount()) |
---|
232 | { |
---|
233 | $sql = "ALTER TABLE `kb3_alliances` ". |
---|
234 | "ADD `all_external_id` INT( 11 ) UNSIGNED NULL ". |
---|
235 | "DEFAULT NULL , ADD UNIQUE ( all_external_id )"; |
---|
236 | $qry->execute($sql); |
---|
237 | } |
---|
238 | |
---|
239 | $qry->execute("SHOW COLUMNS FROM kb3_corps LIKE 'crp_external_id'"); |
---|
240 | if(!$qry->recordCount()) |
---|
241 | { |
---|
242 | $sql = "ALTER TABLE `kb3_corps` ". |
---|
243 | "ADD `crp_external_id` INT( 11 ) UNSIGNED NULL ". |
---|
244 | "DEFAULT NULL , ADD UNIQUE ( crp_external_id )"; |
---|
245 | $qry->execute($sql); |
---|
246 | } |
---|
247 | |
---|
248 | $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_external_id'"); |
---|
249 | if(!$qry->recordCount()) |
---|
250 | { |
---|
251 | $sql = "ALTER TABLE `kb3_kills` ". |
---|
252 | "ADD `kll_external_id` INT( 11 ) UNSIGNED NULL ". |
---|
253 | "DEFAULT NULL , ADD UNIQUE ( kll_external_id )"; |
---|
254 | $qry->execute($sql); |
---|
255 | } |
---|
256 | config::set('007updatestatus',1); |
---|
257 | echo "<html><head>"; |
---|
258 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
259 | echo"</head><body>7. External ID columns added</body>"; |
---|
260 | die(); |
---|
261 | } |
---|
262 | // Add isk loss column to kb3_kills |
---|
263 | if(config::get('007updatestatus') <8) |
---|
264 | { |
---|
265 | // Update price with items destroyed and ship value, excluding |
---|
266 | // blueprints since default cost is for BPO and BPC looks identical |
---|
267 | $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_ship` ( |
---|
268 | `kll_id` int(11) NOT NULL DEFAULT '0', |
---|
269 | `value` float NOT NULL DEFAULT '0', |
---|
270 | PRIMARY KEY (`kll_id`) |
---|
271 | ) ENGINE=MyISAM"; |
---|
272 | $qry->execute($sql); |
---|
273 | $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_destroyed` ( |
---|
274 | `kll_id` int(11) NOT NULL DEFAULT '0', |
---|
275 | `value` float NOT NULL DEFAULT '0', |
---|
276 | PRIMARY KEY (`kll_id`) |
---|
277 | ) ENGINE=MyISAM"; |
---|
278 | $qry->execute($sql); |
---|
279 | $sql = "CREATE TABLE IF NOT EXISTS `tmp_price_dropped` ( |
---|
280 | `kll_id` int(11) NOT NULL DEFAULT '0', |
---|
281 | `value` float NOT NULL DEFAULT '0', |
---|
282 | PRIMARY KEY (`kll_id`) |
---|
283 | ) ENGINE=MyISAM"; |
---|
284 | $qry->execute($sql); |
---|
285 | $qry->execute("LOCK TABLES tmp_price_ship WRITE, tmp_price_destroyed WRITE, |
---|
286 | tmp_price_dropped WRITE, kb3_kills WRITE, kb3_ships WRITE, |
---|
287 | kb3_ships_values WRITE, kb3_items_destroyed WRITE, kb3_items_dropped WRITE, |
---|
288 | kb3_invtypes WRITE, kb3_item_price WRITE, kb3_config WRITE"); |
---|
289 | if(config::get('007updatestatus') <3) |
---|
290 | { |
---|
291 | $qry->execute("INSERT IGNORE INTO tmp_price_ship select |
---|
292 | kll_id,if(isnull(shp_value),shp_baseprice,shp_value) FROM kb3_kills |
---|
293 | INNER JOIN kb3_ships ON kb3_ships.shp_id = kll_ship_id |
---|
294 | LEFT JOIN kb3_ships_values ON kb3_ships_values.shp_id = kll_ship_id"); |
---|
295 | $qry->execute($sql); |
---|
296 | config::set('007updatestatus',3); |
---|
297 | echo "<html><head>"; |
---|
298 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
299 | echo"</head><body>7. Kill values: Ship prices calculated</body>"; |
---|
300 | die(); |
---|
301 | } |
---|
302 | if(config::get('007updatestatus') <4) |
---|
303 | { |
---|
304 | $sql = "INSERT IGNORE INTO tmp_price_destroyed |
---|
305 | SELECT itd_kll_id, |
---|
306 | sum(if(typeName LIKE '%Blueprint%',0,if(isnull(itd_quantity), |
---|
307 | 0,itd_quantity * if(price = 0 OR isnull(price),basePrice,price)))) |
---|
308 | FROM kb3_items_destroyed |
---|
309 | LEFT JOIN kb3_item_price ON kb3_item_price.typeID = itd_itm_id |
---|
310 | LEFT JOIN kb3_invtypes ON itd_itm_id = kb3_invtypes.typeID |
---|
311 | GROUP BY itd_kll_id"; |
---|
312 | $qry->execute($sql); |
---|
313 | config::set('007updatestatus',4); |
---|
314 | echo "<html><head>"; |
---|
315 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
316 | echo"</head><body>7. Kill values: Destroyed item prices calculated</body>"; |
---|
317 | die(); |
---|
318 | } |
---|
319 | if(config::get('007updatestatus') <5) |
---|
320 | { |
---|
321 | if(config::get(kd_droptototal)) |
---|
322 | { |
---|
323 | $action = "calculated"; |
---|
324 | $sql = "INSERT INTO tmp_price_dropped |
---|
325 | SELECT itd_kll_id, |
---|
326 | sum(if(typeName LIKE '%Blueprint%',0,if(isnull(itd_quantity), |
---|
327 | 0,itd_quantity * if(price = 0 OR isnull(price),basePrice,price)))) |
---|
328 | FROM kb3_items_dropped |
---|
329 | LEFT JOIN kb3_item_price ON kb3_item_price.typeID = itd_itm_id |
---|
330 | LEFT JOIN kb3_invtypes ON itd_itm_id = kb3_invtypes.typeID |
---|
331 | GROUP BY itd_kll_id"; |
---|
332 | $qry->execute($sql); |
---|
333 | } |
---|
334 | else $action = "ignored"; |
---|
335 | config::set('007updatestatus',5); |
---|
336 | echo "<html><head>"; |
---|
337 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
338 | echo"</head><body>7. Kill values: Dropped item prices $action</body>"; |
---|
339 | die(); |
---|
340 | } |
---|
341 | if(config::get('007updatestatus') <7) |
---|
342 | { |
---|
343 | $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_isk_loss'"); |
---|
344 | if(!$qry->recordCount()) |
---|
345 | { |
---|
346 | $qry->execute("ALTER TABLE `kb3_kills` ADD `kll_isk_loss` FLOAT NOT NULL DEFAULT '0'"); |
---|
347 | config::set('007updatestatus',7); |
---|
348 | echo "<html><head>"; |
---|
349 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
350 | echo"</head><body>7. Kill values: ISK column created</body>"; |
---|
351 | die(); |
---|
352 | } |
---|
353 | config::set('007updatestatus',7); |
---|
354 | echo "<html><head>"; |
---|
355 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
356 | echo"</head><body>7. Kill values: ISK column already exists.</body>"; |
---|
357 | die(); |
---|
358 | } |
---|
359 | if(config::get('007updatestatus') <8) |
---|
360 | { |
---|
361 | $sql = 'UPDATE kb3_kills |
---|
362 | natural join tmp_price_ship |
---|
363 | natural left join tmp_price_destroyed '; |
---|
364 | if(config::get(kd_droptototal)) $sql .= ' natural left join tmp_price_dropped '; |
---|
365 | $sql .= 'SET kb3_kills.kll_isk_loss = tmp_price_ship.value + ifnull(tmp_price_destroyed.value,0) '; |
---|
366 | if(config::get(kd_droptototal)) $sql .= ' + ifnull(tmp_price_dropped.value,0) '; |
---|
367 | $qry->execute ($sql); |
---|
368 | $qry->execute("UNLOCK TABLES"); |
---|
369 | $qry->execute('DROP TABLE tmp_price_ship'); |
---|
370 | $qry->execute('DROP TABLE tmp_price_destroyed'); |
---|
371 | $qry->execute('DROP TABLE tmp_price_dropped'); |
---|
372 | config::set('007updatestatus',8); |
---|
373 | echo "<html><head>"; |
---|
374 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
375 | echo"</head><body>7. Kill values: Totals updated</body>"; |
---|
376 | die(); |
---|
377 | } |
---|
378 | } |
---|
379 | if(config::get('007updatestatus') <9) |
---|
380 | { |
---|
381 | $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_fb_crp_id'"); |
---|
382 | if($qry->recordCount()) $qry->execute("ALTER TABLE `kb3_kills` DROP `kll_fb_crp_id`"); |
---|
383 | config::set('007updatestatus',9); |
---|
384 | echo "<html><head>"; |
---|
385 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
386 | echo"</head><body>7. kll_fb_crp_id column dropped</body>"; |
---|
387 | die(); |
---|
388 | } |
---|
389 | if(config::get('007updatestatus') <10) |
---|
390 | { |
---|
391 | $qry->execute("SHOW COLUMNS FROM kb3_kills LIKE 'kll_fb_all_id'"); |
---|
392 | if($qry->recordCount()) $qry->execute("ALTER TABLE `kb3_kills` DROP `kll_fb_all_id`"); |
---|
393 | config::set('007updatestatus',10); |
---|
394 | echo "<html><head>"; |
---|
395 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
396 | echo"</head><body>7. kll_fb_all_id column dropped</body>"; |
---|
397 | die(); |
---|
398 | } |
---|
399 | if(config::get('007updatestatus') <11) |
---|
400 | { |
---|
401 | // Drop unused columns |
---|
402 | $qry->execute("SHOW COLUMNS FROM kb3_corps LIKE 'crp_trial'"); |
---|
403 | if($qry->recordCount()) $qry->execute("ALTER TABLE kb3_corps DROP crp_trial"); |
---|
404 | $qry->execute("SHOW COLUMNS FROM kb3_pilots LIKE 'plt_killpoints'"); |
---|
405 | if($qry->recordCount()) $qry->execute("ALTER TABLE kb3_pilots DROP plt_killpoints"); |
---|
406 | $qry->execute("SHOW COLUMNS FROM kb3_pilots LIKE 'plt_losspoints'"); |
---|
407 | if($qry->recordCount()) $qry->execute("ALTER TABLE kb3_pilots DROP plt_losspoints"); |
---|
408 | config::set('007updatestatus',11); |
---|
409 | echo "<html><head>"; |
---|
410 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
411 | echo"</head><body>7. Unused crp and plt columns dropped</body>"; |
---|
412 | die(); |
---|
413 | } |
---|
414 | |
---|
415 | // Add corp and alliance index to kb3_inv_detail |
---|
416 | $qry->execute("SHOW INDEX FROM kb3_inv_detail"); |
---|
417 | |
---|
418 | $indexcexists = false; |
---|
419 | $indexaexists = false; |
---|
420 | while($testresult = $qry->getRow()) |
---|
421 | if($testresult['Column_name'] == 'ind_crp_id') |
---|
422 | $indexcexists = true; |
---|
423 | if($testresult['Column_name'] == 'ind_all_id') |
---|
424 | $indexaexists = true; |
---|
425 | if(config::get('007updatestatus') <12) |
---|
426 | { |
---|
427 | if(!indexcexists) |
---|
428 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_crp_id` ) "); |
---|
429 | config::set('007updatestatus',12); |
---|
430 | echo "<html><head>"; |
---|
431 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
432 | echo"</head><body>7. kb3_inv_detail ind_crp_id index added</body>"; |
---|
433 | die(); |
---|
434 | } |
---|
435 | if(config::get('007updatestatus') <13) |
---|
436 | { |
---|
437 | if(!indexaexists) |
---|
438 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_all_id` ) "); |
---|
439 | config::set('007updatestatus',13); |
---|
440 | echo "<html><head>"; |
---|
441 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
442 | echo"</head><body>7. kb3_inv_detail ind_all_id index added</body>"; |
---|
443 | die(); |
---|
444 | } |
---|
445 | if(config::get('007updatestatus') <14) |
---|
446 | { |
---|
447 | // Add table for api cache |
---|
448 | $sql = "CREATE TABLE IF NOT EXISTS `kb3_apicache` ( |
---|
449 | `cfg_site` varchar(16) NOT NULL default '', |
---|
450 | `cfg_key` varchar(32) NOT NULL default '', |
---|
451 | `cfg_value` text NOT NULL, |
---|
452 | PRIMARY KEY (`cfg_site`,`cfg_key`) |
---|
453 | )"; |
---|
454 | $qry->execute($sql); |
---|
455 | $qry->execute("CREATE TABLE IF NOT EXISTS `kb3_apilog` ( |
---|
456 | `log_site` VARCHAR( 20 ) NOT NULL , |
---|
457 | `log_keyname` VARCHAR( 20 ) NOT NULL , |
---|
458 | `log_posted` INT NOT NULL , |
---|
459 | `log_errors` INT NOT NULL , |
---|
460 | `log_ignored` INT NOT NULL , |
---|
461 | `log_verified` INT NOT NULL , |
---|
462 | `log_totalmails` INT NOT NULL , |
---|
463 | `log_source` VARCHAR( 20 ) NOT NULL , |
---|
464 | `log_type` VARCHAR( 20 ) NOT NULL , |
---|
465 | `log_timestamp` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' |
---|
466 | ) ENGINE = MYISAM "); |
---|
467 | |
---|
468 | // set API update complete |
---|
469 | config::set('API_DBUpdate', '1'); |
---|
470 | config::set('007updatestatus',14); |
---|
471 | echo "<html><head>"; |
---|
472 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
473 | echo"</head><body>7. API tables added</body>"; |
---|
474 | die(); |
---|
475 | } |
---|
476 | if(config::get('007updatestatus') <15) |
---|
477 | { |
---|
478 | |
---|
479 | // Add subsystem slot |
---|
480 | $qry->execute("SELECT 1 FROM kb3_item_locations WHERE itl_id = 7"); |
---|
481 | if(!$qry->recordCount()) |
---|
482 | { |
---|
483 | $qry->execute("INSERT INTO `kb3_item_locations` (`itl_id`, `itl_location`) VALUES(7, 'Subsystem Slot')"); |
---|
484 | $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 954 LIMIT 1"); |
---|
485 | $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 955 LIMIT 1"); |
---|
486 | $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 956 LIMIT 1"); |
---|
487 | $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 957 LIMIT 1"); |
---|
488 | $qry->execute("UPDATE `kb3_item_types` SET `itt_slot` = '7' WHERE `kb3_item_types`.`itt_id` = 958 LIMIT 1"); |
---|
489 | } |
---|
490 | config::set('007updatestatus',15); |
---|
491 | echo "<html><head>"; |
---|
492 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
493 | echo"</head><body>7. Subsystem slots added</body>"; |
---|
494 | die(); |
---|
495 | } |
---|
496 | if(config::get('007updatestatus') <16) |
---|
497 | { |
---|
498 | $qry->execute('SHOW TABLES'); |
---|
499 | $qry2 = new DBQuery(true); |
---|
500 | while($row = $qry->getRow()) |
---|
501 | { |
---|
502 | $tablename = implode($row); |
---|
503 | if($tablename == 'kb3_inv_all') $qry2->execute("TRUNCATE kb3_inv_all"); |
---|
504 | if($tablename == 'kb3_inv_crp') $qry2->execute("TRUNCATE kb3_inv_crp"); |
---|
505 | if($tablename == 'kb3_inv_plt') $qry2->execute("TRUNCATE kb3_inv_plt"); |
---|
506 | } |
---|
507 | killCache(); |
---|
508 | config::set("DBUpdate","007"); |
---|
509 | config::del('007updatestatus'); |
---|
510 | echo "<html><head>"; |
---|
511 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
512 | echo"</head><body>7. Empty tables truncated.<br>Update 007 completed.</body>"; |
---|
513 | die(); |
---|
514 | } |
---|
515 | } |
---|
516 | } |
---|
517 | // Add unique name indices to alliance, corp and pilot |
---|
518 | // Check kb3_inv_detail has correct indices |
---|
519 | function update008() |
---|
520 | { |
---|
521 | //Checking if this Update already done |
---|
522 | if (CURRENT_DB_UPDATE < "008" ) |
---|
523 | { |
---|
524 | |
---|
525 | if(!config::get('008updatestatus')) config::set('008updatestatus',0); |
---|
526 | $qry = new DBQuery(true); |
---|
527 | |
---|
528 | if(config::get('008updatestatus') <1) |
---|
529 | { |
---|
530 | // Add pilot, corp and alliance index to kb3_inv_detail |
---|
531 | // Incomplete in update007 |
---|
532 | $qry->execute("SHOW INDEXES FROM kb3_inv_detail"); |
---|
533 | $indexcexists = false; |
---|
534 | $indexaexists = false; |
---|
535 | $indexpexists = false; |
---|
536 | $indexkexists = false; |
---|
537 | while($testresult = $qry->getRow()) |
---|
538 | { |
---|
539 | if($testresult['Column_name'] == 'ind_kll_id' && $testresult['Seq_in_index'] == 1) |
---|
540 | $indexkexists = true; |
---|
541 | if($testresult['Column_name'] == 'ind_crp_id' && $testresult['Seq_in_index'] == 1) |
---|
542 | $indexcexists = true; |
---|
543 | if($testresult['Column_name'] == 'ind_all_id' && $testresult['Seq_in_index'] == 1) |
---|
544 | $indexaexists = true; |
---|
545 | if($testresult['Column_name'] == 'ind_plt_id' && $testresult['Seq_in_index'] == 1) |
---|
546 | $indexpexists = true; |
---|
547 | } |
---|
548 | // |
---|
549 | if(!indexkexists) |
---|
550 | { |
---|
551 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_kll_id`, `ind_order` ) "); |
---|
552 | echo "<html><head>"; |
---|
553 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
554 | echo"</head><body>8. kb3_inv_detail index id_order added</body>"; |
---|
555 | die(); |
---|
556 | } |
---|
557 | if(!indexcexists) |
---|
558 | { |
---|
559 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_crp_id` ) "); |
---|
560 | echo "<html><head>"; |
---|
561 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
562 | echo"</head><body>8. kb3_inv_detail index id_order added</body>"; |
---|
563 | die(); |
---|
564 | } |
---|
565 | if(!indexaexists) |
---|
566 | { |
---|
567 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_all_id` ) "); |
---|
568 | echo "<html><head>"; |
---|
569 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
570 | echo"</head><body>8. kb3_inv_detail index id_order added</body>"; |
---|
571 | die(); |
---|
572 | } |
---|
573 | if(!indexpexists) |
---|
574 | { |
---|
575 | $qry->execute("ALTER TABLE `kb3_inv_detail` ADD INDEX ( `ind_plt_id` ) "); |
---|
576 | echo "<html><head>"; |
---|
577 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
578 | echo"</head><body>8. kb3_inv_detail index id_order added</body>"; |
---|
579 | die(); |
---|
580 | } |
---|
581 | config::set('008updatestatus', 1); |
---|
582 | } |
---|
583 | |
---|
584 | $qry->execute("SHOW INDEXES FROM kb3_corps"); |
---|
585 | $indexaexists = false; |
---|
586 | while($testresult = $qry->getRow()) |
---|
587 | { |
---|
588 | if($testresult['Column_name'] == 'crp_name' && $testresult['Non_unique'] == 0) |
---|
589 | $indexcexists = true; |
---|
590 | } |
---|
591 | if(!$indexcexists) |
---|
592 | { |
---|
593 | $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'; |
---|
594 | |
---|
595 | if(config::get('008updatestatus') <2) |
---|
596 | { |
---|
597 | $qry->execute('update kb3_inv_detail join ('.$sqlcrp.') c on c.oldid = ind_crp_id set ind_crp_id = c.newid'); |
---|
598 | config::set('008updatestatus', 2); |
---|
599 | echo "<html><head>"; |
---|
600 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
601 | echo"</head><body>8. Unique corp names: updated kb3_inv_detail</body>"; |
---|
602 | die(); |
---|
603 | } |
---|
604 | if(config::get('008updatestatus') <3) |
---|
605 | { |
---|
606 | $qry->execute('update kb3_pilots join ('.$sqlcrp.') c on (c.oldid = plt_crp_id) set plt_crp_id = c.newid'); |
---|
607 | config::set('008updatestatus', 3); |
---|
608 | echo "<html><head>"; |
---|
609 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
610 | echo"</head><body>8. Unique corp names: updated kb3_pilots</body>"; |
---|
611 | die(); |
---|
612 | } |
---|
613 | if(config::get('008updatestatus') <4) |
---|
614 | { |
---|
615 | $qry->execute('update kb3_kills join ('.$sqlcrp.') c on (c.oldid = kll_crp_id) set kll_crp_id = c.newid'); |
---|
616 | config::set('008updatestatus', 4); |
---|
617 | echo "<html><head>"; |
---|
618 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
619 | echo"</head><body>8. Unique corp names: updated kb3_kills</body>"; |
---|
620 | die(); |
---|
621 | } |
---|
622 | if(config::get('008updatestatus') <6) |
---|
623 | { |
---|
624 | $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'); |
---|
625 | config::set('008updatestatus', 6); |
---|
626 | echo "<html><head>"; |
---|
627 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
628 | echo"</head><body>8. Unique corp names: updated kb3_corps</body>"; |
---|
629 | die(); |
---|
630 | } |
---|
631 | if(config::get('008updatestatus') <7) |
---|
632 | { |
---|
633 | $qry->execute("SHOW INDEXES FROM kb3_corps"); |
---|
634 | $indexcexists = false; |
---|
635 | while($testresult = $qry->getRow()) |
---|
636 | { |
---|
637 | if($testresult['Column_name'] == 'crp_name' && $testresult['Seq_in_index'] == 1) |
---|
638 | { |
---|
639 | $indexcname = $testresult['Key_name']; |
---|
640 | $indexcexists = true; |
---|
641 | } |
---|
642 | // Don't replace a custom multi-column index. |
---|
643 | elseif($testresult['Key_name'] == $indexcname && $testresult['Seq_in_index'] == 2) |
---|
644 | $indexcexists = false; |
---|
645 | } |
---|
646 | if($indexcexists) $qry->execute("ALTER TABLE `kb3_corps` DROP INDEX `".$indexcname."`"); |
---|
647 | $qry->execute("ALTER TABLE `kb3_corps` ADD UNIQUE INDEX ( `crp_name` ) "); |
---|
648 | |
---|
649 | |
---|
650 | config::set('008updatestatus', 7); |
---|
651 | echo "<html><head>"; |
---|
652 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
653 | echo"</head><body>8. Unique corp names: unique index added to kb3_corps</body>"; |
---|
654 | die(); |
---|
655 | } |
---|
656 | } |
---|
657 | // Make kb3_alliances.all_name unique without losing kills |
---|
658 | $qry->execute("SHOW INDEXES FROM kb3_alliances"); |
---|
659 | $indexaexists = false; |
---|
660 | while($testresult = $qry->getRow()) |
---|
661 | { |
---|
662 | if($testresult['Column_name'] == 'all_name' && $testresult['Non_unique'] == 0) |
---|
663 | $indexaexists = true; |
---|
664 | } |
---|
665 | if(!$indexaexists) |
---|
666 | { |
---|
667 | $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'; |
---|
668 | if(config::get('008updatestatus') <8) |
---|
669 | { |
---|
670 | $qry->execute('update kb3_inv_detail join ('.$sqlall.') c on c.oldid = ind_all_id set ind_all_id = c.newid'); |
---|
671 | config::set('008updatestatus', 8); |
---|
672 | echo "<html><head>"; |
---|
673 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
674 | echo"</head><body>8. Unique all names: updated kb3_inv_detail</body>"; |
---|
675 | die(); |
---|
676 | } |
---|
677 | if(config::get('008updatestatus') <9) |
---|
678 | { |
---|
679 | $qry->execute('update kb3_corps join ('.$sqlall.') c on (c.oldid = crp_all_id) set crp_all_id = c.newid'); |
---|
680 | config::set('008updatestatus', 9); |
---|
681 | echo "<html><head>"; |
---|
682 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
683 | echo"</head><body>8. Unique all names: updated kb3_corps</body>"; |
---|
684 | die(); |
---|
685 | } |
---|
686 | if(config::get('008updatestatus') <10) |
---|
687 | { |
---|
688 | $qry->execute('update kb3_kills join ('.$sqlall.') c on (c.oldid = kll_all_id) set kll_all_id = c.newid'); |
---|
689 | config::set('008updatestatus', 10); |
---|
690 | echo "<html><head>"; |
---|
691 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
692 | echo"</head><body>8. Unique all names: updated kb3_kills</body>"; |
---|
693 | die(); |
---|
694 | } |
---|
695 | |
---|
696 | if(config::get('008updatestatus') <12) |
---|
697 | { |
---|
698 | $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'); |
---|
699 | config::set('008updatestatus', 12); |
---|
700 | echo "<html><head>"; |
---|
701 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
702 | echo"</head><body>8. Unique all names: updated kb3_alliances</body>"; |
---|
703 | die(); |
---|
704 | } |
---|
705 | if(config::get('008updatestatus') <13) |
---|
706 | { |
---|
707 | $qry->execute("SHOW INDEXES FROM kb3_alliances"); |
---|
708 | $indexaexists = false; |
---|
709 | while($testresult = $qry->getRow()) |
---|
710 | { |
---|
711 | if($testresult['Column_name'] == 'all_name' && $testresult['Seq_in_index'] == 1) |
---|
712 | { |
---|
713 | $indexaname = $testresult['Key_name']; |
---|
714 | $indexaexists = true; |
---|
715 | } |
---|
716 | // Don't replace a custom multi-column index. |
---|
717 | elseif($testresult['Key_name'] == $indexaname && $testresult['Seq_in_index'] == 2) |
---|
718 | $indexaexists = false; |
---|
719 | } |
---|
720 | if($indexaexists) $qry->execute("ALTER TABLE `kb3_alliances` DROP INDEX `".$indexaname."`"); |
---|
721 | $qry->execute("ALTER TABLE `kb3_alliances` ADD UNIQUE INDEX ( `all_name` ) "); |
---|
722 | config::set('008updatestatus', 13); |
---|
723 | echo "<html><head>"; |
---|
724 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
725 | echo"</head><body>8. Unique all names: unique index applied to kb3_alliances</body>"; |
---|
726 | die(); |
---|
727 | } |
---|
728 | } |
---|
729 | |
---|
730 | // Make kb3_pilots.plt_name unique without losing kills |
---|
731 | $qry->execute("SHOW INDEXES FROM kb3_pilots"); |
---|
732 | $indexaexists = false; |
---|
733 | while($testresult = $qry->getRow()) |
---|
734 | { |
---|
735 | if($testresult['Column_name'] == 'plt_name' && $testresult['Non_unique'] == 0) |
---|
736 | $indexaexists = true; |
---|
737 | } |
---|
738 | if(!$indexaexists) |
---|
739 | { |
---|
740 | $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'; |
---|
741 | if(config::get('008updatestatus') <14) |
---|
742 | { |
---|
743 | $qry->execute('update kb3_inv_detail join ('.$sqlplt.') c on c.oldid = ind_plt_id set ind_plt_id = c.newid'); |
---|
744 | config::set('008updatestatus', 14); |
---|
745 | echo "<html><head>"; |
---|
746 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
747 | echo"</head><body>8. Unique plt names: updated kb3_inv_detail</body>"; |
---|
748 | die(); |
---|
749 | } |
---|
750 | if(config::get('008updatestatus') <15) |
---|
751 | { |
---|
752 | $qry->execute('update kb3_kills join ('.$sqlplt.') c on (c.oldid = kll_victim_id) set kll_victim_id = c.newid'); |
---|
753 | config::set('008updatestatus', 15); |
---|
754 | echo "<html><head>"; |
---|
755 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
756 | echo"</head><body>8. Unique plt names: updated kb3_kills victim</body>"; |
---|
757 | die(); |
---|
758 | } |
---|
759 | if(config::get('008updatestatus') <16) |
---|
760 | { |
---|
761 | $qry->execute('update kb3_kills join ('.$sqlplt.') c on (c.oldid = kll_fb_plt_id) set kll_fb_plt_id = c.newid'); |
---|
762 | config::set('008updatestatus', 16); |
---|
763 | echo "<html><head>"; |
---|
764 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
765 | echo"</head><body>8. Unique plt names: updated kb3_kills killer</body>"; |
---|
766 | die(); |
---|
767 | } |
---|
768 | if(config::get('008updatestatus') <17) |
---|
769 | { |
---|
770 | $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'); |
---|
771 | config::set('008updatestatus', 17); |
---|
772 | echo "<html><head>"; |
---|
773 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
774 | echo"</head><body>8. Unique plt names: updated kb3_pilots</body>"; |
---|
775 | die(); |
---|
776 | } |
---|
777 | if(config::get('008updatestatus') <18) |
---|
778 | { |
---|
779 | $qry->execute("SHOW INDEXES FROM kb3_pilots"); |
---|
780 | $indexpexists = false; |
---|
781 | while($testresult = $qry->getRow()) |
---|
782 | { |
---|
783 | if($testresult['Column_name'] == 'plt_name' && $testresult['Seq_in_index'] == 1) |
---|
784 | { |
---|
785 | $indexpname = $testresult['Key_name']; |
---|
786 | $indexpexists = true; |
---|
787 | } |
---|
788 | // Don't replace a custom multi-column index. |
---|
789 | elseif($testresult['Key_name'] == $indexpname && $testresult['Seq_in_index'] == 2) |
---|
790 | $indexpexists = false; |
---|
791 | } |
---|
792 | if($indexpexists) $qry->execute("ALTER TABLE `kb3_pilots` DROP INDEX `".$indexpname."`"); |
---|
793 | $qry->execute("ALTER TABLE `kb3_pilots` ADD UNIQUE INDEX ( `plt_name` ) "); |
---|
794 | config::set('008updatestatus', 18); |
---|
795 | echo "<html><head>"; |
---|
796 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
797 | echo"</head><body>8. Unique plt names: unique index applied to kb3_pilots.<br>Update 8 applied.</body>"; |
---|
798 | die(); |
---|
799 | } |
---|
800 | } |
---|
801 | config::set('cache_update', '*'); |
---|
802 | config::set('cache_time', '10'); |
---|
803 | |
---|
804 | killCache(); |
---|
805 | config::set("DBUpdate", "008"); |
---|
806 | config::del("008updatestatus"); |
---|
807 | } |
---|
808 | } |
---|
809 | |
---|
810 | // Add alliance and corp summary tables. |
---|
811 | function update009() |
---|
812 | { |
---|
813 | //Checking if this Update already done |
---|
814 | if (CURRENT_DB_UPDATE < "009" ) |
---|
815 | { |
---|
816 | $qry = new DBQuery(); |
---|
817 | $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_alliance` ( |
---|
818 | `asm_all_id` int(11) NOT NULL DEFAULT '0', |
---|
819 | `asm_shp_id` int(3) NOT NULL DEFAULT '0', |
---|
820 | `asm_kill_count` int(11) NOT NULL DEFAULT '0', |
---|
821 | `asm_kill_isk` float NOT NULL DEFAULT '0', |
---|
822 | `asm_loss_count` int(11) NOT NULL DEFAULT '0', |
---|
823 | `asm_loss_isk` float NOT NULL DEFAULT '0', |
---|
824 | PRIMARY KEY (`asm_all_id`,`asm_shp_id`) |
---|
825 | ) ENGINE=InnoDB"; |
---|
826 | $qry->execute($sql); |
---|
827 | $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_corp` ( |
---|
828 | `csm_crp_id` int(11) NOT NULL DEFAULT '0', |
---|
829 | `csm_shp_id` int(3) NOT NULL DEFAULT '0', |
---|
830 | `csm_kill_count` int(11) NOT NULL DEFAULT '0', |
---|
831 | `csm_kill_isk` float NOT NULL DEFAULT '0', |
---|
832 | `csm_loss_count` int(11) NOT NULL DEFAULT '0', |
---|
833 | `csm_loss_isk` float NOT NULL DEFAULT '0', |
---|
834 | PRIMARY KEY (`csm_crp_id`,`csm_shp_id`) |
---|
835 | ) ENGINE=InnoDB"; |
---|
836 | $qry->execute($sql); |
---|
837 | config::set("DBUpdate", "009"); |
---|
838 | echo "<html><head>"; |
---|
839 | echo "<meta http-equiv='refresh' content='5;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."' />"; |
---|
840 | echo"</head><body>9. Update 9 applied.</body>"; |
---|
841 | die(); |
---|
842 | } |
---|
843 | } |
---|
844 | |
---|
845 | // Add alliance and corp summary tables. |
---|
846 | function update010() |
---|
847 | { |
---|
848 | //Checking if this Update already done |
---|
849 | if (CURRENT_DB_UPDATE < "010" ) |
---|
850 | { |
---|
851 | $qry = new DBQuery(); |
---|
852 | $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_pilot` ( |
---|
853 | `psm_plt_id` int(11) NOT NULL DEFAULT '0', |
---|
854 | `psm_shp_id` int(3) NOT NULL DEFAULT '0', |
---|
855 | `psm_kill_count` int(11) NOT NULL DEFAULT '0', |
---|
856 | `psm_kill_isk` float NOT NULL DEFAULT '0', |
---|
857 | `psm_loss_count` int(11) NOT NULL DEFAULT '0', |
---|
858 | `psm_loss_isk` float NOT NULL DEFAULT '0', |
---|
859 | PRIMARY KEY (`psm_plt_id`,`psm_shp_id`) |
---|
860 | ) ENGINE=InnoDB"; |
---|
861 | $qry->execute($sql); |
---|
862 | |
---|
863 | config::set("DBUpdate", "010"); |
---|
864 | } |
---|
865 | } |
---|
866 | |
---|
867 | function update_slot_of_group($id,$oldSlot = 0 ,$newSlot){ |
---|
868 | $qry = new DBQuery(); |
---|
869 | $query = "UPDATE kb3_item_types |
---|
870 | SET itt_slot = $newSlot WHERE itt_id = $id and itt_slot = $oldSlot;"; |
---|
871 | $qry->execute($query); |
---|
872 | $query = "UPDATE kb3_items_destroyed |
---|
873 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
874 | SET itd_itl_id = $newSlot |
---|
875 | WHERE itd_itl_id = $oldSlot;"; |
---|
876 | $qry->execute($query); |
---|
877 | |
---|
878 | $query = "UPDATE kb3_items_dropped |
---|
879 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
880 | SET itd_itl_id = $newSlot |
---|
881 | WHERE itd_itl_id = $oldSlot;"; |
---|
882 | $qry->execute($query); |
---|
883 | } |
---|
884 | |
---|
885 | function move_item_to_group($id,$oldGroup ,$newGroup){ |
---|
886 | $qry = new DBQuery(); |
---|
887 | $query = "UPDATE kb3_invtypes |
---|
888 | SET groupID = $newGroup |
---|
889 | WHERE typeID = $id AND groupID = $oldGroup;"; |
---|
890 | $qry->execute($query); |
---|
891 | } |
---|
892 | |
---|
893 | function killCache() |
---|
894 | { |
---|
895 | if(!is_dir(KB_CACHEDIR)) return; |
---|
896 | $dir = opendir(KB_CACHEDIR); |
---|
897 | while ($line = readdir($dir)) |
---|
898 | { |
---|
899 | if (strstr($line, 'qcache_qry') !== false) |
---|
900 | { |
---|
901 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
902 | } |
---|
903 | elseif (strstr($line, 'qcache_tbl') !== false) |
---|
904 | { |
---|
905 | @unlink(KB_CACHEDIR.'/'.$line); |
---|
906 | } |
---|
907 | } |
---|
908 | } |
---|
909 | |
---|
910 | ?> |
---|