From 656387e7f9a99ba61bf597a23dd12e09451b2495 Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 12 Sep 2007 01:18:56 +0000 Subject: another optimization. --- framework/Security/TAuthorizationRule.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'framework/Security') diff --git a/framework/Security/TAuthorizationRule.php b/framework/Security/TAuthorizationRule.php index 5b3a3c25..42a11412 100644 --- a/framework/Security/TAuthorizationRule.php +++ b/framework/Security/TAuthorizationRule.php @@ -212,27 +212,8 @@ class TAuthorizationRule extends TComponent $ip=Prado::getApplication()->getRequest()->getUserHostAddress(); foreach($this->_ipRules as $rule) { - if($rule===$ip) + if($rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) return 1; - if(strpos($rule,'*')!==false) - { - $a=explode('.',$rule); - $b=explode('.',$ip); - if(isset($a[3]) && isset($b[3])) - { - $matched=true; - for($i=0;$i<4;++$i) - { - if($a[$i]!==$b[i] && $a[$i]!=='*') - { - $matched=false; - break; - } - } - if($matched) - return 1; - } - } } return 0; } -- cgit v1.2.3