REST_Controller::_check_whitelist_auth PHP Метод

_check_whitelist_auth() защищенный Метод

Check if the client's ip is in the 'rest_ip_whitelist' config and generates a 401 response
protected _check_whitelist_auth ( ) : void
Результат void
    protected function _check_whitelist_auth()
    {
        $whitelist = explode(',', $this->config->item('rest_ip_whitelist'));
        array_push($whitelist, '127.0.0.1', '0.0.0.0');
        foreach ($whitelist as &$ip) {
            // As $ip is a reference, trim leading and trailing whitespace, then store the new value
            // using the reference
            $ip = trim($ip);
        }
        if (in_array($this->input->ip_address(), $whitelist) === FALSE) {
            $this->response([$this->config->item('rest_status_field_name') => FALSE, $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_unauthorized')], self::HTTP_UNAUTHORIZED);
        }
    }