1 | <?php |
||
14 | class IpAccess extends Object |
||
|
|||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | public $allowedIps = array(); |
||
20 | |||
21 | /** |
||
22 | * @config |
||
23 | * @var array |
||
24 | */ |
||
25 | private static $allowed_ips = array(); |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $ip = ''; |
||
31 | |||
32 | /** |
||
33 | * IpAccess constructor. |
||
34 | * |
||
35 | * @param string $ip |
||
36 | * @param array $allowedIps |
||
37 | */ |
||
38 | public function __construct($ip = '', $allowedIps = array()) |
||
45 | |||
46 | /** |
||
47 | * @param $ip |
||
48 | */ |
||
49 | public function setIp($ip) |
||
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | public function getAllowedIps() |
||
58 | { |
||
59 | if (!empty($this->allowedIps)) { |
||
60 | Deprecation::notice('1.1', 'Use the "IpAccess.allowed_ips" config setting instead'); |
||
61 | self::config()->allowed_ips = $this->allowedIps; |
||
62 | } |
||
63 | return self::$allowed_ips ? self::$allowed_ips : (array)self::config()->allowed_ips; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function isEnabled() |
||
73 | |||
74 | /** |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function hasAccess() |
||
85 | |||
86 | /** |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function matchIp() |
||
93 | |||
94 | /** |
||
95 | * @param Controller $controller |
||
96 | * @throws SS_HTTPResponse_Exception |
||
97 | */ |
||
98 | public function respondNoAccess(Controller $controller) |
||
106 | |||
107 | /** |
||
108 | * @return string |
||
109 | */ |
||
110 | public function matchExact() |
||
114 | |||
115 | /** |
||
116 | * Try to match against a ip range |
||
117 | * Example : 192.168.1.50-100 |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function matchRange() |
||
141 | |||
142 | /** |
||
143 | * Try to match cidr range |
||
144 | * Example : 192.168.1.0/24 |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | public function matchCIDR() |
||
162 | |||
163 | /** |
||
164 | * Try to match against a range that ends with a wildcard * |
||
165 | * Example : 192.168.1.* |
||
166 | * Example : 192.168.* |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function matchWildCard() |
||
183 | |||
184 | } |
||
185 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.