bypass smarty wherever using intltext_templates (install, register, friend confirmation emails, etc.)

This commit is contained in:
friendica 2013-01-07 20:14:00 -08:00
parent 972060a8ff
commit 4ab363ed71
8 changed files with 537 additions and 461 deletions

View file

@ -12,7 +12,7 @@ require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php'); require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.1.1578' ); define ( 'FRIENDICA_VERSION', '3.1.1581' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1157 ); define ( 'DB_UPDATE_VERSION', 1157 );
@ -839,6 +839,10 @@ if(! function_exists('check_config')) {
$retval = $func(); $retval = $func();
if($retval) { if($retval) {
//send the administrator an e-mail //send the administrator an e-mail
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array( $email_msg = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
@ -846,6 +850,9 @@ if(! function_exists('check_config')) {
'$update' => $x, '$update' => $x,
'$error' => sprintf( t('Update %s failed. See error logs.'), $x) '$error' => sprintf( t('Update %s failed. See error logs.'), $x)
)); ));
get_app()->set_template_engine($engine);
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
require_once('include/email.php'); require_once('include/email.php');
$subject = email_header_encode($subject,'UTF-8'); $subject = email_header_encode($subject,'UTF-8');

View file

@ -3361,6 +3361,10 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
} }
if(($r[0]['notify-flags'] & NOTIFY_INTRO) && ($r[0]['page-flags'] == PAGE_NORMAL)) { if(($r[0]['notify-flags'] & NOTIFY_INTRO) && ($r[0]['page-flags'] == PAGE_NORMAL)) {
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template('follow_notify_eml.tpl'); $email_tpl = get_intltext_template('follow_notify_eml.tpl');
$email = replace_macros($email_tpl, array( $email = replace_macros($email_tpl, array(
'$requestor' => ((strlen($name)) ? $name : t('[Name Withheld]')), '$requestor' => ((strlen($name)) ? $name : t('[Name Withheld]')),
@ -3369,6 +3373,9 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
'$siteurl' => $a->get_baseurl(), '$siteurl' => $a->get_baseurl(),
'$sitename' => $a->config['sitename'] '$sitename' => $a->config['sitename']
)); ));
get_app()->set_template_engine($engine);
$res = mail($r[0]['email'], $res = mail($r[0]['email'],
email_header_encode((($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'],'UTF-8'), email_header_encode((($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'],'UTF-8'),
$email, $email,

View file

@ -737,6 +737,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
? get_intltext_template('friend_complete_eml.tpl') ? get_intltext_template('friend_complete_eml.tpl')
: get_intltext_template('intro_complete_eml.tpl')); : get_intltext_template('intro_complete_eml.tpl'));
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = replace_macros($tpl, array( $email_tpl = replace_macros($tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
'$siteurl' => $a->get_baseurl(), '$siteurl' => $a->get_baseurl(),
@ -746,6 +751,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
'$dfrn_url' => $r[0]['url'], '$dfrn_url' => $r[0]['url'],
'$uid' => $newuid ) '$uid' => $newuid )
); );
get_app()->set_template_engine($engine);
require_once('include/email.php'); require_once('include/email.php');
$res = mail($r[0]['email'], email_header_encode( sprintf( t("Connection accepted at %s") , $a->config['sitename']),'UTF-8'), $res = mail($r[0]['email'], email_header_encode( sprintf( t("Connection accepted at %s") , $a->config['sitename']),'UTF-8'),

View file

@ -73,6 +73,9 @@ function install_post(&$a) {
// connect to db // connect to db
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
// disable smarty for this template
$engine = $a->get_template_engine();
$a->set_template_engine();
$tpl = get_intltext_template('htconfig.tpl'); $tpl = get_intltext_template('htconfig.tpl');
$txt = replace_macros($tpl,array( $txt = replace_macros($tpl,array(
'$dbhost' => $dbhost, '$dbhost' => $dbhost,
@ -84,6 +87,7 @@ function install_post(&$a) {
'$phpath' => $phpath, '$phpath' => $phpath,
'$adminmail' => $adminmail '$adminmail' => $adminmail
)); ));
$a->set_template_engine($engine);
$result = file_put_contents('.htconfig.php', $txt); $result = file_put_contents('.htconfig.php', $txt);
if(! $result) { if(! $result) {

View file

@ -32,6 +32,9 @@ function lostpass_post(&$a) {
if($r) if($r)
info( t('Password reset request issued. Check your email.') . EOL); info( t('Password reset request issued. Check your email.') . EOL);
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("lostpass_eml.tpl"); $email_tpl = get_intltext_template("lostpass_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
@ -41,6 +44,8 @@ function lostpass_post(&$a) {
'$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password
)); ));
get_app()->set_template_engine($engine);
$res = mail($email, email_header_encode(sprintf( t('Password reset requested at %s'),$a->config['sitename']),'UTF-8'), $res = mail($email, email_header_encode(sprintf( t('Password reset requested at %s'),$a->config['sitename']),'UTF-8'),
$email_tpl, $email_tpl,
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
@ -94,6 +99,8 @@ function lostpass_content(&$a) {
info("Your password has been reset." . EOL); info("Your password has been reset." . EOL);
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("passchanged_eml.tpl"); $email_tpl = get_intltext_template("passchanged_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
@ -104,6 +111,8 @@ function lostpass_content(&$a) {
'$new_password' => $new_password, '$new_password' => $new_password,
'$uid' => $newuid )); '$uid' => $newuid ));
get_app()->set_template_engine($engine);
$subject = sprintf( t('Your password has been changed at %s'), $a->config['sitename']); $subject = sprintf( t('Your password has been changed at %s'), $a->config['sitename']);
$res = mail($email, email_header_encode( $subject, 'UTF-8'), $email_tpl, $res = mail($email, email_header_encode( $subject, 'UTF-8'), $email_tpl,

View file

@ -79,6 +79,10 @@ function register_post(&$a) {
set_pconfig($user['uid'],'system','invites_remaining',$num_invites); set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
} }
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = get_intltext_template("register_open_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
@ -88,6 +92,10 @@ function register_post(&$a) {
'$password' => $result['password'], '$password' => $result['password'],
'$uid' => $user['uid'] )); '$uid' => $user['uid'] ));
get_app()->set_template_engine($engine);
$res = mail($user['email'], email_header_encode( sprintf( t('Registration details for %s'), $a->config['sitename']),'UTF-8'), $res = mail($user['email'], email_header_encode( sprintf( t('Registration details for %s'), $a->config['sitename']),'UTF-8'),
$email_tpl, $email_tpl,
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
@ -131,6 +139,10 @@ function register_post(&$a) {
set_pconfig($user['uid'],'system','invites_remaining',$num_invites); set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
} }
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("register_verify_eml.tpl"); $email_tpl = get_intltext_template("register_verify_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
@ -142,6 +154,9 @@ function register_post(&$a) {
'$hash' => $hash '$hash' => $hash
)); ));
get_app()->set_template_engine($engine);
$res = mail($a->config['admin_email'], email_header_encode( sprintf(t('Registration request at %s'), $a->config['sitename']),'UTF-8'), $res = mail($a->config['admin_email'], email_header_encode( sprintf(t('Registration request at %s'), $a->config['sitename']),'UTF-8'),
$email_tpl, $email_tpl,
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"

View file

@ -41,6 +41,9 @@ function user_allow($hash) {
push_lang($register[0]['language']); push_lang($register[0]['language']);
$engine = get_app()->get_template_engine();
get_app()->set_template_engine();
$email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = get_intltext_template("register_open_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
@ -51,6 +54,10 @@ function user_allow($hash) {
'$uid' => $user[0]['uid'] '$uid' => $user[0]['uid']
)); ));
get_app()->set_template_engine($engine);
$res = mail($user[0]['email'], email_header_encode( sprintf(t('Registration details for %s'), $a->config['sitename']), 'UTF-8'), $res = mail($user[0]['email'], email_header_encode( sprintf(t('Registration details for %s'), $a->config['sitename']), 'UTF-8'),
$email_tpl, $email_tpl,
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"

File diff suppressed because it is too large Load diff