本文整理汇总了PHP中rawLocale函数的典型用法代码示例。如果您正苦于以下问题:PHP rawLocale函数的具体用法?PHP rawLocale怎么用?PHP rawLocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rawLocale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Helper function for sending a mail
*
* @author Adrian Lang <lang@cosmocode.de>
*
* @param string $subscriber_mail The target mail address
* @param string $subject The lang id of the mail subject (without the
* prefix “mail_”)
* @param string $context The context of this mail, eg. page or namespace id
* @param string $template The name of the mail template
* @param array $trep Predefined parameters used to parse the
* template (in text format)
* @param array $hrep Predefined parameters used to parse the
* template (in HTML format), null to default to $trep
* @param array $headers Additional mail headers in the form 'name' => 'value'
* @return bool
*/
protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null, $headers = array())
{
global $lang;
global $conf;
$text = rawLocale($template);
$subject = $lang['mail_' . $subject] . ' ' . $context;
$mail = new Mailer();
$mail->bcc($subscriber_mail);
$mail->subject($subject);
$mail->setBody($text, $trep, $hrep);
if (in_array($template, array('subscr_list', 'subscr_digest'))) {
$mail->from($conf['mailfromnobody']);
}
if (isset($trep['SUBSCRIBE'])) {
$mail->setHeader('List-Unsubscribe', '<' . $trep['SUBSCRIBE'] . '>', false);
}
foreach ($headers as $header => $value) {
$mail->setHeader($header, $value);
}
return $mail->send();
}
示例2: act_resendpwd
//.........这里部分代码省略.........
global $lang;
global $conf;
/* @var auth_basic $auth */
global $auth;
/* @var Input $INPUT */
global $INPUT;
if (!actionOK('resendpwd')) {
msg($lang['resendna'], -1);
return false;
}
$token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth'));
if ($token) {
// we're in token phase - get user info from token
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!@file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
$INPUT->remove('pwauth');
return false;
}
// token is only valid for 3 days
if (time() - filemtime($tfile) > 3 * 60 * 60 * 24) {
msg($lang['resendpwdbadauth'], -1);
$INPUT->remove('pwauth');
@unlink($tfile);
return false;
}
$user = io_readfile($tfile);
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
if (!$conf['autopasswd']) {
// we let the user choose a password
$pass = $INPUT->str('pass');
// password given correctly?
if (!$pass) {
return false;
}
if ($pass != $INPUT->str('passchk')) {
msg($lang['regbadpass'], -1);
return false;
}
// change it
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
} else {
// autogenerate the password and send by mail
$pass = auth_pwgen();
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
if (auth_sendPassword($user, $pass)) {
msg($lang['resendpwdsuccess'], 1);
} else {
msg($lang['regmailfail'], -1);
}
}
@unlink($tfile);
return true;
} else {
// we're in request phase
if (!$INPUT->post->bool('save')) {
return false;
}
if (!$INPUT->post->str('login')) {
msg($lang['resendpwdmissing'], -1);
return false;
} else {
$user = trim($auth->cleanUser($INPUT->post->str('login')));
}
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
// generate auth token
$token = md5(auth_cookiesalt() . $user);
//secret but user based
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
io_saveFile($tfile, $user);
$text = rawLocale('pwconfirm');
$trep = array('FULLNAME' => $userinfo['name'], 'LOGIN' => $user, 'CONFIRM' => $url);
$mail = new Mailer();
$mail->to($userinfo['name'] . ' <' . $userinfo['mail'] . '>');
$mail->subject($lang['regpwmail']);
$mail->setBody($text, $trep);
if ($mail->send()) {
msg($lang['resendpwdconfirm'], 1);
} else {
msg($lang['regmailfail'], -1);
}
return true;
}
// never reached
}
示例3: notify
/**
* Sends a notify mail on page change
*
* @param string $id The changed page
* @param string $who Who to notify (admin|subscribers)
* @param int $rev Old page revision
* @param string $summary What changed
* @param boolean $minor Is this a minor edit?
* @param array $replace Additional string substitutions, @KEY@ to be replaced by value
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
global $lang;
global $conf;
// decide if there is something to do
if ($who == 'admin') {
if (empty($conf['notify'])) {
return;
}
//notify enabled?
$text = rawLocale('mailtext');
$to = $conf['notify'];
$bcc = '';
} elseif ($who == 'subscribers') {
if (!$conf['subscribers']) {
return;
}
//subscribers enabled?
if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
return;
}
//skip minors
$bcc = subscriber_addresslist($id);
if (empty($bcc)) {
return;
}
$to = '';
$text = rawLocale('subscribermail');
} elseif ($who == 'register') {
if (empty($conf['registernotify'])) {
return;
}
$text = rawLocale('registermail');
$to = $conf['registernotify'];
$bcc = '';
} else {
return;
//just to be safe
}
$text = str_replace('@DATE@', date($conf['dformat']), $text);
$text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
$text = str_replace('@IPADDRESS@', $_SERVER['REMOTE_ADDR'], $text);
$text = str_replace('@HOSTNAME@', gethostbyaddr($_SERVER['REMOTE_ADDR']), $text);
$text = str_replace('@NEWPAGE@', wl($id, '', true), $text);
$text = str_replace('@PAGE@', $id, $text);
$text = str_replace('@TITLE@', $conf['title'], $text);
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@SUMMARY@', $summary, $text);
$text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
foreach ($replace as $key => $substitution) {
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
if ($who == 'register') {
$subject = $lang['mail_new_user'] . ' ' . $summary;
} elseif ($rev) {
$subject = $lang['mail_changed'] . ' ' . $id;
$text = str_replace('@OLDPAGE@', wl($id, "rev={$rev}", true), $text);
require_once DOKU_INC . 'inc/DifferenceEngine.php';
$df = new Diff(split("\n", rawWiki($id, $rev)), split("\n", rawWiki($id)));
$dformat = new UnifiedDiffFormatter();
$diff = $dformat->format($df);
} else {
$subject = $lang['mail_newpage'] . ' ' . $id;
$text = str_replace('@OLDPAGE@', 'none', $text);
$diff = rawWiki($id);
}
$text = str_replace('@DIFF@', $diff, $text);
$subject = '[' . $conf['title'] . '] ' . $subject;
mail_send($to, $subject, $text, $conf['mailfrom'], '', $bcc);
}
示例4: notify
/**
* Sends a notify mail on page change or registration
*
* @param string $id The changed page
* @param string $who Who to notify (admin|subscribers|register)
* @param int|string $rev Old page revision
* @param string $summary What changed
* @param boolean $minor Is this a minor edit?
* @param array $replace Additional string substitutions, @KEY@ to be replaced by value
*
* @return bool
* @author Andreas Gohr <andi@splitbrain.org>
*/
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
global $lang;
global $conf;
global $INFO;
global $DIFF_INLINESTYLES;
// decide if there is something to do, eg. whom to mail
if ($who == 'admin') {
if (empty($conf['notify'])) {
return false;
}
//notify enabled?
$text = rawLocale('mailtext');
$to = $conf['notify'];
$bcc = '';
} elseif ($who == 'subscribers') {
if (!$conf['subscribers']) {
return false;
}
//subscribers enabled?
if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
return false;
}
//skip minors
$data = array('id' => $id, 'addresslist' => '', 'self' => false);
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
$bcc = $data['addresslist'];
if (empty($bcc)) {
return false;
}
$to = '';
$text = rawLocale('subscr_single');
} elseif ($who == 'register') {
if (empty($conf['registernotify'])) {
return false;
}
$text = rawLocale('registermail');
$to = $conf['registernotify'];
$bcc = '';
} else {
return false;
//just to be safe
}
// prepare replacements (keys not set in hrep will be taken from trep)
$trep = array('NEWPAGE' => wl($id, '', true, '&'), 'PAGE' => $id, 'SUMMARY' => $summary);
$trep = array_merge($trep, $replace);
$hrep = array();
// prepare content
if ($who == 'register') {
$subject = $lang['mail_new_user'] . ' ' . $summary;
} elseif ($rev) {
$subject = $lang['mail_changed'] . ' ' . $id;
$trep['OLDPAGE'] = wl($id, "rev={$rev}", true, '&');
$df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id)));
$dformat = new UnifiedDiffFormatter();
$tdiff = $dformat->format($df);
$DIFF_INLINESTYLES = true;
$dformat = new InlineDiffFormatter();
$hdiff = $dformat->format($df);
$hdiff = '<table>' . $hdiff . '</table>';
$DIFF_INLINESTYLES = false;
} else {
$subject = $lang['mail_newpage'] . ' ' . $id;
$trep['OLDPAGE'] = '---';
$tdiff = rawWiki($id);
$hdiff = nl2br(hsc($tdiff));
}
$trep['DIFF'] = $tdiff;
$hrep['DIFF'] = $hdiff;
// send mail
$mail = new Mailer();
$mail->to($to);
$mail->bcc($bcc);
$mail->subject($subject);
$mail->setBody($text, $trep, $hrep);
if ($who == 'subscribers') {
$mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
}
return $mail->send();
}
示例5: subscription_send
/**
* Helper function for sending a mail
*
* @param string $subscriber_mail The target mail address
* @param array $replaces Predefined parameters used to parse the
* template
* @param string $subject The lang id of the mail subject (without the
* prefix “mail_”)
* @param string $id The page or namespace id
* @param string $template The name of the mail template
*
* @author Adrian Lang <lang@cosmocode.de>
*/
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template)
{
global $conf;
global $lang;
$text = rawLocale($template);
$trep = array_merge($replaces, array('PAGE' => $id));
$subject = $lang['mail_' . $subject] . ' ' . $id;
$mail = new Mailer();
$mail->bcc($subscriber_mail);
$mail->subject($subject);
$mail->setBody($text, $trep);
$mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
return $mail->send();
}
示例6: setBody
/**
* Set the text and HTML body and apply replacements
*
* This function applies a whole bunch of default replacements in addition
* to the ones specified as parameters
*
* If you pass the HTML part or HTML replacements yourself you have to make
* sure you encode all HTML special chars correctly
*
* @param string $text plain text body
* @param array $textrep replacements to apply on the text part
* @param array $htmlrep replacements to apply on the HTML part, leave null to use $textrep
* @param string $html the HTML body, leave null to create it from $text
* @param bool $wrap wrap the HTML in the default header/Footer
*/
public function setBody($text, $textrep = null, $htmlrep = null, $html = null, $wrap = true)
{
$htmlrep = (array) $htmlrep;
$textrep = (array) $textrep;
// create HTML from text if not given
if (is_null($html)) {
$html = $text;
$html = hsc($html);
$html = preg_replace('/^----+$/m', '<hr >', $html);
$html = nl2br($html);
}
if ($wrap) {
$wrap = rawLocale('mailwrap', 'html');
$html = preg_replace('/\\n-- <br \\/>.*$/s', '', $html);
//strip signature
$html = str_replace('@EMAILSIGNATURE@', '', $html);
//strip @EMAILSIGNATURE@
$html = str_replace('@HTMLBODY@', $html, $wrap);
}
if (strpos($text, '@EMAILSIGNATURE@') === false) {
$text .= '@EMAILSIGNATURE@';
}
// copy over all replacements missing for HTML (autolink URLs)
foreach ($textrep as $key => $value) {
if (isset($htmlrep[$key])) {
continue;
}
if (media_isexternal($value)) {
$htmlrep[$key] = '<a href="' . hsc($value) . '">' . hsc($value) . '</a>';
} else {
$htmlrep[$key] = hsc($value);
}
}
// embed media from templates
$html = preg_replace_callback('/@MEDIA\\(([^\\)]+)\\)@/', array($this, 'autoembed_cb'), $html);
// add default token replacements
$trep = array_merge($this->replacements['text'], (array) $textrep);
$hrep = array_merge($this->replacements['html'], (array) $htmlrep);
// Apply replacements
foreach ($trep as $key => $substitution) {
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
foreach ($hrep as $key => $substitution) {
$html = str_replace('@' . strtoupper($key) . '@', $substitution, $html);
}
$this->setHTML($html);
$this->setText($text);
}
示例7: notify
/**
* Sends a notify mail on page change or registration
*
* @param string $id The changed page
* @param string $who Who to notify (admin|subscribers|register)
* @param int $rev Old page revision
* @param string $summary What changed
* @param boolean $minor Is this a minor edit?
* @param array $replace Additional string substitutions, @KEY@ to be replaced by value
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
global $lang;
global $conf;
global $INFO;
// decide if there is something to do
if ($who == 'admin') {
if (empty($conf['notify'])) {
return;
}
//notify enabled?
$text = rawLocale('mailtext');
$to = $conf['notify'];
$bcc = '';
} elseif ($who == 'subscribers') {
if (!$conf['subscribers']) {
return;
}
//subscribers enabled?
if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
return;
}
//skip minors
$data = array('id' => $id, 'addresslist' => '', 'self' => false);
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
$bcc = $data['addresslist'];
if (empty($bcc)) {
return;
}
$to = '';
$text = rawLocale('subscr_single');
} elseif ($who == 'register') {
if (empty($conf['registernotify'])) {
return;
}
$text = rawLocale('registermail');
$to = $conf['registernotify'];
$bcc = '';
} else {
return;
//just to be safe
}
$ip = clientIP();
$text = str_replace('@DATE@', dformat(), $text);
$text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
$text = str_replace('@IPADDRESS@', $ip, $text);
$text = str_replace('@HOSTNAME@', gethostsbyaddrs($ip), $text);
$text = str_replace('@NEWPAGE@', wl($id, '', true, '&'), $text);
$text = str_replace('@PAGE@', $id, $text);
$text = str_replace('@TITLE@', $conf['title'], $text);
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@SUMMARY@', $summary, $text);
$text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
$text = str_replace('@NAME@', $INFO['userinfo']['name'], $text);
$text = str_replace('@MAIL@', $INFO['userinfo']['mail'], $text);
foreach ($replace as $key => $substitution) {
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
if ($who == 'register') {
$subject = $lang['mail_new_user'] . ' ' . $summary;
} elseif ($rev) {
$subject = $lang['mail_changed'] . ' ' . $id;
$text = str_replace('@OLDPAGE@', wl($id, "rev={$rev}", true, '&'), $text);
$df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id)));
$dformat = new UnifiedDiffFormatter();
$diff = $dformat->format($df);
} else {
$subject = $lang['mail_newpage'] . ' ' . $id;
$text = str_replace('@OLDPAGE@', 'none', $text);
$diff = rawWiki($id);
}
$text = str_replace('@DIFF@', $diff, $text);
if (utf8_strlen($conf['title']) < 20) {
$subject = '[' . $conf['title'] . '] ' . $subject;
} else {
$subject = '[' . utf8_substr($conf['title'], 0, 20) . '...] ' . $subject;
}
mail_send($to, $subject, $text, $conf['mailfrom'], '', $bcc);
}
示例8: subscription_send
/**
* Helper function for sending a mail
*
* @param string $subscriber_mail The target mail address
* @param array $replaces Predefined parameters used to parse the
* template
* @param string $subject The lang id of the mail subject (without the
* prefix “mail_”)
* @param string $id The page or namespace id
* @param string $template The name of the mail template
*
* @author Adrian Lang <lang@cosmocode.de>
*/
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template)
{
global $conf;
$text = rawLocale($template);
$replaces = array_merge($replaces, array('TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL, 'PAGE' => $id));
foreach ($replaces as $key => $substitution) {
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
global $lang;
$subject = $lang['mail_' . $subject] . ' ' . $id;
mail_send('', '[' . $conf['title'] . '] ' . $subject, $text, $conf['mailfrom'], '', $subscriber_mail);
}
示例9: act_resendpwd
/**
* Send a new password
*
* This function handles both phases of the password reset:
*
* - handling the first request of password reset
* - validating the password reset auth token
*
* @author Benoit Chesneau <benoit@bchesneau.info>
* @author Chris Smith <chris@jalakai.co.uk>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return bool true on success, false on any error
*/
function act_resendpwd()
{
global $lang;
global $conf;
global $auth;
if (!actionOK('resendpwd')) {
return false;
}
if (!$auth) {
return false;
}
// should not be able to get here without modPass being possible...
if (!$auth->canDo('modPass')) {
msg($lang['resendna'], -1);
return false;
}
$token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
if ($token) {
// we're in token phase
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!@file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
return false;
}
$user = io_readfile($tfile);
@unlink($tfile);
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
$pass = auth_pwgen();
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
if (auth_sendPassword($user, $pass)) {
msg($lang['resendpwdsuccess'], 1);
} else {
msg($lang['regmailfail'], -1);
}
return true;
} else {
// we're in request phase
if (!$_POST['save']) {
return false;
}
if (empty($_POST['login'])) {
msg($lang['resendpwdmissing'], -1);
return false;
} else {
$user = trim($auth->cleanUser($_POST['login']));
}
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
// generate auth token
$token = md5(auth_cookiesalt() . $user);
//secret but user based
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
io_saveFile($tfile, $user);
$text = rawLocale('pwconfirm');
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@FULLNAME@', $userinfo['name'], $text);
$text = str_replace('@LOGIN@', $user, $text);
$text = str_replace('@TITLE@', $conf['title'], $text);
$text = str_replace('@CONFIRM@', $url, $text);
if (mail_send($userinfo['name'] . ' <' . $userinfo['mail'] . '>', $lang['regpwmail'], $text, $conf['mailfrom'])) {
msg($lang['resendpwdconfirm'], 1);
} else {
msg($lang['regmailfail'], -1);
}
return true;
}
return false;
// never reached
}
示例10: setBody
/**
* Set the text and HTML body and apply replacements
*
* This function applies a whole bunch of default replacements in addition
* to the ones specidifed as parameters
*
* If you pass the HTML part or HTML replacements yourself you have to make
* sure you encode all HTML special chars correctly
*
* @param string $text plain text body
* @param array $textrep replacements to apply on the text part
* @param array $htmlrep replacements to apply on the HTML part, leave null to use $textrep
* @param string $html the HTML body, leave null to create it from $text
* @param bool $wrap wrap the HTML in the default header/Footer
*/
public function setBody($text, $textrep = null, $htmlrep = null, $html = null, $wrap = true)
{
global $INFO;
global $conf;
/* @var Input $INPUT */
global $INPUT;
$htmlrep = (array) $htmlrep;
$textrep = (array) $textrep;
// create HTML from text if not given
if (is_null($html)) {
$html = $text;
$html = hsc($html);
$html = preg_replace('/^-----*$/m', '<hr >', $html);
$html = nl2br($html);
}
if ($wrap) {
$wrap = rawLocale('mailwrap', 'html');
$html = preg_replace('/\\n-- <br \\/>.*$/s', '', $html);
//strip signature
$html = str_replace('@HTMLBODY@', $html, $wrap);
}
// copy over all replacements missing for HTML (autolink URLs)
foreach ($textrep as $key => $value) {
if (isset($htmlrep[$key])) {
continue;
}
if (media_isexternal($value)) {
$htmlrep[$key] = '<a href="' . hsc($value) . '">' . hsc($value) . '</a>';
} else {
$htmlrep[$key] = hsc($value);
}
}
// embed media from templates
$html = preg_replace_callback('/@MEDIA\\(([^\\)]+)\\)@/', array($this, 'autoembed_cb'), $html);
// prepare default replacements
$ip = clientIP();
$cip = gethostsbyaddrs($ip);
$trep = array('DATE' => dformat(), 'BROWSER' => $INPUT->server->str('HTTP_USER_AGENT'), 'IPADDRESS' => $ip, 'HOSTNAME' => $cip, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL, 'USER' => $INPUT->server->str('REMOTE_USER'), 'NAME' => $INFO['userinfo']['name'], 'MAIL' => $INFO['userinfo']['mail']);
$trep = array_merge($trep, (array) $textrep);
$hrep = array('DATE' => '<i>' . hsc(dformat()) . '</i>', 'BROWSER' => hsc($INPUT->server->str('HTTP_USER_AGENT')), 'IPADDRESS' => '<code>' . hsc($ip) . '</code>', 'HOSTNAME' => '<code>' . hsc($cip) . '</code>', 'TITLE' => hsc($conf['title']), 'DOKUWIKIURL' => '<a href="' . DOKU_URL . '">' . DOKU_URL . '</a>', 'USER' => hsc($INPUT->server->str('REMOTE_USER')), 'NAME' => hsc($INFO['userinfo']['name']), 'MAIL' => '<a href="mailto:"' . hsc($INFO['userinfo']['mail']) . '">' . hsc($INFO['userinfo']['mail']) . '</a>');
$hrep = array_merge($hrep, (array) $htmlrep);
// Apply replacements
foreach ($trep as $key => $substitution) {
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
foreach ($hrep as $key => $substitution) {
$html = str_replace('@' . strtoupper($key) . '@', $substitution, $html);
}
$this->setHTML($html);
$this->setText($text);
}
示例11: act_resendpwd
/**
* Send a new password
*
* This function handles both phases of the password reset:
*
* - handling the first request of password reset
* - validating the password reset auth token
*
* @author Benoit Chesneau <benoit@bchesneau.info>
* @author Chris Smith <chris@jalakai.co.uk>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return bool true on success, false on any error
*/
function act_resendpwd()
{
global $lang;
global $conf;
global $auth;
if (!actionOK('resendpwd')) {
msg($lang['resendna'], -1);
return false;
}
$token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
if ($token) {
// we're in token phase - get user info from token
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!@file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
unset($_REQUEST['pwauth']);
return false;
}
// token is only valid for 3 days
if (time() - filemtime($tfile) > 3 * 60 * 60 * 24) {
msg($lang['resendpwdbadauth'], -1);
unset($_REQUEST['pwauth']);
@unlink($tfile);
return false;
}
$user = io_readfile($tfile);
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
if (!$conf['autopasswd']) {
// we let the user choose a password
// password given correctly?
if (!isset($_REQUEST['pass']) || $_REQUEST['pass'] == '') {
return false;
}
if ($_REQUEST['pass'] != $_REQUEST['passchk']) {
msg($lang['regbadpass'], -1);
return false;
}
$pass = $_REQUEST['pass'];
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
} else {
// autogenerate the password and send by mail
$pass = auth_pwgen();
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
if (auth_sendPassword($user, $pass)) {
msg($lang['resendpwdsuccess'], 1);
} else {
msg($lang['regmailfail'], -1);
}
}
@unlink($tfile);
return true;
} else {
// we're in request phase
if (!$_POST['save']) {
return false;
}
if (empty($_POST['login'])) {
msg($lang['resendpwdmissing'], -1);
return false;
} else {
$user = trim($auth->cleanUser($_POST['login']));
}
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
// generate auth token
$token = md5(auth_cookiesalt() . $user);
//secret but user based
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
io_saveFile($tfile, $user);
$text = rawLocale('pwconfirm');
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@FULLNAME@', $userinfo['name'], $text);
//.........这里部分代码省略.........
示例12: media_notify
/**
* Send a notify mail on uploads
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function media_notify($id, $file, $mime, $old_rev = false)
{
global $lang;
global $conf;
global $INFO;
if (empty($conf['notify'])) {
return;
}
//notify enabled?
$ip = clientIP();
$text = rawLocale('uploadmail');
$text = str_replace('@DATE@', dformat(), $text);
$text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
$text = str_replace('@IPADDRESS@', $ip, $text);
$text = str_replace('@HOSTNAME@', gethostsbyaddrs($ip), $text);
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
$text = str_replace('@MIME@', $mime, $text);
$text = str_replace('@MEDIA@', ml($id, '', true, '&', true), $text);
$text = str_replace('@SIZE@', filesize_h(filesize($file)), $text);
if ($old_rev && $conf['mediarevisions']) {
$text = str_replace('@OLD@', ml($id, "rev={$old_rev}", true, '&', true), $text);
} else {
$text = str_replace('@OLD@', '', $text);
}
if (empty($conf['mailprefix'])) {
$subject = '[' . $conf['title'] . '] ' . $lang['mail_upload'] . ' ' . $id;
} else {
$subject = '[' . $conf['mailprefix'] . '] ' . $lang['mail_upload'] . ' ' . $id;
}
mail_send($conf['notify'], $subject, $text, $conf['mailfrom']);
}
示例13: media_notify
/**
* Send a notify mail on uploads
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function media_notify($id, $file, $mime)
{
global $lang;
global $conf;
if (empty($conf['notify'])) {
return;
}
//notify enabled?
$ip = clientIP();
$text = rawLocale('uploadmail');
$text = str_replace('@DATE@', dformat(), $text);
$text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
$text = str_replace('@IPADDRESS@', $ip, $text);
$text = str_replace('@HOSTNAME@', gethostsbyaddrs($ip), $text);
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
$text = str_replace('@MIME@', $mime, $text);
$text = str_replace('@MEDIA@', ml($id, '', true, '&', true), $text);
$text = str_replace('@SIZE@', filesize_h(filesize($file)), $text);
$from = $conf['mailfrom'];
$from = str_replace('@USER@', $_SERVER['REMOTE_USER'], $from);
$from = str_replace('@NAME@', $INFO['userinfo']['name'], $from);
$from = str_replace('@MAIL@', $INFO['userinfo']['mail'], $from);
$subject = '[' . $conf['title'] . '] ' . $lang['mail_upload'] . ' ' . $id;
mail_send($conf['notify'], $subject, $text, $from);
}
示例14: media_notify
/**
* Send a notify mail on uploads
*
* @author Andreas Gohr <andi@splitbrain.org>
* @fixme this should embed thumbnails of images in HTML version
*/
function media_notify($id, $file, $mime, $old_rev = false)
{
global $lang;
global $conf;
global $INFO;
if (empty($conf['notify'])) {
return;
}
//notify enabled?
$text = rawLocale('uploadmail');
$trep = array('MIME' => $mime, 'MEDIA' => ml($id, '', true, '&', true), 'SIZE' => filesize_h(filesize($file)));
if ($old_rev && $conf['mediarevisions']) {
$trep['OLD'] = ml($id, "rev={$old_rev}", true, '&', true);
} else {
$trep['OLD'] = '---';
}
$mail = new Mailer();
$mail->to($conf['notify']);
$mail->subject($lang['mail_upload'] . ' ' . $id);
$mail->setBody($text, $trep);
return $mail->send();
}
示例15: subscription_send
/**
* Helper function for sending a mail
*
* @author Adrian Lang <lang@cosmocode.de>
*
* @param string $subscriber_mail The target mail address
* @param array $replaces Predefined parameters used to parse the
* template
* @param string $subject The lang id of the mail subject (without the
* prefix “mail_”)
* @param string $id The page or namespace id
* @param string $template The name of the mail template
* @return bool
*/
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template)
{
global $lang;
global $conf;
$text = rawLocale($template);
$trep = array_merge($replaces, array('PAGE' => $id));
$hrep = $trep;
$hrep['DIFF'] = nl2br(htmlspecialchars($hrep['DIFF']));
$subject = $lang['mail_' . $subject] . ' ' . $id;
$mail = new Mailer();
$mail->bcc($subscriber_mail);
$mail->subject($subject);
$mail->setBody($text, $trep, $hrep);
$mail->from($conf['mailfromnobody']);
$mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
return $mail->send();
}