本文整理汇总了PHP中Piwik\Url::isLocalHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::isLocalHost方法的具体用法?PHP Url::isLocalHost怎么用?PHP Url::isLocalHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Url
的用法示例。
在下文中一共展示了Url::isLocalHost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyIfURLIsNotSecure
private static function notifyIfURLIsNotSecure()
{
$isURLSecure = ProxyHttp::isHttps();
if ($isURLSecure) {
return;
}
if (!Piwik::hasUserSuperUserAccess()) {
return;
}
if (Url::isLocalHost(Url::getCurrentHost())) {
return;
}
$message = Piwik::translate('General_CurrentlyUsingUnsecureHttp');
$message .= " ";
$message .= Piwik::translate('General_ReadThisToLearnMore', array('<a rel="noreferrer" target="_blank" href="https://piwik.org/faq/how-to/faq_91/">', '</a>'));
$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
$notification->raw = true;
Notification\Manager::notify('ControllerAdmin_HttpIsUsed', $notification);
}
示例2: isHostDefinedAndNotLocal
/**
* @param array $url
* @return bool
*/
protected function isHostDefinedAndNotLocal($url)
{
return isset($url['host']) && !Url::isLocalHost($url['host']);
}
示例3: getProxyConfiguration
/**
* 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);
if (Url::isLocalHost($hostname)) {
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);
}
示例4: getPiwikUrl
/**
* Returns the URL to this Piwik instance, eg. **http://demo.piwik.org/** or **http://example.org/piwik/**.
*
* @return string
* @api
*/
public static function getPiwikUrl()
{
$url = Option::get(self::OPTION_PIWIK_URL);
$isPiwikCoreDispatching = defined('PIWIK_ENABLE_DISPATCH') && PIWIK_ENABLE_DISPATCH;
if (Common::isPhpCliMode() || SettingsServer::isArchivePhpTriggered() || !$isPiwikCoreDispatching) {
return $url;
}
$currentUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
// when script is called from /misc/cron/archive.php, Piwik URL is /index.php
$currentUrl = str_replace("/misc/cron", "", $currentUrl);
if (empty($url) || $currentUrl != $url) {
$host = Url::getHostFromUrl($url);
if (strlen($currentUrl) >= strlen('http://a/') && !Url::isLocalHost($host)) {
self::overwritePiwikUrl($currentUrl);
}
$url = $currentUrl;
}
if (ProxyHttp::isHttps()) {
$url = str_replace("http://", "https://", $url);
}
return $url;
}
示例5: test_isLocalHost
/**
* @dataProvider getIsLocalHost
*/
public function test_isLocalHost($expectedIsLocal, $host)
{
$this->assertSame($expectedIsLocal, Url::isLocalHost($host));
}