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


PHP Piwik_Url::getCurrentHost方法代码示例

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


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

示例1: setFrom

 public function setFrom($email, $name = null)
 {
     $hostname = Zend_Registry::get('config')->mail->defaultHostnameIfEmpty;
     $piwikHost = Piwik_Url::getCurrentHost($hostname);
     $email = str_replace('{DOMAIN}', $piwikHost, $email);
     parent::setFrom($email, $name);
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:7,代码来源:Mail.php

示例2: testGetCurrentHost

 /**
  * @dataProvider getCurrentHosts
  * @group Core
  * @group Url
  */
 public function testGetCurrentHost($description, $test)
 {
     $_SERVER['HTTP_HOST'] = $test[0];
     $_SERVER['HTTP_X_FORWARDED_HOST'] = $test[1];
     Piwik_Config::getInstance()->General['proxy_host_headers'] = array($test[2]);
     Piwik_Config::getInstance()->General['proxy_ips'] = array($test[3]);
     $this->assertEquals($test[4], Piwik_Url::getCurrentHost(), $description);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:13,代码来源:UrlTest.php

示例3: setFrom

 /**
  * Sets the sender to use
  *
  * @param string       $email
  * @param null|string  $name
  */
 public function setFrom($email, $name = null)
 {
     $hostname = Piwik_Config::getInstance()->mail['defaultHostnameIfEmpty'];
     $piwikHost = Piwik_Url::getCurrentHost($hostname);
     // If known Piwik URL, use it instead of "localhost"
     $piwikUrl = Piwik::getPiwikUrl();
     $url = parse_url($piwikUrl);
     if (isset($url['host']) && $url['host'] != 'localhost' && $url['host'] != '127.0.0.1') {
         $piwikHost = $url['host'];
     }
     $email = str_replace('{DOMAIN}', $piwikHost, $email);
     parent::setFrom($email, $name);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:19,代码来源:Mail.php

示例4: test_getCurrentHost

 public function test_getCurrentHost()
 {
     $GLOBALS['PIWIK_TRACKER_MODE'] = false;
     Piwik::createConfigObject();
     Piwik_Config::getInstance()->setTestEnvironment();
     $saved = $this->saveGlobals(array('HTTP_HOST', 'HTTP_X_FORWARDED_HOST'));
     $tests = array('localhost IPv4' => array('127.0.0.1', null, null, null, '127.0.0.1'), 'localhost IPv6' => array('[::1]', null, null, null, '[::1]'), 'localhost name' => array('localhost', null, null, null, 'localhost'), 'IPv4 without proxy' => array('128.1.2.3', null, null, null, '128.1.2.3'), 'IPv6 without proxy' => array('[2001::b0b]', null, null, null, '[2001::b0b]'), 'name without proxy' => array('example.com', null, null, null, 'example.com'), 'IPv4 with one proxy' => array('127.0.0.1', '128.1.2.3', 'HTTP_X_FORWARDED_HOST', null, '128.1.2.3'), 'IPv6 with one proxy' => array('[::1]', '[2001::b0b]', 'HTTP_X_FORWARDED_HOST', null, '[2001::b0b]'), 'name with one IPv4 proxy' => array('192.168.1.10', 'example.com', 'HTTP_X_FORWARDED_HOST', null, 'example.com'), 'name with one IPv6 proxy' => array('[::10]', 'www.example.com', 'HTTP_X_FORWARDED_HOST', null, 'www.example.com'), 'name with one named proxy' => array('dmz.example.com', 'www.example.com', 'HTTP_X_FORWARDED_HOST', null, 'www.example.com'), 'IPv4 with multiple proxies' => array('127.0.0.1', '128.1.2.3, 192.168.1.10', 'HTTP_X_FORWARDED_HOST', '192.168.1.*', '128.1.2.3'), 'IPv6 with multiple proxies' => array('[::1]', '[2001::b0b], [::ffff:192.168.1.10]', 'HTTP_X_FORWARDED_HOST', '::ffff:192.168.1.0/124', '[2001::b0b]'), 'name with multiple proxies' => array('dmz.example.com', 'www.example.com, dmz.example.com', 'HTTP_X_FORWARDED_HOST', 'dmz.example.com', 'www.example.com'));
     foreach ($tests as $description => $test) {
         $_SERVER['HTTP_HOST'] = $test[0];
         $_SERVER['HTTP_X_FORWARDED_HOST'] = $test[1];
         Piwik_Config::getInstance()->General['proxy_host_headers'] = array($test[2]);
         Piwik_Config::getInstance()->General['proxy_ips'] = array($test[3]);
         $this->assertEqual(Piwik_Url::getCurrentHost(), $test[4], $description);
     }
     $this->restoreGlobals($saved);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:16,代码来源:Url.test.php

示例5: test_allMethods

 /**
  * display output of all methods
  */
 public function test_allMethods()
 {
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
     $this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentUrlWithoutQueryString());
     $this->assertEqual(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
     print "<br>\nPiwik_Url::getCurrentQueryStringWithParametersModified() " . Piwik_Url::getCurrentQueryStringWithParametersModified(array());
     print "<br>\nPiwik_Url::getCurrentUrl() " . Piwik_Url::getCurrentUrl();
     print "<br>\nPiwik_Url::getCurrentUrlWithoutQueryString() " . Piwik_Url::getCurrentUrlWithoutQueryString();
     print "<br>\nPiwik_Url::getCurrentUrlWithoutFileName() " . Piwik_Url::getCurrentUrlWithoutFileName();
     print "<br>\nPiwik_Url::getCurrentScriptName() " . Piwik_Url::getCurrentScriptName();
     print "<br>\nPiwik_Url::getCurrentScriptPath() " . Piwik_Url::getCurrentScriptPath();
     print "<br>\nPiwik_Url::getCurrentHost() " . Piwik_Url::getCurrentHost();
     print "<br>\nPiwik_Url::getCurrentQueryString() " . Piwik_Url::getCurrentQueryString();
     print "<br>\nPiwik_Url::getArrayFromCurrentQueryString() ";
     var_dump(Piwik_Url::getArrayFromCurrentQueryString());
     // setting parameter to null should remove it from url
     // test on Url.test.php?test=value
     $parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
     $parametersNameToValue = array();
     foreach ($parameters as $name) {
         $parametersNameToValue[$name] = null;
     }
     $this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue), '');
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:27,代码来源:Url.test.php

示例6: getRandomTitle

 public static function getRandomTitle()
 {
     $titles = array('Web analytics', 'Analytics', 'Web analytics api', 'Open source analytics', 'Open source web analytics', 'Google Analytics alternative', 'open source Google Analytics', 'Free analytics', 'Analytics software', 'Free web analytics', 'Free web statistics', 'Web 2.0 analytics', 'Statistics web 2.0');
     $id = abs(intval(md5(substr(Piwik_Url::getCurrentHost(), 7))));
     $title = $titles[$id % count($titles)];
     return $title;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:Piwik.php

示例7: getRandomTitle

 /**
  * Generate a title for image tags
  *
  * @return string
  */
 public static function getRandomTitle()
 {
     static $titles = array('Web analytics', 'Real Time Web Analytics', 'Analytics', 'Real Time Analytics', 'Open Source Analytics', 'Open Source Web Analytics', 'Free Website Analytics', 'Free Web Analytics');
     $id = abs(intval(md5(Piwik_Url::getCurrentHost())));
     $title = $titles[$id % count($titles)];
     return $title;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:12,代码来源:Piwik.php

示例8: getAcceptableOrigins

	/**
	 * Returns acceptable origins (not simply scheme://host) that
	 * should handle a variety of proxy and web server (mis)configurations,.
	 *
	 * @return array
	 */
	static public function getAcceptableOrigins()
	{
		$host = Piwik_Url::getCurrentHost(null);
		$port = '';

		// parse host:port
		if(preg_match('/^([^:]+):([0-9]+)$/', $host, $matches))
		{
			$host = $matches[1];
			$port = $matches[2];
		}

		if(empty($host))
		{
			return array();
		}

		// standard ports
		$origins[] = 'http://'.$host;
		$origins[] = 'https://'.$host;

		// non-standard ports
		if(!empty($port) && $port != 80 && $port != 443)
		{
			$origins[] = 'http://'.$host.':'.$port;
			$origins[] = 'https://'.$host.':'.$port;
		}

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

示例9: checkForceSslLogin

 /**
  * Check force_ssl_login and redirect if connection isn't secure and not using a reverse proxy
  *
  * @param none
  * @return void
  */
 protected function checkForceSslLogin()
 {
     $forceSslLogin = Zend_Registry::get('config')->General->force_ssl_login;
     if ($forceSslLogin) {
         if (!Piwik::isHttps()) {
             $url = 'https://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName() . Piwik_Url::getCurrentQueryString();
             Piwik_Url::redirectToUrl($url);
         }
     }
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:16,代码来源:Controller.php

示例10: checkForceSslLogin

 /**
  * Check force_ssl_login and redirect if connection isn't secure and not using a reverse proxy
  *
  * @param none
  * @return void
  */
 protected function checkForceSslLogin()
 {
     $forceSslLogin = Piwik_Config::getInstance()->General['force_ssl_login'];
     if ($forceSslLogin && !Piwik::isHttps()) {
         $url = 'https://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName() . Piwik_Url::getCurrentQueryString();
         Piwik_Url::redirectToUrl($url);
     }
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:14,代码来源:Controller.php

示例11: userSettings

	/**
	 * The "User Settings" admin UI screen view
	 */
	public function userSettings()
	{
		$view = Piwik_View::factory('userSettings');
		
		$userLogin = Piwik::getCurrentUserLogin();
		if(Piwik::isUserIsSuperUser())
		{
			$view->userAlias = $userLogin;
			$view->userEmail = Piwik::getSuperUserEmail();
			if(!Zend_Registry::get('config')->isFileWritable())
			{
				$view->configFileNotWritable = true;
			}
		}
		else
		{
			$user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
			$view->userAlias = $user['alias'];
	 		$view->userEmail = $user['email'];
		}
		
		$defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
		if($defaultReport === false)
		{
			$defaultReport = $this->getDefaultWebsiteId();
		}
		$view->defaultReport = $defaultReport;

		$view->defaultDate = $this->getDefaultDateForUser($userLogin);
		$view->availableDefaultDates = array(
			'today' => Piwik_Translate('General_Today'),
			'yesterday' => Piwik_Translate('General_Yesterday'),
			'previous7' => Piwik_Translate('General_PreviousDays', 7),
			'previous30' => Piwik_Translate('General_PreviousDays', 30),
			'last7' => Piwik_Translate('General_LastDays', 7),
			'last30' => Piwik_Translate('General_LastDays', 30),
			'week' => Piwik_Translate('General_CurrentWeek'),
			'month' => Piwik_Translate('General_CurrentMonth'),
			'year' => Piwik_Translate('General_CurrentYear'),
		);
		
		$view->ignoreCookieSet = Piwik_Tracker_IgnoreCookie::isIgnoreCookieFound();
		$this->initViewAnonymousUserSettings($view);
		$view->piwikHost = Piwik_Url::getCurrentHost();
		$this->setBasicVariablesView($view);
		$view->menu = Piwik_GetAdminMenu();
		echo $view->render();
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:51,代码来源:Controller.php


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