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


PHP Piwik_Url::isLocalUrl方法代码示例

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


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

示例1: verifyNonce

	/**
	 * Verify nonce and check referrer (if present, i.e., it may be suppressed by the browser or a proxy/network).
	 *
	 * @param string $id Unique id
	 * @param string $cnonce Nonce sent to client
	 * @return bool true if valid; false otherwise
	 */
	static public function verifyNonce($id, $cnonce)
	{
		$ns = new Piwik_Session_Namespace($id);
		$nonce = $ns->nonce;

		// validate token
		if(empty($cnonce) || $cnonce !== $nonce)
		{
			return false;
		}

		// validate referer
		$referer = Piwik_Url::getReferer();
		if(!empty($referer) && !Piwik_Url::isLocalUrl($referer))
		{
			return false;
		}

		// validate origin
		$origin = self::getOrigin();
		if(!empty($origin) &&
			($origin == 'null'
			|| !in_array($origin, self::getAcceptableOrigins())))
		{
			return false;
		}

		return true;
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:36,代码来源:Nonce.php

示例2: testIsLocalUrl

 /**
  * @dataProvider getLocalUrls
  * @group Core
  * @group Url
  */
 public function testIsLocalUrl($httphost, $scripturi, $requesturi, $testurl, $result)
 {
     $_SERVER['HTTP_HOST'] = $httphost;
     $_SERVER['SCRIPT_URI'] = $scripturi;
     $_SERVER['REQUEST_URI'] = $requesturi;
     $urlToTest = $testurl;
     $this->assertEquals($result, Piwik_Url::isLocalUrl($urlToTest));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:13,代码来源:UrlTest.php

示例3: testIsLocalUrl

 /**
  * @dataProvider getLocalUrls
  * @group Core
  * @group Url
  */
 public function testIsLocalUrl($httphost, $scripturi, $requesturi, $testurl, $result)
 {
     $_SERVER['HTTP_HOST'] = $httphost;
     $_SERVER['SCRIPT_URI'] = $scripturi;
     $_SERVER['REQUEST_URI'] = $requesturi;
     Piwik_Config::getInstance()->General['trusted_hosts'] = array($httphost);
     $urlToTest = $testurl;
     $this->assertEquals($result, Piwik_Url::isLocalUrl($urlToTest));
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:14,代码来源:UrlTest.php

示例4: test_isLocalUrl

 public function test_isLocalUrl()
 {
     $saved = $this->saveGlobals(array('HTTP_HOST', 'SCRIPT_URI', 'REQUEST_URI'));
     $tests = array(array('www.example.com', 'http://www.example.com/path/index.php', '/path/index.php', 'http://www.example.com/path/index.php', true), array('www.example.com', 'http://www.example.com/path/index.php?module=X', '/path/index.php', 'http://www.example.com/path/', true), array('www.example.com', 'http://www.example.com/path/', '/path/index.php', 'http://www.example.com/path/index.php?module=Y', true), array('www.example.com', 'http://www.example.com/path/#anchor', '/path/index.php', 'http://www.example.com/path/?query', true), array('localhost:8080', 'http://localhost:8080/path/index.php', '/path/index.php', 'http://localhost:8080/path/index.php', true), array('www.example.com', 'http://www.example.com/path/', '/path/', 'http://www.example.com/path2/', true), array('www.example.com', 'http://www.example.com:80/path/index.php', '/path/index.php', 'http://www.example.com/path/index.php', true), array('www.example.com', 'http://www.example.com/path/index.php', '/path/index.php', 'http://www.example.com:80/path/index.php', true), array('localhost', 'http://localhost:8080/path/index.php', '/path/index.php', 'http://localhost:8080/path/index.php', true), array('localhost', 'http://localhost/path/index.php', '/path/index.php', 'http://localhost:8080/path/index.php', true), array('localhost', 'http://localhost:8080/path/index.php', '/path/index.php', 'http://localhost/path/index.php', true), array('localhost:8080', 'http://localhost/path/index.php', '/path/index.php', 'http://localhost:8080/path/index.php', true), array('localhost:8080', 'http://localhost:8080/path/index.php', '/path/index.php', 'http://localhost/path/index.php', true), array('localhost:8080', 'http://localhost/path/index.php', '/path/index.php', 'http://localhost/path/index.php', true), array('localhost:8080', 'http://localhost:8080/path/index.php', '/path/index.php', 'http://localhost:8080/path/index.php', true), array('[::1]', 'http://[::1]/path/index.php', '/path/index.php', 'http://[::1]/path/index.php', true), array('[::1]:8080', 'http://[::1]:8080/path/index.php', '/path/index.php', 'http://[::1]/path/index.php', true), array('[::1]:8080', 'http://[::1]/path/index.php', '/path/index.php', 'http://[::1]:8080/path/index.php', true), array('www.example.com', null, '/path/index.php', 'http://www.example.com/path/index.php', true), array('localhost:8080', null, '/path/index.php', 'http://localhost:8080/path/index.php', true), array('127.0.0.1:8080', null, '/path/index.php', 'http://127.0.0.1:8080/path/index.php', true), array('[::1]', null, '/path/index.php', 'http://[::1]/path/index.php', true), array('[::1]:8080', null, '/path/index.php', 'http://[::1]:8080/path/index.php', true), array('www.example.com', 'http://www.example.com/path/#anchor', 'http://www.example.com/path/index.php', 'http://www.example.com/path/?query', true), array('www.example.com', 'http://example.com/path/#anchor', '/path/index.php', 'http://example.com/path/referrer', true), array('www.example.com', 'http://www.example.com/path/#anchor', '/path/index.php', null, true), array('www.example.com', 'http://www.example.com/path/#anchor', '/path/index.php', '', true), array('www.example.com', 'http://www.example.com/path/?module=X', '/path/index.php', 'ftp://www.example.com/path/index.php', false), array('www.example.com', 'http://www.example.com/path/?module=X', '/path/index.php', 'http://example.com/path/index.php', false), array('www.example.com', 'http://www.example.com/path/', '/path/', 'http://crsf.example.com/path/', false));
     foreach ($tests as $i => $test) {
         $_SERVER['HTTP_HOST'] = $test[0];
         $_SERVER['SCRIPT_URI'] = $test[1];
         $_SERVER['REQUEST_URI'] = $test[2];
         $urlToTest = $test[3];
         $this->assertEqual(Piwik_Url::isLocalUrl($urlToTest), $test[4], $i);
     }
     $this->restoreGlobals($saved);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:13,代码来源:Url.test.php

示例5: redirect

    /**
     * Output redirection page instead of linking directly to avoid
     * exposing the referrer on the Piwik demo.
     *
     * @param string $url (via $_GET)
     */
    public function redirect()
    {
        $url = Piwik_Common::getRequestVar('url', '', 'string', $_GET);
        // validate referrer
        $referrer = Piwik_Url::getReferer();
        if (!empty($referrer) && !Piwik_Url::isLocalUrl($referrer)) {
            die('Invalid Referer detected - check that your browser sends the Referer header. <br/>The link you would have been redirected to is: ' . $url);
            exit;
        }
        // mask visits to *.piwik.org
        if (self::isPiwikUrl($url)) {
            echo '<html><head>
<meta http-equiv="refresh" content="0;url=' . $url . '" />
</head></html>';
        }
        exit;
    }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:23,代码来源:Controller.php


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