Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
install.php
Go to the documentation of this file.
1 <?php
2 
3 error_reporting(E_ERROR | E_WARNING | E_PARSE);
4 set_magic_quotes_runtime(0);
5 //ini_set('date.timezone','Asia/Shanghai');
6 
7 define('IN_GAME', TRUE);
8 define('GAME_ROOT', '');
9 
10 if(PHP_VERSION < '4.3.0') {
11  exit('PHP version must >= 4.3.0!');
12 }
13 
14 $action = $_POST['action'] ? $_POST['action'] : $_GET['action'];
15 $language = $_POST['language'] ? $_POST['language'] : $_GET['language'];
16 
17 @set_time_limit(1000);
18 @include './config.inc.php';
19 
20 switch($language) {
21  case 'simplified_chinese_gbk':
22  $dbcharset = $charset = 'gbk';
23  break;
24  case 'simplified_chinese_utf8':
25  $dbcharset = 'utf8';
26  $charset = 'utf-8';
27  break;
28  case 'traditional_chinese_big5':
29  $dbcharset = $charset = 'big5';
30  break;
31  case 'traditional_chinese_utf8':
32  $dbcharset = 'utf8';
33  $charset = 'utf-8';
34  break;
35  case 'english':
36  $dbcharset = 'utf8';
37  $charset = 'utf-8';
38  break;
39  default:
40  $language = '';
41  $dbcharset = 'utf8';
42  $charset = 'utf-8';
43 }
44 
45 if($language) {
46 
47  $languagefile = './install/'.$language.'.lang.php';
48  $sqlfile = './install/bra.sql';
49  if(!is_readable($languagefile) || !is_readable($sqlfile)) {
50  exit('Please upload ./install and all its files completely.');
51  }
52 
53  require_once $languagefile;
54 
55  $lockfile = './gamedata/install.lock';
56  if(file_exists($lockfile)) {
57  exit($lang['lock_exists']);
58  }
59 
60  $fp = fopen($sqlfile, 'rb');
61  $sql = fread($fp, 2048000);
62  fclose($fp);
63 }
64 
65 header('Content-Type: text/html; charset='.$charset);
66 $version = '3.0.0';
67 
68 ?>
69 <html>
70 <head>
71 <title>Bra Installation Wizard</title>
72 <style>
73 A:visited {COLOR: #3A4273; TEXT-DECORATION: none}
74 A:link {COLOR: #3A4273; TEXT-DECORATION: none}
75 A:hover {COLOR: #3A4273; TEXT-DECORATION: underline}
76 body,table,td {COLOR: #3A4273; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; LINE-HEIGHT: 20px; scrollbar-base-color: #E3E3EA; scrollbar-arrow-color: #5C5C8D}
77 input {COLOR: #085878; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; background-color: #3A4273; color: #FFFFFF; scrollbar-base-color: #E3E3EA; scrollbar-arrow-color: #5C5C8D}
78 .install {FONT-FAMILY: Arial, Verdana; FONT-SIZE: 20px; FONT-WEIGHT: bold; COLOR: #000000}
79 </style>
80 </head>
81 <?php
82 
83 if(!in_array($language, array('simplified_chinese_gbk', 'simplified_chinese_utf8', 'traditional_chinese_big5', 'traditional_chinese_utf8', 'english'))) {
84 
85 ?>
86 <body bgcolor="#FFFFFF">
87 <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" align="center">
88 <tr><td valign="middle" align="center">
89 
90 <table cellpadding="0" cellspacing="0" border="0" align="center">
91  <tr align="center" valign="middle">
92  <td bgcolor="#000000">
93  <table cellpadding="10" cellspacing="1" border="0" width="500" height="100%" align="center">
94  <tr>
95  <td valign="middle" align="center" bgcolor="#EBEBEB">
96  <!-- final utf8/orig <br><b>Bra Installation Wizard</b><br><br>Please choose your prefered language<br><br><center><a href="?language=simplified_chinese_gbk">[&#31616;&#20307;&#20013;&#25991; GBK]</a> &nbsp; <a href="?language=simplified_chinese_utf8">[&#31616;&#20307;&#20013;&#25991; UTF-8]</a><br><a href="?language=traditional_chinese_big5">[&#32321;&#39636;&#20013;&#25991; BIG5]</a> &nbsp; <a href="?language=traditional_chinese_utf8">[&#32321;&#39636;&#20013;&#25991; UTF-8]</a><br><a href="?language=english">[English]</a><br><br> -->
97  <br><b>Bra Installation Wizard</b><br><br>Please choose your prefered language<br><br><center> &nbsp; <a href="?language=simplified_chinese_utf8">[&#31616;&#20307;&#20013;&#25991;]</a><br> &nbsp; <a href="?language=traditional_chinese_utf8">[&#32321;&#39636;&#20013;&#25991;]</a><br><br>
98  </td>
99  </tr>
100  </table>
101  </td>
102  </tr>
103 </table>
104 
105 </td></td></table>
106 </body>
107 </html>
108 <?php
109 
110  exit();
111 
112 } else {
113 ?>
114 <body bgcolor="#3A4273" text="#000000">
115 <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
116  <tr>
117  <td>
118  <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
119  <tr>
120  <td class="install" height="30" valign="bottom"><font color="#FF0000">&gt;&gt;</font>
121  <?php echo $lang['install_wizard']; ?></td>
122  </tr>
123  <tr>
124  <td>
125  <hr noshade align="center" width="100%" size="1">
126  </td>
127  </tr>
128  <tr>
129  <td align="center">
130  <b><?php echo $lang['welcome']; ?></b>
131  </td>
132  </tr>
133  <tr>
134  <td>
135  <hr noshade align="center" width="100%" size="1">
136  </td>
137  </tr>
138 <?php
139 }
140 if(!$action) {
141 
142  $discuz_license = str_replace(' ', '&nbsp; ', $lang['license']);
143 
144 ?>
145  <tr>
146  <td><b><?php echo $lang['current_process']; ?> </b><font color="#0000EE"><?php echo $lang['show_license']; ?></font></td>
147  </tr>
148  <tr>
149  <td>
150  <hr noshade align="center" width="100%" size="1">
151  </td>
152  </tr>
153  <tr>
154  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['agreement']; ?></font></b></td>
155  </tr>
156  <tr>
157  <td><br>
158  <table width="90%" cellspacing="1" bgcolor="#000000" border="0" align="center">
159  <tr>
160  <td bgcolor="#E3E3EA">
161  <table width="99%" cellspacing="1" border="0" align="center">
162  <tr>
163  <td>
164  <?php echo $discuz_license; ?>
165  </td>
166  </tr>
167  </table>
168  </td>
169  </tr>
170  </table>
171  </td>
172  </tr>
173  <tr>
174  <td align="center">
175  <br>
176  <form method="post" action="?language=<?php echo $language; ?>">
177  <input type="hidden" name="action" value="config">
178  <input type="submit" name="submit" value="<?php echo $lang['agreement_yes']; ?>" style="height: 25">&nbsp;
179  <input type="button" name="exit" value="<?php echo $lang['agreement_no']; ?>" style="height: 25" onclick="javascript: window.close();">
180  </form>
181  </td>
182  </tr>
183 <?php
184 } elseif($action == 'config') {
185 
186  $exist_error = FALSE;
187  $write_error = FALSE;
188  if(file_exists('./config.inc.php')) {
189  $fileexists = result(1, 0);
190  } else {
191  $fileexists = result(0, 0);
192  $exist_error = TRUE;
193  $config_info = $lang['config_nonexistence'];
194  }
195  if(is_writeable('./config.inc.php')) {
196  $filewriteable = result(1, 0);
197  $config_info = $lang['config_comment'];
198  } else {
199  $filewriteable = result(0, 0);
200  $write_error = TRUE;
201  $config_info = $lang['config_unwriteable'];
202  }
203 
204 ?>
205  <tr>
206  <td><b><?php echo $lang['current_process']; ?> </b><font color="#0000EE"><?php echo $lang['configure']; ?></font></td>
207  </tr>
208  <tr>
209  <td>
210  <hr noshade align="center" width="100%" size="1">
211  </td>
212  </tr>
213  <tr>
214  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['check_config']; ?></font></b></td>
215  </tr>
216  <tr>
217  <td>config.inc.php <?php echo $lang['check_existence']; ?> <?php echo $fileexists; ?></td>
218  </tr>
219  <tr>
220  <td>config.inc.php <?php echo $lang['check_writeable']; ?> <?php echo $filewriteable; ?></td>
221  </tr>
222  <tr>
223  <td>
224  <hr noshade align="center" width="100%" size="1">
225  </td>
226  </tr>
227  <tr>
228  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['edit_config']; ?></font></b></td>
229  </tr>
230  <tr>
231  <td align="center"><br><?php echo $config_info; ?></td>
232  </tr>
233 <?php
234 
235  if(!$exist_error) {
236 
237  if(!$write_error) {
238 
239  $dbhost = 'localhost';
240  $dbuser = 'dbuser';
241  $dbpw = 'dbpw';
242  $dbname = 'dbname';
243  $tablepre = 'bra_';
244  $authkey = 'bra';
245  $moveut = 0;
246  $gamefounder = 'admin';
247 
248  @include './config.inc.php';
249  $now = time();
250  list($nowsec,$nowmin,$nowhour,$nowday,$nowmonth,$nowyear,$nowwday,$nowyday,$nowisdst) = localtime($now);
251  $nowmonth++;
252  $nowyear += 1900;
253 
254 
255 ?>
256  <tr>
257  <td align="center">
258  <br>
259  <form method="post" action="?language=<?php echo $language; ?>">
260  <table width="650" cellspacing="1" bgcolor="#000000" border="0" align="center">
261  <tr bgcolor="#3A4273">
262  <td align="center" width="20%" style="color: #FFFFFF"><?php echo $lang['variable']; ?></td>
263  <td align="center" width="40%" style="color: #FFFFFF"><?php echo $lang['value']; ?></td>
264  <td align="center" width="40%" style="color: #FFFFFF"><?php echo $lang['comment']; ?></td>
265  </tr>
266  <tr>
267  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['gamefounder']; ?></td>
268  <td bgcolor="#EEEEF6" align="center"><input type="text" name="gamefounder" value="<?php echo $gamefounder; ?>" size="30"></td>
269  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['gamefounder_comment']; ?></td>
270  </tr>
271  <tr>
272  <td bgcolor="#E3E3EA" style="color: #FF0000">&nbsp;<?php echo $lang['dbhost']; ?></td>
273  <td bgcolor="#EEEEF6" align="center"><input type="text" name="dbhost" value="<?php echo $dbhost; ?>" size="30"></td>
274  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['dbhost_comment']; ?></td>
275  </tr>
276  <tr>
277  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['dbuser']; ?></td>
278  <td bgcolor="#EEEEF6" align="center"><input type="text" name="dbuser" value="<?php echo $dbuser; ?>" size="30"></td>
279  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['dbuser_comment']; ?></td>
280  </tr>
281  <tr>
282  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['dbpw']; ?></td>
283  <td bgcolor="#EEEEF6" align="center"><input type="password" name="dbpw" value="<?php echo $dbpw; ?>" size="30"></td>
284  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['dbpw_comment']; ?></td>
285  </tr>
286  <tr>
287  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['moveut']; ?></td>
288  <td bgcolor="#EEEEF6" align="center"><input type="text" name="moveut" value="<?php echo $moveut; ?>" size="30"></td>
289  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['moveut_comment']; ?><br><?php echo $nowyear; ?><?php echo $lang['year']; ?><?php echo $nowmonth; ?><?php echo $lang['month']; ?><?php echo $nowday; ?><?php echo $lang['day']; ?><?php echo $nowhour; ?><?php echo $lang['hour']; ?><?php echo $nowmin; ?><?php echo $lang['min']; ?></td>
290  </tr>
291  <tr>
292  <td bgcolor="#E3E3EA" style="color: #FF0000">&nbsp;<?php echo $lang['tablepre']; ?></td>
293  <td bgcolor="#EEEEF6" align="center"><input type="text" name="tablepre" value="<?php echo $tablepre; ?>" size="30" onClick="javascript: alert('<?php echo $lang['install_note']; ?>:\n\n<?php echo $lang['tablepre_prompt']; ?>');"></td>
294  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['tablepre_comment']; ?></td>
295  </tr>
296  <!--
297  <tr>
298  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['authkey']; ?></td>
299  <td bgcolor="#EEEEF6" align="center"><input type="text" name="authkey" value="<?php echo $authkey; ?>" size="30"></td>
300  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['authkey_comment']; ?></td>
301  </tr>
302  -->
303  <input type="hidden" name="authkey" value="<?php echo $authkey; ?>">
304  <tr>
305  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['bbsurl']; ?></td>
306  <td bgcolor="#EEEEF6" align="center"><input type="text" name="bbsurl" value="<?php echo $bbsurl; ?>" size="30"></td>
307  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['bbsurl_comment']; ?></td>
308  </tr>
309  <tr>
310  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['gameurl']; ?></td>
311  <td bgcolor="#EEEEF6" align="center"><input type="text" name="gameurl" value="<?php echo $gameurl; ?>" size="30"></td>
312  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['gameurl_comment']; ?></td>
313  </tr>
314  </table>
315  <br>
316  <input type="hidden" name="action" value="dbselect">
317  <input type="hidden" name="saveconfig" value="1">
318  <input type="submit" name="submit" value="<?php echo $lang['save_config']; ?>" style="height: 25">
319  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
320  </form>
321  </td>
322  </tr>
323 <?php
324 
325  } else {
326 
327  @include './config.inc.php';
328  $now = time();
329  list($nowsec,$nowmin,$nowhour,$nowday,$nowmonth,$nowyear,$nowwday,$nowyday,$nowisdst) = localtime($now);
330  $nowmonth++;
331  $nowyear += 1900;
332 
333 ?>
334  <tr>
335  <td>
336  <br>
337  <table width="60%" cellspacing="1" bgcolor="#000000" border="0" align="center">
338  <tr bgcolor="#3A4273">
339  <td align="center" style="color: #FFFFFF"><?php echo $lang['variable']; ?></td>
340  <td align="center" style="color: #FFFFFF"><?php echo $lang['value']; ?></td>
341  <td align="center" style="color: #FFFFFF"><?php echo $lang['comment']; ?></td>
342  </tr>
343  <tr>
344  <td bgcolor="#E3E3EA" align="center">$gamefounder</td>
345  <td bgcolor="#EEEEF6" align="center"><?php echo $gamefounder; ?></td>
346  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['gamefounder_comment']; ?></td>
347  </tr>
348  <tr>
349  <td bgcolor="#E3E3EA" align="center">$dbhost</td>
350  <td bgcolor="#EEEEF6" align="center"><?php echo $dbhost; ?></td>
351  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['dbhost_comment']; ?></td>
352  </tr>
353  <tr>
354  <td bgcolor="#E3E3EA" align="center">$dbuser</td>
355  <td bgcolor="#EEEEF6" align="center"><?php echo $dbuser; ?></td>
356  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['dbuser_comment']; ?></td>
357  </tr>
358  <tr>
359  <td bgcolor="#E3E3EA" align="center">$dbpw</td>
360  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpw; ?></td>
361  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['dbpw_comment']; ?></td>
362  </tr>
363  <tr>
364  <td bgcolor="#E3E3EA" align="center">$dbname</td>
365  <td bgcolor="#EEEEF6" align="center"><?php echo $dbname; ?></td>
366  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['dbname_comment']; ?></td>
367  </tr>
368  <tr>
369  <td bgcolor="#E3E3EA" align="center">$moveut</td>
370  <td bgcolor="#EEEEF6" align="center"><?php echo $moveut; ?></td>
371  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['moveut_comment']; ?><br><?php echo $nowyear; ?><?php echo $lang['year']; ?><?php echo $nowmonth; ?><?php echo $lang['month']; ?><?php echo $nowday; ?><?php echo $lang['day']; ?><?php echo $nowhour; ?><?php echo $lang['hour']; ?><?php echo $nowmin; ?><?php echo $lang['min']; ?></td>
372  </tr>
373  <tr>
374  <td bgcolor="#E3E3EA" align="center">$tablepre</td>
375  <td bgcolor="#EEEEF6" align="center"><?php echo $tablepre; ?></td>
376  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['tablepre_comment']; ?></td>
377  </tr>
378  <!--
379  <tr>
380  <td bgcolor="#E3E3EA" align="center">$authkey</td>
381  <td bgcolor="#EEEEF6" align="center"><?php echo $authkey; ?></td>
382  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['authkey_comment']; ?></td>
383  </tr>
384  -->
385  <input type="hidden" name="authkey" value="<?php echo $authkey; ?>">
386  <tr>
387  <td bgcolor="#E3E3EA" align="center">$bbsurl</td>
388  <td bgcolor="#EEEEF6" align="center"><?php echo $bbsurl; ?></td>
389  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['bbsurl_comment']; ?></td>
390  </tr>
391  <tr>
392  <td bgcolor="#E3E3EA" align="center">$gameurl</td>
393  <td bgcolor="#EEEEF6" align="center"><?php echo $gameurl; ?></td>
394  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['gameurl_comment']; ?></td>
395  </tr>
396  </table>
397  <br>
398  </td>
399  </tr>
400  <tr>
401  <td align="center">
402  <form method="post" action="?language=<?php echo $language; ?>">
403  <input type="hidden" name="action" value="environment">
404  <input type="submit" name="submit" value="<?php echo $lang['confirm_config']; ?>" style="height: 25">
405  <input type="button" name="exit" value="<?php echo $lang['refresh_config']; ?>" style="height: 25" onclick="javascript: window.location=('?language=<?php echo $language; ?>&action=config');">
406  </form>
407  </td>
408  </tr>
409 <?php
410 
411  }
412 
413  } else {
414 
415 ?>
416  <tr>
417  <td align="center">
418  <br>
419  <form method="post" action="?language=<?php echo $language; ?>">
420  <input type="hidden" name="action" value="config">
421  <input type="submit" name="submit" value="<?php echo $lang['recheck_config']; ?>" style="height: 25">
422  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
423  </form>
424  </td>
425  </tr>
426 <?php
427  }
428 } elseif($action == 'dbselect') {
429 
430  $exist_error = FALSE;
431  $write_error = FALSE;
432  if(file_exists('./config.inc.php')) {
433  $fileexists = result(1, 0);
434  } else {
435  $fileexists = result(0, 0);
436  $exist_error = TRUE;
437  $config_info = $lang['config_nonexistence'];
438  }
439  if(is_writeable('./config.inc.php')) {
440  $filewriteable = result(1, 0);
441  $config_info = $lang['choice_or_new_db'];
442  } else {
443  $filewriteable = result(0, 0);
444  $write_error = TRUE;
445  $config_info = $lang['config_unwriteable'];
446  }
447 ?>
448  <tr>
449  <td><b><?php echo $lang['current_process']; ?> </b><font color="#0000EE"><?php echo $lang['game_db_conf']; ?></font></td>
450  </tr>
451  <tr>
452  <td>
453  <hr noshade align="center" width="100%" size="1">
454  </td>
455  </tr>
456  <tr>
457  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['check_config']; ?></font></b></td>
458  </tr>
459  <tr>
460  <td>config.inc.php <?php echo $lang['check_existence']; ?> <?php echo $fileexists; ?></td>
461  </tr>
462  <tr>
463  <td>config.inc.php <?php echo $lang['check_writeable']; ?> <?php echo $filewriteable; ?></td>
464  </tr>
465  <tr>
466  <td>
467  <hr noshade align="center" width="100%" size="1">
468  </td>
469  </tr>
470  <tr>
471  <td><b><font color="#FF0000">&gt;</font><font color="#000000"><?php echo $lang['show_and_edit_db_conf']; ?></font></b></td>
472  </tr>
473  <tr>
474  <td align="center"><br><?php echo $config_info; ?></td>
475  </tr>
476  <tr>
477  <td align="center">
478  <br>
479  <form method="post" action="?language=<?php echo $language; ?>">
480  <table width="40%" cellspacing="1" bgcolor="#000000" border="0" align="center">
481  <tr bgcolor="#3A4273">
482  <td align="center" colspan="3" style="color: #FFFFFF"><?php echo $lang['db_set']; ?></td>
483  </tr>
484 <?php
485  if(!$exist_error) {
486 
487  if(!$write_error) {
488 
489  if($_POST['saveconfig'] && is_writeable('./config.inc.php')) {
490  $gamefounder = setconfig($_POST['gamefounder']);
491  $dbhost = setconfig($_POST['dbhost']);
492  $dbuser = setconfig($_POST['dbuser']);
493  $dbpw = setconfig($_POST['dbpw']);
494  $tablepre = setconfig($_POST['tablepre']);
495  $authkey = setconfig($_POST['authkey']);
496  $bbsurl = setconfig($_POST['bbsurl']);
497  $gameurl = setconfig($_POST['gameurl']);
498  $moveut = (int)$_POST['moveut'];
499 
500  $fp = fopen('./config.inc.php', 'r');
501  $configfile = fread($fp, filesize('./config.inc.php'));
502  fclose($fp);
503 
504  $configfile = preg_replace("/[$]gamefounder\s*\=\s*[\"'].*?[\"'];/is", "\$gamefounder = '$gamefounder';", $configfile);
505  $configfile = preg_replace("/[$]dbhost\s*\=\s*[\"'].*?[\"'];/is", "\$dbhost = '$dbhost';", $configfile);
506  $configfile = preg_replace("/[$]dbuser\s*\=\s*[\"'].*?[\"'];/is", "\$dbuser = '$dbuser';", $configfile);
507  $configfile = preg_replace("/[$]dbpw\s*\=\s*[\"'].*?[\"'];/is", "\$dbpw = '$dbpw';", $configfile);
508  $configfile = preg_replace("/[$]tablepre\s*\=\s*[\"'].*?[\"'];/is", "\$tablepre = '$tablepre';", $configfile);
509  $configfile = preg_replace("/[$]authkey\s*\=\s*[\"'].*?[\"'];/is", "\$authkey = '$authkey';", $configfile);
510  $configfile = preg_replace("/[$]bbsurl\s*\=\s*[\"'].*?[\"'];/is", "\$bbsurl = '$bbsurl';", $configfile);
511  $configfile = preg_replace("/[$]gameurl\s*\=\s*[\"'].*?[\"'];/is", "\$gameurl = '$gameurl';", $configfile);
512  $configfile = preg_replace("/[$]moveut\s*\=\s*-?[0-9]+;/is", "\$moveut = $moveut;", $configfile);
513 
514  $fp = fopen('./config.inc.php', 'w');
515  fwrite($fp, trim($configfile));
516  fclose($fp);
517  }
518 
519  include './config.inc.php';
520  include './include/db_'.$database.'.class.php';
521  $db = new dbstuff;
522  $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
523 
524  $query = $db->query("CREATE DATABASE bra_temp", 'SILENT');
525  if($db->error()) {
526  $createerror = TRUE;
527  } else {
528  $query = $db->query("DROP DATABASE bra_temp", 'SILENT');
529  $createerror = FALSE;
530  }
531 
532  $query = $db->query("SHOW DATABASES", 'SILENT');
533 
534  $option = '';
535  if($query) {
536  while($database = $db->fetch_array($query)) {
537  if($database['Database'] != 'mysql') {
538  $option .= '<option value="'.$database['Database'].'"' .($dbname == $database['Database'] ? ' selected' : '') . '>'.$database['Database']."</option>";
539  }
540  }
541  }
542  if(!empty($option)) {
543 ?>
544  <tr>
545  <td bgcolor="#EEEEF6">&nbsp;
546  <input name="type" type="radio" value="2" checked style="background-color:#EEEEF6">
547  <?php echo $lang['db_use_existence']; ?>:
548  </td>
549  <td bgcolor="#EEEEF6">&nbsp;
550  <select name="dbnameselect" style="width:200px"><?php echo $option; ?></select>
551  </td>
552  </tr>
553 
554 <?php
555  }
556  if(!$createerror) {
557 ?>
558  <tr>
559  <td bgcolor="#EEEEF6">&nbsp;
560  <input name="type" type="radio" value="1" style="background-color:#EEEEF6"<?php echo ((empty($option)) ? ' checked' : ''); ?>>
561  <?php echo $lang['db_create_new']; ?>:
562  </td>
563  <td bgcolor="#EEEEF6">&nbsp;
564  <input type="text" name="dbname" value="<?php echo $dbname; ?>" style="width:200px">
565  </td>
566  </tr>
567 <?php
568  }
569  if($createerror && empty($option)) {
570 ?>
571  <tr>
572  <td bgcolor="#EEEEF6">&nbsp;
573  <?php echo $lang['choice_one_db']; ?>:
574  </td>
575  <td bgcolor="#EEEEF6">&nbsp;
576  <input type="text" name="dbname" value="<?php echo $dbname; ?>" style="width:200px">
577  </td>
578  </tr>
579 <?php
580  }
581 ?>
582  </table>
583  </td>
584  </tr>
585 <?php
586  } else {
587  @include './config.inc.php';
588 ?>
589  <tr>
590  <td bgcolor="#EEEEF6">&nbsp;
591  <?php echo $lang['db']; ?>:
592  </td>
593  <td bgcolor="#EEEEF6">&nbsp;
594  <input type="hidden" name="dbname" value="<?php echo $dbname; ?>"><?php echo $dbname; ?>
595  </td>
596  </tr>
597  </table>
598  </td>
599  </tr>
600 <?php
601  }
602 ?>
603  <tr>
604  <td align="center">
605  <br>
606  <input type="hidden" name="action" value="environment">
607  <input type="hidden" name="saveconfig" value="1">
608  <input type="submit" name="submit" value="<?php echo $lang['save_config']; ?>" style="height: 25">
609  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
610  </td>
611  </tr>
612  </form>
613 <?php
614  }
615  if($exist_error) {
616 ?>
617  <tr>
618  <td align="center">
619  <br>
620  <form method="post" action="?language=<?php echo $language; ?>">
621  <input type="hidden" name="action" value="config">
622  <input type="submit" name="submit" value="<?php echo $lang['recheck_config']; ?>" style="height: 25">
623  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
624  </form>
625  </td>
626  </tr>
627 <?php
628 
629  }
630 } elseif($action == 'environment') {
631 
632  if($_POST['saveconfig'] && is_writeable('./config.inc.php')) {
633 
634  $dbname = ($_POST['type'] == 1) ? $_POST['dbname'] : $_POST['dbnameselect'];
636 
637  $fp = fopen('./config.inc.php', 'r');
638  $configfile = fread($fp, filesize('./config.inc.php'));
639  fclose($fp);
640 
641  $configfile = preg_replace("/[$]dbname\s*\=\s*[\"'].*?[\"'];/is", "\$dbname = '$dbname';", $configfile);
642 
643  $fp = fopen('./config.inc.php', 'w');
644  fwrite($fp, trim($configfile));
645  fclose($fp);
646 
647  }
648 
649  include './config.inc.php';
650  include './include/db_'.$database.'.class.php';
651  $db = new dbstuff;
652  $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
653 
654  $msg = '';
655  $quit = FALSE;
656 
657  $curr_os = PHP_OS;
658 
659  $curr_php_version = PHP_VERSION;
660  if($curr_php_version < '4.3.0') {
661  $msg .= "<font color=\"#FF0000\">$lang[php_version_430]</font>\t";
662  $quit = TRUE;
663  }
664 
665  if(@ini_get(file_uploads)) {
666  $max_size = @ini_get(upload_max_filesize);
667  $curr_upload_status = $lang['attach_enabled'].$max_size;
668  $msg .= $lang['attach_enabled_info'].$max_size."\t";
669  } else {
670  $curr_upload_status = $lang['attach_disabled'];
671  $msg .= "<font color=\"#FF0000\">$lang[attach_disabled_info]</font>\t";
672  }
673 
674  $query = $db->query("SELECT VERSION()");
675  $curr_mysql_version = $db->result($query, 0);
676  if($curr_mysql_version < '3.23') {
677  $msg .= "<font color=\"#FF0000\">$lang[mysql_version_323]</font>\t";
678  $quit = TRUE;
679  }
680 
681  $curr_disk_space = intval(diskfreespace('.') / (1024 * 1024)).'M';
682 
683  if(dir_writeable('./templates')) {
684  $curr_tpl_writeable = $lang['writeable'];
685  } else {
686  $curr_tpl_writeable = $lang['unwriteable'];
687  $msg .= "<font color=\"#FF0000\">$lang[unwriteable_template]</font>\t";
688  }
689 
690  if(dir_writeable('./gamedata')) {
691  $curr_data_writeable = $lang['writeable'];
692  } else {
693  $curr_data_writeable = $lang['unwriteable'];
694  $msg .= "<font color=\"#FF0000\">$lang[unwriteable_gamedata]</font>\t";
695  }
696 
697  if(strstr($tablepre, '.')) {
698  $msg .= "<font color=\"#FF0000\">$lang[tablepre_invalid]</font>\t";
699  $quit = TRUE;
700  }
701 
702  $db->select_db($dbname);
703  if($db->error()) {
704  if($db->version() > '4.1') {
705  $db->query("CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET $dbcharset");
706  } else {
707  $db->query("CREATE DATABASE IF NOT EXISTS $dbname");
708  }
709  if($db->error()) {
710  $msg .= "<font color=\"#FF0000\">$lang[db_invalid]</font>\t";
711  $quit = TRUE;
712  } else {
713  $db->select_db($dbname);
714  $msg .= "$lang[db_auto_created]\t";
715  }
716  }
717 
718  $query = $db->query("CREATE TABLE bra_test (test TINYINT (3) UNSIGNED)", 'SILENT');
719  if($db->error()) {
720  $dbpriv_createtable = '<font color="#FF0000">'.$lang['no'].'</font>';
721  $quit = TRUE;
722  } else {
723  $dbpriv_createtable = $lang['yes'];
724  }
725  $query = $db->query("INSERT INTO bra_test (test) VALUES (1)", 'SILENT');
726  if($db->error()) {
727  $dbpriv_insert = '<font color="#FF0000">'.$lang['no'].'</font>';
728  $quit = TRUE;
729  } else {
730  $dbpriv_insert = $lang['yes'];
731  }
732  $query = $db->query("SELECT * FROM bra_test", 'SILENT');
733  if($db->error()) {
734  $dbpriv_select = '<font color="#FF0000">'.$lang['no'].'</font>';
735  $quit = TRUE;
736  } else {
737  $dbpriv_select = $lang['yes'];
738  }
739  $query = $db->query("UPDATE bra_test SET test='2' WHERE test='1'", 'SILENT');
740  if($db->error()) {
741  $dbpriv_update = '<font color="#FF0000">'.$lang['no'].'</font>';
742  $quit = TRUE;
743  } else {
744  $dbpriv_update = $lang['yes'];
745  }
746  $query = $db->query("DELETE FROM bra_test WHERE test='2'", 'SILENT');
747  if($db->error()) {
748  $dbpriv_delete = '<font color="#FF0000">'.$lang['no'].'</font>';
749  $quit = TRUE;
750  } else {
751  $dbpriv_delete = $lang['yes'];
752  }
753  $query = $db->query("DROP TABLE bra_test", 'SILENT');
754  if($db->error()) {
755  $dbpriv_droptable = '<font color="#FF0000">'.$lang['no'].'</font>';
756  $quit = TRUE;
757  } else {
758  $dbpriv_droptable = $lang['yes'];
759  }
760 
761  $query - $db->query("SELECT COUNT(*) FROM $tablepre"."users", 'SILENT');
762  if(!$db->error()) {
763  $msg .= "<font color=\"#FF0000\">$lang[db_not_null]</font>\t";
764  $alert = " onSubmit=\"return confirm('$lang[db_drop_table_confirm]');\"";
765  } else {
766  $alert = '';
767  }
768 
769  if($quit) {
770  $msg .= "<font color=\"#FF0000\">$lang[install_abort]</font>";
771  } else {
772  $msg .= $lang['install_process'];
773  }
774 ?>
775  <tr>
776  <td><b><?php echo $lang['current_process']; ?> </b><font color="#0000EE"><?php echo $lang['check_env']; ?></font></td>
777  </tr>
778  <tr>
779  <td>
780  <hr noshade align="center" width="100%" size="1">
781  </td>
782  </tr>
783  <tr>
784  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['check_user_and_pass']; ?></font></b></td>
785  </tr>
786  <tr>
787  <td>
788  <br>
789  <table width="50%" cellspacing="1" bgcolor="#000000" border="0" align="center">
790  <tr bgcolor="#3A4273">
791  <td align="center" style="color: #FFFFFF"><?php echo $lang['permission']; ?></td>
792  <td align="center" style="color: #FFFFFF"><?php echo $lang['status']; ?></td>
793  </tr>
794  <tr>
795  <td bgcolor="#E3E3EA" align="center">CREATE TABLE</td>
796  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_createtable; ?></td>
797  </tr>
798  <tr>
799  <td bgcolor="#E3E3EA" align="center">INSERT</td>
800  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_insert; ?></td>
801  </tr>
802  <tr>
803  <td bgcolor="#E3E3EA" align="center">SELECT</td>
804  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_select; ?></td>
805  </tr>
806  <tr>
807  <td bgcolor="#E3E3EA" align="center">UPDATE</td>
808  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_update; ?></td>
809  </tr>
810  <tr>
811  <td bgcolor="#E3E3EA" align="center">DELETE</td>
812  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_delete; ?></td>
813  </tr>
814  <tr>
815  <td bgcolor="#E3E3EA" align="center">DROP TABLE</td>
816  <td bgcolor="#EEEEF6" align="center"><?php echo $dbpriv_droptable; ?></td>
817  </tr>
818  </table>
819  <br>
820  </td>
821  </tr>
822  <tr>
823  <td>
824  <hr noshade align="center" width="100%" size="1">
825  </td>
826  </tr>
827  <tr>
828  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['compare_env']; ?></font></b></td>
829  </tr>
830  <tr>
831  <td>
832  <br>
833  <table width="80%" cellspacing="1" bgcolor="#000000" border="0" align="center">
834  <tr bgcolor="#3A4273">
835  <td align="center"></td>
836  <td align="center" style="color: #FFFFFF"><?php echo $lang['env_required']; ?></td>
837  <td align="center" style="color: #FFFFFF"><?php echo $lang['env_best']; ?></td>
838  <td align="center" style="color: #FFFFFF"><?php echo $lang['env_current']; ?></td>
839  </tr>
840  <tr>
841  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['env_os']; ?></td>
842  <td bgcolor="#EEEEF6" align="center"><?php echo $lang['unlimited']; ?></td>
843  <td bgcolor="#E3E3EA" align="center">UNIX/Linux/FreeBSD</td>
844  <td bgcolor="#E3E3EA" align="center"><?php echo $curr_os; ?></td>
845  </tr>
846  <tr>
847  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['env_php']; ?></td>
848  <td bgcolor="#EEEEF6" align="center">4.3.0+</td>
849  <td bgcolor="#E3E3EA" align="center">5.2.0+</td>
850  <td bgcolor="#EEEEF6" align="center"><?php echo $curr_php_version; ?></td>
851  </tr>
852  <tr>
853  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['env_mysql']; ?></td>
854  <td bgcolor="#EEEEF6" align="center">3.23+</td>
855  <td bgcolor="#E3E3EA" align="center">4.0.18</td>
856  <td bgcolor="#EEEEF6" align="center"><?php echo $curr_mysql_version; ?></td>
857  </tr>
858  <tr>
859  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['env_diskspace']; ?></td>
860  <td bgcolor="#EEEEF6" align="center">10M+</td>
861  <td bgcolor="#E3E3EA" align="center">50M+</td>
862  <td bgcolor="#EEEEF6" align="center"><?php echo $curr_disk_space; ?></td>
863  </tr>
864  <tr>
865  <td bgcolor="#E3E3EA" align="center">./templates <?php echo $lang['env_dir_writeable']; ?></td>
866  <td bgcolor="#EEEEF6" align="center"><?php echo $lang['unlimited']; ?></td>
867  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['writeable']; ?></td>
868  <td bgcolor="#EEEEF6" align="center"><?php echo $curr_tpl_writeable; ?></td>
869  </tr>
870  <tr>
871  <td bgcolor="#E3E3EA" align="center">./gamedata <?php echo $lang['env_dir_writeable']; ?></td>
872  <td bgcolor="#EEEEF6" align="center"><?php echo $lang['unlimited']; ?></td>
873  <td bgcolor="#E3E3EA" align="center"><?php echo $lang['writeable']; ?></td>
874  <td bgcolor="#EEEEF6" align="center"><?php echo $curr_data_writeable; ?></td>
875  </tr>
876  </table>
877  <br>
878  </td>
879  </tr>
880  <tr>
881  <td>
882  <hr noshade align="center" width="100%" size="1">
883  </td>
884  </tr>
885  <tr>
886  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['confirm_preparation']; ?></font></b></td>
887  </tr>
888  <tr>
889  <td>
890  <br>
891  <ol><?php echo $lang['preparation']; ?></ol>
892  </td>
893  </tr>
894  <tr>
895  <td>
896  <hr noshade align="center" width="100%" size="1">
897  </td>
898  </tr>
899  <tr>
900  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['install_note']; ?></font></b></td>
901  </tr>
902  <tr>
903  <td>
904  <br>
905  <ol>
906 <?php
907 
908  foreach(explode("\t", $msg) as $message) {
909  echo " <li>$message</li>\n";
910  }
911  echo" </ol>\n";
912 
913  if($quit) {
914 
915 ?>
916  <center>
917  <input type="button" name="refresh" value="<?php echo $lang['recheck_config']; ?>" style="height: 25" onclick="javascript: window.location=('?language=<?php echo $language; ?>&action=environment');">&nbsp;
918  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
919  </center>
920 <?php
921 
922  } else {
923  include './config.inc.php';
924  include './gamedata/system.php';
925  $now = time() + $moveut*3600;
926  list($nowsec,$nowmin,$nowhour,$nowday,$nowmonth,$nowyear,$nowwday,$nowyday,$nowisdst) = localtime($now);
927  $nowmonth++;
928  $nowyear += 1900;
929 
930 ?>
931  <form method="post" action="?language=<?php echo $language; ?>" <?php echo $alert; ?>>
932 
933  <tr>
934  <td>
935  <hr noshade align="center" width="100%" size="1">
936  </td>
937  </tr>
938  <tr>
939  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['add_admin']; ?></font></b></td>
940  </tr>
941  <tr>
942  <td align="center">
943  <br>
944  <table width="650" cellspacing="1" bgcolor="#000000" border="0" align="center">
945  <tr bgcolor="#3A4273">
946  <td align="center" width="20%" style="color: #FFFFFF"><?php echo $lang['variable']; ?></td>
947  <td align="center" width="30%" style="color: #FFFFFF"><?php echo $lang['value']; ?></td>
948  <td align="center" width="50%" style="color: #FFFFFF"><?php echo $lang['comment']; ?></td>
949  </tr>
950  <tr>
951  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['username']; ?></td>
952  <td bgcolor="#EEEEF6" width="30%"><input type="text" name="username" value="admin" size="30"></td>
953  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['username_comment']; ?></td>
954  </tr>
955  <tr>
956  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['brpswd']; ?></td>
957  <td bgcolor="#EEEEF6" width="30%"><input type="password" name="brpswd" size="30"></td>
958  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['brpswd_comment']; ?></td>
959  </tr>
960  <tr>
961  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['adminmsg']; ?></td>
962  <td bgcolor="#EEEEF6" width="30%"><textarea cols="30" rows="4" style="overflow:auto" name="adminmsg" value=""></textarea></td>
963  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['adminmsg_comment']; ?></td>
964  </tr>
965  <tr>
966  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['startmode']; ?></td>
967  <td bgcolor="#EEEEF6" width="30%"><input type="radio" name="startmode" value="1" checked><?php echo $lang['startmode_1']; ?><input type="radio" name="startmode" value="2"><?php echo $lang['startmode_2']; ?><input type="radio" name="startmode" value="3"><?php echo $lang['startmode_3']; ?><input type="radio" name="startmode" value="0"><?php echo $lang['startmode_0']; ?></td>
968  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['startmode_comment']; ?></td>
969  </tr>
970  <tr>
971  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['starttime']; ?></td>
972  <td bgcolor="#EEEEF6" colspan="2"><input type="radio" name="starttime" value="<?php echo $now; ?>" checked><?php echo $lang['starttime_1']; ?><input type="radio" name="starttime" value="0"><?php echo $lang['starttime_0']; ?><input type="text" name="setyear" size="4" value="<?php echo $nowyear; ?>"><?php echo $lang['year']; ?><input type="text" name="setmonth" size="2" value="<?php echo $nowmonth; ?>"><?php echo $lang['month']; ?><input type="text" name="setday" size="2" value="<?php echo $nowday; ?>"><?php echo $lang['day']; ?><input type="text" name="sethour" size="2" value="<?php echo $nowhour; ?>"><?php echo $lang['hour']; ?><input type="hidden" name="startmin" size="2" value="<?php echo $startmin; ?>"></td>
973  </tr>
974  <tr>
975  <td bgcolor="#E3E3EA" width="20%">&nbsp;<?php echo $lang['iplimit']; ?></td>
976  <td bgcolor="#EEEEF6" width="30%"><input type="text" name="iplimit" value="<?php echo $iplimit; ?>" size="30"></td>
977  <td bgcolor="#E3E3EA">&nbsp;<?php echo $lang['iplimit_comment']; ?></td>
978  </tr>
979  </table>
980  <br>
981  <input type="hidden" name="action" value="install">
982  <input type="submit" name="submit" value="<?php echo $lang['start_install']; ?>" style="height: 25" >&nbsp;
983  <input type="button" name="exit" value="<?php echo $lang['exit']; ?>" style="height: 25" onclick="javascript: window.close();">
984  </td>
985  </tr>
986 
987  </form>
988 <?php
989 
990  }
991 } elseif($action == 'install') {
992 
993  $username = $_POST['username'];
994  $brpswd = $_POST['brpswd']
995 
996 ?>
997  <tr>
998  <td><b><?php echo $lang['current_process']; ?> </b><font color="#0000EE"> <?php echo $lang['installing']; ?></font></td>
999  </tr>
1000  <tr>
1001  <td>
1002  <hr noshade align="center" width="100%" size="1">
1003  </td>
1004  </tr>
1005  <tr>
1006  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['check_admin']; ?></font></b></td>
1007  </tr>
1008  <tr>
1009  <td><?php echo $lang['check_admin_validity']; ?>
1010 <?php
1011 
1012  $msg = '';
1013  if(!$username) {
1014  $msg = $lang['admin_username_invalid'];
1015  }
1016  if(!$brpswd) {
1017  $msg = $lang['admin_password_invalid'];
1018  }
1019  else {
1020  $brpswd=md5($brpswd);
1021  }
1022 
1023  if($msg) {
1024 
1025 ?>
1026  ... <font color="#FF0000"><?php echo $lang['fail_reason']; ?> <?php echo $msg; ?></font></td>
1027  </tr>
1028  <tr>
1029  <td align="center">
1030  <br>
1031  <input type="button" name="back" value="<?php echo $lang['go_back']; ?>" onclick="javascript: history.go(-1);">
1032  </td>
1033  </tr>
1034  <tr>
1035  <td>
1036  <hr noshade align="center" width="100%" size="1">
1037  </td>
1038  </tr>
1039  <tr>
1040  <td align="center">
1041  <b style="font-size: 11px">Powered by <a href="http://loongyou.com" target="_blank"><?php echo $lang['gamename']; ?> <?php echo $version; ?></a> , &nbsp; Copyright &copy; <a href="http://www.loongyou.com" target=\"_blank\">loongyou.com</a>, 2006-2007</b>
1042  </td>
1043  </tr>
1044  </table>
1045  </td>
1046  </tr>
1047 </table>
1048 <br>
1049 </body>
1050 </html>
1051 
1052 <?php
1053 
1054  exit();
1055  } else {
1056  echo result(1, 0)."</td>\n";
1057  echo" </tr>\n";
1058  }
1059 
1060 ?>
1061  <tr>
1062  <td>
1063  <hr noshade align="center" width="100%" size="1">
1064  </td>
1065  </tr>
1066  <tr>
1067  <td><b><font color="#FF0000">&gt;</font><font color="#000000"> <?php echo $lang['select_db']; ?></font></b></td>
1068  </tr>
1069 <?php
1070  include './config.inc.php';
1071 
1072  if(empty($dbcharset) && ($charset == 'gbk' || $charset == 'big5')) {
1073  $dbcharset = $charset;
1074  }
1075 
1076  include './include/db_'.$database.'.class.php';
1077  $db = new dbstuff;
1078  $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
1079  $db->select_db($dbname);
1080 
1081 
1082 echo" <tr>\n";
1083 echo" <td>$lang[select_db] $dbname ".result(1, 0)."</td>\n";
1084 echo" </tr>\n";
1085 echo" <tr>\n";
1086 echo" <td>\n";
1087 echo" <hr noshade align=\"center\" width=\"100%\" size=\"1\">\n";
1088 echo" </td>\n";
1089 echo" </tr>\n";
1090 echo" <tr>\n";
1091 echo" <td><b><font color=\"#FF0000\">&gt;</font><font color=\"#000000\"> $lang[create_table]</font></b></td>\n";
1092 echo" </tr>\n";
1093 echo" <tr>\n";
1094 echo" <td>\n";
1095 
1096 $extrasql = <<<EOT
1097 INSERT INTO bra_users (username,`password`,groupid) VALUES ('$username','$brpswd','9');
1098 EOT;
1099 
1100  runquery($sql);
1101  runquery($extrasql);
1102 
1103 loginit('adminlog');
1104 loginit('newsinfo');
1105 
1106 dir_clear('./gamedata/bak');
1107 //dir_clear('./gamedata/log');
1108 //dir_clear('./gamedata/mapitem');
1109 //dir_clear('./gamedata/shopitem');
1110 dir_clear('./gamedata/templates');
1111 
1112 echo $lang['init_game'];
1113 
1114 
1115 $adminmsg = setconfig($_POST['adminmsg']);
1116 $startmode = (int)$_POST['startmode'];
1117 $iplimit = (int)$_POST['iplimit'];
1118 
1119 if($startmode == 1) {
1120  $starthour = 10;
1121 } elseif($startmode == 2) {
1122  $starthour = 1;
1123 } else {
1124  $starthour = 0;
1125 }
1126 
1127 
1128 $fp = fopen('./gamedata/system.php', 'r');
1129 $systemfile = fread($fp, filesize('./gamedata/system.php'));
1130 fclose($fp);
1131 
1132 $systemfile = preg_replace("/[$]adminmsg\s*\=\s*[\"'].*?[\"'];/is", "\$adminmsg = '$adminmsg';", $systemfile);
1133 $systemfile = preg_replace("/[$]startmode\s*\=\s*[0-9]+;/is", "\$startmode = $startmode;", $systemfile);
1134 $systemfile = preg_replace("/[$]starthour\s*\=\s*[0-9]+;/is", "\$starthour = $starthour;", $systemfile);
1135 $systemfile = preg_replace("/[$]iplimit\s*\=\s*[0-9]+;/is", "\$iplimit = $iplimit;", $systemfile);
1136 
1137 $fp = fopen('./gamedata/system.php', 'w');
1138 @fwrite($fp, trim($systemfile));
1139 @fclose($fp);
1140 
1141 result();
1142 echo $lang['new_game'];
1143 $starttime = (int)$_POST['starttime'];
1144 $startmin = (int)$_POST['startmin'];
1145 if(!$starttime) {
1146  $nowtime = time()+$moveut*3600;
1147  $settime = mktime((int)$_POST['sethour'],(int)$_POST['startmin'],0,(int)$_POST['setmonth'],(int)$_POST['setday'],(int)$_POST['setyear']);
1148  $starttime = $nowtime > $settime ? $nowtime : $settime;
1149 
1150 }
1151 $fp = fopen('./install/gameinfo.php', 'r');
1152 $systemfile = fread($fp, filesize('./install/gameinfo.php'));
1153 fclose($fp);
1154 
1155 $systemfile = preg_replace("/[$]starttime\s*\=\s*[0-9]+;/is", "\$starttime = $starttime;", $systemfile);
1156 
1157 $fp = fopen('./gamedata/gameinfo.php', 'w+');
1158 @fwrite($fp, trim($systemfile));
1159 @fclose($fp);
1160 
1161 result();
1162 
1163 touch(GAME_ROOT.$lockfile);
1164 ?>
1165  </td>
1166  </tr>
1167  <tr>
1168  <td>
1169  <hr noshade align="center" width="100%" size="1">
1170  </td>
1171  </tr>
1172  <tr>
1173  <td align="center">
1174  <font color="#FF0000"><b><?php echo $lang['install_succeed']; ?></font><br>
1175  <?php echo $lang['username']; ?></b> <?php echo $username; ?><br><br>
1176  <a href="<?php echo $gameurl; ?>" target="_blank"><?php echo $lang['goto_game']; ?></a>
1177  </td>
1178  </tr>
1179 <?php
1180 
1181 }
1182 
1183 ?>
1184  <tr>
1185  <td>
1186  <hr noshade align="center" width="100%" size="1">
1187  </td>
1188  </tr>
1189  <tr>
1190  <td align="center">
1191  <b style="font-size: 11px">Powered by <a href="http://loongyou.com" target="_blank"><?php echo $lang['gamename']; ?> <?php echo $version; ?></a> , &nbsp; Copyright &copy; <a href="http://www.loongyou.com" target=\"_blank\">loongyou.com</a>, 2006-2007</b>
1192  </td>
1193  </tr>
1194  </table>
1195  </td>
1196  </tr>
1197 </table>
1198 <br>
1199 </body>
1200 </html>
1201 <?php
1202 
1203 function loginit($logfile) {
1204  global $lang;
1205 
1206  echo $lang['init_log'].' '.$logfile;
1207  $fp = @fopen('./gamedata/'.$logfile.'.php', 'w');
1208  @fwrite($fp, "<? if(!defined(\"IN_GAME\")) exit(\"Access Denied\"); ?>\n");
1209  @fclose($fp);
1210  result();
1211 }
1212 
1213 function runquery($sql) {
1214  global $lang, $dbcharset, $tablepre, $db;
1215 
1216  $sql = str_replace("\r", "\n", str_replace(' bra_', ' '.$tablepre, $sql));
1217  $ret = array();
1218  $num = 0;
1219  foreach(explode(";\n", trim($sql)) as $query) {
1220  $queries = explode("\n", trim($query));
1221  foreach($queries as $query) {
1222  $ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
1223  }
1224  $num++;
1225  }
1226  unset($sql);
1227 
1228  foreach($ret as $query) {
1229  $query = trim($query);
1230  if($query) {
1231  if(substr($query, 0, 12) == 'CREATE TABLE') {
1232  $name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
1233  echo $lang['create_table'].' '.$name.' ... <font color="#0000EE">'.$lang['succeed'].'</font><br>';
1234  $db->query(createtable($query, $dbcharset));
1235  } else {
1236  $db->query($query);
1237  }
1238  }
1239  }
1240 }
1241 
1242 function result($result = 1, $output = 1) {
1243  global $lang;
1244 
1245  if($result) {
1246  $text = '... <font color="#0000EE">'.$lang['succeed'].'</font><br>';
1247  if(!$output) {
1248  return $text;
1249  }
1250  echo $text;
1251  } else {
1252  $text = '... <font color="#FF0000">'.$lang['fail'].'</font><br>';
1253  if(!$output) {
1254  return $text;
1255  }
1256  echo $text;
1257  }
1258 }
1259 
1260 function dir_writeable($dir) {
1261  if(!is_dir($dir)) {
1262  @mkdir($dir, 0777);
1263  }
1264  if(is_dir($dir)) {
1265  if($fp = @fopen("$dir/test.test", 'w')) {
1266  @fclose($fp);
1267  @unlink("$dir/test.test");
1268  $writeable = 1;
1269  } else {
1270  $writeable = 0;
1271  }
1272  }
1273  return $writeable;
1274 }
1275 
1276 function dir_clear($dir) {
1277  global $lang;
1278 
1279  echo $lang['clear_dir'].' '.$dir;
1280  $directory = dir($dir);
1281  while($entry = $directory->read()) {
1282  $filename = $dir.'/'.$entry;
1283  if(is_file($filename)) {
1284  @unlink($filename);
1285  }
1286  }
1287  $directory->close();
1288  result();
1289 }
1290 
1291 function random($length) {
1292  $hash = '';
1293  $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
1294  $max = strlen($chars) - 1;
1295  mt_srand((double)microtime() * 1000000);
1296  for($i = 0; $i < $length; $i++) {
1297  $hash .= $chars[mt_rand(0, $max)];
1298  }
1299  return $hash;
1300 }
1301 
1302 function createtable($sql, $dbcharset) {
1303  $type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
1304  $type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
1305  return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
1306  (mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
1307 }
1308 
1309 function setconfig($string) {
1310  if(!get_magic_quotes_gpc()) {
1311  $string = str_replace('\'', '\\\'', $string);
1312  } else {
1313  $string = str_replace('\"', '"', $string);
1314  }
1315  return $string;
1316 }
1317 
1318 ?>
setconfig($string)
Definition: install.php:1309
$tablepre
Definition: config.inc.php:58
if(PHP_VERSION< '4.3.0')
Definition: clear.php:9
$bbsurl
Definition: config.inc.php:82
$database
Definition: config.inc.php:67
$dbcharset
Definition: config.inc.php:73
$startmode
Definition: system.php:16
$dir
Definition: chmod.php:2
const GAME_ROOT
Definition: install.php:8
$dbpw
Definition: config.inc.php:12
$i
Definition: botservice.php:267
if(!$action) elseif($action== 'config') elseif($action== 'dbselect') elseif($action== 'environment') elseif($action== 'install') runquery($sql)
Definition: install.php:1213
< inputtype="radio"name="tplrefresh"value="0"<?phpif(!$tplrefresh){?> checked
random($length)
Definition: install.php:1291
if(PHP_VERSION< '4.3.0') $action
Definition: install.php:14
$db
Definition: clear.php:32
$moveut
Definition: config.inc.php:49
【生存者数:<?php echo $alivenum?> 人】< input type="button"value="显示全部幸存者"onClick="$('alivemode').value='all';$('gbmode').value='none';postCmd('alive','alive.php');"></p > if($gamblingon &&$gamestate >=20) elseif($gamblingon &&$gamestate<=10)
Definition: 1_alive.tpl.php:18
$gamefounder
Definition: config.inc.php:43
dir_writeable($dir)
Definition: install.php:1260
$iplimit
Definition: banlist.php:4
$now
Definition: clear.php:23
$lang
Definition: admin.lang.php:4
$charset
Definition: config.inc.php:70
config($file= '', $cfg=1)
value
Definition: 1_alive.tpl.php:10
$starthour
Definition: system.php:18
$startmin
Definition: system.php:20
$dbhost
Definition: config.inc.php:6
$dbuser
Definition: config.inc.php:9
$language
Definition: install.php:15
$version
Definition: install.php:66
$pconnect
Definition: config.inc.php:40
createtable($sql, $dbcharset)
Definition: install.php:1302
$dbname
Definition: config.inc.php:15
result($result=1, $output=1)
Definition: install.php:1242
$starttime
Definition: gameinfo.php:5
$nowmonth
Definition: configmng.php:56
$gameurl
Definition: config.inc.php:85
if(!$cuser||!$cpass) $result
Definition: admin.php:25
$nowyear
Definition: configmng.php:57
$authkey
Definition: config.inc.php:61
adminlog($op, $an1='', $an2='', $an3='')
Definition: admin.php:58
if(!defined('IN_ADMIN')) $adminmsg
Definition: systemmng.php:6
dir_clear($dir)
Definition: install.php:1276