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

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

[mail_supervisor] Fix Bug 'session_start() ' delete space in functions.php

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