Changeset 2133
- Timestamp:
- Oct 10, 2007, 1:03:30 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/include/functions_mail.inc.php
r2128 r2133 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( 110 '"' 111 .addcslashes($cvt_name,'"') 112 .'"'); 113 $cvt_name .= ' '; 114 } 85 115 86 116 if (strpos($cvt_email, '<') === false) 87 117 { 88 return $cvt_name.' 118 return $cvt_name.'<'.$cvt_email.'>'; 89 119 } 90 120 else … … 113 143 114 144 $res = array(); 115 145 116 146 if (empty($args['template']) or empty($args['theme'])) 117 147 { … … 152 182 153 183 /** 154 * Return string email format (html or not) 184 * Return string email format (html or not) 155 185 * 156 186 * @param string format … … 161 191 } 162 192 163 /* 193 /* 164 194 * Switch language to param language 165 195 * All entries are push on language stack … … 215 245 } 216 246 217 /* 247 /* 218 248 * Switch back language pushed with switch_lang_to function 219 249 * … … 252 282 /* 253 283 * send en notification email to all administrators 254 * if a administrator is doing action, 284 * if a administrator is doing action, 255 285 * he's be removed to email list 256 286 * … … 315 345 'Bcc' => $admins, 316 346 'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject), 317 'content' => 347 'content' => 318 348 l10n_args($keyargs_content)."\n\n" 319 349 .l10n_args($keyargs_content_admin_info)."\n", … … 343 373 */ 344 374 function pwg_mail_group( 345 $group_id, $email_format, $keyargs_subject, 375 $group_id, $email_format, $keyargs_subject, 346 376 $dirname, $tpl_shortname, 347 377 $assign_vars = array(), $language_selected = '') … … 353 383 SELECT 354 384 distinct language, template 355 FROM 356 '.USER_GROUP_TABLE.' as ug 385 FROM 386 '.USER_GROUP_TABLE.' as ug 357 387 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 358 388 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 359 WHERE 389 WHERE 360 390 '.$conf['user_fields']['email'].' IS NOT NULL 361 391 AND group_id = '.$group_id; … … 388 418 u.'.$conf['user_fields']['username'].' as username, 389 419 u.'.$conf['user_fields']['email'].' as mail_address 390 FROM 391 '.USER_GROUP_TABLE.' as ug 420 FROM 421 '.USER_GROUP_TABLE.' as ug 392 422 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 393 423 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 394 WHERE 424 WHERE 395 425 '.$conf['user_fields']['email'].' IS NOT NULL 396 426 AND group_id = '.$group_id.' … … 417 447 418 448 $mail_template = get_mail_template($email_format, $elem); 419 $mail_template->set_filename($tpl_shortname, 449 $mail_template->set_filename($tpl_shortname, 420 450 (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); 421 451 $mail_template->assign_vars($assign_vars); … … 471 501 return true; 472 502 } 473 503 474 504 if (!isset($conf_mail)) 475 505 { … … 509 539 $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); 510 540 // Ascii convertion 511 $cvt_subject = str_translate_to_ascii7bits($cvt_subject);541 $cvt_subject = encode_mime_header($cvt_subject); 512 542 513 543 if (!isset($args['content'])) … … 577 607 'LANG' => $lang_info['code'], 578 608 'DIR' => $lang_info['direction'], 579 609 580 610 // Footer 581 611 'GALLERY_URL' => … … 670 700 global $user; 671 701 @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']; 673 703 if ($args['content_format'] == 'text/plain') 674 704 {
Note: See TracChangeset
for help on using the changeset viewer.