本文整理汇总了PHP中Piwik_Url::getCurrentUrlWithoutQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Url::getCurrentUrlWithoutQueryString方法的具体用法?PHP Piwik_Url::getCurrentUrlWithoutQueryString怎么用?PHP Piwik_Url::getCurrentUrlWithoutQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Url
的用法示例。
在下文中一共展示了Piwik_Url::getCurrentUrlWithoutQueryString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Check for a newer version
*
* @param bool $force Force check
*/
public static function check($force = false)
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if($force || $lastTimeChecked === false
|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
{
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
$parameters = array(
'piwik_version' => Piwik_Version::VERSION,
'php_version' => PHP_VERSION,
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
'trigger' => Piwik_Common::getRequestVar('module','','string'),
'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
);
$url = Zend_Registry::get('config')->General->api_service_url;
$url .= '/1.0/getLatestVersion/';
$url .= '?' . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
Piwik_SetOption(self::LATEST_VERSION, '');
}
}
}
示例2: check
/**
* Check for a newer version
*/
public static function check()
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if($lastTimeChecked === false
|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
{
$parameters = array(
'piwik_version' => Piwik_Version::VERSION,
'php_version' => phpversion(),
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
'trigger' => Piwik_Common::getRequestVar('module','','string'),
);
$url = self::PIWIK_HOST . "?" . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik::sendHttpRequest($url, $timeout);
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
Piwik_SetOption(self::LATEST_VERSION, '');
}
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
}
}
示例3: getFlashInvocationCode
protected function getFlashInvocationCode($url = 'libs/open-flash-chart/data-files/nodata.txt', $use_swfobject = true)
{
$width = $this->width;
$height = $this->height;
$libPathInPiwik = 'libs/open-flash-chart/';
$currentPath = Piwik_Url::getCurrentUrlWithoutFileName();
$pathToLibraryOpenChart = $currentPath . $libPathInPiwik;
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . $url;
// escape the & and stuff:
$url = urlencode($url);
$obj_id = $this->id . "Chart";
$div_name = $this->id . "FlashContent";
$return = '';
if ($use_swfobject) {
// Using library for auto-enabling Flash object on IE, disabled-Javascript proof
$return .= '
<div id="' . $div_name . '"></div>
<script type="text/javascript">
var so = new SWFObject("' . $pathToLibraryOpenChart . 'open-flash-chart.swf", "' . $obj_id . '_swf", "' . $width . '", "' . $height . '", "9", "#FFFFFF");
so.addVariable("data", "' . $url . '");
so.addParam("allowScriptAccess", "sameDomain");
so.write("' . $div_name . '");
</script>
<noscript>
';
}
$urlGraph = $pathToLibraryOpenChart . "open-flash-chart.swf?data=" . $url;
$this->codeEmbed .= "<div><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" . $width . "' height='" . $height . "' id='" . $obj_id . "' >" . "<param name='movie' value='" . $urlGraph . "' />" . "<param name='allowScriptAccess' value='sameDomain' /> " . "<embed src='{$urlGraph}' allowScriptAccess='sameDomain' quality='high' bgcolor='#FFFFFF' width='" . $width . "' height='" . $height . "' name='open-flash-chart' type='application/x-shockwave-flash' id='" . $obj_id . "' />" . "</object></div>";
$return .= $this->codeEmbed;
if ($use_swfobject) {
$return .= '</noscript>';
}
return $return;
}
示例4: test_allMethods
/**
* display output of all methods
*/
public function test_allMethods()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$this->assertEqual(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
$expectedUrl = parse_url(Piwik_Url::getCurrentUrl());
$port = isset($expectedUrl['port']) ? ":{$expectedUrl['port']}" : '';
$expectedUrl = $expectedUrl['scheme'] . '://' . $expectedUrl['host'] . $port . $expectedUrl['path'];
$this->assertEqual($expectedUrl, Piwik_Url::getCurrentUrlWithoutQueryString());
$this->assertEqual($expectedUrl, Piwik_Url::getCurrentScheme() . '://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
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::getCurrentScriptPath() -> " . Piwik_Url::getCurrentScriptPath();
print "<br/>\nPiwik_Url::getCurrentHost() -> " . Piwik_Url::getCurrentHost();
print "<br/>\nPiwik_Url::getCurrentScriptName() -> " . Piwik_Url::getCurrentScriptName();
print "<br/>\nPiwik_Url::getCurrentQueryString() -> " . Piwik_Url::getCurrentQueryString();
print "<br/>\nPiwik_Url::getArrayFromCurrentQueryString() -> ";
var_dump(Piwik_Url::getArrayFromCurrentQueryString());
print "<br/>\nPiwik_Url::getCurrentQueryStringWithParametersModified() -> " . Piwik_Url::getCurrentQueryStringWithParametersModified(array());
echo "<br/>\n\n";
// 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), '');
}
示例5: testClearspring
function testClearspring()
{
$view = Piwik_View::factory('test_widget');
$view->url1 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&filter_limit=5&token_auth=' . Piwik::getCurrentUserTokenAuth();
$view->url2 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=VisitTime&actionToWidgetize=getVisitInformationPerServerTime&idSite=1&period=day&date=yesterday&viewDataTable=graphVerticalBar&show_footer=0&token_auth=' . Piwik::getCurrentUserTokenAuth();
$view->url3 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=1&filter_limit=15&show_search=false&token_auth=' . Piwik::getCurrentUserTokenAuth();
echo $view->render();
}
示例6: testAllMethods
/**
* @group Core
* @group Url
*/
public function testAllMethods()
{
$this->assertEquals(Piwik_Url::getCurrentQueryStringWithParametersModified(array()), Piwik_Url::getCurrentQueryString());
$this->assertEquals(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentUrlWithoutQueryString());
$this->assertEquals(Piwik_Url::getCurrentUrl(), Piwik_Url::getCurrentScheme() . '://' . Piwik_Url::getCurrentHost() . Piwik_Url::getCurrentScriptName());
$_SERVER['QUERY_STRING'] = 'q=test';
$parameters = array_keys(Piwik_Url::getArrayFromCurrentQueryString());
$parametersNameToValue = array();
foreach ($parameters as $name) {
$parametersNameToValue[$name] = null;
}
$this->assertEquals('', Piwik_Url::getCurrentQueryStringWithParametersModified($parametersNameToValue));
}
示例7: 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), '');
}
示例8: check
/**
* Check for a newer version
*
* @param bool $force Force check
*/
public static function check($force = false)
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if ($force || $lastTimeChecked === false || time() - self::CHECK_INTERVAL > $lastTimeChecked) {
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
$parameters = array('piwik_version' => Piwik_Version::VERSION, 'php_version' => PHP_VERSION, 'url' => Piwik_Url::getCurrentUrlWithoutQueryString(), 'trigger' => Piwik_Common::getRequestVar('module', '', 'string'), 'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone());
$url = Piwik_Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
if (@Piwik_Config::getInstance()->Debug['allow_upgrades_to_beta']) {
$url = 'http://builds.piwik.org/LATEST_BETA';
}
try {
$latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
$latestVersion = '';
}
} catch (Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
$latestVersion = '';
}
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
}
}
示例9: sendEmailConfirmationLink
/**
* Sends email confirmation link for a password reset request.
*
* @param array $user User info for the requested password reset.
*/
private function sendEmailConfirmationLink($user)
{
$login = $user['login'];
$email = $user['email'];
// construct a password reset token from user information
$resetToken = self::generatePasswordResetToken($user);
$ip = Piwik_IP::getIpFromHeader();
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=confirmResetPassword&login=" . urlencode($login) . "&resetToken=" . urlencode($resetToken);
// send email with new password
$mail = new Piwik_Mail();
$mail->addTo($email, $login);
$mail->setSubject(Piwik_Translate('Login_MailTopicPasswordChange'));
$bodyText = str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordChangeBody'), $login, $ip, $url)) . "\n";
$mail->setBodyText($bodyText);
$fromEmailName = Piwik_Config::getInstance()->General['login_password_recovery_email_name'];
$fromEmailAddress = Piwik_Config::getInstance()->General['login_password_recovery_email_address'];
$mail->setFrom($fromEmailAddress, $fromEmailName);
@$mail->send();
}
示例10: setHostValidationVariablesView
/**
* Checks if the current host is valid and sets variables on the given view, including:
*
* isValidHost - true if host is valid, false if otherwise
* invalidHostMessage - message to display if host is invalid (only set if host is invalid)
* invalidHost - the invalid hostname (only set if host is invalid)
* mailLinkStart - the open tag of a link to email the super user of this problem (only set
* if host is invalid)
*/
public static function setHostValidationVariablesView($view)
{
// check if host is valid
$view->isValidHost = Piwik_Url::isValidHost();
if (!$view->isValidHost) {
// invalid host, so display warning to user
$validHost = Piwik_Config::getInstance()->General['trusted_hosts'][0];
$invalidHost = Piwik_Common::sanitizeInputValue($_SERVER['HTTP_HOST']);
$emailSubject = rawurlencode(Piwik_Translate('CoreHome_InjectedHostEmailSubject', $invalidHost));
$emailBody = rawurlencode(Piwik_Translate('CoreHome_InjectedHostEmailBody'));
$superUserEmail = Piwik::getSuperUserEmail();
$mailToUrl = "mailto:{$superUserEmail}?subject={$emailSubject}&body={$emailBody}";
$mailLinkStart = "<a href=\"{$mailToUrl}\">";
$invalidUrl = Piwik_Url::getCurrentUrlWithoutQueryString($checkIfTrusted = false);
$validUrl = Piwik_Url::getCurrentScheme() . '://' . $validHost . Piwik_Url::getCurrentScriptName();
$validLink = "<a href=\"{$validUrl}\">{$validUrl}</a>";
$changeTrustedHostsUrl = "index.php" . Piwik_Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'generalSettings')) . "#trustedHostsSection";
$warningStart = Piwik_Translate('CoreHome_InjectedHostWarningIntro', array('<strong>' . $invalidUrl . '</strong>', '<strong>' . $validUrl . '</strong>')) . ' <br/>';
if (Piwik::isUserIsSuperUser()) {
$view->invalidHostMessage = $warningStart . ' ' . Piwik_Translate('CoreHome_InjectedHostSuperUserWarning', array("<a href=\"{$changeTrustedHostsUrl}\">", $invalidHost, '</a>', "<br/><a href=\"{$validUrl}\">", $validHost, '</a>'));
} else {
$view->invalidHostMessage = $warningStart . ' ' . Piwik_Translate('CoreHome_InjectedHostNonSuperUserWarning', array("<br/><a href=\"{$validUrl}\">", '</a>', $mailLinkStart, '</a>'));
}
$view->invalidHostMessageHowToFix = '<b>How do I fix this problem and how do I login again?</b><br/> The Piwik Super User can manually edit the file piwik/config/config.ini.php
and add the following lines: <pre>[General]' . "\n" . 'trusted_hosts[] = "' . $validHost . '"</pre><br/>After making the change, you will be able to login again.<br/><br/>
You may also <i>disable this security feature (not recommended)</i>. To do so edit config/config.ini.php and add:
<pre>[General]' . "\n" . 'enable_trusted_host_check=0</pre>';
$view->invalidHost = $invalidHost;
// for UserSettings warning
$view->invalidHostMailLinkStart = $mailLinkStart;
}
}
示例11: generalSetup
/**
* Installation Step 6: General Set-up (superuser login/password/email and subscriptions)
*/
function generalSetup()
{
$this->checkPreviousStepIsValid( __FUNCTION__ );
$view = new Piwik_Installation_View(
$this->pathView . 'generalSetup.tpl',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep( __FUNCTION__ );
$form = new Piwik_Installation_FormGeneralSetup();
if($form->validate())
{
$superUserInfos = array(
'login' => $form->getSubmitValue('login'),
'password' => md5( $form->getSubmitValue('password') ),
'email' => $form->getSubmitValue('email'),
'salt' => Piwik_Common::generateUniqId(),
);
$this->session->superuser_infos = $superUserInfos;
$url = Zend_Registry::get('config')->General->api_service_url;
$url .= '/1.0/subscribeNewsletter/';
$params = array(
'email' => $form->getSubmitValue('email'),
'security' => $form->getSubmitValue('subscribe_newsletter_security'),
'community' => $form->getSubmitValue('subscribe_newsletter_community'),
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
);
if($params['security'] == '1'
|| $params['community'] == '1')
{
if( !isset($params['security'])) { $params['security'] = '0'; }
if( !isset($params['community'])) { $params['community'] = '0'; }
$url .= '?' . http_build_query($params, '', '&');
try {
Piwik_Http::sendHttpRequest($url, $timeout = 2);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
}
}
$this->redirectToNextStep( __FUNCTION__ );
}
$view->addForm($form);
echo $view->render();
}
示例12: generalSetup
function generalSetup()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
$view = new Piwik_Installation_View($this->pathView . 'generalSetup.tpl', $this->getInstallationSteps(), __FUNCTION__);
$this->skipThisStep(__FUNCTION__);
$form = new Piwik_Installation_FormGeneralSetup();
if ($form->validate()) {
$superUserInfos = array('login' => $form->getSubmitValue('login'), 'password' => md5($form->getSubmitValue('password')), 'email' => $form->getSubmitValue('email'));
$this->session->superuser_infos = $superUserInfos;
$host = 'http://api.piwik.org/1.0/';
$host .= 'subscribeNewsletter/';
$params = array('email' => $form->getSubmitValue('email'), 'security' => $form->getSubmitValue('subscribe_newsletter_security'), 'community' => $form->getSubmitValue('subscribe_newsletter_community'), 'url' => Piwik_Url::getCurrentUrlWithoutQueryString());
if ($params['security'] == '1' || $params['community'] == '1') {
if (!isset($params['security'])) {
$params['security'] = '0';
}
if (!isset($params['community'])) {
$params['community'] = '0';
}
$url = $host . "?" . http_build_query($params, '', '&');
Piwik::sendHttpRequest($url, $timeout = 2);
}
$this->redirectToNextStep(__FUNCTION__);
}
$view->addForm($form);
echo $view->render();
}
示例13: getFlashInvocationCode
protected function getFlashInvocationCode($url = 'libs/open-flash-chart/data-files/nodata.txt')
{
$width = $this->width;
$height = $this->height;
$pathToLibraryOpenChart = 'libs/open-flash-chart/';
$pathToLibrarySwfObject = 'libs/swfobject/';
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . $url;
// escape the & and stuff:
$url = urlencode($url);
$requiredFlashVersion = "9.0.0";
// - Export as Image feature from Open Flash Chart
// - Using library for auto-enabling Flash object on IE, disabled-Javascript proof
$return = '
<div id="' . $this->chartDivId . '">
Displaying Graphs in Piwik requires Flash >= ' . $requiredFlashVersion . '. <a target="_blank" href="misc/redirectToUrl.php?url=' . urlencode('http://piwik.org/faq/troubleshooting/#faq_53') . '">More information about displaying graphs in Piwik.</a>
</div>
<script type="text/javascript">
OFC = {};
OFC.jquery = {
name: "jQuery",
rasterize: function (src, dst) { $("#"+ dst).replaceWith(Control.OFC.image(src)); },
image: function (src) { return "<img title=\'Piwik Graph\' src=\'data:image/png;base64," + $("#"+src)[0].get_img_binary() + "\' />"; },
popup: function (src) {
var img_win = window.open("", "Charts: Export as Image");
img_win.document.write("<html><head><title>' . Piwik_Translate('General_ExportAsImage') . '<\\/title><\\/head><body>" + Control.OFC.image(src) + "<br><br><p>' . htmlentities(Piwik_Translate('General_SaveImageOnYourComputer')) . '<\\/p><\\/body><\\/html>");
}
};
if (typeof Control == "undefined") { var Control = {OFC: OFC.jquery}; }
// By default, right-clicking on OFC and choosing "save image locally" calls this function.
function save_image() { OFC.jquery.popup("' . $this->chartDivId . '"); }
swfobject.embedSWF(
"' . $pathToLibraryOpenChart . 'open-flash-chart.swf?v2i",
"' . $this->chartDivId . '",
"' . $width . '", "' . $height . '",
"' . $requiredFlashVersion . '",
"' . $pathToLibrarySwfObject . 'expressInstall.swf",
{
"data-file":"' . $url . '",
"loading":"' . htmlspecialchars(Piwik_Translate('General_Loading')) . '"
},
{
"allowScriptAccess":"sameDomain",
"wmode":"opaque"
},
{"bgcolor":"#FFFFFF"}
);
</script>';
return $return;
}
示例14: lostPasswordFormValidated
/**
* Validate user (by username or email address).
*
* @param string $loginMail (user name or email address)
* @param string $urlToRedirect (URL to redirect to, if successfully validated)
* @return string (failure message if unable to validate)
*/
protected function lostPasswordFormValidated($loginMail, $urlToRedirect)
{
$user = self::getUserInformation($loginMail);
if ($user === null) {
return Piwik_Translate('Login_InvalidUsernameEmail');
}
$view = Piwik_View::factory('passwordsent');
$login = $user['login'];
$email = $user['email'];
// construct a password reset token from user information
$resetToken = self::generatePasswordResetToken($user);
$ip = Piwik_Common::getIpString();
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=resetPassword&token={$resetToken}";
// send email with new password
try {
$mail = new Piwik_Mail();
$mail->addTo($email, $login);
$mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery'));
$mail->setBodyText(str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $ip, $url, $resetToken)) . "\n");
$piwikHost = $_SERVER['HTTP_HOST'];
if (strlen($piwikHost) == 0) {
$piwikHost = 'piwik.org';
}
$fromEmailName = Zend_Registry::get('config')->General->login_password_recovery_email_name;
$fromEmailAddress = Zend_Registry::get('config')->General->login_password_recovery_email_address;
$fromEmailAddress = str_replace('{DOMAIN}', $piwikHost, $fromEmailAddress);
$mail->setFrom($fromEmailAddress, $fromEmailName);
@$mail->send();
} catch (Exception $e) {
$view->ErrorString = $e->getMessage();
}
$view->linkTitle = Piwik::getRandomTitle();
$view->urlToRedirect = $urlToRedirect;
echo $view->render();
exit;
}
示例15: lostPasswordFormValidated
/**
* Validate user (by username or email address).
*
* @param string $loginMail user name or email address
* @return string failure message if unable to validate
*/
protected function lostPasswordFormValidated($loginMail)
{
if ($loginMail === 'anonymous') {
return Piwik_Translate('Login_InvalidUsernameEmail');
}
$user = self::getUserInformation($loginMail);
if ($user === null) {
return Piwik_Translate('Login_InvalidUsernameEmail');
}
$view = Piwik_View::factory('passwordsent');
$login = $user['login'];
$email = $user['email'];
// construct a password reset token from user information
$resetToken = self::generatePasswordResetToken($user);
$ip = Piwik_IP::getIpFromHeader();
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=resetPassword&token={$resetToken}";
// send email with new password
try {
$mail = new Piwik_Mail();
$mail->addTo($email, $login);
$mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery'));
$bodyText = str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $ip, $url, $resetToken)) . "\n";
$mail->setBodyText($bodyText);
$fromEmailName = Piwik_Config::getInstance()->General['login_password_recovery_email_name'];
$fromEmailAddress = Piwik_Config::getInstance()->General['login_password_recovery_email_address'];
$mail->setFrom($fromEmailAddress, $fromEmailName);
@$mail->send();
} catch (Exception $e) {
$view->ErrorString = $e->getMessage();
}
$this->configureView($view);
echo $view->render();
exit;
}