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


PHP UrlHelper::isLookLikeUrl方法代码示例

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


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

示例1: getReferrerInformation

 /**
  * Returns an array containing the following information:
  * - referer_type
  *        - direct            -- absence of referrer URL OR referrer URL has the same host
  *        - site                -- based on the referrer URL
  *        - search_engine        -- based on the referrer URL
  *        - campaign            -- based on campaign URL parameter
  *
  * - referer_name
  *         - ()
  *         - piwik.net            -- site host name
  *         - google.fr            -- search engine host name
  *         - adwords-search    -- campaign name
  *
  * - referer_keyword
  *         - ()
  *         - ()
  *         - my keyword
  *         - my paid keyword
  *         - ()
  *         - ()
  *
  * - referer_url : the same for all the referrer types
  *
  * @param string $referrerUrl must be URL Encoded
  * @param string $currentUrl
  * @param int $idSite
  * @return array
  */
 public function getReferrerInformation($referrerUrl, $currentUrl, $idSite)
 {
     $this->idsite = $idSite;
     // default values for the referer_* fields
     $referrerUrl = Common::unsanitizeInputValue($referrerUrl);
     if (!empty($referrerUrl) && !UrlHelper::isLookLikeUrl($referrerUrl)) {
         $referrerUrl = '';
     }
     $currentUrl = PageUrl::cleanupUrl($currentUrl);
     $this->referrerUrl = $referrerUrl;
     $this->referrerUrlParse = @parse_url($this->referrerUrl);
     $this->currentUrlParse = @parse_url($currentUrl);
     $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY;
     $this->nameReferrerAnalyzed = '';
     $this->keywordReferrerAnalyzed = '';
     $this->referrerHost = '';
     if (isset($this->referrerUrlParse['host'])) {
         $this->referrerHost = $this->referrerUrlParse['host'];
     }
     $referrerDetected = $this->detectReferrerCampaign();
     if (!$referrerDetected) {
         if ($this->detectReferrerDirectEntry() || $this->detectReferrerSearchEngine()) {
             $referrerDetected = true;
         }
     }
     if (!empty($this->referrerHost) && !$referrerDetected) {
         $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_WEBSITE;
         $this->nameReferrerAnalyzed = Common::mb_strtolower($this->referrerHost);
     }
     $referrerInformation = array('referer_type' => $this->typeReferrerAnalyzed, 'referer_name' => $this->nameReferrerAnalyzed, 'referer_keyword' => $this->keywordReferrerAnalyzed, 'referer_url' => $this->referrerUrl);
     return $referrerInformation;
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:61,代码来源:Referrer.php

示例2: checkUrls

 /**
  * Check that the array of URLs are valid URLs
  *
  * @param array $urls
  * @throws Exception if any of the urls is not valid
  */
 public function checkUrls($urls)
 {
     $urls = $this->cleanParameterUrls($urls);
     foreach ($urls as $url) {
         if (!UrlHelper::isLookLikeUrl($url)) {
             throw new Exception(sprintf(Piwik::translate('SitesManager_ExceptionInvalidUrl'), $url));
         }
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:15,代码来源:Urls.php

示例3: 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

示例4: index

 /**
  * Main Plugin Index
  *
  * @return mixed
  * @throws \Exception
  */
 public function index()
 {
     Piwik::checkUserHasSomeAdminAccess();
     if (isset($_SERVER['REQUEST_METHOD']) && 'POST' == $_SERVER['REQUEST_METHOD']) {
         // Cannot use Common::getRequestVar, because the function remove whitespaces and newline breaks
         $postedSiteData = isset($_POST['site']) ? $_POST['site'] : null;
         if (is_array($postedSiteData) && count($postedSiteData) > 0) {
             foreach ($postedSiteData as $id => $site) {
                 if (!isset($site['css'], $site['file'])) {
                     continue;
                 }
                 // Check URL
                 if (!UrlHelper::isLookLikeUrl($site['file'])) {
                     $site['file'] = null;
                 }
                 API::getInstance()->saveSite($id, $site['css'], $site['file']);
             }
             // Redirect to, clear POST vars
             $this->redirectToIndex('CustomOptOut', 'index');
             return;
         }
     }
     $view = new View('@CustomOptOut/index.twig');
     Site::clearCache();
     if (Piwik::hasUserSuperUserAccess()) {
         $sitesRaw = APISiteManager::getInstance()->getAllSites();
     } else {
         $sitesRaw = APISiteManager::getInstance()->getSitesWithAdminAccess();
     }
     // Gets sites after Site.setSite hook was called
     $sites = array_values(Site::getSites());
     if (count($sites) != count($sitesRaw)) {
         throw new \Exception("One or more website are missing or invalid.");
     }
     foreach ($sites as &$site) {
         $site['alias_urls'] = APISiteManager::getInstance()->getSiteUrlsFromId($site['idsite']);
     }
     $view->adminSites = $sites;
     $view->adminSitesCount = count($sites);
     $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
     $view->isEditorEnabled = API::getInstance()->isCssEditorEnabled();
     $view->editorTheme = API::getInstance()->getEditorTheme();
     $view->showOldLinks = false;
     $this->setBasicVariablesView($view);
     return $view->render();
 }
开发者ID:peterbo,项目名称:PiwikCustomOptOut,代码行数:52,代码来源:Controller.php

示例5: getReferrerUrl

 public function getReferrerUrl()
 {
     if ($this->getReferrerType() == 'search') {
         if ($this->details['referer_keyword'] == API::LABEL_KEYWORD_NOT_DEFINED) {
             return 'http://piwik.org/faq/general/#faq_144';
         } elseif ($this->getReferrerName() == 'Google' && strpos($this->details['referer_url'], '/url')) {
             $refUrl = @parse_url($this->details['referer_url']);
             if (isset($refUrl['host'])) {
                 $url = SearchEngine::getInstance()->getBackLinkFromUrlAndKeyword('http://google.com', $this->getKeyword());
                 $url = str_replace('google.com', $refUrl['host'], $url);
                 return $url;
             }
         }
     }
     if (UrlHelper::isLookLikeUrl($this->details['referer_url'])) {
         return $this->details['referer_url'];
     }
     return null;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:19,代码来源:Visitor.php

示例6: getReferrerInformation

 /**
  * Returns an array containing the following information:
  * - referer_type
  *        - direct            -- absence of referrer URL OR referrer URL has the same host
  *        - site                -- based on the referrer URL
  *        - search_engine        -- based on the referrer URL
  *        - campaign            -- based on campaign URL parameter
  *
  * - referer_name
  *         - ()
  *         - piwik.net            -- site host name
  *         - google.fr            -- search engine host name
  *         - adwords-search    -- campaign name
  *
  * - referer_keyword
  *         - ()
  *         - ()
  *         - my keyword
  *         - my paid keyword
  *         - ()
  *         - ()
  *
  * - referer_url : the same for all the referrer types
  *
  * @param string $referrerUrl must be URL Encoded
  * @param string $currentUrl
  * @param int $idSite
  * @return array
  */
 protected function getReferrerInformation($referrerUrl, $currentUrl, $idSite, Request $request)
 {
     $cacheKey = $referrerUrl . $currentUrl . $idSite;
     if (isset(self::$cachedReferrer[$cacheKey])) {
         return self::$cachedReferrer[$cacheKey];
     }
     $this->idsite = $idSite;
     // default values for the referer_* fields
     $referrerUrl = Common::unsanitizeInputValue($referrerUrl);
     if (!empty($referrerUrl) && !UrlHelper::isLookLikeUrl($referrerUrl)) {
         $referrerUrl = '';
     }
     $currentUrl = PageUrl::cleanupUrl($currentUrl);
     $this->referrerUrl = $referrerUrl;
     $this->referrerUrlParse = @parse_url($this->referrerUrl);
     $this->currentUrlParse = @parse_url($currentUrl);
     $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY;
     $this->nameReferrerAnalyzed = '';
     $this->keywordReferrerAnalyzed = '';
     $this->referrerHost = '';
     if (isset($this->referrerUrlParse['host'])) {
         $this->referrerHost = $this->referrerUrlParse['host'];
     }
     $referrerDetected = $this->detectReferrerCampaign($request);
     if (!$referrerDetected) {
         if ($this->detectReferrerDirectEntry() || $this->detectReferrerSearchEngine()) {
             $referrerDetected = true;
         }
     }
     if (!$referrerDetected && !empty($this->referrerHost)) {
         $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_WEBSITE;
         $this->nameReferrerAnalyzed = Common::mb_strtolower($this->referrerHost);
         $urlsByHost = $this->getCachedUrlsByHostAndIdSite();
         $directEntry = new SiteUrls();
         $path = $directEntry->getPathMatchingUrl($this->referrerUrlParse, $urlsByHost);
         if (!empty($path) && $path !== '/') {
             $this->nameReferrerAnalyzed .= rtrim($path, '/');
         }
     }
     $referrerInformation = array('referer_type' => $this->typeReferrerAnalyzed, 'referer_name' => $this->nameReferrerAnalyzed, 'referer_keyword' => $this->keywordReferrerAnalyzed, 'referer_url' => $this->referrerUrl);
     self::$cachedReferrer[$cacheKey] = $referrerInformation;
     return $referrerInformation;
 }
开发者ID:dev-bobsong,项目名称:piwik,代码行数:72,代码来源:Base.php

示例7: getRank

 function getRank()
 {
     $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);
     $view = new View('@SEO/getRank');
     $view->urlToRank = RankChecker::extractDomainFromUrl($url);
     /** @var \Piwik\DataTable\Renderer\Php $renderer */
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     $view->ranks = $renderer->render($dataTable);
     return $view->render();
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:20,代码来源:Controller.php

示例8: redirect

    /**
     * Output redirection page instead of linking directly to avoid
     * exposing the referrer on the Piwik demo.
     *
     * @internal param string $url (via $_GET)
     */
    public function redirect()
    {
        $url = Common::getRequestVar('url', '', 'string', $_GET);
        if (!UrlHelper::isLookLikeUrl($url)) {
            die('Please check the &url= parameter: it should to be a valid URL');
        }
        // validate referrer
        $referrer = Url::getReferrer();
        if (empty($referrer) || !Url::isLocalUrl($referrer)) {
            die('Invalid Referrer detected - This means that your web browser is not sending the "Referrer URL" which is
				required to proceed with the redirect. Verify your browser settings and add-ons, to check why your browser
				 is not sending this referrer.

				<br/><br/>You can access the page at: ' . $url);
        }
        // mask visits to *.piwik.org
        if (!self::isPiwikUrl($url)) {
            Piwik::checkUserHasSomeViewAccess();
        }
        Common::sendHeader('Content-Type: text/html; charset=utf-8');
        echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
        exit;
    }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:29,代码来源:Controller.php

示例9: getHostFromUrl

 public static function getHostFromUrl($url)
 {
     if (!UrlHelper::isLookLikeUrl($url)) {
         $url = "http://" . $url;
     }
     return parse_url($url, PHP_URL_HOST);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:7,代码来源:UrlHelper.php

示例10: isValidUrl

 /**
  * Tests if the URL is a valid URL
  *
  * @param string $url
  * @return bool
  */
 private function isValidUrl($url)
 {
     return UrlHelper::isLookLikeUrl($url);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:10,代码来源:API.php

示例11: getTrustedHostsFromConfig

 public static function getTrustedHostsFromConfig()
 {
     $trustedHosts = @Config::getInstance()->General['trusted_hosts'];
     if (!is_array($trustedHosts)) {
         return array();
     }
     foreach ($trustedHosts as &$trustedHost) {
         // Case user wrote in the config, http://example.com/test instead of example.com
         if (UrlHelper::isLookLikeUrl($trustedHost)) {
             $trustedHost = parse_url($trustedHost, PHP_URL_HOST);
         }
     }
     return $trustedHosts;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:14,代码来源:Url.php

示例12: getTrustedHostsFromConfig

 public static function getTrustedHostsFromConfig()
 {
     $hosts = self::getHostsFromConfig('General', 'trusted_hosts');
     // Case user wrote in the config, http://example.com/test instead of example.com
     foreach ($hosts as &$host) {
         if (UrlHelper::isLookLikeUrl($host)) {
             $host = parse_url($host, PHP_URL_HOST);
         }
     }
     return $hosts;
 }
开发者ID:postalservice14,项目名称:piwik,代码行数:11,代码来源:Url.php

示例13: getUrlIfLookValid

 public static function getUrlIfLookValid($url)
 {
     $url = PageUrl::cleanupString($url);
     if (!UrlHelper::isLookLikeUrl($url)) {
         Common::printDebug("WARNING: URL looks invalid and is discarded");
         return false;
     }
     return $url;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:9,代码来源:PageUrl.php

示例14: initPiwikHost

 private function initPiwikHost($piwikUrl = false)
 {
     // If core:archive command run as a web cron, we use the current hostname+path
     if (empty($piwikUrl)) {
         if (!empty(self::$url)) {
             $piwikUrl = self::$url;
         } else {
             // example.org/piwik/
             $piwikUrl = SettingsPiwik::getPiwikUrl();
         }
     }
     if (!$piwikUrl) {
         $this->logFatalErrorUrlExpected();
     }
     if (!\Piwik\UrlHelper::isLookLikeUrl($piwikUrl)) {
         // try adding http:// in case it's missing
         $piwikUrl = "http://" . $piwikUrl;
     }
     if (!\Piwik\UrlHelper::isLookLikeUrl($piwikUrl)) {
         $this->logFatalErrorUrlExpected();
     }
     // ensure there is a trailing slash
     if ($piwikUrl[strlen($piwikUrl) - 1] != '/' && !Common::stringEndsWith($piwikUrl, 'index.php')) {
         $piwikUrl .= '/';
     }
     $this->initConfigObject($piwikUrl);
     if (Config::getInstance()->General['force_ssl'] == 1) {
         $piwikUrl = str_replace('http://', 'https://', $piwikUrl);
     }
     if (!Common::stringEndsWith($piwikUrl, 'index.php')) {
         $piwikUrl .= 'index.php';
     }
     $this->piwikUrl = $piwikUrl;
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:34,代码来源:CronArchive.php

示例15: redirectToUrl

 /**
  * Redirects the user to the specified URL.
  *
  * @param string $url
  * @api
  */
 public static function redirectToUrl($url)
 {
     if (UrlHelper::isLookLikeUrl($url) || strpos($url, 'index.php') === 0) {
         @header("Location: {$url}");
     } else {
         echo "Invalid URL to redirect to.";
     }
     exit;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:15,代码来源:Url.php


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