本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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), '');
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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();
}