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