本文整理汇总了PHP中Piwik\Url::getCurrentHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getCurrentHost方法的具体用法?PHP Url::getCurrentHost怎么用?PHP Url::getCurrentHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Url
的用法示例。
在下文中一共展示了Url::getCurrentHost方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($username)
{
$this->username = $username;
$this->title = 'Piwik - ' . Url::getCurrentHost();
$this->description = Piwik::getCurrentUserLogin();
$this->load();
}
示例2: testGetCurrentHost
/**
* @dataProvider getCurrentHosts
* @group Core
*/
public function testGetCurrentHost($description, $test)
{
$_SERVER['HTTP_HOST'] = $test[0];
$_SERVER['HTTP_X_FORWARDED_HOST'] = $test[1];
Config::getInstance()->General['proxy_host_headers'] = array($test[2]);
Config::getInstance()->General['proxy_ips'] = array($test[3]);
Config::getInstance()->General['enable_trusted_host_check'] = 0;
$this->assertEquals($test[4], Url::getCurrentHost(), $description);
}
示例3: setFrom
/**
* Sets the sender.
*
* @param string $email Email address of the sender.
* @param null|string $name Name of the sender.
* @return Zend_Mail
*/
public function setFrom($email, $name = null)
{
$hostname = Config::getInstance()->mail['defaultHostnameIfEmpty'];
$piwikHost = Url::getCurrentHost($hostname);
// If known Piwik URL, use it instead of "localhost"
$piwikUrl = SettingsPiwik::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);
return parent::setFrom($email, $name);
}
示例4: notifyIfURLIsNotSecure
private static function notifyIfURLIsNotSecure()
{
$isURLSecure = ProxyHttp::isHttps();
if ($isURLSecure) {
return;
}
if (!Piwik::hasUserSuperUserAccess()) {
return;
}
if (Url::isLocalHost(Url::getCurrentHost())) {
return;
}
$message = Piwik::translate('General_CurrentlyUsingUnsecureHttp');
$message .= " ";
$message .= Piwik::translate('General_ReadThisToLearnMore', array('<a rel="noreferrer" target="_blank" href="https://piwik.org/faq/how-to/faq_91/">', '</a>'));
$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
$notification->raw = true;
Notification\Manager::notify('ControllerAdmin_HttpIsUsed', $notification);
}
示例5: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
$user = APIUsersManager::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
$view->ignoreSalt = $this->getIgnoreCookieSalt();
$userPreferences = new UserPreferences();
$defaultReport = $userPreferences->getDefaultReport();
if ($defaultReport === false) {
$defaultReport = $userPreferences->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$defaultSiteId = $userPreferences->getDefaultWebsiteId();
$view->defaultReportIdSite = $defaultSiteId;
$view->defaultReportSiteName = Site::getNameFor($defaultSiteId);
} else {
$view->defaultReportIdSite = $defaultReport;
$view->defaultReportSiteName = Site::getNameFor($defaultReport);
}
$view->defaultDate = $this->getDefaultDateForUser($userLogin);
$view->availableDefaultDates = $this->getDefaultDates();
$view->languages = APILanguagesManager::getInstance()->getAvailableLanguageNames();
$view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser();
$view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound();
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
return $view->render();
}
示例6: getRandomTitle
/**
* Generate a title for image tags
*
* @return string
*/
public static function getRandomTitle()
{
static $titles = array('Web analytics', 'Open analytics platform', 'Real Time Web Analytics', 'Analytics', 'Real Time Analytics', 'Analytics in Real time', 'Analytics Platform', 'Data Platform');
$id = abs(intval(md5(Url::getCurrentHost())));
$title = $titles[$id % count($titles)];
return $title;
}
示例7: settings
/**
* Settings page for the user - allow activating / disabling Google Authenticator and to generate secrets
*
* @return string
* @throws \Exception
* @throws \Piwik\NoAccessException
*/
public function settings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@GoogleAuthenticator/settings');
$this->setGeneralVariablesView($view);
$googleAuth = new PHPGangsta\GoogleAuthenticator();
$storage = new Storage(Piwik::getCurrentUserLogin());
$view->activated = $view->disabled = false;
if (Common::getRequestVar('activate', 0, 'int')) {
$storage->activate();
$view->activated = true;
}
if (Common::getRequestVar('disable', 0, 'int')) {
$storage->deactivate();
$view->disabled = true;
}
$secret = $storage->getSecret();
$view->showSetUp = Common::getRequestVar('setup', 0, 'int');
$view->googleAuthIsActive = $storage->isActive();
$view->googleAuthSecret = $secret;
$view->googleAuthImage = $googleAuth->getQRCodeGoogleUrl(Piwik::getCurrentUserLogin(), $secret, 'Piwik - ' . Url::getCurrentHost());
return $view->render();
}
示例8: getAcceptableOrigins
/**
* Returns a list acceptable values for the HTTP **Origin** header.
*
* @return array
*/
public static function getAcceptableOrigins()
{
$host = Url::getCurrentHost(null);
$port = '';
// parse host:port
if (preg_match('/^([^:]+):([0-9]+)$/D', $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 = Config::getInstance()->General['force_ssl_login'];
if ($forceSslLogin && !ProxyHttp::isHttps()) {
$url = 'https://' . Url::getCurrentHost() . Url::getCurrentScriptName() . Url::getCurrentQueryString();
Url::redirectToUrl($url);
}
}
示例10: parseDomainPlaceholderAsPiwikHostName
/**
* @param string $email
* @return string
*/
protected function parseDomainPlaceholderAsPiwikHostName($email)
{
$hostname = Config::getInstance()->mail['defaultHostnameIfEmpty'];
$piwikHost = Url::getCurrentHost($hostname);
// If known Piwik URL, use it instead of "localhost"
$piwikUrl = SettingsPiwik::getPiwikUrl();
$url = parse_url($piwikUrl);
if ($this->isHostDefinedAndNotLocal($url)) {
$piwikHost = $url['host'];
}
return str_replace('{DOMAIN}', $piwikHost, $email);
}
示例11: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
$user = Request::processRequest('UsersManager.getUser', array('userLogin' => $userLogin));
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
$view->userTokenAuth = Piwik::getCurrentUserTokenAuth();
$view->ignoreSalt = $this->getIgnoreCookieSalt();
$userPreferences = new UserPreferences();
$defaultReport = $userPreferences->getDefaultReport();
if ($defaultReport === false) {
$defaultReport = $userPreferences->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$defaultSiteId = $userPreferences->getDefaultWebsiteId();
$reportOptionsValue = $defaultSiteId;
$view->defaultReportIdSite = $defaultSiteId;
$view->defaultReportSiteName = Site::getNameFor($defaultSiteId);
} else {
$reportOptionsValue = $defaultReport;
$view->defaultReportIdSite = $defaultReport;
$view->defaultReportSiteName = Site::getNameFor($defaultReport);
}
$view->defaultReportOptions = array(array('key' => 'MultiSites', 'value' => Piwik::translate('General_AllWebsitesDashboard')), array('key' => $reportOptionsValue, 'value' => Piwik::translate('General_DashboardForASpecificWebsite')));
$view->defaultDate = $this->getDefaultDateForUser($userLogin);
$view->availableDefaultDates = $this->getDefaultDates();
$languages = APILanguagesManager::getInstance()->getAvailableLanguageNames();
$languageOptions = array();
foreach ($languages as $language) {
$languageOptions[] = array('key' => $language['code'], 'value' => $language['name']);
}
$view->languageOptions = $languageOptions;
$view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser();
$view->currentTimeformat = (int) LanguagesManager::uses12HourClockForCurrentUser();
$view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound();
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
$view->timeFormats = array('1' => Piwik::translate('General_12HourClock'), '0' => Piwik::translate('General_24HourClock'));
return $view->render();
}
示例12: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
if (Piwik::isUserIsSuperUser()) {
$view->userAlias = $userLogin;
$view->userEmail = Piwik::getSuperUserEmail();
$this->displayWarningIfConfigFileNotWritable();
} else {
$user = APIUsersManager::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
}
$defaultReport = APIUsersManager::getInstance()->getUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT);
if ($defaultReport === false) {
$defaultReport = $this->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$view->defaultReportSiteName = Site::getNameFor($this->getDefaultWebsiteId());
} else {
$view->defaultReportSiteName = Site::getNameFor($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 = IgnoreCookie::isIgnoreCookieFound();
$this->initViewAnonymousUserSettings($view);
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
return $view->render();
}