Check's if server is a webdav compliant server.
True if server returns a DAV Element in Header and when
schema 1,2 is supported.
@return bool true if server is webdav server. Otherwise false.
182243
function check_webdav() {
        $resp = $this->options();
        if (!$resp) {
            return false;
        }
        $this->_error_log($resp['header']['DAV']);
        // check schema
        if (preg_match('/1,2/', $resp['header']['DAV'])) {
            return true;
        }
        // otherwise return false
        return false;
    }
875482
public static function isBehindSsl() : bool
  {
      // Check for proxy first
      if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
          return self::protocolWithActiveSsl($_SERVER['HTTP_X_FORWARDED_PROTO']);
      }

      if (isset($_SERVER['HTTPS'])) {
          return self::protocolWithActiveSsl($_SERVER['HTTPS']);
      }

      return $_SERVER['SERVER_PORT'] == 443;
  }
1026717
public function isAjax()
    {
        $headers = apache_request_headers();
        $is_ajax = (isset($headers['X-Requested-With']) && $headers['X-Requested-With'] == 'XMLHttpRequest');

        return $is_ajax ? true : false;
    }
1324038
protected boolean isWeb() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		if (attributes == null) {
			return false;
		}
		HttpServletRequest request = attributes.getRequest();
		if (request == null) {
			return false;
		}
		return true;
	}
1325296
public static function isAjax()
    {
        $returnValue = (bool) false;

		if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
			if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
				$returnValue = true;
			}
		}
                
        return (bool) $returnValue;
    }
162782
public function isValid()
    {
        // these schemes are allowed
        $allowedSchemes = $this->getAllowedSchemes();

        // get the field value
        $url = $this->field->getValue();


        // not required and empty? Then its valid
        if ($this->isNotRequiredAndEmpty($url)) {
            return true;
        }

        if ($this->getMaxLength() && strlen($url) > $this->getMaxLength()) {
            // Over maximum length.
            return false;
        }

        // do simple validation
        if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_SCHEME_REQUIRED)) {
            return false;
        }

        // check if we have a tld
        if (!$this->isSkipTldCheck() && !preg_match('#\.[a-z]{2,}$#', parse_url($url, PHP_URL_HOST))) {
            return false;
        }

        // further validation is required.
        if (in_array(parse_url($url, PHP_URL_SCHEME), $allowedSchemes)) {
            return true;
        }

        return false;
    }
1329225
public function supports(Request $request): bool
    {
        return $request->query->has('jwt') ||
            $request->headers->has('authorization') ||
            ($this->devTenant && ($this->kernel->getEnvironment() === 'dev'));
    }
1178272
public function isSsl()
    {
        if ($this->server('HTTPS') && ('1' == $this->server('HTTPS') || 'on' == strtolower($this->server('HTTPS')))) {
            return true;
        } elseif ($this->server('SERVER_PORT') && ('443' == $this->server('SERVER_PORT'))) {
            return true;
        }
        return false;
    }
1301791
public function hasTokens()
  {
    if (!is_writable(Remember::$tokensDir) || !is_dir(Remember::$tokensDir)) {
      $tokens = Remember::$tokensDir;
      return $this->exception("'$tokens' does not exist or is not writable by the web server");
    }
  }
21468
protected function verifyCsrfToken()
    {
        if (!Config::get('cms.enableCsrfProtection')) {
            return true;
        }

        if (in_array(Request::method(), ['HEAD', 'GET', 'OPTIONS'])) {
            return true;
        }

        $token = Request::input('_token') ?: Request::header('X-CSRF-TOKEN');

        if (!strlen($token)) {
            return false;
        }

        return hash_equals(
            Session::token(),
            $token
        );
    }
