Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
validlimitmng.php
Go to the documentation of this file.
1 <?php
2 if(!defined('IN_ADMIN')) {
3  exit('Access Denied');
4 }
5 if($mygroup < 6){
6  exit($_ERROR['no_power']);
7 }
8 $dir = GAME_ROOT.'./gamedata/';
9 
10 if($write){
11  write_valid_limit($dir,$postnmlmt,$postiplmt);
12  echo '新的屏蔽列表已经写入。<br>';
13 }
14 
15 include_once $dir.'banlist.list';
16 
17 //foreach(Array('nm','ip') as $ar_nm){
18 // ${$ar_nm.'lmtlist0'} = ${$ar_nm.'lmtlist'} = '';
19 // foreach(${$ar_nm.'limit'} as $value){
20 // ${$ar_nm.'lmtlist'} .= $value.'|';
21 // }
22 // if(${$ar_nm.'lmtlist0'} != ${$ar_nm.'lmtlist'}){
23 // ${$ar_nm.'lmtlist'} = substr(${$ar_nm.'lmtlist'},0,-1);
24 // }
25 //}
26 
27 function write_valid_limit($dir,$nmlmtstr,$iplmtstr){
28  foreach(Array('nm','ip') as $ar_nm){
29  ${$ar_nm.'lmtarray'} = explode('|',${$ar_nm.'lmtstr'});
30  ${$ar_nm.'lmtlist0'} = ${$ar_nm.'lmtlist'} = '';
31  foreach(${$ar_nm.'lmtarray'} as $value){
32  ${$ar_nm.'lmtlist'} .= "'$value',";
33  }
34  if(${$ar_nm.'lmtlist0'} != ${$ar_nm.'lmtlist'}){
35  ${$ar_nm.'lmtlist'} = 'Array('.substr(${$ar_nm.'lmtlist'},0,-1).')';
36  }else{
37  ${$ar_nm.'lmtlist'} = 'Array()';
38  }
39  }
40  $vldata = "<?php\n\n\$nmlimit = {$nmlmtlist};\n\$iplimit = {$iplmtlist};\n\n?>";
41  if($fp = fopen("{$dir}banlist.list", 'w')) {
42  if(flock($fp,LOCK_EX)) {
43  fwrite($fp, $vldata);
44  } else {
45  exit("Couldn't save the game's info !");
46  }
47  fclose($fp);
48  } else {
49  gexit('Can not write to cache files, please check directory ./gamedata/ .', __file__, __line__);
50  }
51  return;
52 }
53 echo <<<EOT
54 <form method="post" name="banlist" onsubmit="admin.php">
55 <input type="hidden" name="mode" value="banlistmng">
56 <input type="hidden" name="command" value="banlistmng">
57 <input type="hidden" name="write" value="1">
58 <div>输入要屏蔽的用户名和IP段,用|隔开。</div>
59 <div>用户名屏蔽:<br><textarea name="postnmlmt" style="width:450;height:150">$nmlist</textarea></div><br>
60 <div>IP段屏蔽:<br><textarea name="postiplmt" style="width:450;height:150">$iplist</textarea></div>
61 <input type="submit" value="提交">
62 </form>
63 EOT;
64 ?>
const GAME_ROOT
Definition: clear.php:6
$_ERROR
if(!defined('IN_ADMIN')) if($mygroup< 6) $dir
value
Definition: 1_alive.tpl.php:10
gexit($message= '', $file= '', $line=0)
Definition: global.func.php:30
write_valid_limit($dir, $nmlmtstr, $iplmtstr)