root/dev/common/includes/autoupgrade.php @ 190

Revision 190, 17.9 KB (checked in by exi, 16 years ago)

This is a big update...
Moved all admin scripts to common/admin.
Moved all includes and classes to common/includes.
Edited all include-paths to reflect the movement.
Fixed a bug with the session system allowing every registered user to access admin pages.
Replaced calls to date() to use a wrapper so gmdate can be used.
Replaced some calls to $config with calls to the static object.
Fixed a big which caused the portrait_grab to not download a new picute.
Added a classified-state to kills.
Removed the sync_server server script in this tree.
Added code to help modules find the includes to index.php.

Line 
1<?php
2require_once("db.php");
3function check_commenttable()
4{
5    $qry = new DBQuery();
6    $query = 'select count(*) from kb3_comments';
7    $result = mysql_query($query);
8    if ($result)
9    {
10        check_commenttablerow();
11        return;
12    }
13    $query = 'CREATE TABLE `kb3_comments` (
14`ID` INT NOT NULL AUTO_INCREMENT ,
15`kll_id` INT NOT NULL ,
16`comment` TEXT NOT NULL ,
17`name` TINYTEXT NOT NULL ,
18`posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL,
19PRIMARY KEY ( `ID` )
20) TYPE = MYISAM';
21    $qry->execute($query);
22}
23
24function check_commenttablerow()
25{
26    $qry = new DBQuery();
27    $query = 'select posttime from kb3_comments limit 1';
28    $result = mysql_query($query);
29    if ($result)
30    {
31        $query = 'ALTER TABLE `kb3_comments` CHANGE `ID` `id` INT( 11 ) NOT NULL AUTO_INCREMENT';
32        $qry->execute($query);
33        return;
34    }
35    $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL';
36    $qry->execute($query);
37}
38
39function check_shipvaltable()
40{
41    $qry = new DBQuery();
42    $query = 'select count(*) from kb3_ships_values';
43    $result = mysql_query($query);
44    if ($result)
45    {
46        return;
47    }
48    $query = 'CREATE TABLE `kb3_ships_values` (
49`shp_id` INT( 11 ) NOT NULL ,
50`shp_value` BIGINT( 4 ) NOT NULL ,
51PRIMARY KEY ( `shp_id` )
52) TYPE = MYISAM ;';
53    $qry->execute($query);
54    $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=257 limit 1');
55    $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=252 limit 1');
56    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=266 limit 1');
57    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=275 limit 1');
58    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=272 limit 1');
59    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=246 limit 1');
60    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=249 limit 1');
61    $qry->execute('UPDATE kb3_ships set shp_techlevel = 2 where shp_class = 22');
62}
63
64function check_invdetail()
65{
66    $qry = new DBQuery();
67    $query = 'select ind_sec_status from kb3_inv_detail limit 1';
68    $qry->execute($query);
69    $len = mysql_field_len($qry->resid_,0);
70    if ($len == 4)
71    {
72        $query = 'ALTER TABLE `kb3_inv_detail` CHANGE `ind_sec_status` `ind_sec_status` VARCHAR(5)';
73        $qry->execute($query);
74    }
75}
76
77function check_pilots()
78{
79    $qry = new DBQuery();
80    $query = 'select plt_name from kb3_pilots limit 1';
81    $qry->execute($query);
82    $len = mysql_field_len($qry->resid_,0);
83    if ($len == 32)
84    {
85        $query = 'ALTER TABLE `kb3_pilots` CHANGE `plt_name` `plt_name` VARCHAR(64) NOT NULL';
86        $qry->execute($query);
87    }
88}
89
90function check_contracts()
91{
92    $qry = new DBQuery();
93    $query = 'select ctd_sys_id from kb3_contract_details limit 1';
94    $result = mysql_query($query);
95    if ($result)
96    {
97        return;
98    }
99    $qry->execute('ALTER TABLE `kb3_contract_details` ADD `ctd_sys_id` INT(11) NOT NULL DEFAULT \'0\'');
100
101    $qry->execute('SHOW columns from `kb3_contract_details` like \'ctd_ctr_id\'');
102    $arr = $qry->getRow();
103    if ($arr['Key'] == 'PRI')
104    {
105        return;
106    }
107    $qry->execute('ALTER TABLE `kb3_contract_details` ADD INDEX (`ctd_ctr_id`) ');
108}
109function check_index()
110{
111    $qry = new DBQuery();
112    $qry->execute('SHOW columns from kb3_item_types like \'itt_id\'');
113    $arr = $qry->getRow();
114    if ($arr['Key'] == 'PRI')
115    {
116        return;
117    }
118    $qry->execute('ALTER TABLE `kb3_item_types` ADD PRIMARY KEY ( `itt_id` ) ');
119}
120function check_tblstrct1()
121{
122    $qry = new DBQuery();
123    $query = 'select shp_description from kb3_ships limit 1';
124    $result = mysql_query($query);
125    if (!$result)
126    {
127        return;
128    }
129    $query = 'ALTER TABLE `kb3_ships` DROP `shp_description`';
130    $qry->execute($query);
131}
132function check_tblstrct2()
133{
134    $qry = new DBQuery();
135    $query = 'select itm_description from kb3_items limit 1';
136    $result = mysql_query($query);
137    if (!$result)
138    {
139        return;
140    }
141    $query = 'ALTER TABLE `kb3_items` DROP `itm_description`';
142    $qry->execute($query);
143}
144function check_tblstrct3()
145{
146    $qry = new DBQuery();
147    $query = 'select Value from kb3_items limit 1';
148    $result = mysql_query($query);
149    if ($result)
150    {
151        $query = 'ALTER TABLE `kb3_items` CHANGE `Value` `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\'';
152        $qry->execute($query);
153    }
154}
155function check_tblstrct4()
156{
157    $qry = new DBQuery();
158    $query = 'select itm_value from kb3_items limit 1';
159    $result = mysql_query($query);
160    if ($result)
161    {
162        return;
163    }
164    $query = 'ALTER TABLE `kb3_items` ADD `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\'';
165    $qry->execute($query);
166    $qry->execute('ALTER TABLE `kb3_items` CHANGE `itm_externalid` `itm_externalid` INT( 11 ) NOT NULL DEFAULT \'0\'');
167}
168
169function check_tblstrct5()
170{
171    $qry = new DBQuery();
172    $query = 'select count(*) from kb3_standings';
173    $result = mysql_query($query);
174    if ($result)
175    {
176        $query = 'select count(*) from kb3_standings where sta_from=1 and sta_to=1 and sta_from_type=\'a\' and
177                  sta_to_type=\'c\'';
178        $result = mysql_query($query);
179        if ($result)
180        {
181            return;
182        }
183        $qry->execute('drop table kb3_standings');
184    }
185$query = 'CREATE TABLE `kb3_standings` (
186  `sta_from` int(11) NOT NULL default \'0\',
187  `sta_to` int(11) NOT NULL default \'0\',
188  `sta_from_type` enum(\'a\',\'c\') NOT NULL default \'a\',
189  `sta_to_type` enum(\'a\',\'c\') NOT NULL default \'a\',
190  `sta_value` float NOT NULL default \'0\',
191  `sta_comment` varchar(200) NOT NULL,
192  KEY `sta_from` (`sta_from`)
193) TYPE=MyISAM;';
194    $qry->execute($query);
195}
196
197function chk_kb3_items()
198{
199    $qry = new DBQuery();
200    $query = 'select count(*) from kb3_item_types where itt_id = 787';
201    $result = mysql_query($query);
202    $result = mysql_fetch_array($result);
203    if ($result['cnt'] == 1)
204    {
205        return;
206    }
207    $queries = "
208        INSERT IGNORE INTO `kb3_item_types` VALUES (737, 'Gas Cloud Harvester',1);
209        INSERT IGNORE INTO `kb3_item_types` VALUES (762, 'Inertia Stabilizer',3);
210        INSERT IGNORE INTO `kb3_item_types` VALUES (763, 'Nanofiber Internal Structure',3);
211        INSERT IGNORE INTO `kb3_item_types` VALUES (764, 'Overdrive Injector System',3);
212        INSERT IGNORE INTO `kb3_item_types` VALUES (765, 'Expanded Cargohold',3);
213        INSERT IGNORE INTO `kb3_item_types` VALUES (766, 'Power Diagnostic System',3);
214        INSERT IGNORE INTO `kb3_item_types` VALUES (767, 'Capacitor Power Relay',3);
215        INSERT IGNORE INTO `kb3_item_types` VALUES (768, 'Capacitor Flux Coil',3);
216        INSERT IGNORE INTO `kb3_item_types` VALUES (769, 'Reactor Control Unit',3);
217        INSERT IGNORE INTO `kb3_item_types` VALUES (770, 'Shield Flux Coil',3);
218        INSERT IGNORE INTO `kb3_item_types` VALUES (771, 'Missile Launcher Heavy Assault',1);
219        INSERT IGNORE INTO `kb3_item_types` VALUES (738, 'Cyber Armor', 0);
220        INSERT IGNORE INTO `kb3_item_types` VALUES (740, 'Cyber Electronics', 0);
221        INSERT IGNORE INTO `kb3_item_types` VALUES (741, 'Cyber Engineering', 0);
222        INSERT IGNORE INTO `kb3_item_types` VALUES (742, 'Cyber Gunnery', 0);
223        INSERT IGNORE INTO `kb3_item_types` VALUES (743, 'Cyber Industry', 0);
224        INSERT IGNORE INTO `kb3_item_types` VALUES (744, 'Cyber Leadership', 0);
225        INSERT IGNORE INTO `kb3_item_types` VALUES (745, 'Cyber Learning', 0);
226        INSERT IGNORE INTO `kb3_item_types` VALUES (746, 'Cyber Missile', 0);
227        INSERT IGNORE INTO `kb3_item_types` VALUES (747, 'Cyber Navigation', 0);
228        INSERT IGNORE INTO `kb3_item_types` VALUES (748, 'Cyber Science', 0);
229        INSERT IGNORE INTO `kb3_item_types` VALUES (749, 'Cyber Shields', 0);
230        INSERT IGNORE INTO `kb3_item_types` VALUES (772, 'Assault Missile', 0);
231        INSERT IGNORE INTO `kb3_item_types` VALUES (773, 'Rig Armor', 5);
232        INSERT IGNORE INTO `kb3_item_types` VALUES (774, 'Rig Shield', 5);
233        INSERT IGNORE INTO `kb3_item_types` VALUES (775, 'Rig Energy Weapon', 5);
234        INSERT IGNORE INTO `kb3_item_types` VALUES (776, 'Rig Hybrid Weapon', 5);
235        INSERT IGNORE INTO `kb3_item_types` VALUES (777, 'Rig Projectile Weapon', 5);
236        INSERT IGNORE INTO `kb3_item_types` VALUES (778, 'Rig Drones', 5);
237        INSERT IGNORE INTO `kb3_item_types` VALUES (779, 'Rig Launcher', 5);
238        INSERT IGNORE INTO `kb3_item_types` VALUES (780, 'Rig Electronics', 5);
239        INSERT IGNORE INTO `kb3_item_types` VALUES (781, 'Rig Energy Grid', 5);
240        INSERT IGNORE INTO `kb3_item_types` VALUES (782, 'Rig Astronautic', 5);
241        INSERT IGNORE INTO `kb3_item_types` VALUES (783, 'Cyber X Specials', 0);
242        INSERT IGNORE INTO `kb3_item_types` VALUES (785, 'Script', 0);
243        INSERT IGNORE INTO `kb3_item_types` VALUES (786, 'Rig Electronics Superiority', 5);
244        INSERT IGNORE INTO `kb3_item_types` VALUES (722, 'Advanced Hybrid Ammo Blueprint', 0);
245        INSERT IGNORE INTO `kb3_item_types` VALUES (723, 'Tractor Beam Blueprint', 0);
246        INSERT IGNORE INTO `kb3_item_types` VALUES (724, 'Implant Blueprints', 0);
247        INSERT IGNORE INTO `kb3_item_types` VALUES (725, 'Advanced Projectile Ammo Blueprint', 0);
248        INSERT IGNORE INTO `kb3_item_types` VALUES (726, 'Advanced Frequency Crystal Blueprint', 0);
249        INSERT IGNORE INTO `kb3_item_types` VALUES (727, 'Mining Crystal Blueprint', 0);
250        INSERT IGNORE INTO `kb3_item_types` VALUES (728, 'Decryptors - Amarr', 0);
251        INSERT IGNORE INTO `kb3_item_types` VALUES (729, 'Decryptors - Minmatar', 0);
252        INSERT IGNORE INTO `kb3_item_types` VALUES (730, 'Decryptors - Gallente', 0);
253        INSERT IGNORE INTO `kb3_item_types` VALUES (731, 'Decryptors - Caldari', 0);
254        INSERT IGNORE INTO `kb3_item_types` VALUES (732, 'Decryptors - Sleepers', 0);
255        INSERT IGNORE INTO `kb3_item_types` VALUES (733, 'Decryptors - Yan Jung', 0);
256        INSERT IGNORE INTO `kb3_item_types` VALUES (734, 'Decryptors - Takmahl', 0);
257        INSERT IGNORE INTO `kb3_item_types` VALUES (735, 'Decryptors - Talocan', 0);
258        INSERT IGNORE INTO `kb3_item_types` VALUES (754, 'Salvaged Materials', 0);
259        INSERT IGNORE INTO `kb3_item_types` VALUES (784, 'Large Collidable Ship', 0);
260        INSERT IGNORE INTO `kb3_item_types` VALUES (787, 'Rig Blueprint', 0);
261        ";
262    $query = explode("\n", $queries);
263    foreach ($query as $querystring)
264    {
265        if ($string = trim(str_replace(');', ')', $querystring)))
266        {
267            $qry->execute($string);
268        }
269    }
270}
271function chk_kb3_items2()
272{
273    $qry = new DBQuery();
274    $query = 'select itm_externalid from kb3_items where itm_name = \'Repair Drone\'';
275    $result = mysql_query($query);
276    $result = mysql_fetch_array($result);
277    if ($result['itm_externalid'] == '9871')
278    {
279        return;
280    }
281    $queries = "
282            update kb3_items set itm_externalid='10246' where itm_name='Mining Drone I';
283            update kb3_items set itm_externalid='10248' where itm_name='Mining Drone - Improved UNUSED';
284            update kb3_items set itm_externalid='10250' where itm_name='Mining Drone II';
285            update kb3_items set itm_externalid='1187' where itm_name='Mining Drone - Elite';
286            update kb3_items set itm_externalid='1201' where itm_name='Proximity Drone';
287            update kb3_items set itm_externalid='1202' where itm_name='Wasp I';
288            update kb3_items set itm_externalid='15508' where itm_name='Civilian Mining Drone';
289            update kb3_items set itm_externalid='15510' where itm_name='Vespa I';
290            update kb3_items set itm_externalid='16206' where itm_name='Valkyrie I';
291            update kb3_items set itm_externalid='17565' where itm_name='Hellhound I';
292            update kb3_items set itm_externalid='21050' where itm_name='Unanchoring Drone';
293            update kb3_items set itm_externalid='21638' where itm_name='Survey Drone';
294            update kb3_items set itm_externalid='21640' where itm_name='Vespa II';
295            update kb3_items set itm_externalid='2173' where itm_name='Valkyrie II';
296            update kb3_items set itm_externalid='2175' where itm_name='Infiltrator I';
297            update kb3_items set itm_externalid='2183' where itm_name='Infiltrator II';
298            update kb3_items set itm_externalid='2185' where itm_name='Hammerhead I';
299            update kb3_items set itm_externalid='2193' where itm_name='Hammerhead II';
300            update kb3_items set itm_externalid='2195' where itm_name='Praetor I';
301            update kb3_items set itm_externalid='2203' where itm_name='Praetor II';
302            update kb3_items set itm_externalid='2205' where itm_name='Acolyte I';
303            update kb3_items set itm_externalid='2205' where itm_name='Acolyte II';
304            update kb3_items set itm_externalid='22572' where itm_name='Praetor EV-900';
305            update kb3_items set itm_externalid='22574' where itm_name='Warp Scrambling Drone';
306            update kb3_items set itm_externalid='22713' where itm_name='10mn webscramblifying Drone';
307            update kb3_items set itm_externalid='22765' where itm_name='Heavy Shield Maintenance Bot I';
308            update kb3_items set itm_externalid='22780' where itm_name='Fighter Uno';
309            update kb3_items set itm_externalid='23055' where itm_name='Templar';
310            update kb3_items set itm_externalid='23057' where itm_name='Dragonfly';
311            update kb3_items set itm_externalid='23059' where itm_name='Firbolg';
312            update kb3_items set itm_externalid='23061' where itm_name='Einherji';
313            update kb3_items set itm_externalid='23473' where itm_name='Wasp EC-900';
314            update kb3_items set itm_externalid='23506' where itm_name='Ogre SD-900';
315            update kb3_items set itm_externalid='23510' where itm_name='Praetor TD-900';
316            update kb3_items set itm_externalid='23512' where itm_name='Berserker TP-900';
317            update kb3_items set itm_externalid='23523' where itm_name='Heavy Armor Maintenance Bot I';
318            update kb3_items set itm_externalid='23525' where itm_name='Curator I';
319            update kb3_items set itm_externalid='23559' where itm_name='Berserker SW-900';
320            update kb3_items set itm_externalid='23559' where itm_name='Warden I';
321            update kb3_items set itm_externalid='23561' where itm_name='Garde I';
322            update kb3_items set itm_externalid='23563' where itm_name='Bouncer I';
323            update kb3_items set itm_externalid='23659' where itm_name='Acolyte EV-300';
324            update kb3_items set itm_externalid='23702' where itm_name='Infiltrator EV-600';
325            update kb3_items set itm_externalid='23705' where itm_name='Vespa EC-600';
326            update kb3_items set itm_externalid='23707' where itm_name='Hornet EC-300';
327            update kb3_items set itm_externalid='23709' where itm_name='Medium Armor Maintenance Bot I';
328            update kb3_items set itm_externalid='23711' where itm_name='Light Armor Maintenance Bot I';
329            update kb3_items set itm_externalid='23713' where itm_name='Hammerhead SD-600';
330            update kb3_items set itm_externalid='23715' where itm_name='Hobgoblin SD-300';
331            update kb3_items set itm_externalid='23717' where itm_name='Medium Shield Maintenance Bot I';
332            update kb3_items set itm_externalid='23719' where itm_name='Light Shield Maintenance Bot I';
333            update kb3_items set itm_externalid='23721' where itm_name='Valkyrie TP-600';
334            update kb3_items set itm_externalid='23723' where itm_name='Warrior TP-300';
335            update kb3_items set itm_externalid='23725' where itm_name='Infiltrator TD-600';
336            update kb3_items set itm_externalid='23727' where itm_name='Acolyte TD-300';
337            update kb3_items set itm_externalid='23729' where itm_name='Valkyrie SW-600';
338            update kb3_items set itm_externalid='23731' where itm_name='Warrior SW-300';
339            update kb3_items set itm_externalid='23759' where itm_name='FA-14 Templar';
340            update kb3_items set itm_externalid='2436' where itm_name='Wasp II';
341            update kb3_items set itm_externalid='2444' where itm_name='Ogre I';
342            update kb3_items set itm_externalid='2446' where itm_name='Ogre II';
343            update kb3_items set itm_externalid='2454' where itm_name='Hobgoblin I';
344            update kb3_items set itm_externalid='2456' where itm_name='Hobgoblin II';
345            update kb3_items set itm_externalid='24618' where itm_name='horrible tracking drone';
346            update kb3_items set itm_externalid='2464' where itm_name='Hornet I';
347            update kb3_items set itm_externalid='2466' where itm_name='Hornet II';
348            update kb3_items set itm_externalid='2476' where itm_name='Berserker I';
349            update kb3_items set itm_externalid='2478' where itm_name='Berserker II';
350            update kb3_items set itm_externalid='2486' where itm_name='Warrior I';
351            update kb3_items set itm_externalid='2488' where itm_name='Warrior II';
352            update kb3_items set itm_externalid='3218' where itm_name='Harvester Mining Drone';
353            update kb3_items set itm_externalid='3549' where itm_name='Tutorial Attack Drone';
354            update kb3_items set itm_externalid='9871' where itm_name='Repair Drone';
355        ";
356    $query = explode("\n", $queries);
357    foreach ($query as $querystring)
358    {
359        if ($string = trim(str_replace(');', ')', $querystring)))
360        {
361            $qry->execute($string);
362        }
363    }
364}
365function check_tblstrct6()
366{
367    $qry = new DBQuery();
368    $query = 'select all_img from kb3_alliances limit 1';
369    $result = mysql_query($query);
370    if (!$result)
371    {
372        return;
373    }
374    $query = 'ALTER TABLE `kb3_alliances` DROP `all_img`';
375    $qry->execute($query);
376}
377?>
Note: See TracBrowser for help on using the browser.