Changeset 2133


Ignore:
Timestamp:
Oct 10, 2007, 1:03:30 AM (17 years ago)
Author:
rub
Message:

Commit 2128 was done with a latest version.
Fix my mistake!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_7/include/functions_mail.inc.php

    r2128 r2133  
    2929// +-----------------------------------------------------------------------+
    3030
     31
     32/**
     33 * Encodes a string using Q form if required (RFC2045)
     34 * mail headers MUST contain only US-ASCII characters
     35 */
     36function encode_mime_header($str)
     37{
     38  $x = preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
     39  if ($x==0)
     40  {
     41    return $str;
     42  }
     43  // Replace every high ascii, control =, ? and _ characters
     44  $str = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
     45                  "'='.sprintf('%02X', ord('\\1'))", $str);
     46
     47  // Replace every spaces to _ (more readable than =20)
     48  $str = str_replace(" ", "_", $str);
     49
     50  global $lang_info;
     51  return '=?'.$lang_info['charset'].'?Q?'.$str.'?=';
     52}
     53
    3154/*
    3255 * Returns an array of mail configuration parameters :
     
    81104    $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name));
    82105    $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email));
    83     // Ascii convertion
    84     $cvt_name = '"'.addslashes(str_translate_to_ascii7bits($cvt_name)).'"';
     106
     107    if ($cvt_name!="")
     108    {
     109      $cvt_name = encode_mime_header(
     110                '"'
     111                .addcslashes($cvt_name,'"')
     112                .'"');
     113      $cvt_name .= ' ';
     114    }
    85115
    86116    if (strpos($cvt_email, '<') === false)
    87117    {
    88       return $cvt_name.' <'.$cvt_email.'>';
     118      return $cvt_name.'<'.$cvt_email.'>';
    89119    }
    90120    else
     
    113143
    114144  $res = array();
    115  
     145
    116146  if (empty($args['template']) or empty($args['theme']))
    117147  {
     
    152182
    153183/**
    154  * Return string email format (html or not) 
     184 * Return string email format (html or not)
    155185 *
    156186 * @param string format
     
    161191}
    162192
    163 /* 
     193/*
    164194 * Switch language to param language
    165195 * All entries are push on language stack
     
    215245}
    216246
    217 /* 
     247/*
    218248 * Switch back language pushed with switch_lang_to function
    219249 *
     
    252282/*
    253283 * send en notification email to all administrators
    254  * if a administrator is doing action, 
     284 * if a administrator is doing action,
    255285 * he's be removed to email list
    256286 *
     
    315345        'Bcc' => $admins,
    316346        'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
    317         'content' => 
     347        'content' =>
    318348           l10n_args($keyargs_content)."\n\n"
    319349          .l10n_args($keyargs_content_admin_info)."\n",
     
    343373 */
    344374function pwg_mail_group(
    345   $group_id, $email_format, $keyargs_subject, 
     375  $group_id, $email_format, $keyargs_subject,
    346376  $dirname, $tpl_shortname,
    347377  $assign_vars = array(), $language_selected = '')
     
    353383SELECT
    354384  distinct language, template
    355 FROM 
    356   '.USER_GROUP_TABLE.' as ug 
     385FROM
     386  '.USER_GROUP_TABLE.' as ug
    357387  INNER JOIN '.USERS_TABLE.' as u  ON '.$conf['user_fields']['id'].' = ug.user_id
    358388  INNER JOIN '.USER_INFOS_TABLE.' as ui  ON ui.user_id = ug.user_id
    359 WHERE 
     389WHERE
    360390        '.$conf['user_fields']['email'].' IS NOT NULL
    361391    AND group_id = '.$group_id;
     
    388418  u.'.$conf['user_fields']['username'].' as username,
    389419  u.'.$conf['user_fields']['email'].' as mail_address
    390 FROM 
    391   '.USER_GROUP_TABLE.' as ug 
     420FROM
     421  '.USER_GROUP_TABLE.' as ug
    392422  INNER JOIN '.USERS_TABLE.' as u  ON '.$conf['user_fields']['id'].' = ug.user_id
    393423  INNER JOIN '.USER_INFOS_TABLE.' as ui  ON ui.user_id = ug.user_id
    394 WHERE 
     424WHERE
    395425        '.$conf['user_fields']['email'].' IS NOT NULL
    396426    AND group_id = '.$group_id.'
     
    417447
    418448          $mail_template = get_mail_template($email_format, $elem);
    419           $mail_template->set_filename($tpl_shortname, 
     449          $mail_template->set_filename($tpl_shortname,
    420450            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
    421451          $mail_template->assign_vars($assign_vars);
     
    471501    return true;
    472502  }
    473  
     503
    474504  if (!isset($conf_mail))
    475505  {
     
    509539  $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject']));
    510540  // Ascii convertion
    511   $cvt_subject = str_translate_to_ascii7bits($cvt_subject);
     541  $cvt_subject = encode_mime_header($cvt_subject);
    512542
    513543  if (!isset($args['content']))
     
    577607        'LANG' => $lang_info['code'],
    578608        'DIR' => $lang_info['direction'],
    579        
     609
    580610        // Footer
    581611        'GALLERY_URL' =>
     
    670700    global $user;
    671701    @mkdir(PHPWG_ROOT_PATH.'testmail');
    672     $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].$cvt_subject;
     702    $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'];
    673703    if ($args['content_format'] == 'text/plain')
    674704    {
Note: See TracChangeset for help on using the changeset viewer.