1 | <?php |
---|
2 | |
---|
3 | function check_commenttable() |
---|
4 | { |
---|
5 | $qry = new DBQuery(); |
---|
6 | $query = 'select count(*) from kb3_comments'; |
---|
7 | $result = $qry->execute($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, |
---|
19 | PRIMARY KEY ( `ID` ) |
---|
20 | ) TYPE = MYISAM'; |
---|
21 | $qry->execute($query); |
---|
22 | } |
---|
23 | |
---|
24 | function check_navigationtable() |
---|
25 | { |
---|
26 | if (CORP_ID) |
---|
27 | { |
---|
28 | $statlink = '?a=corp_detail'; |
---|
29 | } |
---|
30 | elseif (ALLIANCE_ID) |
---|
31 | { |
---|
32 | $statlink = '?a=alliance_detail'; |
---|
33 | } |
---|
34 | |
---|
35 | $qry = new DBQuery(); |
---|
36 | $query = 'select count(*) from kb3_navigation'; |
---|
37 | $result = mysql_query($query); |
---|
38 | if ($result) |
---|
39 | { |
---|
40 | $query = "select hidden from kb3_navigation limit 1"; |
---|
41 | $result = @mysql_query($query); |
---|
42 | if (!$result) |
---|
43 | { |
---|
44 | $qry->execute("ALTER TABLE `kb3_navigation` ADD `hidden` BOOL NOT NULL DEFAULT '0' AFTER `page` ;"); |
---|
45 | } |
---|
46 | $query = "select count(KBSITE) from kb3_navigation WHERE KBSITE = '".KB_SITE."'"; |
---|
47 | $result = @mysql_query($query); |
---|
48 | if ($result) |
---|
49 | { |
---|
50 | $row = mysql_fetch_row($result); |
---|
51 | if ($row[0] == 0) |
---|
52 | { |
---|
53 | $queries = "INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr`,`page` ,`hidden`,`KBSITE`) VALUES ('top',1,'Home','?a=home','_self',1,'ALL_PAGES',0,'".KB_SITE."'); |
---|
54 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Campaigns','?a=campaigns','_self',2,'ALL_PAGES',0,'".KB_SITE."'); |
---|
55 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Contracts','?a=contracts','_self',3,'ALL_PAGES',0,'".KB_SITE."'); |
---|
56 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Kills','?a=kills','_self',4,'ALL_PAGES',0,'".KB_SITE."'); |
---|
57 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Losses','?a=losses','_self',5,'ALL_PAGES',0,'".KB_SITE."'); |
---|
58 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Post Mail','?a=post','_self',6,'ALL_PAGES',0,'".KB_SITE."'); |
---|
59 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Stats','$statlink','_self',7,'ALL_PAGES',0,'".KB_SITE."'); |
---|
60 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Awards','?a=awards','_self',8,'ALL_PAGES',0,'".KB_SITE."'); |
---|
61 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Standings','?a=standings','_self',9,'ALL_PAGES',0,'".KB_SITE."'); |
---|
62 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Search','?a=search','_self',10,'ALL_PAGES',0,'".KB_SITE."'); |
---|
63 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'Admin','?a=admin','_self',11,'ALL_PAGES',0,'".KB_SITE."'); |
---|
64 | INSERT IGNORE INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr` ,`page`,`hidden`,`KBSITE`) VALUES ('top',1,'About','?a=about','_self',12,'ALL_PAGES',0,'".KB_SITE."');"; |
---|
65 | $query = explode("\n", $queries); |
---|
66 | foreach ($query as $querystring) |
---|
67 | { |
---|
68 | if ($string = trim(str_replace(');', ')', $querystring))) |
---|
69 | { |
---|
70 | $qry->execute($string); |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | return; |
---|
75 | } |
---|
76 | $query = 'ALTER TABLE `kb3_navigation` ADD `KBSITE` VARCHAR( 16 ) NOT NULL'; |
---|
77 | $qry->execute($query); |
---|
78 | $query = 'UPDATE `kb3_navigation` SET KBSITE = "'.KB_SITE.'" WHERE KBSITE LIKE "";'; |
---|
79 | $qry->execute($query); |
---|
80 | return; |
---|
81 | }else{ |
---|
82 | $query = 'CREATE TABLE `kb3_navigation` ( |
---|
83 | `ID` INT NOT NULL AUTO_INCREMENT , |
---|
84 | `nav_type` TINYTEXT NOT NULL, |
---|
85 | `intern` INT ( 1 ) NOT NULL, |
---|
86 | `descr` TINYTEXT NOT NULL , |
---|
87 | `url` TINYTEXT NOT NULL , |
---|
88 | `target` VARCHAR( 10 ) NOT NULL, |
---|
89 | `posnr` INT NOT NULL, |
---|
90 | `page` TINYTEXT NOT NULL, |
---|
91 | `hidden` BOOL NOT NULL DEFAULT "0", |
---|
92 | `KBSITE` VARCHAR ( 16 ) NOT NULL, |
---|
93 | PRIMARY KEY ( `ID` ) |
---|
94 | ) TYPE = MYISAM;'; |
---|
95 | $qry->execute($query); |
---|
96 | $queries = "INSERT IGNORE INTO `kb3_navigation` VALUES (1,'top',1,'Home','?a=home','_self',1,'ALL_PAGES',0,'".KB_SITE."'); |
---|
97 | INSERT IGNORE INTO `kb3_navigation` VALUES (2,'top',1,'Campaigns','?a=campaigns','_self',2,'ALL_PAGES',0,'".KB_SITE."'); |
---|
98 | INSERT IGNORE INTO `kb3_navigation` VALUES (3,'top',1,'Contracts','?a=contracts','_self',3,'ALL_PAGES',0,'".KB_SITE."'); |
---|
99 | INSERT IGNORE INTO `kb3_navigation` VALUES (4,'top',1,'Kills','?a=kills','_self',4,'ALL_PAGES',0,'".KB_SITE."'); |
---|
100 | INSERT IGNORE INTO `kb3_navigation` VALUES (5,'top',1,'Losses','?a=losses','_self',5,'ALL_PAGES',0,'".KB_SITE."'); |
---|
101 | INSERT IGNORE INTO `kb3_navigation` VALUES (6,'top',1,'Post Mail','?a=post','_self',6,'ALL_PAGES',0,'".KB_SITE."'); |
---|
102 | INSERT IGNORE INTO `kb3_navigation` VALUES (7,'top',1,'Stats','$statlink','_self',7,'ALL_PAGES',0,'".KB_SITE."'); |
---|
103 | INSERT IGNORE INTO `kb3_navigation` VALUES (8,'top',1,'Awards','?a=awards','_self',8,'ALL_PAGES',0,'".KB_SITE."'); |
---|
104 | INSERT IGNORE INTO `kb3_navigation` VALUES (9,'top',1,'Standings','?a=standings','_self',9,'ALL_PAGES',0,'".KB_SITE."'); |
---|
105 | INSERT IGNORE INTO `kb3_navigation` VALUES (10,'top',1,'Search','?a=search','_self',10,'ALL_PAGES',0,'".KB_SITE."'); |
---|
106 | INSERT IGNORE INTO `kb3_navigation` VALUES (11,'top',1,'Admin','?a=admin','_self',11,'ALL_PAGES',0,'".KB_SITE."'); |
---|
107 | INSERT IGNORE INTO `kb3_navigation` VALUES (12,'top',1,'About','?a=about','_self',12,'ALL_PAGES',0,'".KB_SITE."');"; |
---|
108 | $query = explode("\n", $queries); |
---|
109 | foreach ($query as $querystring) |
---|
110 | { |
---|
111 | if ($string = trim(str_replace(');', ')', $querystring))) |
---|
112 | { |
---|
113 | $qry->execute($string); |
---|
114 | } |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | function check_commenttablerow() |
---|
120 | { |
---|
121 | $qry = new DBQuery(); |
---|
122 | $query = 'select posttime from kb3_comments limit 1'; |
---|
123 | $result = mysql_query($query); |
---|
124 | if ($result) |
---|
125 | { |
---|
126 | $query = 'ALTER TABLE `kb3_comments` CHANGE `ID` `id` INT( 11 ) NOT NULL AUTO_INCREMENT'; |
---|
127 | $qry->execute($query); |
---|
128 | return; |
---|
129 | } |
---|
130 | $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL'; |
---|
131 | $qry->execute($query); |
---|
132 | } |
---|
133 | |
---|
134 | function check_shipvaltable() |
---|
135 | { |
---|
136 | $qry = new DBQuery(); |
---|
137 | $query = 'select count(*) from kb3_ships_values'; |
---|
138 | $result = mysql_query($query); |
---|
139 | if ($result) |
---|
140 | { |
---|
141 | return; |
---|
142 | } |
---|
143 | $query = 'CREATE TABLE `kb3_ships_values` ( |
---|
144 | `shp_id` INT( 11 ) NOT NULL , |
---|
145 | `shp_value` BIGINT( 4 ) NOT NULL , |
---|
146 | PRIMARY KEY ( `shp_id` ) |
---|
147 | ) TYPE = MYISAM ;'; |
---|
148 | $qry->execute($query); |
---|
149 | } |
---|
150 | |
---|
151 | function check_invdetail() |
---|
152 | { |
---|
153 | $qry = new DBQuery(); |
---|
154 | $query = 'select ind_sec_status from kb3_inv_detail limit 1'; |
---|
155 | $qry->execute($query); |
---|
156 | $len = mysql_field_len($qry->resid_,0); |
---|
157 | if ($len == 4) |
---|
158 | { |
---|
159 | $query = 'ALTER TABLE `kb3_inv_detail` CHANGE `ind_sec_status` `ind_sec_status` VARCHAR(5)'; |
---|
160 | $qry->execute($query); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | function check_pilots() |
---|
165 | { |
---|
166 | $qry = new DBQuery(); |
---|
167 | $query = 'select plt_name from kb3_pilots limit 1'; |
---|
168 | $qry->execute($query); |
---|
169 | $len = mysql_field_len($qry->resid_,0); |
---|
170 | if ($len == 32) |
---|
171 | { |
---|
172 | $query = 'ALTER TABLE `kb3_pilots` CHANGE `plt_name` `plt_name` VARCHAR(64) NOT NULL'; |
---|
173 | $qry->execute($query); |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | function check_contracts() |
---|
178 | { |
---|
179 | $qry = new DBQuery(); |
---|
180 | $query = 'select ctd_sys_id from kb3_contract_details limit 1'; |
---|
181 | $result = mysql_query($query); |
---|
182 | if ($result) |
---|
183 | { |
---|
184 | return; |
---|
185 | } |
---|
186 | $qry->execute('ALTER TABLE `kb3_contract_details` ADD `ctd_sys_id` INT(11) NOT NULL DEFAULT \'0\''); |
---|
187 | |
---|
188 | $qry->execute('SHOW columns from `kb3_contract_details` like \'ctd_ctr_id\''); |
---|
189 | $arr = $qry->getRow(); |
---|
190 | if ($arr['Key'] == 'PRI') |
---|
191 | { |
---|
192 | return; |
---|
193 | } |
---|
194 | $qry->execute('ALTER TABLE `kb3_contract_details` ADD INDEX (`ctd_ctr_id`) '); |
---|
195 | } |
---|
196 | |
---|
197 | function check_index() |
---|
198 | { |
---|
199 | check_index_invcrp(); |
---|
200 | check_index_invall(); |
---|
201 | $qry = new DBQuery(); |
---|
202 | $qry->execute('SHOW columns from kb3_item_types like \'itt_id\''); |
---|
203 | $arr = $qry->getRow(); |
---|
204 | if ($arr['Key'] == 'PRI') |
---|
205 | { |
---|
206 | return; |
---|
207 | } |
---|
208 | $qry->execute('ALTER TABLE `kb3_item_types` ADD PRIMARY KEY ( `itt_id` ) '); |
---|
209 | } |
---|
210 | |
---|
211 | function check_index_invcrp() |
---|
212 | { |
---|
213 | $qry = new DBQuery(); |
---|
214 | $qry->execute('SHOW columns from kb3_inv_crp like \'inc_kll_id\''); |
---|
215 | $arr = $qry->getRow(); |
---|
216 | if ($arr['Key'] == 'MUL') |
---|
217 | { |
---|
218 | return; |
---|
219 | } |
---|
220 | $qry->execute('ALTER TABLE `kb3_inv_crp` ADD INDEX ( `inc_kll_id` ) '); |
---|
221 | } |
---|
222 | |
---|
223 | function check_index_invall() |
---|
224 | { |
---|
225 | $qry = new DBQuery(); |
---|
226 | $qry->execute('SHOW columns from kb3_inv_all like \'ina_kll_id\''); |
---|
227 | $arr = $qry->getRow(); |
---|
228 | if ($arr['Key'] == 'MUL') |
---|
229 | { |
---|
230 | return; |
---|
231 | } |
---|
232 | $qry->execute('ALTER TABLE `kb3_inv_all` ADD INDEX ( `ina_kll_id` ) '); |
---|
233 | } |
---|
234 | |
---|
235 | function check_tblstrct1() |
---|
236 | { |
---|
237 | $qry = new DBQuery(); |
---|
238 | $query = 'select shp_description from kb3_ships limit 1'; |
---|
239 | $result = mysql_query($query); |
---|
240 | if (!$result) |
---|
241 | { |
---|
242 | return; |
---|
243 | } |
---|
244 | $query = 'ALTER TABLE `kb3_ships` DROP `shp_description`'; |
---|
245 | $qry->execute($query); |
---|
246 | } |
---|
247 | function check_tblstrct5() |
---|
248 | { |
---|
249 | $qry = new DBQuery(); |
---|
250 | $query = 'select count(*) from kb3_standings'; |
---|
251 | $result = mysql_query($query); |
---|
252 | if ($result) |
---|
253 | { |
---|
254 | $query = 'select count(*) from kb3_standings where sta_from=1 and sta_to=1 and sta_from_type=\'a\' and |
---|
255 | sta_to_type=\'c\''; |
---|
256 | $result = mysql_query($query); |
---|
257 | if ($result) |
---|
258 | { |
---|
259 | return; |
---|
260 | } |
---|
261 | $qry->execute('drop table kb3_standings'); |
---|
262 | } |
---|
263 | $query = 'CREATE TABLE `kb3_standings` ( |
---|
264 | `sta_from` int(11) NOT NULL default \'0\', |
---|
265 | `sta_to` int(11) NOT NULL default \'0\', |
---|
266 | `sta_from_type` enum(\'a\',\'c\') NOT NULL default \'a\', |
---|
267 | `sta_to_type` enum(\'a\',\'c\') NOT NULL default \'a\', |
---|
268 | `sta_value` float NOT NULL default \'0\', |
---|
269 | `sta_comment` varchar(200) NOT NULL, |
---|
270 | KEY `sta_from` (`sta_from`) |
---|
271 | ) TYPE=MyISAM;'; |
---|
272 | $qry->execute($query); |
---|
273 | } |
---|
274 | |
---|
275 | function check_tblstrct6() |
---|
276 | { |
---|
277 | $qry = new DBQuery(); |
---|
278 | $query = 'select all_img from kb3_alliances limit 1'; |
---|
279 | $result = mysql_query($query); |
---|
280 | if (!$result) |
---|
281 | { |
---|
282 | return; |
---|
283 | } |
---|
284 | $query = 'ALTER TABLE `kb3_alliances` DROP `all_img`'; |
---|
285 | $qry->execute($query); |
---|
286 | } |
---|
287 | |
---|
288 | function check_killtables() |
---|
289 | { |
---|
290 | $qry = new DBQuery(); |
---|
291 | $query = 'select kll_dmgtaken from kb3_kills limit 1'; |
---|
292 | $result = mysql_query($query); |
---|
293 | if ($result) |
---|
294 | { |
---|
295 | return; |
---|
296 | } |
---|
297 | $qry->execute('ALTER TABLE `kb3_kills` ADD `kll_dmgtaken` INT(11) NOT NULL DEFAULT \'0\''); |
---|
298 | |
---|
299 | $qry = new DBQuery(); |
---|
300 | $query = 'select ind_dmgdone from kb3_inv_detail limit 1'; |
---|
301 | $result = mysql_query($query); |
---|
302 | if ($result) |
---|
303 | { |
---|
304 | return; |
---|
305 | } |
---|
306 | $qry->execute('ALTER TABLE `kb3_inv_detail` ADD `ind_dmgdone` INT(11) NOT NULL DEFAULT \'0\''); |
---|
307 | } |
---|
308 | |
---|
309 | check_commenttable(); |
---|
310 | check_navigationtable(); |
---|
311 | check_commenttablerow(); |
---|
312 | check_shipvaltable(); |
---|
313 | check_invdetail(); |
---|
314 | check_pilots(); |
---|
315 | check_contracts(); |
---|
316 | check_index(); |
---|
317 | check_index_invcrp(); |
---|
318 | check_index_invall(); |
---|
319 | check_tblstrct1(); |
---|
320 | check_tblstrct5(); |
---|
321 | check_tblstrct6(); |
---|
322 | check_killtables(); |
---|
323 | ?> |
---|