mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
New feature domain names. Ticket #3130.
This commit is contained in:
parent
7da74f9b7c
commit
5c713e15f7
@ -186,15 +186,36 @@ function isInACL($ip) {
|
|||||||
// If the IP is not in the list, we check one by one, all the wildcard registers
|
// If the IP is not in the list, we check one by one, all the wildcard registers
|
||||||
foreach($config['list_ACL_IPs_for_API'] as $acl_ip) {
|
foreach($config['list_ACL_IPs_for_API'] as $acl_ip) {
|
||||||
if (preg_match('/\*/', $acl_ip)) {
|
if (preg_match('/\*/', $acl_ip)) {
|
||||||
|
|
||||||
|
if($acl_ip[0]=='*' && strlen($acl_ip)>1){
|
||||||
|
//example *.lab.artica.es == 151.80.15.*
|
||||||
|
$acl_ip = str_replace('*.','',$acl_ip);
|
||||||
|
$name = array();
|
||||||
|
$name = gethostbyname($acl_ip);
|
||||||
|
$names = explode('.',$name);
|
||||||
|
$names[3] = "";
|
||||||
|
$names = implode('.',$names);
|
||||||
|
if (preg_match('/'.$names.'/', $ip)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//example 192.168.70.* or *
|
||||||
|
$acl_ip = str_replace('.','\.',$acl_ip);
|
||||||
|
// Replace wilcard by .* to do efective in regular expression
|
||||||
|
$acl_ip = str_replace('*','.*',$acl_ip);
|
||||||
|
// If the string match with the beginning of the IP give it access
|
||||||
|
if (preg_match('/'.$acl_ip.'/', $ip)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Scape for protection
|
// Scape for protection
|
||||||
$acl_ip = str_replace('.','\.',$acl_ip);
|
|
||||||
|
}else{
|
||||||
// Replace wilcard by .* to do efective in regular expression
|
//example lab.artica.es without '*'
|
||||||
$acl_ip = str_replace('*','.*',$acl_ip);
|
$name = array();
|
||||||
|
$name = gethostbyname($acl_ip);
|
||||||
// If the string match with the beginning of the IP give it access
|
if (preg_match('/'.$name.'/', $ip)) {
|
||||||
if (preg_match('/'.$acl_ip.'/', $ip)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user