source: extensions/Mail_supervisor/admin/mail_superv_admin.php @ 4715

Last change on this file since 4715 was 4715, checked in by cljosse, 14 years ago

[mail_supervisor] Add option for new register

File size: 17.9 KB
Line 
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
24if ( !defined('PHPWG_ROOT_PATH')) 
25{
26  die('Hacking attempt!');
27}
28
29if (!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);
36include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
37include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
38
39
40$my_base_url = get_admin_plugin_menu_link(__FILE__);
41 load_language('plugin.lang', MAIL_SUPERV_PATH);
42
43
44        if (!isset($_GET['tab']))
45        $page['tab'] = 'mail_superv_admin';
46else
47  $page['tab'] = $_GET['tab'];
48
49 $icon_path = 'template/yoga/icon/help.png';
50
51$tabhelp=  '  <img src="'.PHPWG_ROOT_PATH. $icon_path .'" class="button" alt="(?)"> ';
52
53 
54
55$tabsheet = new tabsheet();
56$tabsheet->add('mail_superv_admin',
57               l10n('Tab_set'),
58               $my_base_url.'&amp;tab=mail_superv_admin');
59                           
60$tabsheet->add('mail_superv_test',
61               l10n('Tab_test'),
62               $my_base_url.'&amp;tab=mail_superv_test');
63                           
64$tabsheet->add( 'mail_black_liste',
65               l10n('blackliste'),
66                           $my_base_url.'&amp;tab=mail_black_liste');
67 
68                                                   
69$tabsheet->add('mail_superv_help',$tabhelp
70              ,
71               $my_base_url.'&amp;tab=mail_superv_help');
72                           
73                           
74$tabsheet->select($page['tab']);
75$tabsheet->assign();
76
77$page['global'] = array();
78$error = array();
79
80global $user, $lang, $conf, $errors,$mails_données;
81global $args, $conf_mail,$infos_message,$erreur_message,$mails_options ;
82include_once (MAIL_SUPERV_PATH.'include/constants.php'); 
83
84if (isset($conf['mail_superv'])) {
85
86include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
87            global $pays,$region,$ville,$ip ;   
88                if(!isset($pays)) Get_geo();
89               
90$mails_options = explode("," , $conf['mail_superv']); 
91        if (!isset($mails_options[7])) $mails_options[7] = 'off' ; //set_id
92                if (!isset($mails_options[6])) $mails_options[6] = $ip   ;
93                if (!isset($mails_options[5])) $mails_options[5] = 'off' ;
94                if (!isset($mails_options[4])) $mails_options[4] = 'off' ;
95                if (!isset($mails_options[3])) $mails_options[3] = 'off' ;
96               
97                if (!isset($mails_options[2])) $mails_options[2] = 'off' ;
98                if (!isset($mails_options[1])) $mails_options[1] = 'off' ;
99                if (!isset($mails_options[0])) $mails_options[0] = 'off' ;
100               
101$mails_données = Get_Datas();
102
103
104}else {
105die ("mail");
106}
107
108
109$aff_nb=true;
110
111
112// *************************************************************************
113// |                          Sélection de l'onglet                        |
114// *************************************************************************
115
116                $modif=false ;
117                $sql="SELECT *
118FROM `".$prefixeTable."plugins`
119WHERE `id` LIKE 'Mail_supervisor'
120";
121 $result = @pwg_query($sql);
122        if ($result) {
123            $versions = mysql_fetch_array($result,MYSQL_ASSOC);
124        }
125$version= $versions['version'];
126//================================================================================
127switch ($page['tab'])
128 {
129   
130// *************************************************************************
131//                         initialisation                                  |
132// *************************************************************************
133  case 'mail_superv_admin':
134       
135//=============================================================
136if ( isset($_POST['submit']) ) {
137if ( $_POST['submit'] == l10n('refresh')   ) {
138
139               
140        if ($mails_données['nb_mails'] == 0 ) 
141            $mails_données['date_mail'] = time();       
142       
143        if ($mails_données['nb_spams'] == 0 )
144           $mails_données['date_spam'] = time();
145       
146       
147        if ($mails_données['quarantaine'] == false)
148        { $mails_données['reste'] = 0;
149          $mails_données['date_quarantaine']=time();
150         }
151         $infos_message .=  l10n('refresh') .'<br />';
152     sauve_données();
153        $aff_nb = false ;
154 
155       
156        }
157
158if ( $_POST['submit'] == l10n('raz')   ) {
159
160        $mails_données['date_quarantaine']=time();
161        $mails_données['nb_mails'] = 0  ;
162        $mails_données['nb_spams'] = 0  ;
163        $mails_données['date_mail'] = time();
164        $mails_données['date_spam'] = time();
165       
166        $mails_données['reste'] = 0;
167        $mails_données['quarantaine']='false';
168       
169     sauve_données();
170         $infos_message .=  l10n('raz') .'<br />'; ;
171       
172        }
173
174if ( $_POST['submit'] == l10n('Valider') ) 
175{
176
177  $mails_options[0] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : 'off' ;
178  $mails_options[1] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : 'off' ;
179  $mails_options[2] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : 'off' ;
180 
181//données 
182$mails_données['nb_mails_maxi'] = isset($_POST['nb_mails_maxi']) ? $_POST['nb_mails_maxi'] :  $mails_données['nb_mails_maxi']  ;
183$mails_données['nb_mails_periode'] = isset($_POST['nb_mails_periode']) ? $_POST['nb_mails_periode'] :  $mails_données['nb_mails_periode']  ;
184$mails_données['nb_spams_maxi'] = isset($_POST['nb_spams_maxi']) ? $_POST['nb_spams_maxi'] :  $mails_données['nb_spams_maxi']  ;
185$mails_données['nb_spams_periode'] = isset($_POST['nb_spams_periode']) ? $_POST['nb_spams_periode'] :  $mails_données['nb_spams_periode']  ;
186$mails_données['quarantaine_periode'] = isset($_POST['quarantaine_periode']) ? $_POST['quarantaine_periode'] :  $mails_données['quarantaine_periode']  ;
187
188$mails_données['message'] = isset($_POST['content']) ? $_POST['content'] :  $mails_données['message']  ;
189$mails_données['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] :  $mails_données['header_text']  ;
190  //=======================================================================================================
191         sauve_options();
192         sauve_données();
193//=======================================================================================================
194                $infos_message .=  l10n('save_config') . " : " . l10n('Datas') . "<br />" ;
195}
196}
197       
198        $mails_données = Get_Datas();
199
200        $rest_mail= $mails_données['rest_mail'];       
201        $rest_spam= $mails_données['rest_spam'];       
202    $reste= $mails_données['reste'];   
203
204$quarantaine = ($mails_données['quarantaine'] == 'true') ? true : false ;;     
205
206         
207       
208$PHPWG_VERSION=PHPWG_VERSION;
209
210$template->assign(
211                                        array(
212   'check_mailto' => ($mails_options[0] == 'on') ? 'checked="checked"' : '' ,
213   'check_header_carbons' => ($mails_options[1] == 'on') ? 'checked="checked"' : '' ,
214   'check_header_text' => ($mails_options[2] == 'on') ? 'checked="checked"' : '' ,
215
216   
217        'nb_mails' => $mails_données['nb_mails'] ,
218        'date_mail' => "'".date(l10n('formatdate'),$mails_données['date_mail'])."'" ,
219        'nb_mails_maxi' => $mails_données['nb_mails_maxi'] ,   
220        'nb_mails_periode' => "'".$mails_données['nb_mails_periode']."'" ,     
221        'time_mails_reste' => "'".int_to_heure( $rest_mail )."'" ,     
222       
223        'nb_spams' => $mails_données['nb_spams'] ,
224        'date_spam' => "'".date(l10n('formatdate'),$mails_données['date_spam'])."'" ,
225        'nb_spams_maxi' => $mails_données['nb_spams_maxi'] ,   
226         'nb_spams_periode' => "'".$mails_données['nb_spams_periode']."'" ,
227         'time_spams_reste' => "'".int_to_heure($rest_spam)."'" ,       
228         
229         'quarantaine' => $quarantaine ,
230        'date_quarantaine' => "'".date(l10n('formatdate'),time()+$reste)."'" ,
231        'quarantaine_periode' => "'".$mails_données['quarantaine_periode']."'" ,
232     'reste' => "'".int_to_heure($reste)."'",
233 
234    'message' => $mails_données['message'] ,
235        'header_text' => "'".$mails_données['header_text']."'" ,
236       
237    'PHPWG_VERSION' =>   PHPWG_VERSION ,
238         'version' =>    $version ,
239       
240                                                )
241                                );     
242
243        $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.tpl')));
244                $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
245               
246 break; 
247 
248 
249// *************************************************************************
250//                        TEST                                             |
251// *************************************************************************
252 
253   case 'mail_superv_test':
254   
255   $mails_données = Get_Datas() ;
256   
257        $group_id = isset($_POST['group']) ? $_POST['group'] :  '-1'  ;
258        if ($group_id >= 0) {
259      $query = '
260                SELECT
261                name
262                FROM '.GROUPS_TABLE.'
263                WHERE id = '.$group_id.'
264                ;';
265                list($group_name) = mysql_fetch_row(pwg_query($query));
266                }       else {
267                                $group_name="";         
268                }               
269//================================================
270
271
272       
273if ( isset($_POST['test_envoie']) ) {
274       
275                $mails_données['message_test'] = isset($_POST['content']) ? $_POST['content'] :  $mails_données['message_test']  ;
276                $message=$mails_données['message_test'];
277                sauve_données();
278                test_envoie($message,$group_name,$group_id);   
279                $mails_données = Get_Datas() ;
280               
281  } 
282
283  $groups[-1] = '---------';
284
285  $query = '
286    SELECT id, name
287                FROM '.GROUPS_TABLE.'
288                ORDER BY name ASC
289                ;';
290
291  $result = pwg_query($query);
292//----------------------------------------------------------------     
293  while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
294  {
295    $groups[$row['id']] = $row['name'];
296  }
297 //---------------------------------------------------------------
298
299  $template->assign(
300        'Group',
301                array(
302                        'group_options'=> $groups,
303                        'selected' => $group_id 
304                        )
305                );
306//=================================================================
307$destinataires= implode("<br />",get_liste($group_id));
308  $template->assign(
309                                        array(
310                                'Groupe'     => $groups,
311                        'message_test' => $mails_données['message_test'] ,
312                                'liste' => $destinataires ,
313 'version' =>    $version ,
314                                                )
315                                );     
316                               
317        $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_test.tpl')));
318                $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
319   break;
320// *************************************************************************
321//              BLACK LISTE                                         |
322// *************************************************************************   
323     case 'mail_black_liste':
324                load_language('help/plugin.lang', MAIL_SUPERV_PATH);   
325
326                global $user_name,$mail_adresse,$ip ;
327 
328                $aff_nb=false;
329 //------------------------------------------------------------------------------------
330
331        $mails_options[3] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : $mails_options[3] ;
332        $mails_options[4] = isset($_POST['no_connect']) ? $_POST['no_connect'] : $mails_options[4] ;
333            $mails_options[5] = isset($_POST['no_connect']) ? $_POST['no_connect'] : $mails_options[5] ;               
334
335//=======================================================================================       
336    $info_ip = (isset($info_ip)) ? $info_ip : '' ;
337    $info_ip = (isset($_POST['info1'])) ? $_POST['info1'] : $info_ip ;
338    $info_ip = (isset($_POST['info'])) ? $_POST['info'] : $info_ip ;
339    $info_ip .= ":";
340 
341   $val=explode(":",$info_ip);
342   $info_ip = trim($val[0]) ;
343   $ip_black = trim($val[1]) ;
344 
345  if (isset($_POST['ip_black']))   $ip_black = ($ip_black == "" ) ? $_POST['ip_black'] : $ip_black ;
346   
347                        $istype="";
348                               
349        if ( isset($_POST['submit']) )
350                {
351
352        if (clj_is_ip($ip_black)) $istype='IP';
353       
354        elseif (clj_is_mail($ip_black))  $istype='MAIL';
355       
356 else   $istype='LOGIN';
357       
358                        if (  $_POST['submit'] == l10n('Ajout') )
359                {
360                               $info_ip = 'Ajout' ;
361                   $ip_black = trim( $_POST['ip_black']) ;
362                               $infos_message .= $info_ip . '---->'. $ip_black ;   
363                        }
364                        if (  $_POST['submit'] == l10n('Valider') )
365                {
366                                $mails_options[3] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : "off" ;
367                        $mails_options[4] = isset($_POST['no_connect']) ? $_POST['no_connect'] : "off" ;
368                        $mails_options[5] = isset($_POST['set_auto']) ? $_POST['set_auto'] : "off" ;
369                                $mails_options[7] = isset($_POST['set_auto']) ? $_POST['set_id'] : "off" ;
370                                sauve_options();
371                            $infos_message .=  l10n('save_config') . '<br />';   
372                           
373                        }
374                }       
375
376include  (MAIL_SUPERV_PATH.'include/save_info.php');       
377
378//=======================================================================================       
379        $f_action  = $my_base_url.'&amp;tab=mail_black_liste' ;
380        $champs_ip=array();
381        $champs_bl=array();
382        if (!empty($liste_ip))          $champs_ip=array_keys($liste_ip[0]);
383        if (!empty($liste_bl))      $champs_bl=array_keys($liste_bl[0]);
384        $smile_bonjour=MAIL_SUPERV_PATH."smilies/mouche.gif" ; 
385          $img_logo=MAIL_SUPERV_PATH."smilies/logo.png" ; 
386     $template->assign(
387                                        array(
388                                            'smile_bonjour' => $smile_bonjour ,
389                                                'img_logo' => $img_logo ,
390                                'champs_ip' => $champs_ip ,                                     
391                                                'liste_ip' => $liste_ip,
392                                                'champs_bl' =>  $champs_bl       ,     
393                                                'liste_bl' => $liste_bl ,
394                                'conf_admin_layout' => $conf['admin_layout'] ,
395                                                'istype' => $istype ,
396                                                'ip_black' => $ip_black ,
397                                                'IS_SPAM' => test_spam(  $ip_black),
398                                                'ip_black_len' =>  strlen($ip_black)  ,
399                                                'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
400
401                                                'F_ACTION' => $f_action ,
402                                               
403                                                'no_mail_list' => ($mails_options[3] == 'on') ? 'checked="checked"' : '' ,
404                        'no_connect' => ($mails_options[4] == 'on') ? 'checked="checked"' : '' ,
405                                                'set_auto' => ($mails_options[5] == 'on') ? 'checked="checked"' : '' ,
406                                                'set_id' => ($mails_options[7] == 'on') ? 'checked="checked"' : '' ,
407                                                'IP' =>  $ip ,                                         
408                                                'PAYS' =>  $pays  ,
409                                'VILLE' =>  $ville ,
410                                'REGION' =>  $region , 
411                                                 'version' =>    $version ,
412                                        )
413                                );                       
414         //===============================================================     
415               
416                                 
417                $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_black_liste.tpl')));
418                $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
419   break; 
420
421// *************************************************************************
422//                      AIDE                                               |
423// *************************************************************************   
424     case 'mail_superv_help':
425
426   load_language('help/plugin.lang', MAIL_SUPERV_PATH); 
427 
428          $aff_nb=false;
429          $smile_bonjour=MAIL_SUPERV_PATH."smilies/bonjour.gif" ; 
430      $template->assign(
431                                        array(
432                                        'smile_bonjour' => $smile_bonjour ,
433                                         'version' =>    $version ,
434                                        )
435                        );             
436        $aff_nb = false;
437        ;
438         
439                $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_help.tpl')));
440                $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
441   break; 
442 //====================================================================
443  }
444//================================================================================
445
446
447        if  ( $mails_données['reste'] < 0 ) {
448            $mails_données['quarantaine'] =false ;
449            $mails_données['date_quarantaine']= time()  ;       
450                $mails_données['nb_spams'] = 0 ;
451            $modif == true ;
452        }
453         
454         
455        $rest_mail =    $mails_données['rest_mail'] ;
456        if ($rest_mail <=0 || $mails_données['nb_mails'] ==0 ){
457           $mails_données['nb_mails'] =0 ;
458           $mails_données['date_mail'] = time();
459           $modif = true ;
460        }
461       
462        $rest_spam =    $mails_données['rest_spam'] ;
463
464        if ($rest_spam <=0 || $mails_données['nb_spams'] ==0 ){
465           $mails_données['nb_spams'] =0 ;
466           $mails_données['date_spam'] = time();
467           $modif = true ;
468        }
469        if ( $modif == true )   { 
470                                sauve_données();
471                                $modif = false ;
472                }
473                if (!isset($infos_message)){
474                  $infos_message = "";
475                } 
476                if ($aff_nb == true) {
477                 $infos_message .= 'Mails    : '.$mails_données['nb_mails']. '  \\  ' . $mails_données['nb_mails_maxi'];
478                 $infos_message .= "\n".'Spams : '.$mails_données['nb_spams']. '  \\  ' . $mails_données['nb_spams_maxi'];
479                }
480               
481
482                 
483                if  ($infos_message != "")  {
484                   array_push($page['infos'],  $infos_message);
485                 $infos_message="";
486                 }
487                if (!isset($erreur_message)){
488                  $erreur_message = "";
489                }               
490                if  ($erreur_message != "")  {
491       
492                  array_push($page['errors'], $erreur_message);
493                  $erreur_message="";
494       
495                 
496                 }               
497                 
498//========================================================================     
499       
500                 
501?>
Note: See TracBrowser for help on using the repository browser.