Everything IP!
Updated IpRange to fix an undefined index (where it tried to convert an IP to a ip/bits format but some didn't contain that, so absolute ip addresses will just have /32 appended) Implemented the logic into WebContextManager.php
This commit is contained in:
parent
b08cc53828
commit
23f608e173
|
|
@ -182,6 +182,9 @@ namespace Alphaland\Web {
|
|||
*/
|
||||
public static function IsIpInCidrRange(string $ip, string $cidr)
|
||||
{
|
||||
if (strpos($cidr, '/') === false)
|
||||
$cidr = "$cidr/32";
|
||||
|
||||
list($subnet, $bits) = explode('/', $cidr);
|
||||
if ($bits === null) {
|
||||
$bits = 32;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Alphaland\Web {
|
||||
|
||||
use PDO;
|
||||
use Alphaland\Web\IpHelper;
|
||||
|
||||
class WebContextManager
|
||||
{
|
||||
|
|
@ -16,7 +17,7 @@ namespace Alphaland\Web {
|
|||
$currentIp = WebContextManager::GetCurrentIPAddress();
|
||||
$ipWhitelist = explode(";", WebsiteSettings::GetSetting("webservice_whitelist", "127.0.0.0/8;192.168.0.0/16;10.0.0.0/8"));
|
||||
|
||||
return in_array($currentIp, $ipWhitelist);
|
||||
return IpHelper::IsIpInCidrNetmaskOrRangeList($currentIp, $ipWhitelist);
|
||||
}
|
||||
|
||||
public static function CanBypassMaintenance()
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ try
|
|||
include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Economy/EconomyHelper.php";
|
||||
include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Groups/Group.php";
|
||||
include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Web/WebsiteSettings.php";
|
||||
include "C:/Webserver/nginx/Alphaland/globals/Dependencies/Web/IpRange.php";
|
||||
|
||||
//authenticator
|
||||
$authenticator = new PHPGangsta_GoogleAuthenticator();
|
||||
|
|
|
|||
Loading…
Reference in New Issue