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


PHP Url::isLocalUrl方法代碼示例

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


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

示例1: testIsLocalUrl

 /**
  * @dataProvider getLocalUrls
  * @group Core
  */
 public function testIsLocalUrl($httphost, $scripturi, $requesturi, $testurl, $result)
 {
     $_SERVER['HTTP_HOST'] = $httphost;
     $_SERVER['SCRIPT_URI'] = $scripturi;
     $_SERVER['REQUEST_URI'] = $requesturi;
     Config::getInstance()->General['enable_trusted_host_check'] = 1;
     Config::getInstance()->General['trusted_hosts'] = array($httphost);
     $urlToTest = $testurl;
     $this->assertEquals($result, Url::isLocalUrl($urlToTest));
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:14,代碼來源:UrlTest.php

示例2: verifyNonce

 /**
  * Returns if a nonce is valid and comes from a valid request.
  * 
  * A nonce is valid if it matches the current nonce and if the current nonce
  * has not expired.
  * 
  * The request is valid if the referrer is a local URL (see {@link Url::isLocalUrl()})
  * and if the HTTP origin is valid (see {@link getAcceptableOrigins()}).
  *
  * @param string $id The nonce's unique ID. See {@link getNonce()}.
  * @param string $cnonce Nonce sent from client.
  * @return bool `true` if valid; `false` otherwise.
  */
 public static function verifyNonce($id, $cnonce)
 {
     $ns = new SessionNamespace($id);
     $nonce = $ns->nonce;
     // validate token
     if (empty($cnonce) || $cnonce !== $nonce) {
         return false;
     }
     // validate referrer
     $referrer = Url::getReferrer();
     if (!empty($referrer) && !Url::isLocalUrl($referrer)) {
         return false;
     }
     // validate origin
     $origin = self::getOrigin();
     if (!empty($origin) && ($origin == 'null' || !in_array($origin, self::getAcceptableOrigins()))) {
         return false;
     }
     return true;
 }
開發者ID:brienomatty,項目名稱:elmsln,代碼行數:33,代碼來源:Nonce.php

示例3: 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);
        // 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();
        }
        if (!UrlHelper::isLookLikeUrl($url)) {
            die('Please check the &url= parameter: it should to be a valid URL');
        }
        @header('Content-Type: text/html; charset=utf-8');
        echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
        exit;
    }
開發者ID:brienomatty,項目名稱:elmsln,代碼行數:29,代碼來源:Controller.php


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