1 | <?php |
---|
2 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
3 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
4 | |
---|
5 | function sauve_options() |
---|
6 | { |
---|
7 | global $mails_options ; |
---|
8 | $query = ' |
---|
9 | UPDATE '.CONFIG_TABLE.' |
---|
10 | SET value="'.$mails_options[0]. ',' .$mails_options[1]. ',' .$mails_options[2].',' .$mails_options[3]. ',' .$mails_options[4]. '" |
---|
11 | WHERE param="mail_superv" |
---|
12 | LIMIT 1'; |
---|
13 | pwg_query($query); |
---|
14 | |
---|
15 | } |
---|
16 | //================================================================================= |
---|
17 | function sauve_données() |
---|
18 | { |
---|
19 | global $mails_données ; |
---|
20 | $query = ' |
---|
21 | UPDATE '.MAIL_SUPERV_TABLE.' |
---|
22 | SET `nb_mails` = '.$mails_données['nb_mails'].', |
---|
23 | `date_mail` = '.$mails_données['date_mail'].', |
---|
24 | `nb_mails_maxi` = '.$mails_données['nb_mails_maxi'].', |
---|
25 | `nb_mails_periode` = "'.$mails_données['nb_mails_periode'].'", |
---|
26 | |
---|
27 | `nb_spams` = '.$mails_données['nb_spams'].', |
---|
28 | `date_spam` = '.$mails_données['date_spam'].', |
---|
29 | `nb_spams_maxi` = '.$mails_données['nb_spams_maxi'].', |
---|
30 | `nb_spams_periode` = "'.$mails_données['nb_spams_periode'].'", |
---|
31 | |
---|
32 | `quarantaine` = "'.$mails_données['quarantaine'].'", |
---|
33 | `date_quarantaine` = '.$mails_données['date_quarantaine'].', |
---|
34 | |
---|
35 | `message` = "'.$mails_données['message'].'", |
---|
36 | `header_text` = "'.$mails_données['header_text'].'" |
---|
37 | WHERE `id` =1 LIMIT 1 '; |
---|
38 | pwg_query($query); |
---|
39 | } |
---|
40 | //================================================================================= |
---|
41 | function affiche_message() |
---|
42 | { |
---|
43 | global $template,$infos_message,$erreur_message ;; |
---|
44 | |
---|
45 | if (isset($erreur_message)) |
---|
46 | { |
---|
47 | |
---|
48 | if ($erreur_message <> "") |
---|
49 | { |
---|
50 | $erreur_message=str_replace("\n",'<br />',$erreur_message) ; |
---|
51 | $erreur_message=sprintf(l10n('free_message "%s"'), $erreur_message ) ; |
---|
52 | $template->assign('errors',$erreur_message); |
---|
53 | $erreur_message=""; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | if (isset($infos_message)) |
---|
59 | { |
---|
60 | |
---|
61 | if ($infos_message <> "") |
---|
62 | { |
---|
63 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
64 | $template->assign('infos',$infos_message); |
---|
65 | $infos_message=""; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | //================================================================================= |
---|
76 | function Get_Datas() |
---|
77 | { |
---|
78 | |
---|
79 | $query = " |
---|
80 | SELECT * |
---|
81 | FROM ".MAIL_SUPERV_TABLE." |
---|
82 | ;"; |
---|
83 | $data = mysql_fetch_array(pwg_query($query)); |
---|
84 | $data['reste']= ($data['date_quarantaine']-time()) ; |
---|
85 | $data['reste_mail']= ($data['date_mail']-time()) ; |
---|
86 | $data['reste_spam']= ($data['date_spam']-time()) ; |
---|
87 | |
---|
88 | return $data; |
---|
89 | } |
---|
90 | |
---|
91 | //================================================================================= |
---|
92 | function corrige_header($Carbonne,$headers) |
---|
93 | { |
---|
94 | global $mails_options,$conf_mail,$mailto; |
---|
95 | |
---|
96 | $splitter="|".$Carbonne.":(.*)\n|U"; |
---|
97 | preg_match_all($splitter,$headers, $out,PREG_PATTERN_ORDER); |
---|
98 | $val=array(); |
---|
99 | $match=array("<",">"); |
---|
100 | $string=array("","") ; |
---|
101 | foreach($out as $messages) |
---|
102 | { |
---|
103 | $val[]= $messages[0] ; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | $val[1]= str_replace( $match,$string,$val[0] ) ; |
---|
108 | $src=$val[0]; |
---|
109 | |
---|
110 | $splitter="|\"(.*)\"|U"; |
---|
111 | preg_match_all($splitter,$val[1], $out,PREG_PATTERN_ORDER); |
---|
112 | $string=array(); |
---|
113 | $string = array_fill( 0, count($out), ''); |
---|
114 | $dest = str_replace($out[0], $string, $val[1]) ; |
---|
115 | if ($mailto <>"" ) { |
---|
116 | $dest=str_replace($mailto.',', '', $dest) ; |
---|
117 | $dest=str_replace($mailto, '', $dest) ; |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | $headers = str_replace( $src,$dest, $headers) ; |
---|
123 | return $headers; |
---|
124 | |
---|
125 | |
---|
126 | } |
---|
127 | |
---|
128 | function int_to_heure($int) |
---|
129 | { |
---|
130 | $week= (int) ($int/(3600*24*7)); |
---|
131 | $int=$int-($week*(3600*24*7)); |
---|
132 | |
---|
133 | $day= (int) ($int/(3600*24)); |
---|
134 | $int=$int-($day*(3600*24)); |
---|
135 | |
---|
136 | $heures=(int) ($int/3600); |
---|
137 | |
---|
138 | $int=$int-($heures*(3600)); |
---|
139 | |
---|
140 | $minutes=(int) ($int/60); |
---|
141 | $int= $int - ($minutes*(60)); |
---|
142 | |
---|
143 | $secondes=(int) ($int); |
---|
144 | |
---|
145 | $heures= substr ('00'. $heures,-2,2); |
---|
146 | $day= substr ('00'. $day,-2,2); |
---|
147 | $minutes=substr ('00'.$minutes,-2,2); |
---|
148 | $secondes=substr ('00'.$secondes,-2,2); |
---|
149 | if ($week > 0 ) |
---|
150 | { |
---|
151 | return $week. " " .l10n('Week'). " " . $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ". $secondes." " .l10n('seconde')."s"; |
---|
152 | } |
---|
153 | return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ". $secondes." " .l10n('seconde')."s"; |
---|
154 | |
---|
155 | } |
---|
156 | |
---|
157 | function memo_var($variables) |
---|
158 | { |
---|
159 | ob_start(); |
---|
160 | echo '<pre>'; |
---|
161 | print_r($variables); |
---|
162 | echo '</pre>'; |
---|
163 | $m= ob_get_contents(); |
---|
164 | |
---|
165 | ob_end_clean(); |
---|
166 | return $m; |
---|
167 | |
---|
168 | } |
---|
169 | |
---|
170 | function test_envoie() |
---|
171 | { |
---|
172 | global $infos_message,$erreur_message ,$conf,$user ; |
---|
173 | $admins = array(); |
---|
174 | $query = ' |
---|
175 | select |
---|
176 | U.'.$conf['user_fields']['username'].' as username, |
---|
177 | U.'.$conf['user_fields']['email'].' as mail_address |
---|
178 | from |
---|
179 | '.USERS_TABLE.' as U, |
---|
180 | '.USER_INFOS_TABLE.' as I |
---|
181 | where |
---|
182 | I.user_id = U.'.$conf['user_fields']['id'].' and |
---|
183 | I.status in (\'webmaster\', \'admin\') and |
---|
184 | I.adviser = \'false\' and |
---|
185 | '.$conf['user_fields']['email'].' is not null and |
---|
186 | I.user_id <> '.$user['id'].' |
---|
187 | order by |
---|
188 | username |
---|
189 | '; |
---|
190 | //================================================================================== |
---|
191 | |
---|
192 | $datas = pwg_query($query); |
---|
193 | |
---|
194 | |
---|
195 | if (!empty($datas)) |
---|
196 | { |
---|
197 | while ($admin = mysql_fetch_array($datas)) |
---|
198 | { |
---|
199 | if (!empty($admin['mail_address'])) |
---|
200 | { |
---|
201 | array_push($admins, format_email($admin['username'], $admin['mail_address'])); |
---|
202 | |
---|
203 | } |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | if (count($admins) > 0) |
---|
208 | { |
---|
209 | |
---|
210 | ob_start(); |
---|
211 | $erreur_message =""; |
---|
212 | $infos_message = memo_var($admins); |
---|
213 | //=========================================================== |
---|
214 | $args = array(); |
---|
215 | |
---|
216 | $args['Bcc']=$admins; |
---|
217 | |
---|
218 | $message_texte="Bonjour."; |
---|
219 | $message_html="Test"; |
---|
220 | |
---|
221 | /* |
---|
222 | $limite = "_parties_".generate_key(32);; |
---|
223 | // $limite=$conf_mail['boundary_key']; |
---|
224 | $nom ='piwigo_logo_sombre_214x100.png'; |
---|
225 | $typemime='image/jpeg'; |
---|
226 | |
---|
227 | $attachement = "-----=".$limite."\n"; |
---|
228 | $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; |
---|
229 | $attachement .= "Content-Transfer-Encoding: base64\n"; |
---|
230 | $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; |
---|
231 | $fd = fopen( $fichier, "r" ); |
---|
232 | $contenu = fread( $fd, filesize( $fichier ) ); |
---|
233 | fclose( $fd ); |
---|
234 | $attachement .= chunk_split(base64_encode($contenu)); |
---|
235 | $attachement .= "\n\n\n-----=".$limite."\n"; |
---|
236 | */ |
---|
237 | |
---|
238 | //========================================================================== |
---|
239 | |
---|
240 | $args['subject']="Plugin Piwigo TEST"; |
---|
241 | $args['content']="TEST "; |
---|
242 | |
---|
243 | $infos_message ="TEST ENVOIE [admin].".memo_var($admins); |
---|
244 | $ret= pwg_mail( "", $args); |
---|
245 | $m= ob_get_contents(); |
---|
246 | ob_end_clean(); |
---|
247 | $erreur_message .=$m; |
---|
248 | } |
---|
249 | } |
---|
250 | |
---|
251 | ?> |
---|