/**
* Initializes default rules to use.
*
* @return void
*/
protected function _init() {
parent::_init();
$this->_rules += array(
'allowAll' => function() {
return true;
},
'denyAll' => function() {
return false;
},
'allowAnyUser' => function($user) {
return $user ? true : false;
},
'allowIp' => function($user, $request, $options) {
$options += array('ip' => false);
if (is_string($options['ip']) && strpos($options['ip'], '/') === 0) {
return (boolean) preg_match($options['ip'], $request->env('REMOTE_ADDR'));
}
if (is_array($options['ip'])) {
return in_array($request->env('REMOTE_ADDR'), $options['ip']);
}
return $request->env('REMOTE_ADDR') == $options['ip'];
}
);
}