NukeViet\Core\Request::__construct PHP Method

__construct() public method

Request::__construct()
public __construct ( mixed $config, mixed $ip )
$config mixed
$ip mixed
    public function __construct($config, $ip)
    {
        if (isset($config['allowed_html_tags']) and is_array($config['allowed_html_tags'])) {
            $this->disabletags = array_diff($this->disabletags, $config['allowed_html_tags']);
        }
        if (isset($config['allow_request_mods']) and !empty($config['allow_request_mods'])) {
            if (!is_array($config['allow_request_mods'])) {
                $config['allow_request_mods'] = array($config['allow_request_mods']);
            }
            $this->allow_request_mods = array_intersect($this->allow_request_mods, $config['allow_request_mods']);
        }
        if (isset($config['request_default_mode']) and !empty($config['request_default_mode']) and in_array($config['request_default_mode'], $this->allow_request_mods)) {
            $this->request_default_mode = $config['request_default_mode'];
        }
        if (isset($config['cookie_secure']) and !empty($config['cookie_secure'])) {
            $this->secure = true;
        }
        if (isset($config['cookie_httponly']) and !empty($config['cookie_httponly'])) {
            $this->httponly = true;
        }
        if (isset($config['cookie_prefix']) and !empty($config['cookie_prefix'])) {
            $this->cookie_prefix = preg_replace('/[^a-zA-Z0-9\\_]+/', '', $config['cookie_prefix']);
        }
        if (isset($config['session_prefix']) and !empty($config['session_prefix'])) {
            $this->session_prefix = preg_replace('/[^a-zA-Z0-9\\_]+/', '', $config['session_prefix']);
        }
        if (isset($config['sitekey']) and !empty($config['sitekey'])) {
            $this->cookie_key = $config['sitekey'];
        }
        if (!empty($config['str_referer_blocker'])) {
            $this->str_referer_blocker = true;
        }
        $this->engine_allowed = (array) $config['engine_allowed'];
        if (empty($ip)) {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        if (preg_match('#^(?:(?:\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(?:\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$#', $ip)) {
            $ip2long = ip2long($ip);
        } else {
            if (substr_count($ip, '::')) {
                $ip = str_replace('::', str_repeat(':0000', 8 - substr_count($ip, ':')) . ':', $ip);
            }
            $ip = explode(':', $ip);
            $r_ip = '';
            foreach ($ip as $v) {
                $r_ip .= str_pad(base_convert($v, 16, 2), 16, 0, STR_PAD_LEFT);
            }
            $ip2long = base_convert($r_ip, 2, 10);
        }
        if ($ip2long == -1 || $ip2long === false) {
            trigger_error(Request::INCORRECT_IP, 256);
        }
        $this->ip_addr = $ip2long;
        $this->cookie_key = md5($this->cookie_key);
        if (extension_loaded('filter') && filter_id(ini_get('filter.default')) !== FILTER_UNSAFE_RAW) {
            $this->is_filter = true;
        }
        $this->Initialize($config['my_domains']);
        $this->get_cookie_save_path();
        $this->sessionStart();
        $_REQUEST = array_merge($_POST, array_diff_key($_GET, $_POST));
    }