Changeset 2128
- Timestamp:
- Oct 9, 2007, 11:34:03 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/include/functions_mail.inc.php
r2125 r2128 29 29 // +-----------------------------------------------------------------------+ 30 30 31 32 /**33 * Encodes a string using Q form if required (RFC2045)34 * mail headers MUST contain only US-ASCII characters35 */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 _ characters44 $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 54 31 /* 55 32 * Returns an array of mail configuration parameters : … … 104 81 $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name)); 105 82 $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email)); 106 107 if ($cvt_name!="") 108 { 109 $cvt_name = encode_mime_header( 110 '"' 111 .addcslashes($cvt_name,'"') 112 .'"'); 113 $cvt_name .= ' '; 114 } 83 // Ascii convertion 84 $cvt_name = '"'.addslashes(str_translate_to_ascii7bits($cvt_name)).'"'; 115 85 116 86 if (strpos($cvt_email, '<') === false) 117 87 { 118 return $cvt_name.' <'.$cvt_email.'>';88 return $cvt_name.' <'.$cvt_email.'>'; 119 89 } 120 90 else … … 143 113 144 114 $res = array(); 145 115 146 116 if (empty($args['template']) or empty($args['theme'])) 147 117 { … … 182 152 183 153 /** 184 * Return string email format (html or not) 154 * Return string email format (html or not) 185 155 * 186 156 * @param string format … … 191 161 } 192 162 193 /* 163 /* 194 164 * Switch language to param language 195 165 * All entries are push on language stack … … 245 215 } 246 216 247 /* 217 /* 248 218 * Switch back language pushed with switch_lang_to function 249 219 * … … 282 252 /* 283 253 * send en notification email to all administrators 284 * if a administrator is doing action, 254 * if a administrator is doing action, 285 255 * he's be removed to email list 286 256 * … … 345 315 'Bcc' => $admins, 346 316 'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject), 347 'content' => 317 'content' => 348 318 l10n_args($keyargs_content)."\n\n" 349 319 .l10n_args($keyargs_content_admin_info)."\n", … … 373 343 */ 374 344 function pwg_mail_group( 375 $group_id, $email_format, $keyargs_subject, 345 $group_id, $email_format, $keyargs_subject, 376 346 $dirname, $tpl_shortname, 377 347 $assign_vars = array(), $language_selected = '') … … 383 353 SELECT 384 354 distinct language, template 385 FROM 386 '.USER_GROUP_TABLE.' as ug 355 FROM 356 '.USER_GROUP_TABLE.' as ug 387 357 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 388 358 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 389 WHERE 359 WHERE 390 360 '.$conf['user_fields']['email'].' IS NOT NULL 391 361 AND group_id = '.$group_id; … … 411 381 $list[] = $row; 412 382 } 413 } 414 415 foreach ($list as $elem) 416 { 417 $query = ' 383 384 foreach ($list as $elem) 385 { 386 $query = ' 418 387 SELECT 419 388 u.'.$conf['user_fields']['username'].' as username, 420 389 u.'.$conf['user_fields']['email'].' as mail_address 421 FROM 422 '.USER_GROUP_TABLE.' as ug 390 FROM 391 '.USER_GROUP_TABLE.' as ug 423 392 INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id 424 393 INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id 425 WHERE 394 WHERE 426 395 '.$conf['user_fields']['email'].' IS NOT NULL 427 396 AND group_id = '.$group_id.' … … 430 399 ;'; 431 400 432 $result = pwg_query($query); 433 434 if (mysql_num_rows($result) > 0) 435 { 436 $Bcc = array(); 437 while ($row = mysql_fetch_array($result)) 401 $result = pwg_query($query); 402 403 if (mysql_num_rows($result) > 0) 438 404 { 439 if (!empty($row['mail_address'])) 405 $Bcc = array(); 406 while ($row = mysql_fetch_array($result)) 440 407 { 441 array_push($Bcc, format_email($row['username'], $row['mail_address'])); 408 if (!empty($row['mail_address'])) 409 { 410 array_push($Bcc, format_email($row['username'], $row['mail_address'])); 411 } 442 412 } 443 } 444 445 if (count($Bcc) > 0) 446 { 447 switch_lang_to($elem['language']); 448 449 $mail_template = get_mail_template($email_format, $elem); 450 $mail_template->set_filename($tpl_shortname, 451 (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); 452 $mail_template->assign_vars($assign_vars); 453 454 $return = pwg_mail 455 ( 456 '', 457 array 413 414 if (count($Bcc) > 0) 415 { 416 switch_lang_to($elem['language']); 417 418 $mail_template = get_mail_template($email_format, $elem); 419 $mail_template->set_filename($tpl_shortname, 420 (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl'); 421 $mail_template->assign_vars($assign_vars); 422 423 $return = pwg_mail 458 424 ( 459 'Bcc' => $Bcc, 460 'subject' => l10n_args($keyargs_subject), 461 'email_format' => $email_format, 462 'content' => $mail_template->parse($tpl_shortname, true), 463 'content_format' => $email_format, 464 'template' => $elem['template'], 465 'theme' => $elem['theme'] 466 ) 467 ) and $return; 468 469 switch_lang_back(); 425 '', 426 array 427 ( 428 'Bcc' => $Bcc, 429 'subject' => l10n_args($keyargs_subject), 430 'email_format' => $email_format, 431 'content' => $mail_template->parse($tpl_shortname, true), 432 'content_format' => $email_format, 433 'template' => $elem['template'], 434 'theme' => $elem['theme'] 435 ) 436 ) and $return; 437 438 switch_lang_back(); 439 } 470 440 } 471 441 } … … 501 471 return true; 502 472 } 503 473 504 474 if (!isset($conf_mail)) 505 475 { … … 539 509 $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); 540 510 // Ascii convertion 541 $cvt_subject = encode_mime_header($cvt_subject);511 $cvt_subject = str_translate_to_ascii7bits($cvt_subject); 542 512 543 513 if (!isset($args['content'])) … … 589 559 $content = ''; 590 560 591 if (!isset($conf_mail[$args['email_format']][$lang_info['c harset']][$args['template']][$args['theme']]))561 if (!isset($conf_mail[$args['email_format']][$lang_info['code']][$lang_info['charset']][$args['template']][$args['theme']])) 592 562 { 593 563 if (!isset($mail_template)) … … 607 577 'LANG' => $lang_info['code'], 608 578 'DIR' => $lang_info['direction'], 609 579 610 580 // Footer 611 581 'GALLERY_URL' => … … 651 621 // what are displayed on the header of each mail ? 652 622 $conf_mail[$args['email_format']] 653 [$lang_info['c harset']]623 [$lang_info['code']][$lang_info['charset']] 654 624 [$args['template']][$args['theme']]['header'] = 655 625 $mail_template->parse('mail_header', true); … … 657 627 // what are displayed on the footer of each mail ? 658 628 $conf_mail[$args['email_format']] 659 [$lang_info['c harset']]629 [$lang_info['code']][$lang_info['charset']] 660 630 [$args['template']][$args['theme']]['footer'] = 661 631 $mail_template->parse('mail_footer', true); … … 664 634 // Header 665 635 $content.= $conf_mail[$args['email_format']] 666 [$lang_info['c harset']]636 [$lang_info['code']][$lang_info['charset']] 667 637 [$args['template']][$args['theme']]['header']; 668 638 … … 684 654 // Footer 685 655 $content.= $conf_mail[$args['email_format']] 686 [$lang_info['c harset']]656 [$lang_info['code']][$lang_info['charset']] 687 657 [$args['template']][$args['theme']]['footer']; 688 658 … … 700 670 global $user; 701 671 @mkdir(PHPWG_ROOT_PATH.'testmail'); 702 $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'] ;672 $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].$cvt_subject; 703 673 if ($args['content_format'] == 'text/plain') 704 674 {
Note: See TracChangeset
for help on using the changeset viewer.