当前位置: 首页>>代码示例>>PHP>>正文


PHP Url::getHostFromUrl方法代码示例

本文整理汇总了PHP中Piwik\Url::getHostFromUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getHostFromUrl方法的具体用法?PHP Url::getHostFromUrl怎么用?PHP Url::getHostFromUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Url的用法示例。


在下文中一共展示了Url::getHostFromUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRank

 /**
  * Returns SEO statistics for a URL.
  *
  * @param string $url URL to request SEO stats for
  * @return DataTable
  */
 public function getRank($url)
 {
     Piwik::checkUserHasSomeViewAccess();
     $metricProvider = new ProviderCache(new Aggregator());
     $domain = Url::getHostFromUrl($url);
     $metrics = $metricProvider->getMetrics($domain);
     return $this->toDataTable($metrics);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:14,代码来源:API.php

示例2: render

 public function render()
 {
     $idSite = Common::getRequestVar('idSite');
     $site = new Site($idSite);
     $url = urldecode(Common::getRequestVar('url', '', 'string'));
     if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
         $url = 'http://' . $url;
     }
     if (empty($url) || !UrlHelper::isLookLikeUrl($url)) {
         $url = $site->getMainUrl();
     }
     $dataTable = API::getInstance()->getRank($url);
     /** @var \Piwik\DataTable\Renderer\Php $renderer */
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     return $this->renderTemplate('getRank', array('urlToRank' => Url::getHostFromUrl($url), 'ranks' => $renderer->render($dataTable)));
 }
开发者ID:piwik,项目名称:piwik,代码行数:17,代码来源:GetRank.php

示例3: testGetHostsFromUrl

 /**
  * @group Core
  *
  * @dataProvider getHostsFromUrl
  */
 public function testGetHostsFromUrl($url, $expectedHost)
 {
     $this->assertEquals($expectedHost, Url::getHostFromUrl($url));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:UrlTest.php

示例4: performRedirectToUrlIfSet

 private function performRedirectToUrlIfSet()
 {
     if (!$this->hasRedirectUrl()) {
         return;
     }
     if (empty($this->requests)) {
         return;
     }
     $redirectUrl = $this->getRedirectUrl();
     $host = Url::getHostFromUrl($redirectUrl);
     if (empty($host)) {
         return;
     }
     $siteIds = array();
     foreach ($this->requests as $request) {
         $siteIds[] = (int) $request['idsite'];
     }
     $siteIds = array_unique($siteIds);
     $model = new Model();
     foreach ($siteIds as $siteId) {
         $siteUrls = $model->getSiteUrlsFromId($siteId);
         if (Url::isHostInUrls($host, $siteUrls)) {
             Url::redirectToUrl($redirectUrl);
         }
     }
 }
开发者ID:mats116,项目名称:piwik,代码行数:26,代码来源:Tracker.php

示例5: shouldPerformRedirectToUrl

 public function shouldPerformRedirectToUrl()
 {
     if (!$this->hasRedirectUrl()) {
         return false;
     }
     if (!$this->hasRequests()) {
         return false;
     }
     $redirectUrl = $this->getRedirectUrl();
     $host = Url::getHostFromUrl($redirectUrl);
     if (empty($host)) {
         return false;
     }
     $urls = new SiteUrls();
     $siteUrls = $urls->getAllCachedSiteUrls();
     $siteIds = $this->getAllSiteIdsWithinRequest();
     foreach ($siteIds as $siteId) {
         if (empty($siteUrls[$siteId])) {
             $siteUrls[$siteId] = array();
         }
         if (Url::isHostInUrls($host, $siteUrls[$siteId])) {
             return $redirectUrl;
         }
     }
     return false;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:26,代码来源:RequestSet.php

示例6: performRedirectToUrlIfSet

 private function performRedirectToUrlIfSet()
 {
     if (!$this->hasRedirectUrl()) {
         return;
     }
     if (empty($this->requests)) {
         return;
     }
     $redirectUrl = $this->getRedirectUrl();
     $host = Url::getHostFromUrl($redirectUrl);
     if (empty($host)) {
         return;
     }
     $urls = new SiteUrls();
     $siteUrls = $urls->getAllCachedSiteUrls();
     $siteIds = $this->getAllSiteIdsWithinRequest();
     foreach ($siteIds as $siteId) {
         if (empty($siteUrls[$siteId])) {
             continue;
         }
         if (Url::isHostInUrls($host, $siteUrls[$siteId])) {
             Url::redirectToUrl($redirectUrl);
         }
     }
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:25,代码来源:Tracker.php

示例7: 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;
 }
开发者ID:piwik,项目名称:piwik,代码行数:28,代码来源:SettingsPiwik.php


注:本文中的Piwik\Url::getHostFromUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。