1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if ( !defined('PHPWG_ROOT_PATH')) |
---|
25 | { |
---|
26 | die('Hacking attempt!'); |
---|
27 | } |
---|
28 | |
---|
29 | if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
30 | |
---|
31 | |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | Check Access and exit when user status is not ok | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | //check_status(ACCESS_ADMINISTRATOR); |
---|
36 | |
---|
37 | global $user, $lang, $conf, $errors,$mails_données; |
---|
38 | global $args, $conf_mail,$infos_message,$erreur_message ; |
---|
39 | |
---|
40 | |
---|
41 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
42 | |
---|
43 | |
---|
44 | include_once (MAIL_SUPERV_PATH.'include/constants.php'); |
---|
45 | include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); |
---|
46 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
47 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
52 | |
---|
53 | |
---|
54 | $mails_options = explode("," , $conf['mail_superv']); |
---|
55 | $mails_données=Get_Datas(); |
---|
56 | |
---|
57 | if (!isset($_GET['tab'])) |
---|
58 | $page['tab'] = 'mail_superv_admin'; |
---|
59 | else |
---|
60 | $page['tab'] = $_GET['tab']; |
---|
61 | |
---|
62 | $icon_path = 'template/yoga/icon/help.png'; |
---|
63 | |
---|
64 | $tabhelp= ' <img src="'.PHPWG_ROOT_PATH. $icon_path .'" class="button" alt="(?)"> '; |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | $tabsheet = new tabsheet(); |
---|
69 | $tabsheet->add('mail_superv_admin', |
---|
70 | l10n('Tab_set'), |
---|
71 | $my_base_url.'&tab=mail_superv_admin'); |
---|
72 | |
---|
73 | $tabsheet->add('mail_superv_test', |
---|
74 | l10n('Tab_test'), |
---|
75 | $my_base_url.'&tab=mail_superv_test'); |
---|
76 | |
---|
77 | $tabsheet->add( 'mail_black_liste', |
---|
78 | l10n('blackliste'), |
---|
79 | $my_base_url.'&tab=mail_black_liste'); |
---|
80 | |
---|
81 | |
---|
82 | $tabsheet->add('mail_superv_help',$tabhelp |
---|
83 | , |
---|
84 | $my_base_url.'&tab=mail_superv_help'); |
---|
85 | |
---|
86 | |
---|
87 | $tabsheet->select($page['tab']); |
---|
88 | $tabsheet->assign(); |
---|
89 | |
---|
90 | $page['global'] = array(); |
---|
91 | $error = array(); |
---|
92 | |
---|
93 | vérif_base(); |
---|
94 | |
---|
95 | $aff_nb=true; |
---|
96 | |
---|
97 | |
---|
98 | // ************************************************************************* |
---|
99 | // | Sélection de l'onglet | |
---|
100 | // ************************************************************************* |
---|
101 | |
---|
102 | $modif=false ; |
---|
103 | |
---|
104 | |
---|
105 | //================================================================================ |
---|
106 | switch ($page['tab']) |
---|
107 | { |
---|
108 | |
---|
109 | // ************************************************************************* |
---|
110 | // initialisation | |
---|
111 | // ************************************************************************* |
---|
112 | case 'mail_superv_admin': |
---|
113 | |
---|
114 | //============================================================= |
---|
115 | if ( isset($_POST['refresh']) ) { |
---|
116 | |
---|
117 | if ($mails_données['nb_mails'] == 0 ) |
---|
118 | $mails_données['date_mail'] = time(); |
---|
119 | |
---|
120 | if ($mails_données['nb_spams'] == 0 ) |
---|
121 | $mails_données['date_spam'] = time(); |
---|
122 | |
---|
123 | |
---|
124 | if ($mails_données['quarantaine'] == false) |
---|
125 | { $mails_données['reste'] = 0; |
---|
126 | $mails_données['date_quarantaine']=time(); |
---|
127 | } |
---|
128 | sauve_données(); |
---|
129 | $erreur_message .="<DIV > <input name='' type='checkbox' value='' /> </DIV>" ; |
---|
130 | $aff_nb = false ; |
---|
131 | |
---|
132 | } |
---|
133 | |
---|
134 | if ( isset($_POST['raz']) ) { |
---|
135 | $mails_données['date_quarantaine']=time(); |
---|
136 | $mails_données['nb_mails'] = 0 ; |
---|
137 | $mails_données['nb_spams'] = 0 ; |
---|
138 | $mails_données['date_mail'] = time(); |
---|
139 | $mails_données['date_spam'] = time(); |
---|
140 | |
---|
141 | $mails_données['reste'] = 0; |
---|
142 | $mails_données['quarantaine']='false'; |
---|
143 | |
---|
144 | sauve_données(); |
---|
145 | array_push($page['infos'], l10n('save_config')); |
---|
146 | } |
---|
147 | |
---|
148 | if ( isset($_POST['submit']) ) |
---|
149 | { |
---|
150 | //Options |
---|
151 | $mails_options[0] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : '' ; |
---|
152 | $mails_options[1] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : '' ; |
---|
153 | $mails_options[2] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : '' ; |
---|
154 | |
---|
155 | |
---|
156 | //données |
---|
157 | $mails_données['nb_mails_maxi'] = isset($_POST['nb_mails_maxi']) ? $_POST['nb_mails_maxi'] : $mails_données['nb_mails_maxi'] ; |
---|
158 | $mails_données['nb_mails_periode'] = isset($_POST['nb_mails_periode']) ? $_POST['nb_mails_periode'] : $mails_données['nb_mails_periode'] ; |
---|
159 | $mails_données['nb_spams_maxi'] = isset($_POST['nb_spams_maxi']) ? $_POST['nb_spams_maxi'] : $mails_données['nb_spams_maxi'] ; |
---|
160 | $mails_données['nb_spams_periode'] = isset($_POST['nb_spams_periode']) ? $_POST['nb_spams_periode'] : $mails_données['nb_spams_periode'] ; |
---|
161 | $mails_données['quarantaine_periode'] = isset($_POST['quarantaine_periode']) ? $_POST['quarantaine_periode'] : $mails_données['quarantaine_periode'] ; |
---|
162 | |
---|
163 | $mails_données['message'] = isset($_POST['content']) ? $_POST['content'] : $mails_données['message'] ; |
---|
164 | $mails_données['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] : $mails_données['header_text'] ; |
---|
165 | //=========================================================================================================== |
---|
166 | sauve_options(); |
---|
167 | sauve_données(); |
---|
168 | //=========================================================================================================== |
---|
169 | array_push($page['infos'], l10n('save_config')); |
---|
170 | } |
---|
171 | |
---|
172 | $mails_options = explode("," , $conf['mail_superv']); |
---|
173 | $mails_données = Get_Datas(); |
---|
174 | |
---|
175 | $rest_mail= $mails_données['rest_mail']; |
---|
176 | $rest_spam= $mails_données['rest_spam']; |
---|
177 | $reste= $mails_données['reste']; |
---|
178 | |
---|
179 | $quarantaine = ($mails_données['quarantaine'] == 'true') ? true : false ;; |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | $PHPWG_VERSION=PHPWG_VERSION; |
---|
184 | |
---|
185 | $template->assign( |
---|
186 | array( |
---|
187 | 'check_mailto' => $mails_options[0] == 'on' ? 'checked="checked"' : '' , |
---|
188 | 'check_header_carbons' => $mails_options[1] == 'on' ? 'checked="checked"' : '' , |
---|
189 | 'check_header_text' => $mails_options[2] == 'on' ? 'checked="checked"' : '' , |
---|
190 | |
---|
191 | |
---|
192 | 'nb_mails' => $mails_données['nb_mails'] , |
---|
193 | 'date_mail' => "'".date(l10n('formatdate'),$mails_données['date_mail'])."'" , |
---|
194 | 'nb_mails_maxi' => $mails_données['nb_mails_maxi'] , |
---|
195 | 'nb_mails_periode' => "'".$mails_données['nb_mails_periode']."'" , |
---|
196 | 'time_mails_reste' => "'".int_to_heure( $rest_mail )."'" , |
---|
197 | |
---|
198 | 'nb_spams' => $mails_données['nb_spams'] , |
---|
199 | 'date_spam' => "'".date(l10n('formatdate'),$mails_données['date_spam'])."'" , |
---|
200 | 'nb_spams_maxi' => $mails_données['nb_spams_maxi'] , |
---|
201 | 'nb_spams_periode' => "'".$mails_données['nb_spams_periode']."'" , |
---|
202 | 'time_spams_reste' => "'".int_to_heure($rest_spam)."'" , |
---|
203 | |
---|
204 | 'quarantaine' => $quarantaine , |
---|
205 | 'date_quarantaine' => "'".date(l10n('formatdate'),time()+$reste)."'" , |
---|
206 | 'quarantaine_periode' => "'".$mails_données['quarantaine_periode']."'" , |
---|
207 | 'reste' => "'".int_to_heure($reste)."'", |
---|
208 | |
---|
209 | 'message' => $mails_données['message'] , |
---|
210 | 'header_text' => "'".$mails_données['header_text']."'" , |
---|
211 | |
---|
212 | 'PHPWG_VERSION' => PHPWG_VERSION , |
---|
213 | |
---|
214 | |
---|
215 | ) |
---|
216 | ); |
---|
217 | |
---|
218 | $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.tpl'))); |
---|
219 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
220 | |
---|
221 | break; |
---|
222 | |
---|
223 | |
---|
224 | // ************************************************************************* |
---|
225 | // TEST | |
---|
226 | // ************************************************************************* |
---|
227 | |
---|
228 | case 'mail_superv_test': |
---|
229 | |
---|
230 | $mails_données = Get_Datas() ; |
---|
231 | |
---|
232 | $group_id = isset($_POST['group']) ? $_POST['group'] : '-1' ; |
---|
233 | if ($group_id >= 0) { |
---|
234 | $query = ' |
---|
235 | SELECT |
---|
236 | name |
---|
237 | FROM '.GROUPS_TABLE.' |
---|
238 | WHERE id = '.$group_id.' |
---|
239 | ;'; |
---|
240 | list($group_name) = mysql_fetch_row(pwg_query($query)); |
---|
241 | } else { |
---|
242 | $group_name=""; |
---|
243 | } |
---|
244 | //================================================ |
---|
245 | |
---|
246 | |
---|
247 | |
---|
248 | if ( isset($_POST['test_envoie']) ) { |
---|
249 | |
---|
250 | $mails_données['message_test'] = isset($_POST['content']) ? $_POST['content'] : $mails_données['message_test'] ; |
---|
251 | $message=$mails_données['message_test']; |
---|
252 | sauve_données(); |
---|
253 | test_envoie($message,$group_name,$group_id); |
---|
254 | $mails_données = Get_Datas() ; |
---|
255 | |
---|
256 | } |
---|
257 | |
---|
258 | $groups[-1] = '---------'; |
---|
259 | |
---|
260 | $query = ' |
---|
261 | SELECT id, name |
---|
262 | FROM '.GROUPS_TABLE.' |
---|
263 | ORDER BY name ASC |
---|
264 | ;'; |
---|
265 | |
---|
266 | $result = pwg_query($query); |
---|
267 | //---------------------------------------------------------------- |
---|
268 | while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) |
---|
269 | { |
---|
270 | $groups[$row['id']] = $row['name']; |
---|
271 | } |
---|
272 | //--------------------------------------------------------------- |
---|
273 | |
---|
274 | $template->assign( |
---|
275 | 'Group', |
---|
276 | array( |
---|
277 | 'group_options'=> $groups, |
---|
278 | 'selected' => $group_id |
---|
279 | ) |
---|
280 | ); |
---|
281 | //================================================================= |
---|
282 | $destinataires= implode("<br />",get_liste($group_id)); |
---|
283 | $template->assign( |
---|
284 | array( |
---|
285 | 'Groupe' => $groups, |
---|
286 | 'message_test' => $mails_données['message_test'] , |
---|
287 | 'liste' => $destinataires , |
---|
288 | |
---|
289 | ) |
---|
290 | ); |
---|
291 | |
---|
292 | $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_test.tpl'))); |
---|
293 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
294 | break; |
---|
295 | // ************************************************************************* |
---|
296 | // BLACK LISTE | |
---|
297 | // ************************************************************************* |
---|
298 | case 'mail_black_liste': |
---|
299 | load_language('help/plugin.lang', MAIL_SUPERV_PATH); |
---|
300 | $aff_nb=false; |
---|
301 | $smile_bonjour=MAIL_SUPERV_PATH."smilies/bonjour.gif" ; |
---|
302 | $template->assign( |
---|
303 | array( |
---|
304 | 'smile_bonjour' => $smile_bonjour , |
---|
305 | ) |
---|
306 | ); |
---|
307 | $aff_nb = false; |
---|
308 | $liste_bl=array(); |
---|
309 | $liste_ip=array(); |
---|
310 | |
---|
311 | $ip_black=""; |
---|
312 | $info_ip =""; |
---|
313 | |
---|
314 | include (MAIL_SUPERV_PATH.'include/save_info.php'); |
---|
315 | $ip_black_test = (isset($_POST['ip_black_test'])) ? $_POST['ip_black_test'] : $ip_black ; |
---|
316 | if ( isset($_POST['submit']) ) |
---|
317 | { |
---|
318 | $mails_options[3] = isset($_POST['NO_MAIL_LIST']) ? $_POST['NO_MAIL_LIST'] : '' ; |
---|
319 | $mails_options[4] = isset($_POST['NO_CONNECT']) ? $_POST['NO_CONNECT'] : '' ; |
---|
320 | sauve_options(); |
---|
321 | array_push($page['infos'], l10n('save_config')); |
---|
322 | } |
---|
323 | |
---|
324 | |
---|
325 | if ($mails_options[4] == 'on' || $mails_options[3] == 'on' ){ |
---|
326 | if (kill_list()) |
---|
327 | { |
---|
328 | $erreur_message .= l10n('is_a_spam') ; |
---|
329 | }else{ |
---|
330 | |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | $f_action = $my_base_url.'&tab=mail_black_liste' ; |
---|
335 | $champs_ip=array(); |
---|
336 | $champs_bl=array(); |
---|
337 | if (!empty($liste_ip)) $champs_ip=array_keys($liste_ip[0]); |
---|
338 | if (!empty($liste_bl)) $champs_bl=array_keys($liste_bl[0]); |
---|
339 | $smile_bonjour=MAIL_SUPERV_PATH."smilies/mouche.gif" ; |
---|
340 | $template->assign( |
---|
341 | array( |
---|
342 | 'smile_bonjour' => $smile_bonjour , |
---|
343 | 'champs_ip' => $champs_ip , |
---|
344 | 'liste_ip' => $liste_ip, |
---|
345 | 'champs_bl' => $champs_bl , |
---|
346 | 'liste_bl' => $liste_bl , |
---|
347 | 'conf_admin_layout' => $conf['admin_layout'] , |
---|
348 | 'ip_black' => $ip_black , |
---|
349 | 'IS_SPAM' => test_spam( $ip_black_test ), |
---|
350 | 'ip_black_test' => (isset($_POST['ip_black_test']) ) ? $_POST['ip_black_test'] : $ip_black , |
---|
351 | 'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH , |
---|
352 | |
---|
353 | 'F_ACTION' => $f_action , |
---|
354 | 'IP' => $_SERVER['REMOTE_ADDR'], |
---|
355 | 'NO_MAIL_LIST' => $mails_options[3] == 'on' ? 'checked="checked"' : '' , |
---|
356 | 'NO_CONNECT' => $mails_options[4] == 'on' ? 'checked="checked"' : '' , |
---|
357 | ) |
---|
358 | ); |
---|
359 | //=============================================================== |
---|
360 | |
---|
361 | $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_black_liste.tpl'))); |
---|
362 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
363 | break; |
---|
364 | |
---|
365 | // ************************************************************************* |
---|
366 | // AIDE | |
---|
367 | // ************************************************************************* |
---|
368 | case 'mail_superv_help': |
---|
369 | |
---|
370 | load_language('help/plugin.lang', MAIL_SUPERV_PATH); |
---|
371 | |
---|
372 | $aff_nb=false; |
---|
373 | $smile_bonjour=MAIL_SUPERV_PATH."smilies/bonjour.gif" ; |
---|
374 | $template->assign( |
---|
375 | array( |
---|
376 | 'smile_bonjour' => $smile_bonjour , |
---|
377 | ) |
---|
378 | ); |
---|
379 | $aff_nb = false; |
---|
380 | ; |
---|
381 | |
---|
382 | $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_help.tpl'))); |
---|
383 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
384 | break; |
---|
385 | //==================================================================== |
---|
386 | } |
---|
387 | //================================================================================ |
---|
388 | |
---|
389 | |
---|
390 | if ( $mails_données['reste'] < 0 ) { |
---|
391 | $mails_données['quarantaine'] =false ; |
---|
392 | $mails_données['date_quarantaine']= time() ; |
---|
393 | $mails_données['nb_spams'] = 0 ; |
---|
394 | $modif == true ; |
---|
395 | } |
---|
396 | |
---|
397 | |
---|
398 | $rest_mail = $mails_données['rest_mail'] ; |
---|
399 | if ($rest_mail <=0 || $mails_données['nb_mails'] ==0 ){ |
---|
400 | $mails_données['nb_mails'] =0 ; |
---|
401 | $mails_données['date_mail'] = time(); |
---|
402 | $modif = true ; |
---|
403 | } |
---|
404 | |
---|
405 | $rest_spam = $mails_données['rest_spam'] ; |
---|
406 | |
---|
407 | if ($rest_spam <=0 || $mails_données['nb_spams'] ==0 ){ |
---|
408 | $mails_données['nb_spams'] =0 ; |
---|
409 | $mails_données['date_spam'] = time(); |
---|
410 | $modif = true ; |
---|
411 | } |
---|
412 | if ( $modif == true ) { |
---|
413 | sauve_données(); |
---|
414 | $modif = false ; |
---|
415 | } |
---|
416 | if (!isset($infos_message)){ |
---|
417 | $infos_message = ""; |
---|
418 | } |
---|
419 | if ($aff_nb == true) { |
---|
420 | $infos_message .= 'Mails : '.$mails_données['nb_mails']. ' \\ ' . $mails_données['nb_mails_maxi']; |
---|
421 | $infos_message .= "\n".'Spams : '.$mails_données['nb_spams']. ' \\ ' . $mails_données['nb_spams_maxi']; |
---|
422 | } |
---|
423 | |
---|
424 | |
---|
425 | |
---|
426 | if ($infos_message != "") { |
---|
427 | array_push($page['infos'], $infos_message); |
---|
428 | $infos_message=""; |
---|
429 | } |
---|
430 | if (!isset($erreur_message)){ |
---|
431 | $erreur_message = ""; |
---|
432 | } |
---|
433 | if ($erreur_message != "") { |
---|
434 | |
---|
435 | array_push($page['errors'], $erreur_message); |
---|
436 | $erreur_message=""; |
---|
437 | |
---|
438 | |
---|
439 | } |
---|
440 | |
---|
441 | //======================================================================== |
---|
442 | |
---|
443 | |
---|
444 | ?> |
---|