/** * @param array $url * @return bool */ protected function isHostDefinedAndNotLocal($url) { return isset($url['host']) && !in_array($url['host'], Url::getLocalHostnames(), true); }
/** * Returns Proxy to use for connecting via HTTP to given URL * * @param string $url * @return array */ private static function getProxyConfiguration($url) { $hostname = UrlHelper::getHostFromUrl($url); $localHostnames = Url::getLocalHostnames(); if (in_array($hostname, $localHostnames)) { return array(null, null, null, null); } // proxy configuration $proxyHost = Config::getInstance()->proxy['host']; $proxyPort = Config::getInstance()->proxy['port']; $proxyUser = Config::getInstance()->proxy['username']; $proxyPassword = Config::getInstance()->proxy['password']; return array($proxyHost, $proxyPort, $proxyUser, $proxyPassword); }
/** * Checks whether the given host is a local host like `127.0.0.1` or `localhost`. * * @param string $host * @return bool */ public static function isLocalHost($host) { if (empty($host)) { return false; } return in_array($host, Url::getLocalHostnames(), true); }