Determines if a file is externally hosted based on url.

@param string $file_url File url.
@return boolean Whether a file is externally hosted or not.
338575
public function is_external_file( $file_url ) {

        // Set default return value.
        $is_external_file = false;

        // Parse url.
        $parsed_file_url = parse_url( $file_url );

        // Parse site url.
        $parsed_site_url = parse_url( site_url() );

        // Check if hosts don't match.
        if ( $parsed_file_url[ 'host' ] !== $parsed_site_url[ 'host' ] ) {

            // We now know the file is externally hosted.
            $is_external_file = true;

        }

        return $is_external_file;

    }
970507
protected boolean isRarArchive(URL url)
   {
      if (url == null)
         return false;

      return isRarFile(url) || isRarDirectory(url);
   }
1319469
private function _view_file_exists()
    {
        $route = Rails::application()->dispatcher()->router()->route();
        /**
         * Build a simple path for the view file, as there's no support for
         * stuff like modules.
         * Note that the extension is PHP, there's no support for different
         * request formats.
         */
        $base_path = Rails::config()->paths->views;
        $view_path = $base_path . '/' . $route->path() . '.php';
        return is_file($view_path);
    }
486128
public function isUrl($url)
    {
        $path = parse_url($url, PHP_URL_PATH);
        $encoded_path = array_map('urlencode', explode('/', $path));
        $url = str_replace($path, implode('/', $encoded_path), $url);

        return filter_var($url, FILTER_VALIDATE_URL);
    }
557053
public static function isUrlArchive($url)
    {
        if (0 === strpos($url, 'http')) {
            foreach (self::$extensions as $extension) {
                if (substr($url, -\strlen($extension)) === $extension) {
                    return true;
                }
            }
        }

        return false;
    }
466718
public function isUrlRewritingEnabled()
    {
        $urlRewritingEnabled = $this->getConfig('rewrite_url');
        if ($urlRewritingEnabled !== null) {
            return $urlRewritingEnabled;
        }

        if (isset($_SERVER['PICO_URL_REWRITING'])) {
            $this->config['rewrite_url'] = (bool) $_SERVER['PICO_URL_REWRITING'];
        } elseif (isset($_SERVER['REDIRECT_PICO_URL_REWRITING'])) {
            $this->config['rewrite_url'] = (bool) $_SERVER['REDIRECT_PICO_URL_REWRITING'];
        } else {
            $this->config['rewrite_url'] = false;
        }

        return $this->config['rewrite_url'];
    }
824845
public static function preprocess($url_parsed) {
        if (preg_match('/\/([^\/]+)\.(rm|rmvb)$/i', $url_parsed['path'], $matches) == 1) {
            $filename = htmlspecialchars($matches[1] . '.' . $matches[2]);
            $extension = strtolower($matches[2]);
            return array(
                'filetype' => $extension,
                'url' => URL::build($url_parsed),
            );
        }
        return FALSE;
    }
1373239
public static function get_remote_filesize($url, $maxredirs = 2) {
		$parts = parse_url($url);
		if (empty($parts['host'])) {
			return false;
		}

		if ($parts['scheme'] === 'https') {
			$host = 'ssl://'.$parts['host'];
			$port = (isset($parts['port'])) ? $parts['port'] : 443;
		} else {
			$host = $parts['host'];
			$port = (isset($parts['port'])) ? $parts['port'] : 80;
		}
		$errno = $errstr = '';
		$timeout = 30;

		try {
			$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
		} catch (\Exception $e) {
			return false;
		}
		if (empty($fp)) {
			return false;
		}

		$path = $parts['path'];
		if (!empty($parts['query'])) {
			$path .= '?'.$parts['query'];
		}

		$out = 'HEAD '.$path.' HTTP/1.1'."\r\n"
			.'Host: '.$parts['host']."\r\n"
			.'Connection: Close'."\r\n\r\n";

		fwrite($fp, $out);
		$headers = '';
		while (!@feof($fp)) {
			$headers .= @fgets($fp, 128);
		}
		fclose($fp);

		$return = false;
		$headers = explode("\n", $headers);
		foreach ($headers as $header) {
			$hparts = explode(':', mb_strtolower($header), 2);
			if (!isset($hparts[1])) {
				continue;
			}
			list($hkey, $hval) = $hparts;
			switch ($hkey) {
				case 'location':
					if ($maxredirs > 0) {
						return static::get_remote_filesize(trim($hval), ($maxredirs - 1));
					} else {
						return false;
					}

				case 'content-length':
					return (int)trim($hval);
			}
		}
	}
