Changeset 2121 for trunk/include/functions_mail.inc.php
- Timestamp:
- Oct 4, 2007, 6:39:59 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_mail.inc.php
r2106 r2121 29 29 // +-----------------------------------------------------------------------+ 30 30 31 32 /** 33 * Encodes a string using Q form if required (RFC2045) 34 * mail headers MUST contain only US-ASCII characters 35 */ 36 function 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 31 54 /* 32 55 * Returns an array of mail configuration parameters : … … 81 104 $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name)); 82 105 $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('"'.$cvt_name.'"').' '; 110 } 85 111 86 112 if (strpos($cvt_email, '<') === false) 87 113 { 88 return $cvt_name.' 114 return $cvt_name.'<'.$cvt_email.'>'; 89 115 } 90 116 else … … 113 139 114 140 $res = array(); 115 141 116 142 if (empty($args['template']) or empty($args['theme'])) 117 143 { … … 152 178 153 179 /** 154 * Return string email format (html or not) 180 * Return string email format (html or not) 155 181 * 156 182 * @param string format … … 161 187 } 162 188 163 /* 189 /* 164 190 * Switch language to param language 165 191 * All entries are push on language stack … … 215 241 } 216 242 217 /* 243 /* 218 244 * Switch back language pushed with switch_lang_to function 219 245 * … … 252 278 /* 253 279 * send en notification email to all administrators 254 * if a administrator is doing action, 280 * if a administrator is doing action, 255 281 * he's be removed to email list 256 282 * … … 315 341 'Bcc' => $admins, 316 342 'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject), 317 'content' => 343 'content' => 318 344 l10n_args($keyargs_content)."\n\n" 319 345 .l10n_args($keyargs_content_admin_info)."\n", … … 343 369 */ 344 370 function pwg_mail_group( 345 $group_id, $email_format, $keyargs_subject, 371 $group_id, $email_format, $keyargs_subject, 346 372 $dirname, $tpl_shortname, 347 373 $assign_vars = array(), $language_selected = '') … … 353 379 SELECT 354 380 distinct language, template 355 FROM 356 '.USER_GROUP_TABLE.' as ug 381 FROM 382 '.USER_GROUP_TABLE.' as ug 357 383 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 358 384 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 359 WHERE 385 WHERE 360 386 '.$conf['user_fields']['email'].' IS NOT NULL 361 387 AND group_id = '.$group_id; … … 389 415 u.'.$conf['user_fields']['username'].' as username, 390 416 u.'.$conf['user_fields']['email'].' as mail_address 391 FROM 392 '.USER_GROUP_TABLE.' as ug 417 FROM 418 '.USER_GROUP_TABLE.' as ug 393 419 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 394 420 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 395 WHERE 421 WHERE 396 422 '.$conf['user_fields']['email'].' IS NOT NULL 397 423 AND group_id = '.$group_id.' … … 418 444 419 445 $mail_template = get_mail_template($email_format, $elem); 420 $mail_template->set_filename($tpl_shortname, 446 $mail_template->set_filename($tpl_shortname, 421 447 (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); 422 448 $mail_template->assign_vars($assign_vars); … … 471 497 return true; 472 498 } 473 499 474 500 if (!isset($conf_mail)) 475 501 { … … 509 535 $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); 510 536 // Ascii convertion 511 $cvt_subject = str_translate_to_ascii7bits($cvt_subject);537 $cvt_subject = encode_mime_header($cvt_subject); 512 538 513 539 if (!isset($args['content'])) … … 577 603 'LANG' => $lang_info['code'], 578 604 'DIR' => $lang_info['direction'], 579 605 580 606 // Footer 581 607 'GALLERY_URL' =>
Note: See TracChangeset
for help on using the changeset viewer.