1335885
public function is_server_ready() {

        $configured = $this->is_server_configured();
        if ($configured !== true) {
            return $configured;
        }

        // As part of the above we have already checked that we can contact the server. For pages
        // where performance is important, we skip doing a full schema check as well.
        if ($this->should_skip_schema_check()) {
            return true;
        }

        // Update schema if required/possible.
        $schemalatest = $this->check_latest_schema();
        if ($schemalatest !== true) {
            return $schemalatest;
        }

        // Check that the schema is already set up.
        try {
            $schema = new \search_solr\schema();
            $schema->validate_setup();
        } catch (\moodle_exception $e) {
            return $e->getMessage();
        }

        return true;
    }
943114
private function initiate_webdavclient() {
        if ($this->dav !== null) {
            return $this->dav;
        }

        $webdavendpoint = issuer_management::parse_endpoint_url('webdav', $this->issuer);

        // Selects the necessary information (port, type, server) from the path to build the webdavclient.
        $server = $webdavendpoint['host'];
        if ($webdavendpoint['scheme'] === 'https') {
            $webdavtype = 'ssl://';
            $webdavport = 443;
        } else if ($webdavendpoint['scheme'] === 'http') {
            $webdavtype = '';
            $webdavport = 80;
        }

        // Override default port, if a specific one is set.
        if (isset($webdavendpoint['port'])) {
            $webdavport = $webdavendpoint['port'];
        }

        // Authentication method is `bearer` for OAuth 2. Pass token of authenticated client, too.
        $this->dav = new \webdav_client($server, '', '', 'bearer', $webdavtype,
            $this->get_user_oauth_client()->get_accesstoken()->token);

        $this->dav->port = $webdavport;
        $this->dav->debug = false;
        return $this->dav;
    }
645693
private function verifyExtensionFile()
    {
        $supported_image = array(
            'gif',
            'jpg',
            'jpeg',
            'png'
        );

        $fileName = $_SERVER['HTTP_X_FILE_NAME'];

        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (in_array($ext, $supported_image)) {
            return true;
        }
        return false;
    }
645791
public static function isAjax()
    {
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
            && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
        ) {
            return true;

        } elseif (self::isCli()) {
            return true;

        } elseif (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            foreach ($headers as $key => $value) {
                if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') {
                    return true;
                }
            }

        } elseif (isset($_REQUEST['ajax']) && $_REQUEST['ajax']) {
            return true;

        } elseif (isset($_REQUEST['AJAX']) && $_REQUEST['AJAX']) {
            return true;

        }

        return false;
    }
1349335
function isValid()
    {
        if ( !$this->currentUserHasAccess() )
        {
            eZDebug::writeNotice('Current user does not have access to ezoe, falling back to normal xml editor!', __METHOD__ );
            return false;
        }

        if ( !self::browserSupportsDHTMLType() )
        {
            if ( $this->currentUserHasAccess( 'disable_editor' ) )
            {
                eZDebug::writeNotice('Current browser is not supported by ezoe, falling back to normal xml editor!', __METHOD__ );
                return false;
            }
            eZDebug::writeWarning('Current browser is not supported by ezoe, but user does not have access to disable editor!', __METHOD__ );
        }

        return true;
    }
310387
public static function isSupportedShell()
        {
            if (isset($_ENV['TERM'])) {
                if (isset(self::$_supportedShells[$_ENV['TERM']])) {
                    return true;
                }
            } elseif (isset($_SERVER['TERM'])) {
                if (isset(self::$_supportedShells[$_SERVER['TERM']])) {
                    return true;
                }
            } elseif (isset($_SERVER['ConEmuANSI']) && $_SERVER['ConEmuANSI'] == 'ON') {
                return true;
            }

            return isAke($_SERVER, 'CLI', false);
        }
474326
public static function isHttps()
    {
        // Default is http scheme.
        $https = false;

        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
            // $_SERVER['HTTPS'] is NOT set behind a proxy / load balancer
            $https = true;
        } elseif (
            // $_SERVER['HTTPS'] is set behind a proxy / load balancer
            !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ||
            !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
            $https = true;
        }
        return $https;
    }