defender::verify_url PHP Method

verify_url() protected method

returns str the input or bool FALSE if check fails
protected verify_url ( )
    protected function verify_url()
    {
        if ($this->field_config['required'] && !$this->field_value) {
            self::setInputError($this->field_name);
        }
        if ($this->field_value) {
            $url_parts = parse_url($this->field_value);
            if (!isset($url_parts['scheme']) && isset($url_parts['path'])) {
                $this->field_value = 'http://' . $this->field_value;
            }
            if (function_exists('curl_version')) {
                $fp = curl_init($this->field_value);
                curl_setopt($fp, CURLOPT_TIMEOUT, 20);
                curl_setopt($fp, CURLOPT_FAILONERROR, 1);
                curl_setopt($fp, CURLOPT_REFERER, $this->field_value);
                curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($fp, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
                curl_exec($fp);
                if (curl_errno($fp) != 0) {
                    curl_close($fp);
                    return FALSE;
                } else {
                    curl_close($fp);
                    return $this->field_value;
                }
            } elseif (filter_var($this->field_value, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) === FALSE) {
                return FALSE;
            }
        }
    }