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