summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2007-09-12 01:18:56 +0000
committerxue <>2007-09-12 01:18:56 +0000
commit656387e7f9a99ba61bf597a23dd12e09451b2495 (patch)
tree7cc153361ef972bce2a5c4cad9f4ac217c211d7a /framework
parent899503300d19dcbb381674c61b952f928a12978d (diff)
another optimization.
Diffstat (limited to 'framework')
-rw-r--r--framework/Security/TAuthorizationRule.php21
1 files changed, 1 insertions, 20 deletions
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;
}