類別IpRangeRule的繼承圖:

公開方法(Public Methods) | |
| IpRangeRule ($range) | |
| setRange ($range) | |
| getRange () | |
| validate ($value) | |
公開屬性 | |
| $_range | |
It will set the error flag ERROR_RULE_IP_NOT_IN_RANGE error if the address is not in the given range.
定義在 iprangerule.class.php 檔案之第 17 行.
|
|
Initializes the rule with the given range
定義在 iprangerule.class.php 檔案之第 26 行. 參考 Rule::Rule(). 00027 { 00028 $this->Rule(); 00029 $this->_range = $range; 00030 }
|
|
|
Returns the current range being used for the calculations
定義在 iprangerule.class.php 檔案之第 47 行.
|
|
|
Sets a different range than the one given in the constructor
定義在 iprangerule.class.php 檔案之第 37 行.
|
|
|
Returns true if the address is within the given range or false otherwise. It will also set the error ERROR_RULE_IP_NOT_IN_RANGE
依據Rule重新實作. 定義在 iprangerule.class.php 檔案之第 59 行. 00060 { 00061 $counter = 0; 00062 $range = explode("/", $this->_range); 00063 00064 if ($range[1] < 32) 00065 { 00066 $maskBits = $range[1]; 00067 $hostBits = 32 - $maskBits; 00068 $hostCount = pow(2, $hostBits) - 1; 00069 $ipStart = ip2long($range[0]); 00070 $ipEnd = $ipStart + $hostCount; 00071 00072 if ((ip2long($value) > $ipStart) && (ip2long($value) < $ipEnd)) 00073 { 00074 $this->_setError(false); 00075 return true; 00076 } 00077 } 00078 elseif (ip2long($value) == ip2long($range[0])) 00079 { 00080 $this->_setError(false); 00081 return true; 00082 } 00083 00084 $this->_setError(ERROR_RULE_IP_NOT_IN_RANGE); 00085 return false; 00086 }
|
|
|
定義在 iprangerule.class.php 檔案之第 19 行. |