- Timestamp:
- Nov 5, 2013, 8:23:29 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/config_default.inc.php
r25338 r25344 230 230 $conf['available_permission_levels'] = array(0,1,2,4,8); 231 231 232 // mail_options: only set it true if you have a send mail warning with 233 // "options" parameter missing on mail() function execution. 234 $conf['mail_options'] = false; 232 // check_upgrade_feed: check if there are database upgrade required. Set to 233 // true, a message will strongly encourage you to upgrade your database if 234 // needed. 235 // 236 // This configuration parameter is set to true in BSF branch and to false 237 // elsewhere. 238 $conf['check_upgrade_feed'] = true; 239 240 // rate_items: available rates for a picture 241 $conf['rate_items'] = array(0,1,2,3,4,5); 242 243 // Define default method to use ('http' or 'html' in order to do redirect) 244 $conf['default_redirect_method'] = 'http'; 245 246 // Define using double password type in admin's users management panel 247 $conf['double_password_type_in_admin'] = false; 248 249 // Define if logins must be case sentitive or not at users registration. ie : 250 // If set true, the login "user" will equal "User" or "USER" or "user", 251 // etc. ... And it will be impossible to use such login variation to create a 252 // new user account. 253 $conf['insensitive_case_logon'] = false; 254 255 // how should we check for unicity when adding a photo. Can be 'md5sum' or 256 // 'filename' 257 $conf['uniqueness_mode'] = 'md5sum'; 258 259 // Library used for image resizing. Value could be 'auto', 'imagick', 260 // 'ext_imagick' or 'gd'. If value is 'auto', library will be choosen in this 261 // order. If choosen library is not available, another one will be picked up. 262 $conf['graphics_library'] = 'auto'; 263 264 // If library used is external installation of ImageMagick ('ext_imagick'), 265 // you can define imagemagick directory. 266 $conf['ext_imagick_dir'] = ''; 267 268 // how many user comments to display by default on comments.php. Use 'all' 269 // to display all user comments without pagination. Default available values 270 // are array(5,10,20,50,'all') but you can set any other numeric value. 271 $conf['comments_page_nb_comments'] = 10; 272 273 // +-----------------------------------------------------------------------+ 274 // | email | 275 // +-----------------------------------------------------------------------+ 235 276 236 277 // send_bcc_mail_webmaster: send bcc mail to webmaster. Set true for debug … … 238 279 $conf['send_bcc_mail_webmaster'] = false; 239 280 240 // default_email_format: 241 // Define the default email format use to send email 242 // Value could be text/plain or text/html 243 $conf['default_email_format'] = 'text/html'; 244 245 // alternative_email_format: 246 // Define the alternative email format use to send email 247 // Value could be text/plain or text/html 248 $conf['alternative_email_format'] = 'text/plain'; 249 250 // define the name of sender mail: 251 // If value is empty, gallery title is used 281 // define the name of sender mail: if value is empty, gallery title is used 252 282 $conf['mail_sender_name'] = ''; 253 283 254 // smtp configuration 255 // (work if fsockopen function is allowed for smtp port) 284 // define the email of sender mail: if valie is empty, webmaster email is used 285 $conf['mail_sender_email'] = ''; 286 287 // set true to allow text/html emails 288 $conf['allow_html_email'] = true; 289 290 // 'clear' or 'dark' 291 $conf['mail_theme'] = 'clear'; 292 293 // smtp configuration (work if fsockopen function is allowed for smtp port) 256 294 // smtp_host: smtp server host 257 295 // if null, regular mail function is used … … 265 303 // 'ssl' or 'tls' 266 304 $conf['smtp_secure'] = null; 267 268 // check_upgrade_feed: check if there are database upgrade required. Set to269 // true, a message will strongly encourage you to upgrade your database if270 // needed.271 //272 // This configuration parameter is set to true in BSF branch and to false273 // elsewhere.274 $conf['check_upgrade_feed'] = true;275 276 // rate_items: available rates for a picture277 $conf['rate_items'] = array(0,1,2,3,4,5);278 279 // Define default method to use ('http' or 'html' in order to do redirect)280 $conf['default_redirect_method'] = 'http';281 282 // Define using double password type in admin's users management panel283 $conf['double_password_type_in_admin'] = false;284 285 // Define if logins must be case sentitive or not at users registration. ie :286 // If set true, the login "user" will equal "User" or "USER" or "user",287 // etc. ... And it will be impossible to use such login variation to create a288 // new user account.289 $conf['insensitive_case_logon'] = false;290 291 // how should we check for unicity when adding a photo. Can be 'md5sum' or292 // 'filename'293 $conf['uniqueness_mode'] = 'md5sum';294 295 // Library used for image resizing. Value could be 'auto', 'imagick',296 // 'ext_imagick' or 'gd'. If value is 'auto', library will be choosen in this297 // order. If choosen library is not available, another one will be picked up.298 $conf['graphics_library'] = 'auto';299 300 // If library used is external installation of ImageMagick ('ext_imagick'),301 // you can define imagemagick directory.302 $conf['ext_imagick_dir'] = '';303 304 // how many user comments to display by default on comments.php. Use 'all'305 // to display all user comments without pagination. Default available values306 // are array(5,10,20,50,'all') but you can set any other numeric value.307 $conf['comments_page_nb_comments'] = 10;308 305 309 306 // +-----------------------------------------------------------------------+ -
trunk/include/functions_mail.inc.php
r25018 r25344 22 22 // +-----------------------------------------------------------------------+ 23 23 24 // +-----------------------------------------------------------------------+ 25 // | functions | 26 // +-----------------------------------------------------------------------+ 27 28 /* 29 * Returns the name of the mail sender : 30 * 24 /** 25 * Returns the name of the mail sender 31 26 * @return string 32 27 */ … … 38 33 } 39 34 40 /* 35 /** 36 * Returns the email of the mail sender 37 * @since 2.6 38 * @return string 39 */ 40 function get_mail_sender_email() 41 { 42 global $conf; 43 44 return (empty($conf['mail_sender_email']) ? get_webmaster_mail_address() : $conf['mail_sender_email']); 45 } 46 47 /** 41 48 * Returns an array of mail configuration parameters : 42 *43 * - mail_options44 49 * - send_bcc_mail_webmaster 45 * - default_email_format 46 * - alternative_email_format 50 * - allow_html_email 47 51 * - use_smtp 48 52 * - smtp_host 49 53 * - smtp_user 50 54 * - smtp_password 51 * - boundary_key55 * - smtp_secure 52 56 * - email_webmaster 53 * - formated_email_webmaster57 * - name_webmaster 54 58 * 55 59 * @return array … … 60 64 61 65 $conf_mail = array( 62 'mail_options' => $conf['mail_options'],63 66 'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'], 64 ' default_email_format' => $conf['default_email_format'],65 ' alternative_email_format' => $conf['alternative_email_format'],67 'allow_html_email' => $conf['allow_html_email'], 68 'mail_theme' => $conf['mail_theme'], 66 69 'use_smtp' => !empty($conf['smtp_host']), 67 70 'smtp_host' => $conf['smtp_host'], … … 69 72 'smtp_password' => $conf['smtp_password'], 70 73 'smtp_secure' => $conf['smtp_secure'], 74 'email_webmaster' => get_mail_sender_email(), 75 'name_webmaster' => get_mail_sender_name(), 71 76 ); 72 77 73 // we have webmaster id among user list, what's his email address ?74 $conf_mail['email_webmaster'] = get_webmaster_mail_address();75 76 // name of the webmaster is the title of the gallery77 $conf_mail['formated_email_webmaster'] = format_email(get_mail_sender_name(), $conf_mail['email_webmaster']);78 79 78 return $conf_mail; 80 79 } … … 82 81 /** 83 82 * Returns an email address with an associated real name 84 *85 83 * @param string name 86 84 * @param string email … … 88 86 function format_email($name, $email) 89 87 { 90 // Spring cleaning91 88 $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email)); 92 89 $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name)); … … 108 105 109 106 /** 107 * Returns the mail and the name from a formatted address 108 * @since 2.6 109 * @param string|array $input 110 * @return array 111 */ 112 function unformat_email($input) 113 { 114 if (is_array($input)) 115 { 116 return $input; 117 } 118 119 if (preg_match('/(.*)<(.*)>.*/', $input, $matches)) 120 { 121 return array( 122 'email' => trim($matches[2]), 123 'name' => trim($matches[1]), 124 ); 125 } 126 else 127 { 128 return array( 129 'email' => trim($input), 130 'name' => '', 131 ); 132 } 133 } 134 135 136 /** 110 137 * Returns an email address list with minimal email string 111 * 112 * @ param string with email list (email separated by comma)138 * @param string $email_list - comma separated 139 * @return string 113 140 */ 114 141 function get_strict_email_list($email_list) … … 116 143 $result = array(); 117 144 $list = explode(',', $email_list); 145 118 146 foreach ($list as $email) 119 147 { … … 131 159 /** 132 160 * Return an new mail template 133 * 134 * @param string email_format: mail format, text/html or text/plain 135 * @param string theme: theme to use [default get_default_theme()] 136 */ 137 function & get_mail_template($email_format, $theme='') 138 { 139 if (empty($theme)) 140 { 141 $theme = get_default_theme(); 142 } 143 144 $mail_template = new Template(PHPWG_ROOT_PATH.'themes', $theme, 'template/mail/'.$email_format); 145 146 return $mail_template; 147 } 148 149 /** 150 * Return string email format (text/html or text/plain) 151 * 152 * @param string format 153 */ 154 function get_str_email_format($is_html) 155 { 156 return ($is_html ? 'text/html' : 'text/plain'); 157 } 158 159 /* 160 * Switch language to param language 161 * @param string $email_format - text/html or text/plain 162 * @return Template 163 */ 164 function &get_mail_template($email_format) 165 { 166 $template = new Template(PHPWG_ROOT_PATH.'themes', 'default', 'template/mail/'.$email_format); 167 return $template; 168 } 169 170 /** 171 * Switch language to specified language 161 172 * All entries are push on language stack 162 * 163 * @param string language 173 * @param string $language 164 174 */ 165 175 function switch_lang_to($language) … … 198 208 load_language('admin.lang', '', array('language'=>$language) ); 199 209 210 // Reload all plugins files (see load_language declaration) 200 211 if (!empty($language_files)) 201 212 { … … 220 231 } 221 232 222 /* 233 /** 223 234 * Switch back language pushed with switch_lang_to function 224 *225 * @param: none226 235 */ 227 236 function switch_lang_back() … … 457 466 } 458 467 459 /* 468 /** 460 469 * sends an email, using Piwigo specific informations 461 470 * 462 * @param: 463 * - to: receiver(s) of the mail (list separated by comma). 464 * - args: function params of mail function: 471 * @param string|string[] $to 472 * @param array $args 465 473 * o from: sender [default value webmaster email] 466 474 * o Cc: array of carbon copy receivers of the mail. [default value empty] … … 470 478 * o content_format: format of mail content [default value 'text/plain'] 471 479 * o email_format: global mail format [default value $conf_mail['default_email_format']] 472 * o theme: template to use [default get_default_theme()] 480 * o theme: theme to use [default value $conf_mail['mail_theme']] 481 * o mail_title: main title of the mail [default value $conf['gallery_title']] 482 * o mail_subtitle: subtitle of the mail [default value subject] 473 483 * 474 * @return boolean (Ok or not)484 * @return boolean 475 485 */ 476 486 function pwg_mail($to, $args = array()) … … 492 502 $mail = new PHPMailer; 493 503 494 foreach (explode(',', get_strict_email_list($to)) as $recipient) 495 { 496 $mail->addAddress($recipient); 497 } 498 504 $recipients = !is_array($to) ? explode(',', $to) : $to; 505 foreach ($recipients as $recipient) 506 { 507 $recipient = unformat_email($recipient); 508 $mail->addAddress($recipient['email'], $recipient['name']); 509 } 510 499 511 $mail->WordWrap = 76; 500 512 $mail->CharSet = 'UTF-8'; … … 505 517 if (empty($args['from'])) 506 518 { 507 $ mail->From = get_webmaster_mail_address();508 $mail->FromName = get_mail_sender_name();509 510 $mail->addReplyTo(get_webmaster_mail_address(), get_mail_sender_name());519 $from = array( 520 'email' => $conf_mail['email_webmaster'], 521 'name' => $conf_mail['name_webmaster'], 522 ); 511 523 } 512 524 else 513 525 { 514 $mail->From = $args['from']; 515 $mail->addReplyTo($args['from']); 516 } 526 $from = unformat_email($args['from']); 527 } 528 $mail->setFrom($from['email'], $from['name']); 529 $mail->addReplyTo($from['email'], $from['name']); 517 530 518 531 // Subject … … 521 534 $args['subject'] = 'Piwigo'; 522 535 } 523 524 536 $args['subject'] = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); 525 526 537 $mail->Subject = $args['subject']; 527 538 … … 529 540 if (!empty($args['Cc'])) 530 541 { 531 $mail->addCC($args['Cc']); 542 foreach ($args['Cc'] as $cc) 543 { 544 $cc = unformat_email($cc); 545 $mail->addCC($cc['email'], $cc['name']); 546 } 532 547 } 533 548 … … 535 550 if ($conf_mail['send_bcc_mail_webmaster']) 536 551 { 537 $args['Bcc'][] = get_webmaster_mail_address();; 538 } 539 552 $args['Bcc'][] = get_webmaster_mail_address(); 553 } 540 554 if (!empty($args['Bcc'])) 541 555 { 542 556 foreach ($args['Bcc'] as $bcc) 543 557 { 544 $mail->addBCC($bcc); 545 } 558 $bcc = unformat_email($bcc); 559 $mail->addBCC($bcc['email'], $bcc['name']); 560 } 561 } 562 563 // theme 564 if (empty($args['theme']) or !in_array($args['theme'], array('clear','dark'))) 565 { 566 $args['theme'] = $conf_mail['mail_theme']; 546 567 } 547 568 548 569 // content 549 if (empty($args['email_format']))550 {551 $args['email_format'] = $conf_mail['default_email_format'];552 }553 554 570 if (!isset($args['content'])) 555 571 { 556 572 $args['content'] = ''; 557 573 } 558 574 if (!isset($args['mail_title'])) 575 { 576 $args['mail_title'] = $conf['gallery_title']; 577 } 578 if (!isset($args['mail_subtitle'])) 579 { 580 $args['mail_subtitle'] = $args['subject']; 581 } 582 583 // content type 559 584 if (empty($args['content_format'])) 560 585 { … … 562 587 } 563 588 564 if (empty($args['theme'])) 565 { 566 $args['theme'] = get_default_theme(); 567 } 568 569 $content_type_list[] = $args['email_format']; 570 if (!empty($conf_mail['alternative_email_format'])) 571 { 572 $content_type_list[] = $conf_mail['alternative_email_format']; 573 } 589 $content_type_list = array(); 590 if ($conf_mail['allow_html_email'] and @$args['email_format'] != 'text/plain') 591 { 592 $content_type_list[] = 'text/html'; 593 } 594 $content_type_list[] = 'text/plain'; 574 595 575 596 $contents = array(); 576 577 foreach (array_unique($content_type_list) as $content_type)578 {579 // key compose of indexes witch allow ti cache mail data580 $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme'];597 foreach ($content_type_list as $content_type) 598 { 599 // key compose of indexes witch allow to cache mail data 600 $cache_key = $content_type.'-'.$lang_info['code']; 601 $cache_key.= '-'.crc32(@$args['mail_title'] . @$args['mail_subtitle']); 581 602 582 603 if (!isset($conf_mail[$cache_key])) 583 604 { 605 // instanciate a new Template 584 606 if (!isset($conf_mail[$cache_key]['theme'])) 585 607 { 586 $conf_mail[$cache_key]['theme'] = get_mail_template($content_type, $args['theme']); 608 $conf_mail[$cache_key]['theme'] = get_mail_template($content_type); 609 trigger_action('before_parse_mail_template', $cache_key, $content_type); 587 610 } 588 611 … … 595 618 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 596 619 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 597 'PHPWG_URL' => PHPWG_URL, 598 'TITLE_MAIL' => urlencode(l10n('A comment on your site')), 599 'MAIL' => get_webmaster_mail_address() 620 'PHPWG_URL' => defined('PHPWG_URL') ? PHPWG_URL : '', 621 'CONTENT_ENCODING' => get_pwg_charset(), 622 'CONTACT_MAIL' => $conf_mail['email_webmaster'], 623 'MAIL_TITLE' => $args['mail_title'], 624 'MAIL_SUBTITLE' => $args['mail_subtitle'], 600 625 ) 601 626 ); … … 609 634 } 610 635 611 $file = PHPWG_ROOT_PATH.'themes/'.$args['theme'].'/mail-css.tpl'; 612 if (is_file($file)) 636 if ($conf_mail[$cache_key]['theme']->smarty->template_exists('mail-css-'. $args['theme'] .'.tpl')) 613 637 { 614 $conf_mail[$cache_key]['theme']->set_filename('css', realpath($file));638 $conf_mail[$cache_key]['theme']->set_filename('css', 'mail-css-'. $args['theme'] .'.tpl'); 615 639 $conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css'); 616 640 } 617 641 } 618 642 619 // what are displayed on the header of each mail ?620 643 $conf_mail[$cache_key]['header'] = $conf_mail[$cache_key]['theme']->parse('mail_header', true); 621 622 // what are displayed on the footer of each mail ?623 644 $conf_mail[$cache_key]['footer'] = $conf_mail[$cache_key]['theme']->parse('mail_footer', true); 624 645 } … … 628 649 629 650 // Content 630 if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html')) 631 { 632 $contents[$content_type].= '<p>'. 633 nl2br( 634 preg_replace("/(http:\/\/)([^\s,]*)/i", 635 "<a href='$1$2' class='thumblnk'>$1$2</a>", 636 htmlspecialchars($args['content']))). 637 '</p>'; 638 } 639 else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain')) 651 if ($args['content_format'] == 'text/plain' and $content_type == 'text/html') 652 { 653 // convert plain text to html 654 $contents[$content_type].= 655 '<p>'. 656 nl2br( 657 preg_replace( 658 '/(https?:\/\/([-\w\.]+[-\w])+(:\d+)?(\/([\w\/_\.\#-]*(\?\S+)?[^\.\s])?)?)/i', 659 '<a href="$1">$1</a>', 660 htmlspecialchars($args['content']) 661 ) 662 ). 663 '</p>'; 664 } 665 else if ($args['content_format'] == 'text/html' and $content_type == 'text/plain') 640 666 { 641 667 // convert html text to plain text … … 654 680 unset_make_full_url(); 655 681 682 // Send content to PHPMailer 656 683 if (isset($contents['text/html'])) 657 684 { 658 $mail->isHTML(true); // Set email format to HTML659 $mail->Body = $contents['text/html'];685 $mail->isHTML(true); 686 $mail->Body = move_css_to_body($contents['text/html']); 660 687 661 688 if (isset($contents['text/plain'])) … … 704 731 } 705 732 706 $ret = $mail->send(); 707 if(!$ret) 708 { 709 trigger_error( 'Mailer Error: ' . $mail->ErrorInfo, E_USER_WARNING); 710 } 733 $ret = true; 734 $pre_result = trigger_event('before_send_mail', true, $to, $args, $mail); 735 736 if ($pre_result) 737 { 738 $ret = $mail->send(); 739 if (!$ret and is_admin()) 740 { 741 trigger_error('Mailer Error: ' . $mail->ErrorInfo, E_USER_WARNING); 742 } 743 } 744 711 745 return $ret; 712 746 } 713 747 714 /* DEPRECATED 715 * pwg sendmail 716 * 717 * @param: 718 * - result of other sendmail 719 * - to: Receiver or receiver(s) of the mail. 720 * - subject [default value 'Piwigo'] 721 * - content: content of mail 722 * - headers: headers of mail 723 * 724 * @return boolean (Ok or not) 725 */ 726 function pwg_send_mail($result, $to, $subject, $contents, $headers) 727 { 748 /** 749 * @deprecated 2.6 750 */ 751 function pwg_send_mail($result, $to, $subject, $content, $headers) 752 { 753 trigger_error('pwg_send_mail function is deprecated', E_USER_NOTICE); 754 728 755 if (!$result) 729 756 { 730 include_once(PHPWG_ROOT_PATH.'include/class.phpmailer.php'); 757 return pwg_mail($to, array( 758 'content' => $content, 759 'subject' => $subject, 760 )); 761 } 762 else 763 { 764 return $result; 765 } 766 } 767 768 /** 769 * @deprecated 2.6 770 */ 771 function move_ccs_rules_to_body($content) 772 { 773 trigger_error('move_ccs_rules_to_body function is deprecated, use move_css_to_body', E_USER_NOTICE); 774 775 return move_css_to_body($content); 776 } 777 778 /** 779 * Moves CSS rules contained in the <style> tag to inline CSS 780 * (for compatibility with Gmail and such clients) 781 * @since 2.6 782 * @param string $content 783 * @return string 784 */ 785 function move_css_to_body($content) 786 { 787 include_once(PHPWG_ROOT_PATH.'include/emogrifier.class.php'); 788 789 $e = new Emogrifier($content); 790 $e->preserveStyleTag = true; 791 return $e->emogrify(); 792 } 793 794 /** 795 * Saves a copy of the mail if _data/tmp 796 * @param boolean $result 797 * @param string $to 798 * @param array $args 799 * @param PHPMailer $mail 800 * @return boolean $result 801 */ 802 function pwg_send_mail_test($result, $to, $args, $mail) 803 { 804 global $conf, $user, $lang_info; 805 806 $dir = PHPWG_ROOT_PATH.$conf['data_location'].'tmp'; 807 if (mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR)) 808 { 809 $filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'.'.$args['theme'].'-'.date('YmdHis'); 810 if ($args['content_format'] == 'text/plain') 811 { 812 $filename .= '.txt'; 813 } 814 else 815 { 816 $filename .= '.html'; 817 } 731 818 732 global $conf_mail; 733 734 if ($conf_mail['use_smtp']) 735 { 736 include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' ); 737 $smtp_mail = new smtp_mail( 738 $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'], 739 $conf_mail['email_webmaster']); 740 return $smtp_mail->mail($to, $subject, $content, $headers); 741 } 742 else 743 { 744 $mail = new PHPMailer; 745 746 $mail->From = 'plg@pigolabs.com'; 747 $mail->FromName = 'Pierrick en local'; 748 foreach (explode(',', $to) as $recipient) 749 { 750 $mail->addAddress($recipient); // Add a recipient 751 } 752 // $mail->addReplyTo('plg@piwigo.org', 'Pierrick de Piwigo.org'); 753 // $mail->addCC('cc@example.com'); 754 // $mail->addBCC('bcc@example.com'); 755 756 $mail->WordWrap = 76; // Set word wrap to 50 characters 757 758 if (isset($contents['text/html'])) 759 { 760 $mail->isHTML(true); // Set email format to HTML 761 $mail->Body = $contents['text/html']; 762 763 if (isset($contents['text/plain'])) 764 { 765 $mail->AltBody = $contents['text/plain']; 766 } 767 } 768 else 769 { 770 $mail->isHTML(false); 771 $mail->Body = $contents['text/plain']; 772 } 773 774 $mail->CharSet = 'UTF-8'; 775 $mail->Subject = $subject; 776 777 if(!$mail->send()) { 778 echo 'Message could not be sent.'; 779 echo 'Mailer Error: ' . $mail->ErrorInfo; 780 exit; 781 } 782 783 // if ($conf_mail['mail_options']) 784 // { 785 // $options = '-f '.$conf_mail['email_webmaster']; 786 // return mail($to, $subject, $content, $headers, $options); 787 // } 788 // else 789 // { 790 // return mail($to, $subject, $content, $headers); 791 // } 792 } 793 } 794 else 795 { 796 return $result; 797 } 798 } 799 800 function move_ccs_rules_to_body($content) 801 { 802 return $content; 803 // We search all css rules in style tags 804 preg_match('#<style>(.*?)</style>#s', $content, $matches); 805 806 if (!empty($matches[1])) 807 { 808 preg_match_all('#([^\n]*?)\{(.*?)\}#s', $matches[1], $matches); 809 810 $selectors = array(); 811 $unknow_selectors = ''; 812 813 foreach ($matches[1] as $key => $value) 814 { 815 $selects = explode(',', $value); 816 $style = trim($matches[2][$key], ' ;'); 817 818 foreach($selects as $select) 819 { 820 $select = trim($select); 821 $selectors[$select][] = $style; 822 } 823 } 824 825 foreach ($selectors as $selector => $style) 826 { 827 if (!preg_match('/^(#|\.|)([A-Za-z0-9_-]*)$/', $selector, $matches)) 828 { 829 $unknow_selectors .= $selector.' {'.implode(";\n", $style).";}\n"; 830 } 831 else switch ($matches[1]) 832 { 833 case '#': 834 $content = preg_replace('|id="'.$matches[2].'"|', 'id="'.$matches[2].'" style="'.implode(";\n", $style).";\"\n", $content); 835 break; 836 case '.': 837 $content = preg_replace('|class="'.$matches[2].'"|', 'class="'.$matches[2].'" style="'.implode(";\n", $style).";\"\n", $content); 838 break; 839 default: 840 $content = preg_replace('#<'.$matches[2].'( |>)#', '<'.$matches[2].' style="'.implode(";\n", $style).";\"\n$1", $content); 841 break; 842 } 843 } 844 845 // Keep unknow tags in page head 846 if (!empty($unknow_selectors)) 847 { 848 $content = preg_replace('#<style>.*?</style>#s', "<style type=\"text/css\">\n$unknow_selectors</style>", $content); 849 } 850 else 851 { 852 $content = preg_replace('#<style>.*?</style>#s', '', $content); 853 } 854 } 855 return $content; 856 } 857 858 /*Testing block*/ 859 function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args) 860 { 861 global $conf, $user, $lang_info; 862 $dir = PHPWG_ROOT_PATH.$conf['data_location'].'tmp'; 863 if ( mkgetdir( $dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR) ) 864 { 865 $filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'.'.$args['theme'].'-'.date('YmdHis'); 866 if ($args['content_format'] == 'text/plain') 867 { 868 $filename .= '.txt'; 869 } 870 else 871 { 872 $filename .= '.html'; 873 } 874 $file = fopen($filename, 'w+'); 875 fwrite($file, $to ."\n"); 876 fwrite($file, $subject ."\n"); 877 fwrite($file, $headers); 878 fwrite($file, $content); 879 fclose($file); 880 } 881 return $result; 882 } 819 $file = fopen($filename, 'w+'); 820 fwrite($file, implode(', ', $to) ."\n"); 821 fwrite($file, $mail->Subject ."\n"); 822 fwrite($file, $mail->createHeader() ."\n"); 823 fwrite($file, $mail->createBody()); 824 fclose($file); 825 } 826 827 return $result; 828 } 829 883 830 if ($conf['debug_mail']) 884 add_event_handler('send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 6); 885 886 887 add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5); 888 add_event_handler('send_mail_content', 'move_ccs_rules_to_body'); 831 { 832 add_event_handler('before_send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 4); 833 } 834 889 835 trigger_action('functions_mail_included'); 890 836 -
trunk/themes/default/template/mail/text/html/footer.tpl
r5287 r25344 1 </div> <!-- content --> 2 <div id="copyright"> 3 <hr> 4 {'Sent by'|@translate} 5 <a href="{$GALLERY_URL}">{$GALLERY_TITLE}</a> 1 {* <!-- end $CONTENT --> *} 2 </td></tr> 6 3 7 {* Please, do not remove this copyright. If you really want to, 8 contact us on http://piwigo.org to find a solution on how 9 to show the origin of the script...*} 10 - {'Powered by'|@translate} 11 <a href="http://piwigo.org" class="Piwigo"> 12 <span class="Piwigo">Piwigo</span></a> 13 {$VERSION} 4 <tr><td id="footer"> 5 {* <!-- begin FOOTER --> *} 6 {* <!-- Please, do not remove this copyright. If you really want to, 7 contact us on http://piwigo.org to find a solution on how 8 to show the origin of the script... --> *} 9 10 {'Sent by'|translate} <a href="{$GALLERY_URL}">{$GALLERY_TITLE}</a> 11 - {'Powered by'|translate} <a href="{$PHPWG_URL}" class="Piwigo">Piwigo</a> 12 {if not empty($VERSION)}{$VERSION}{/if} 13 14 - {'Contact'|translate} 15 <a href="mailto:{$CONTACT_MAIL}?subject={'A comment on your site'|translate|escape:url}">{'Webmaster'|@translate}</a> 16 {* <!-- end FOOTER --> *} 17 </td></tr> 18 </table> 14 19 15 - {'Contact'|@translate} 16 <a href="mailto:{$MAIL}?subject={$TITLE_MAIL}">{'Webmaster'|@translate}</a> 17 18 </div> <!-- copyright --> 19 </div> <!-- the_page --> 20 21 </body> 20 </td></tr> 21 </table> 22 </body> 22 23 </html> -
trunk/themes/default/template/mail/text/html/global-mail-css.tpl
r5695 r25344 1 /* Global mail css */ 1 {strip} 2 /* page */ 3 body { 4 font-family:"Verdana", "Helvetica", "Optima", sans-serif; 5 font-size:12px; 6 margin:0px; 7 padding:0px; 8 } 2 9 3 body {ldelim} font-family: Univers, Helvetica, Optima; font-size:12px; margin:0px; padding:0px; } 4 #the_page {ldelim} margin:0px; padding:0px; text-align:left;} 5 #content {ldelim} margin:0px; padding:30px 0px 0px 30px; width:732px;} 6 hr {ldelim} width:632px; margin-left:0;} 7 #copyright {ldelim} font-size:10px; margin:0px; padding:48px 0px 32px 62px;} 8 .PWG {ldelim} font-family:verdana, sans-serif !important; font-size:0.9em; font-weight:normal; letter-spacing:0px;} 9 h2 {ldelim} padding:7px 15px; width:617px; font-weight:bold;} 10 img {ldelim} margin:16px; border:16px solid #aaa; -moz-border-radius: 4px; border-radius: 4px 4px; } 11 img:hover {ldelim} padding: 15px; border: 1px solid yellow; -moz-border-radius: 4px; border-radius: 4px 4px; } 10 html, body, #bodyTable { 11 width:100%; 12 height:100%; 13 } 14 15 /* main block */ 16 #header { 17 padding:20px; 18 } 19 #header #title { 20 font-size:26px; 21 font-weight:bold; 22 } 23 #header #subtitle { 24 font-size:20px; 25 } 26 #content { 27 padding:0 20px 20px 20px; 28 } 29 #footer { 30 font-size:10px; 31 padding:5px; 32 } 33 #topSpacer { 34 margin-bottom:20px; 35 } 36 37 /* images */ 38 img { 39 border:none; 40 } 41 42 h1, h2, h3, h4, h5 { 43 margin:0.5em 0 0.25em 0; 44 } 45 h1 { font-size:26px; } 46 h2 { font-size:20px; } 47 h3 { font-size:16px; } 48 h4 { font-size:12px; } 49 h5 { font-size:10px; } 50 51 /* paragraphs */ 52 p { 53 margin:0.25em 0 0.5em 0; 54 } 55 blockquote { 56 margin-left:10px; 57 padding-left:10px; 58 font-family:"Times",serif; 59 font-size:14px; 60 } 61 62 /* list */ 63 ul, ol { 64 margin:0.5em 0 0.25em 30px; 65 padding:0; 66 } 67 dl { 68 margin:0.5em 0 0.25em 10px; 69 } 70 dt { 71 margin:0.25em 0 0 0; 72 font-weight:bold; 73 } 74 dd { 75 margin:0 0 0.25em 10px; 76 } 77 78 /* tables */ 79 #content table { 80 width:100%; 81 border-spacing:0; 82 border-collapse:collapse; 83 } 84 #content table td { 85 padding:2px 3px; 86 } 87 #content table th { 88 font-weight:bold; 89 text-align:center; 90 padding:4px 0; 91 } 92 #content table tfoot td { 93 font-size:0.8em; 94 } 95 96 /* line */ 97 hr { 98 border-width:0 0 1px 0; 99 border-color:#ddd; 100 border-style:solid; 101 margin:1em; 102 } 103 {/strip} -
trunk/themes/default/template/mail/text/html/header.tpl
r24951 r25344 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 2 <html lang="{$lang_info.code}" dir="{$lang_info.direction}"> 3 <head> 4 <title>Piwigo Mail</title> 5 <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}"> 6 <style><!-- /* Mini style for mails */ 7 {if isset($GLOBAL_MAIL_CSS)}{$GLOBAL_MAIL_CSS}{/if} 8 {if isset($MAIL_CSS)}{$MAIL_CSS}{/if} 9 --></style> 10 </head> 11 <body> 12 <div id="the_page"> 13 <div id="content" class="content"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}"/> 5 <title>Piwigo Mail</title> 6 7 <style type="text/css"> 8 {if isset($GLOBAL_MAIL_CSS)}{$GLOBAL_MAIL_CSS}{/if} 9 {if isset($MAIL_CSS)}{$MAIL_CSS}{/if} 10 </style> 11 </head> 12 13 <body> 14 <table id="bodyTable" cellspacing="0" cellpadding="10" border="0"> 15 <tr><td align="center" valign="top"> 16 17 <table id="contentTable" cellspacing="0" cellpadding="0" border="0"> 18 <tr><td id="header"> 19 {* <!-- begin HEADER --> *} 20 <div id="title">{$MAIL_TITLE}</div> 21 {if not empty($MAIL_SUBTITLE)}<div id="subtitle">{$MAIL_SUBTITLE}</div>{/if} 22 {* <!-- end HEADER --> *} 23 </td></tr> 24 25 <tr><td id="content"> 26 {* <!-- use an invisible div with a bottom margin to force the browser 27 to merge the margin with the element bellow (typically h1/h2/...) --> *} 28 <div id="topSpacer"></div> 29 {* <!-- begin CONTENT --> *} -
trunk/themes/default/template/mail/text/plain/footer.tpl
r9354 r25344 1 {literal} 1 2 2 -- 3 {/literal} 4 ---- 3 5 {'Sent by'|@translate} "{$GALLERY_TITLE}" {$GALLERY_URL} 4 {' Contact'|@translate} {$MAIL}5 {' Powered by'|@translate} Piwigo {$VERSION}6 {'Powered by'|@translate} "Piwigo{if not empty($VERSION)} {$VERSION}{/if}" {$PHPWG_URL} 7 {'Contact'|@translate}: {$CONTACT_MAIL} -
trunk/themes/default/template/mail/text/plain/header.tpl
r24951 r25344 1 {$MAIL_TITLE} 2 {if not empty($MAIL_SUBTITLE)}{$MAIL_SUBTITLE} 3 {/if} 4 ---- 1 5 {literal} 2 3 {/literal}{*note that there must be an empty line to separate the mime headers*} 6 {/literal}
Note: See TracChangeset
for help on using the changeset viewer.