當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Piwik\UrlHelper類代碼示例

本文整理匯總了PHP中Piwik\UrlHelper的典型用法代碼示例。如果您正苦於以下問題:PHP UrlHelper類的具體用法?PHP UrlHelper怎麽用?PHP UrlHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UrlHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPathFromUrl

/**
 * Returns path component from a URL
 *
 * @param string $url
 * @return string path
 */
function getPathFromUrl($url)
{
    $path = UrlHelper::getPathAndQueryFromUrl($url);
    if (empty($path)) {
        return 'index';
    }
    return $path;
}
開發者ID:carriercomm,項目名稱:piwik,代碼行數:14,代碼來源:functions.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: initHostAndQueryString

 /**
  * @param InputInterface $input
  */
 protected function initHostAndQueryString(InputInterface $input)
 {
     $_GET = array();
     $hostname = $input->getOption('piwik-domain');
     Url::setHost($hostname);
     $query = $input->getArgument('url-query');
     $query = UrlHelper::getArrayFromQueryString($query);
     foreach ($query as $name => $value) {
         $_GET[$name] = $value;
     }
 }
開發者ID:carriercomm,項目名稱:piwik,代碼行數:14,代碼來源:RequestCommand.php

示例4: getKeywordPosition

 public function getKeywordPosition()
 {
     if ($this->getReferrerType() == 'search' && strpos($this->getReferrerName(), 'Google') !== false) {
         $url = @parse_url($this->details['referer_url']);
         if (empty($url['query'])) {
             return null;
         }
         $position = UrlHelper::getParameterFromQueryString($url['query'], 'cd');
         if (!empty($position)) {
             return $position;
         }
     }
     return null;
 }
開發者ID:dorelljames,項目名稱:piwik,代碼行數:14,代碼來源:Visitor.php

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

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

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

 protected function getEngineHostFromUrl($host, $path, $query)
 {
     $searchEngines = $this->getDefinitions();
     $hostPattern = UrlHelper::getLossyUrl($host);
     /*
      * Try to get the best matching 'host' in definitions
      * 1. check if host + path matches an definition
      * 2. check if host only matches
      * 3. check if host pattern + path matches
      * 4. check if host pattern matches
      * 5. special handling
      */
     if (array_key_exists($host . $path, $searchEngines)) {
         $host = $host . $path;
     } elseif (array_key_exists($host, $searchEngines)) {
         // no need to change host
     } elseif (array_key_exists($hostPattern . $path, $searchEngines)) {
         $host = $hostPattern . $path;
     } elseif (array_key_exists($hostPattern, $searchEngines)) {
         $host = $hostPattern;
     } elseif (!array_key_exists($host, $searchEngines)) {
         if (!strncmp($query, 'cx=partner-pub-', 15)) {
             // Google custom search engine
             $host = 'google.com/cse';
         } elseif (!strncmp($path, '/pemonitorhosted/ws/results/', 28)) {
             // private-label search powered by InfoSpace Metasearch
             $host = 'wsdsold.infospace.com';
         } elseif (strpos($host, '.images.search.yahoo.com') != false) {
             // Yahoo! Images
             $host = 'images.search.yahoo.com';
         } elseif (strpos($host, '.search.yahoo.com') != false) {
             // Yahoo!
             $host = 'search.yahoo.com';
         } else {
             return false;
         }
     }
     return $host;
 }
開發者ID:dorelljames,項目名稱:piwik,代碼行數:39,代碼來源:SearchEngine.php

示例10: getRequestParametersGET

 /**
  * Returns the original request parameters in the current query string as an array mapping
  * query parameter names with values. The result of this function will not be affected
  * by any modifications to `$_GET` and will not include parameters in `$_POST`.
  *
  * @return array
  */
 public static function getRequestParametersGET()
 {
     if (empty($_SERVER['QUERY_STRING'])) {
         return array();
     }
     $GET = UrlHelper::getArrayFromQueryString($_SERVER['QUERY_STRING']);
     return $GET;
 }
開發者ID:josl,項目名稱:CGE-File-Sharing,代碼行數:15,代碼來源:Request.php

示例11: initPiwikHost

 protected function initPiwikHost(InputInterface $input)
 {
     $piwikHostname = $input->getParameterOption('--piwik-domain');
     if (empty($piwikHostname)) {
         $piwikHostname = $input->getParameterOption('--url');
     }
     $piwikHostname = UrlHelper::getHostFromUrl($piwikHostname);
     Url::setHost($piwikHostname);
 }
開發者ID:josl,項目名稱:CGE-File-Sharing,代碼行數:9,代碼來源:Console.php

示例12: extractUtmDetailsFromUrl

 /**
  * Extracts the utm query parameters into array
  * @return array 
  */
 private function extractUtmDetailsFromUrl()
 {
     $query = $this->currentUrlParse['query'];
     $params = UrlHelper::getArrayFromQueryString($query);
     return array('utm_campaign' => isset($params['utm_campaign']) ? $params['utm_campaign'] : '', 'utm_term' => isset($params['utm_term']) ? $params['utm_term'] : '', 'utm_medium' => isset($params['utm_medium']) ? $params['utm_medium'] : '', 'utm_content' => isset($params['utm_content']) ? $params['utm_content'] : '', 'utm_source' => isset($params['utm_source']) ? $params['utm_source'] : '');
 }
開發者ID:adevait,項目名稱:CampaignDetailed,代碼行數:10,代碼來源:Base.php

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

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

示例15: executeAsyncCli

 private function executeAsyncCli($url, Output $output, $cmdId)
 {
     $this->processes[] = new Process($cmdId);
     $url = $this->appendTestmodeParamToUrlIfNeeded($url);
     $query = UrlHelper::getQueryFromUrl($url, array('pid' => $cmdId));
     $hostname = UrlHelper::getHostFromUrl($url);
     $command = $this->buildCommand($hostname, $query, $output->getPathToFile());
     Log::debug($command);
     shell_exec($command);
 }
開發者ID:TensorWrenchOSS,項目名稱:piwik,代碼行數:10,代碼來源:CliMulti.php


注:本文中的Piwik\UrlHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。