1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net | |
---|
7 | // +-----------------------------------------------------------------------+ |
---|
8 | // | branch : BSF (Best So Far) |
---|
9 | // | file : $RCSfile$ |
---|
10 | // | last update : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $ |
---|
11 | // | last modifier : $Author: plg $ |
---|
12 | // | revision : $Revision: 958 $ |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | This program is free software; you can redistribute it and/or modify | |
---|
15 | // | it under the terms of the GNU General Public License as published by | |
---|
16 | // | the Free Software Foundation | |
---|
17 | // | | |
---|
18 | // | This program is distributed in the hope that it will be useful, but | |
---|
19 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
20 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
21 | // | General Public License for more details. | |
---|
22 | // | | |
---|
23 | // | You should have received a copy of the GNU General Public License | |
---|
24 | // | along with this program; if not, write to the Free Software | |
---|
25 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
26 | // | USA. | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | |
---|
29 | /** |
---|
30 | * - Extract mail fonctions of password.php |
---|
31 | * - Modify pwg_mail (add pararameters + news fonctionnalities) |
---|
32 | * - Var conf_mail, function get_mail_configuration, format_email, pwg_mail |
---|
33 | */ |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | functions | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | |
---|
39 | /* |
---|
40 | * Returns an array of mail configuration parameters : |
---|
41 | * |
---|
42 | * - mail_options: see $conf['mail_options'] |
---|
43 | * - send_bcc_mail_webmaster: see $conf['send_bcc_mail_webmaster'] |
---|
44 | * - email_webmaster: mail corresponding to $conf['webmaster_id'] |
---|
45 | * - formated_email_webmaster: the name of webmaster is $conf['gallery_title'] |
---|
46 | * - text_footer: PhpWebGallery and version |
---|
47 | * |
---|
48 | * @return array |
---|
49 | */ |
---|
50 | function get_mail_configuration() |
---|
51 | { |
---|
52 | global $conf; |
---|
53 | |
---|
54 | $conf_mail = array( |
---|
55 | 'mail_options' => $conf['mail_options'], |
---|
56 | 'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'], |
---|
57 | ); |
---|
58 | |
---|
59 | // we have webmaster id among user list, what's his email address ? |
---|
60 | $conf_mail['email_webmaster'] = get_webmaster_mail_address(); |
---|
61 | |
---|
62 | // name of the webmaster is the title of the gallery |
---|
63 | $conf_mail['formated_email_webmaster'] = |
---|
64 | format_email($conf['gallery_title'], $conf_mail['email_webmaster']); |
---|
65 | |
---|
66 | // what to display at the bottom of each mail ? |
---|
67 | $conf_mail['text_footer'] = |
---|
68 | "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : ''); |
---|
69 | |
---|
70 | return $conf_mail; |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | * Returns an email address with an associated real name |
---|
75 | * |
---|
76 | * @param string name |
---|
77 | * @param string email |
---|
78 | */ |
---|
79 | function format_email($name, $email) |
---|
80 | { |
---|
81 | $cvt7b_name = str_translate_to_ascii7bits($name); |
---|
82 | |
---|
83 | if (strpos($email, '<') === false) |
---|
84 | { |
---|
85 | return $cvt7b_name.' <'.$email.'>'; |
---|
86 | } |
---|
87 | else |
---|
88 | { |
---|
89 | return $cvt7b_name.$email; |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * sends an email, using PhpWebGallery specific informations |
---|
95 | */ |
---|
96 | function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '') |
---|
97 | { |
---|
98 | global $conf, $conf_mail; |
---|
99 | |
---|
100 | $cvt7b_subject = str_translate_to_ascii7bits($subject); |
---|
101 | |
---|
102 | if (!isset($conf_mail)) |
---|
103 | { |
---|
104 | $conf_mail = get_mail_configuration(); |
---|
105 | } |
---|
106 | |
---|
107 | $to = format_email('', $to); |
---|
108 | |
---|
109 | if ($from == '') |
---|
110 | { |
---|
111 | $from = $conf_mail['formated_email_webmaster']; |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | $from = format_email('', $from); |
---|
116 | } |
---|
117 | |
---|
118 | $headers = 'From: '.$from."\n"; |
---|
119 | $headers.= 'Reply-To: '.$from."\n"; |
---|
120 | |
---|
121 | if ($conf_mail['send_bcc_mail_webmaster']) |
---|
122 | { |
---|
123 | $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n"; |
---|
124 | } |
---|
125 | |
---|
126 | $content = $infos; |
---|
127 | $content.= $conf_mail['text_footer']; |
---|
128 | |
---|
129 | if ($conf_mail['mail_options']) |
---|
130 | { |
---|
131 | $options = '-f '.$from; |
---|
132 | |
---|
133 | return mail($to, $cvt7b_subject, $content, $headers, $options); |
---|
134 | } |
---|
135 | else |
---|
136 | { |
---|
137 | return mail($to, $cvt7b_subject, $content, $headers); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | ?> |
---|