mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
Fix #971. Add lowercase checking of Config.
This commit is contained in:
parent
e2298d861c
commit
01e9ca7852
@ -21,9 +21,16 @@
|
|||||||
|
|
||||||
class BanAPI{
|
class BanAPI{
|
||||||
private $server;
|
private $server;
|
||||||
|
/*
|
||||||
|
* I would use PHPDoc Template here but PHPStorm does not recognise it. - @sekjun9878
|
||||||
|
*/
|
||||||
|
/** @var Config */
|
||||||
private $whitelist;
|
private $whitelist;
|
||||||
|
/** @var Config */
|
||||||
private $banned;
|
private $banned;
|
||||||
|
/** @var Config */
|
||||||
private $ops;
|
private $ops;
|
||||||
|
/** @var Config */
|
||||||
private $bannedIPs;
|
private $bannedIPs;
|
||||||
private $cmdWL = array();//Command WhiteList
|
private $cmdWL = array();//Command WhiteList
|
||||||
function __construct(){
|
function __construct(){
|
||||||
@ -349,11 +356,14 @@ class BanAPI{
|
|||||||
public function isIPBanned($ip){
|
public function isIPBanned($ip){
|
||||||
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
|
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->bannedIPs->exists($ip)){
|
}elseif($this->bannedIPs->exists($ip, true)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $username
|
* @param string $username
|
||||||
@ -364,11 +374,14 @@ class BanAPI{
|
|||||||
$username = strtolower($username);
|
$username = strtolower($username);
|
||||||
if($this->server->api->dhandle("api.ban.check", $username) === false){
|
if($this->server->api->dhandle("api.ban.check", $username) === false){
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->banned->exists($username)){
|
}elseif($this->banned->exists($username, true)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $username
|
* @param string $username
|
||||||
@ -381,7 +394,7 @@ class BanAPI{
|
|||||||
return true;
|
return true;
|
||||||
}elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
|
}elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->whitelist->exists($username)){
|
}elseif($this->whitelist->exists($username, true)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -182,8 +182,20 @@ class Config{
|
|||||||
$this->config = $v;
|
$this->config = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exists($k){
|
/**
|
||||||
|
* @param mixed $k
|
||||||
|
* @param bool $lowercase If set, searches Config in single-case / lowercase.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function exists($k, $lowercase = false){
|
||||||
|
if($lowercase === true)://Take this ridiculously retarded IF formatting! - @sekjun98888877777778888888888888
|
||||||
|
$k = strtolower($k);//Convert requested key to lower
|
||||||
|
$array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower
|
||||||
|
return isset($array[$k]);//Find $k in modified array
|
||||||
|
else:
|
||||||
return isset($this->config[$k]);
|
return isset($this->config[$k]);
|
||||||
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove($k){
|
public function remove($k){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user