586479
public static function isRfc($url)
    {
        if(isset($url) && 1 < strlen($url)) {
            $host   = self::parseHost($url);
            $scheme = strtolower(parse_url($url, PHP_URL_SCHEME));
            if (false !== $host && ($scheme == 'http' || $scheme == 'https')) {
                $pattern  = '([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/](([A-Za-z0-9$_.+!*,;/?:@&~=-])';
                $pattern .= '|%[A-Fa-f0-9]{2}){1,333}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)';
                return (bool) preg_match($pattern, $url);
            }
        }
        return false;
    }
984144
public static boolean isFileURL(URL url) {
        String protocol = url.getProtocol();
        return (URL_PROTOCOL_FILE.equals(protocol) || protocol.startsWith(URL_PROTOCOL_VFS));
    }
22312
def file_is_present(self, file_path):
        
        p = self.p(file_path)
        if not os.path.exists(p):
            return False
        if not os.path.isfile(p):
            raise IOError("%s is not a file" % file_path)
        return True
473257
protected function isCurrentUrlUriExcluded()
    {
        if ($this->regex_uri_exclusions && preg_match($this->regex_uri_exclusions, $this->currentUrlUri())) {
            return true;
        } elseif ($this->built_in_regex_uri_exclusions && preg_match($this->built_in_regex_uri_exclusions, $this->currentUrlUri())) {
            return true;
        }
        return false;
    }
845842
public function is_url()
    {
        return ($this->scheme == '' || $this->scheme == 'http' || $this->scheme == 'https' || $this->scheme == 'ftp' || $this->scheme == 'ftps' || $this->scheme == 'file');
    }
284082
public function isWritable($remote_file)
    {
        $this->errorHandler->start();

        //remove slashes at beginning and end of dir's, beginning of file
        $dir = substr($this->configuration->getDir(), 0, 1) == '/' ? substr($this->configuration->getDir(), 1) : $this->configuration->getDir();
        $dir = substr($dir, -1, 1) == '/' ? substr($dir, 0, -1) : $dir;
        $remote_file = substr($remote_file, 0, 1) == '/' ? substr($remote_file, 1) : $remote_file;

        //get path info setup properly.
        $dirname = pathinfo('/' . $dir . '/' . $remote_file);
        $dirname = $dirname['dirname'];

        //get a directory listing and check that the file in question is listed (workaround for file_exists)
        $dirlist = $this->driver->nlist($this->resource, $dirname);
        if (is_array($dirlist) && in_array("/$dir/$remote_file", $dirlist)) {
            //file exists, check if we can open the file for appending
            if (!$handle = $this->driver->fopen($dir . '/' . $remote_file, 'a', $this->configuration)) {
                $this->errorHandler->stop();

                return false;
            }

            //attempt to do an empty append
            if (!fwrite($handle, '') === FALSE) {
                $this->errorHandler->stop();

                return false;
            }
            $this->errorHandler->stop();

            return true;
        }

        //file not found, return false
        $this->errorHandler->stop();

        return false;
    }
77592
static function isSameHost($url)
    {
        $urlParts = parse_url($url);
        if(
            isset($_SERVER['SERVER_NAME']) &&
            $_SERVER['SERVER_NAME'] == $urlParts['host']
        ){
            return true;
        }

        return false;
    }
276306
public static function preprocess($url_parsed) {
        if (preg_match('/\.(\w+)$/i', $url_parsed['path'], $matches) == 1) {
            $extension = strtolower($matches[1]);
            if ($extension == 'ogv') $extension = 'ogg';
            return array(
                'filetype' => $extension,
                'url' => URL::build($url_parsed),
            );
        }
        return FALSE;
    }
785229
function convert_url_to_absolute_path( $file_url ) {

        // Remove WordPress site url from file url.
        $file_base = str_replace( trailingslashit( site_url() ), '', $file_url );

        // Add WordPress installation path to file base.
        $absolute_path = ABSPATH . $file_base;

        return $absolute_path;

    }