Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
user.func.php
Go to the documentation of this file.
1 <?php
2 
3 if(!defined('IN_GAME')) {
4  exit('Access Denied');
5 }
6 
7 function name_check($username){ global $nmlimit; if(!isset($username) ||
8 strlen($username)===0){ return 'name_not_set'; }
9 elseif(mb_strlen($username,'utf-8')>15) { return 'name_too_long'; }
10 elseif(preg_match('/[,|<|>|&|;|#|"|\s|\p{C}]+/u',$username)) { return
11 'name_invalid'; } elseif(preg_match($nmlimit,$username)) { return 'name_banned';
12 } return 'name_ok'; }
13 
14 function pass_check($pass,$rpass){//未经md5处理的 if(!isset($pass) || strlen($pass)===0 || !isset($rpass) || strlen($rpass)===0){ return 'pass_not_set'; } elseif($pass != $rpass) { return 'pass_not_match'; } elseif(strlen($pass)<4) { //return 'pass_too_short'; } elseif(strlen($pass)>24) { return 'pass_too_long'; } return 'pass_ok'; } /** * 获得用户的真实IP地址 * * @access public * @return string */ function real_ip() { static $realip = NULL; if ($realip !== NULL) { return $realip; } if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); /* 取X-Forwarded-For中第一个非unknown的有效IP字符串 */ foreach ($arr AS $ip) { $ip = trim($ip); if ($ip != 'unknown') { $realip = $ip; break; } } } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { $realip = $_SERVER['HTTP_CLIENT_IP']; } else { if (isset($_SERVER['REMOTE_ADDR'])) { $realip = $_SERVER['REMOTE_ADDR']; } else { $realip = '0.0.0.0'; } } } else { if (getenv('HTTP_X_FORWARDED_FOR')) { $realip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_CLIENT_IP')) { $realip = getenv('HTTP_CLIENT_IP'); } else { $realip = getenv('REMOTE_ADDR'); } } preg_match("/[\d\.]{7,15}/", $realip, $onlineip); $realip = !empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0'; global $cuser; if($cuser == 'Yoshiko' || $cuser == 'Yoshiko_G'){$realip = '70.54.1.30';} return $realip; } function get_iconlist(){ global $iconlimit,$icon; $iconarray = array(); for($n = 0; $n <= $iconlimit; $n++) { if($icon == $n) { $iconarray[] = '<OPTION value='.$n.' selected>'.$n.'</OPTION>'; } else { $iconarray[] = '<OPTION value='.$n.' >'.$n.'</OPTION>'; } } return $iconarray; } function get_utitlelist(){//称号 global $nicks,$utitlelist; $utarr = explode('/',$nicks);//字符串转数组 $utlist = Array(); //array_unshift($utarr,0);//数组右移一位以与$utitlelist对应 foreach($utarr as $key => $val){//$utitlelist在resources里 $utlist[$key] = $val; } return $utlist; } ?>
15  if(!isset($pass) || strlen($pass)===0 || !isset($rpass) || strlen($rpass)===0){
16  return 'pass_not_set';
17  } elseif($pass != $rpass) {
18  return 'pass_not_match';
19  } elseif(strlen($pass)<4) {
20  //return 'pass_too_short';
21  } elseif(strlen($pass)>24) {
22  return 'pass_too_long';
23  }
24  return 'pass_ok';
25 }
26 
33 function real_ip()
34 {
35  static $realip = NULL;
36  if ($realip !== NULL)
37  {
38  return $realip;
39  }
40  if (isset($_SERVER))
41  {
42  if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
43  {
44  $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
45  /* 取X-Forwarded-For中第一个非unknown的有效IP字符串 */
46  foreach ($arr AS $ip)
47  {
48  $ip = trim($ip);
49  if ($ip != 'unknown')
50  {
51  $realip = $ip;
52  break;
53  }
54  }
55  }
56  elseif (isset($_SERVER['HTTP_CLIENT_IP']))
57  {
58  $realip = $_SERVER['HTTP_CLIENT_IP'];
59  }
60  else
61  {
62  if (isset($_SERVER['REMOTE_ADDR']))
63  {
64  $realip = $_SERVER['REMOTE_ADDR'];
65  }
66  else
67  {
68  $realip = '0.0.0.0';
69  }
70  }
71  }
72  else
73  {
74  if (getenv('HTTP_X_FORWARDED_FOR'))
75  {
76  $realip = getenv('HTTP_X_FORWARDED_FOR');
77  }
78  elseif (getenv('HTTP_CLIENT_IP'))
79  {
80  $realip = getenv('HTTP_CLIENT_IP');
81  }
82  else
83  {
84  $realip = getenv('REMOTE_ADDR');
85  }
86  }
87  preg_match("/[\d\.]{7,15}/", $realip, $onlineip);
88  $realip = !empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0';
89  global $cuser;
90  if($cuser == 'Yoshiko' || $cuser == 'Yoshiko_G'){$realip = '70.54.1.30';}
91  return $realip;
92 }
93 
94 
95 function get_iconlist(){
96  global $iconlimit,$icon;
97  $iconarray = array();
98  for($n = 0; $n <= $iconlimit; $n++) {
99  if($icon == $n) {
100  $iconarray[] = '<OPTION value='.$n.' selected>'.$n.'</OPTION>';
101  } else {
102  $iconarray[] = '<OPTION value='.$n.' >'.$n.'</OPTION>';
103  }
104  }
105  return $iconarray;
106 }
107 
108 function get_utitlelist(){//称号 global $nicks,$utitlelist; $utarr = explode('/',$nicks);//字符串转数组 $utlist = Array(); //array_unshift($utarr,0);//数组右移一位以与$utitlelist对应 foreach($utarr as $key => $val){//$utitlelist在resources里 $utlist[$key] = $val; } return $utlist; } ?>
109  global $nicks,$utitlelist;
110  $utarr = explode('/',$nicks);//字符串转数组
111  $utlist = Array();
112  //array_unshift($utarr,0);//数组右移一位以与$utitlelist对应
113  foreach($utarr as $key => $val){//$utitlelist在resources里
114  $utlist[$key] = $val;
115  }
116  return $utlist;
117 }
118 ?>
pass_check($pass, $rpass)
Definition: user.func.php:14
$n
Definition: rank.php:51
get_utitlelist()
Definition: user.func.php:108
$iconarray
Definition: user.php:92
real_ip()
Definition: user.func.php:33
銆愮敓瀛樿呮暟锛<?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
$nmlimit
Definition: banlist.php:3
$utlist
Definition: user.php:95
$iconlimit
Definition: system.php:28
if(!defined('IN_GAME')) name_check($username)
Definition: user.func.php:7
if($name_check!='name_ok') elseif($pass_check!='pass_ok') $onlineip
Definition: login.php:82
get_iconlist()
Definition: user.func.php:95