Index: extensions/Mail_supervisor/admin/mail_superv_admin.php
===================================================================
--- extensions/Mail_supervisor/admin/mail_superv_admin.php	(revision 8917)
+++ extensions/Mail_supervisor/admin/mail_superv_admin.php	(revision 9702)
@@ -22,8 +22,5 @@
 // +-----------------------------------------------------------------------+
 
-if ( !defined('PHPWG_ROOT_PATH')) 
-{
-  die('Hacking attempt!');
-}
+if ( !defined('PHPWG_ROOT_PATH')) {  die('Hacking attempt!');}
 
 if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
@@ -38,6 +35,4 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
 include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
-
-
 $my_base_url = get_admin_plugin_menu_link(__FILE__);
 
@@ -102,61 +97,41 @@
 $error = array();
 
-
+include_once (MAIL_SUPERV_PATH.'mail_super.inc.php'); 
 include_once (MAIL_SUPERV_PATH.'include/constants.php'); 
 
-	if (!isset($infos_message))
-	{
-    	$infos_message = "";
-	}
-if (!isset($erreur_message))
-	{
-    	$erreur_message = "";
-	}
+  if (!isset($infos_message))	{
+      $infos_message = "";
+  }
+  if (!isset($erreur_message)){
+      $erreur_message = "";
+  }
 
 if (isset($conf['mail_superv'])) {
-
-include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
-	    global $pays,$region,$ville,$ip ;	
-
-		
-$mails_options = explode("," , $conf['mail_superv']); 
-        if (!isset($mails_options[set_id])) $mails_options[set_id] = 'off' ;  // 7
-		if (!isset($mails_options[ip])) $mails_options[ip] = $ip   ;  //6
-		if (!isset($mails_options[set_auto])) $mails_options[set_auto] = 'off' ;  //5
-		if (!isset($mails_options[no_connect])) $mails_options[no_connect] = 'off' ;  //4
-		if (!isset($mails_options[no_mail_list])) $mails_options[no_mail_list] = 'off' ;  //3
-		
-		if (!isset($mails_options[check_header_text])) $mails_options[check_header_text] = 'off' ;  //2
-		if (!isset($mails_options[check_header_carbon])) $mails_options[check_header_carbon] = 'off' ;  //1
-		if (!isset($mails_options[check_mailto])) $mails_options[check_mailto] = 'off' ;  //0
+   global $pays,$region,$ville,$ip ;	
+    include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
 //================================================================================================	
-$mails_options[set_auto] = 'off' ;
-$mails_options[no_connect] = 'off' ;
-	
-$mails_donnees = Get_Datas();
-
-
+
+   $mails_donnees = mail_supervisor::Get_Datas();
 }else {
-die ("mail");
+    die ("mail");
 }
 
 
 $aff_nb=true;
-
 // *************************************************************************
 // |                          Selection de l'onglet                        |
 // *************************************************************************
-
-	 	$modif=false ;
-
-	$plugin =  Get_Version_plugins( MAIL_SUPERV_PATH);
-	$version = $plugin['version'] ;
+  $modif=false ;
+  $plugin =  mail_supervisor::Get_Version_plugins( MAIL_SUPERV_PATH);
+  $version = $plugin['version'] ;
  //=========================================================
-
-		if (!isset($ip)) {
-		       if (getenv("HTTP_CLIENT_IP"))
-					    {    $ip=getenv("HTTP_CLIENT_IP"); 	}
-					else{   $ip=getenv("REMOTE_ADDR"); 	}
-			   }
+  if (!isset($ip)) {
+	  if (getenv("HTTP_CLIENT_IP")){    
+      $ip=getenv("HTTP_CLIENT_IP"); 	
+    } else{   
+      $ip=getenv("REMOTE_ADDR"); 	
+    }
+  }
+               
 //================================================================================
 switch ($page['tab'])
@@ -185,5 +160,5 @@
 	 }
 	 $infos_message .=  l10n('Sv_refresh') .'<br />';
-     sauve_donnees();
+     mail_supervisor::sauve_donnees();
  	 $aff_nb = false ;
  
@@ -192,102 +167,87 @@
 
 	if ( $_POST['submit'] == l10n('Sv_raz')   ) {
-
-	$mails_donnees['date_quarantaine']=time();
-	$mails_donnees['nb_mails'] = 0  ;
-	$mails_donnees['nb_spams'] = 0  ;
-	$mails_donnees['date_mail'] = time();
-	$mails_donnees['date_spam'] = time();
-	
-	$mails_donnees['reste'] = 0;
-	$mails_donnees['quarantaine']='false';
-	
-     sauve_donnees();
-	 $infos_message .=  l10n('Sv_raz') .'<br />'; ;
-	
+	 $mails_donnees['date_quarantaine']=time();
+	 $mails_donnees['nb_mails'] = 0  ;
+	 $mails_donnees['nb_spams'] = 0  ;
+	 $mails_donnees['date_mail'] = time();
+	 $mails_donnees['date_spam'] = time();	
+	 $mails_donnees['reste'] = 0;
+	 $mails_donnees['quarantaine']='false';	
+    mail_supervisor::sauve_donnees();
+	 $infos_message .=  l10n('Sv_raz') .'<br />'; 	
 	}
 
   //===================================================================
-	if ( $_POST['submit'] == l10n('Sv_Valider') )  
-		{
-  		$mails_options[check_mailto] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : 'off' ;               
-  		$mails_options[check_header_carbon] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : 'off' ; 
-  		$mails_options[check_header_text] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : 'off' ;     
+	if ( $_POST['submit'] == l10n('Sv_Valider') ) {
+    $mails_options['check_mailto'] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : 'off' ;               
+    $mails_options['check_header_carbon'] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : 'off' ; 
+    $mails_options['check_header_text'] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : 'off' ;     
   
-		//donnees  
-		$mails_donnees['nb_mails_maxi'] = isset($_POST['nb_mails_maxi']) ? $_POST['nb_mails_maxi'] :  $mails_donnees['nb_mails_maxi']  ;
-		$mails_donnees['nb_mails_periode'] = isset($_POST['nb_mails_periode']) ? $_POST['nb_mails_periode'] :  $mails_donnees['nb_mails_periode']  ;  
-		$mails_donnees['nb_spams_maxi'] = isset($_POST['nb_spams_maxi']) ? $_POST['nb_spams_maxi'] :  $mails_donnees['nb_spams_maxi']  ;
-		$mails_donnees['nb_spams_periode'] = isset($_POST['nb_spams_periode']) ? $_POST['nb_spams_periode'] :  $mails_donnees['nb_spams_periode']  ;
-
-		$mails_donnees['quarantaine_periode'] = isset($_POST['quarantaine_periode']) ? $_POST['quarantaine_periode'] :  $mails_donnees['quarantaine_periode']  ;
- 
-			$mails_donnees['message'] = isset($_POST['content']) ? $_POST['content'] :  $mails_donnees['message']  ;
-			$mails_donnees['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] :  $mails_donnees['header_text']  ;
- //=======================================================================================================
-	 		verif_mails_donnees();
-		 	sauve_options();
-         	sauve_donnees();
-//=======================================================================================================
-			$infos_message  =  l10n('Sv_save_config') . " : " . l10n('Sv_Datas') . "<br />" ;
-			$erreur_message = "";
-			$mails_donnees = Get_Datas() ;
-   			}
-       }
-	
-	$mails_donnees = Get_Datas();
+    //donnees  
+    $mails_donnees['nb_mails_maxi'] = isset($_POST['nb_mails_maxi']) ? $_POST['nb_mails_maxi'] :  $mails_donnees['nb_mails_maxi']  ;
+    $mails_donnees['nb_mails_periode'] = isset($_POST['nb_mails_periode']) ? $_POST['nb_mails_periode'] :  $mails_donnees['nb_mails_periode']  ;  
+    $mails_donnees['nb_spams_maxi'] = isset($_POST['nb_spams_maxi']) ? $_POST['nb_spams_maxi'] :  $mails_donnees['nb_spams_maxi']  ;
+    $mails_donnees['nb_spams_periode'] = isset($_POST['nb_spams_periode']) ? $_POST['nb_spams_periode'] :  $mails_donnees['nb_spams_periode']  ;
+
+    $mails_donnees['quarantaine_periode'] = isset($_POST['quarantaine_periode']) ? $_POST['quarantaine_periode'] :  $mails_donnees['quarantaine_periode']  ;
+ 
+    $mails_donnees['message'] = isset($_POST['content']) ? $_POST['content'] :  $mails_donnees['message']  ;
+    $mails_donnees['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] :  $mails_donnees['header_text']  ;
+    //=======================================================================================================
     verif_mails_donnees();
-//===============================================================================
- 
-	$rest_mail= $mails_donnees['rest_mail'];  	
- 	$rest_spam= $mails_donnees['rest_spam'];  	
-    $reste= $mails_donnees['reste'];  	
-
-$quarantaine = ($mails_donnees['quarantaine'] == 'true') ? true : false ;	
-
-$template->assign(
+    mail_supervisor::sauve_options();
+    mail_supervisor::sauve_donnees();
+    //==============================================================================
+    $infos_message  =  l10n('Sv_save_config') . " : " . l10n('Sv_Datas') . "<br />" ;
+    $erreur_message = "";
+    $mails_donnees = mail_supervisor::Get_Datas() ;
+  }
+ }	
+	$mails_donnees = mail_supervisor::Get_Datas();
+ verif_mails_donnees();
+//=============================================================================== 
+ $rest_mail= $mails_donnees['rest_mail'];  	
+ $rest_spam= $mails_donnees['rest_spam'];  	
+ $reste= $mails_donnees['reste'];  
+ $quarantaine = ($mails_donnees['quarantaine'] == 'true') ? true : false ;	
+ $template->assign(
   					array(
-   'check_mailto' => ($mails_options[check_mailto] == 'on') ? 'checked="checked"' : '' ,
-   'check_header_carbons' => ($mails_options[check_header_carbon] == 'on') ? 'checked="checked"' : '' ,
-   'check_header_text' => ($mails_options[check_header_text] == 'on') ? 'checked="checked"' : '' ,
+                        'check_mailto' => ($mails_options['check_mailto'] == 'on') ? 'checked="checked"' : '' ,
+                        'check_header_carbons' => ($mails_options['check_header_carbon'] == 'on') ? 'checked="checked"' : '' ,
+                        'check_header_text' => ($mails_options['check_header_text'] == 'on') ? 'checked="checked"' : '' ,
 
    
-   	'nb_mails' => $mails_donnees['nb_mails'] ,
-   	'date_mail' => "'".date(l10n('Sv_formatdate'),$mails_donnees['date_mail'])."'" ,
-   	'nb_mails_maxi' => $mails_donnees['nb_mails_maxi'] ,	
-	'nb_mails_periode' => "'". int_to_heure($mails_donnees['nb_mails_periode'])."'" ,	
- 	'time_mails_reste' => "'".int_to_heure( $rest_mail )."'" ,	
-	
-  	'nb_spams' => $mails_donnees['nb_spams'] ,
-	'date_spam' => "'".date(l10n('Sv_formatdate'),$mails_donnees['date_spam'])."'" ,
-	'nb_spams_maxi' => $mails_donnees['nb_spams_maxi'] ,	
-	 'nb_spams_periode' => "'".int_to_heure($mails_donnees['nb_spams_periode'])."'" ,
-	 'time_spams_reste' => "'".int_to_heure($rest_spam)."'" ,	
+                        'nb_mails' => $mails_donnees['nb_mails'] ,
+                        'date_mail' => "'".date(l10n('Sv_formatdate'),$mails_donnees['date_mail'])."'" ,
+                        'nb_mails_maxi' => $mails_donnees['nb_mails_maxi'] ,	
+                        'nb_mails_periode' => "'". int_to_heure($mails_donnees['nb_mails_periode'])."'" ,	
+                        'time_mails_reste' => "'".int_to_heure( $rest_mail )."'" ,	
+	
+                        'nb_spams' => $mails_donnees['nb_spams'] ,
+                        'date_spam' => "'".date(l10n('Sv_formatdate'),$mails_donnees['date_spam'])."'" ,
+                        'nb_spams_maxi' => $mails_donnees['nb_spams_maxi'] ,	
+                        'nb_spams_periode' => "'".int_to_heure($mails_donnees['nb_spams_periode'])."'" ,
+                        'time_spams_reste' => "'".int_to_heure($rest_spam)."'" ,	
 	 
-	 'quarantaine' => $quarantaine ,
-  	'date_quarantaine' => "'".date(l10n('Sv_formatdate'),time()+$reste)."'" ,
-	'quarantaine_periode' => "'".int_to_heure($mails_donnees['quarantaine_periode'])."'" ,
-     'reste' => "'".int_to_heure($reste)."'",
- 
-    'message' => $mails_donnees['message'] ,
-	'header_text' => "'".$mails_donnees['header_text']."'" ,
-	
-    'PHPWG_VERSION' =>	 PHPWG_VERSION ,
-	 'version' =>	 $version ,
-	'MAIL_SUPERV_PATH' =>  MAIL_SUPERV_PATH ,
-	'path_js' => $path_js,
-    'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
+                        'quarantaine' => $quarantaine ,
+                        'date_quarantaine' => "'".date(l10n('Sv_formatdate'),time()+$reste)."'" ,
+                        'quarantaine_periode' => "'".int_to_heure($mails_donnees['quarantaine_periode'])."'" ,
+                        'reste' => "'".int_to_heure($reste)."'",
+ 
+                        'message' => $mails_donnees['message'] ,
+                        'header_text' => "'".$mails_donnees['header_text']."'" ,
+	
+                        'PHPWG_VERSION' =>	 PHPWG_VERSION ,
+                        'version' =>	 $version ,
+                        'MAIL_SUPERV_PATH' =>  MAIL_SUPERV_PATH ,
+                        'path_js' => $path_js,
+                        'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
      
 		 				)
-				);	
-
-	$template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.tpl')));
- 
-
-	$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
-		
+				);	                  
+	 $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.tpl')));
+	 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');		
  break; 
- 
- 
-// *************************************************************************
+  // *************************************************************************
 //                        TEST                                             |
 // *************************************************************************
@@ -295,5 +255,5 @@
    case 'mail_superv_test':
    		load_language('plugin.lang', MAIL_SUPERV_PATH); 
-   		$mails_donnees = Get_Datas() ;
+   		$mails_donnees = mail_supervisor::Get_Datas() ;
    		$group_id = isset($_POST['group']) ? $_POST['group'] :  '-1'  ;
 
@@ -354,6 +314,6 @@
 
  	unset_make_full_url();
-	sauve_donnees();
-	$mails_donnees = Get_Datas() ;
+	mail_supervisor::sauve_donnees();
+	$mails_donnees = mail_supervisor::Get_Datas() ;
     $query = 'SELECT
     		name
@@ -426,50 +386,36 @@
 //              BLACK LISTE                                         |
 // *************************************************************************   
-     case 'mail_black_liste':
-		global $user_name,$mail_adresse,$ip ;
- 	  	$aff_nb=false;
- //------------------------------------------------------------------------------------
-      	$mails_options[no_mail_list] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : $mails_options[no_mail_list] ;
-      	$mails_options[no_connect] = 'off' ;//isset($_POST['no_connect']) ? $_POST['no_connect'] : $mails_options[no_connect] ;
-	    $mails_options[set_auto] = 'off' ;//isset($_POST['set_auto']) ? $_POST['set_auto'] : $mails_options[set_auto] ;		
-//=======================================================================================	
-    $info_ip = (isset($info_ip)) ? $info_ip : '' ;
-    $info_ip = (isset($_POST['info1'])) ? $_POST['info1'] : $info_ip ;
-    $info_ip = (isset($_POST['info'])) ? $_POST['info'] : $info_ip ;
-    $info_ip .= ":";
-   $val=explode(":",$info_ip);
-   $info_ip = trim($val[0]) ;
-   $ip_black = trim($val[1]) ;
-
+ case 'mail_black_liste': 
+  global $user_name,$mail_adresse,$ip ;
+  $aff_nb=false;
+  //=======================================================================================	
+  $info_ip = (isset($info_ip)) ? $info_ip : '' ;
+  $info_ip = (isset($_POST['info1'])) ? $_POST['info1'] : $info_ip ;
+  $info_ip = (isset($_POST['info'])) ? $_POST['info'] : $info_ip ;
+  $info_ip .= ":";
+  $val=explode(":",$info_ip);
+  $info_ip = trim($val[0]) ;
+  $ip_black = trim($val[1]) ;
   if (isset($_POST['ip_black']))   $ip_black = ($ip_black == "" ) ? $_POST['ip_black'] : $ip_black ;
-   
-		 	$istype="";
-		 
-		 
-	if ( isset($_POST['submit']) )
-		{
-
-	if (clj_is_ip($ip_black)) $istype='IP';
-	 elseif (clj_is_mail($ip_black))  $istype='MAIL';
-     else   $istype='LOGIN';
-	 
-			if (  $_POST['submit'] == l10n('Sv_Ajout') )
-      		{
-			       $info_ip = 'Ajout' ;
-                   $ip_black = trim( $_POST['ip_black']) ;
-			       $infos_message .= $info_ip . '---->'. $ip_black ;   
-			}
-			if (  $_POST['submit'] == l10n('Sv_Valider') )
-      		{
-				$mails_options[no_mail_list] = isset($_POST['no_mail_list']) ? $_POST['no_mail_list'] : "off" ;
-      			$mails_options[no_connect] ='off' ;// isset($_POST['no_connect']) ? $_POST['no_connect'] : "off" ;
-      			$mails_options[set_auto] = 'off' ;//isset($_POST['set_auto']) ? $_POST['set_auto'] : "off" ;
-				$mails_options[set_id] = isset($_POST['set_id']) ? $_POST['set_id'] : "off" ;
-				sauve_options();
-			    $infos_message .=  l10n('Sv_save_config') . '<br />';   
-			    
-			}
-		} 	
-
+		$istype="";
+	if ( isset($_POST['submit']) ){
+	 if (clj_is_ip($ip_black)) $istype='IP';
+	 else if (clj_is_mail($ip_black))  $istype='MAIL';
+      else   $istype='LOGIN';	 
+    if (  $_POST['submit'] == l10n('Sv_Ajout') )	{
+      $info_ip = 'Ajout' ;
+      $ip_black = trim( $_POST['ip_black']) ;
+      $infos_message .= $info_ip . '---->'. $ip_black ;   
+    }
+	 if (  $_POST['submit'] == l10n('Sv_Valider') )	{
+    
+     $mails_options['no_mail_list'] = isset($_POST['no_mail_list']) ? "on" : "off" ;
+     $mails_options['no_connect'] = isset($_POST['no_connect']) ? "on" : "off" ;
+     $mails_options['set_auto'] = isset($_POST['set_auto']) ? "on" : "off" ;
+     $mails_options['set_id'] = isset($_POST['set_id']) ? "on" : "off" ;
+     mail_supervisor::sauve_options();
+     $infos_message .=  l10n('Sv_save_config') . '<br />'; 
+  }
+}
 if (!isset($params)) $params=array();
 if (!isset($params['per_page'])) $params['per_page'] = 20 ;
@@ -480,16 +426,13 @@
 if (isset($_POST['next'])) $params['start'] +=   1;
 if (isset($_POST['prev']))  $params['start'] -=   1;
-
-$params['start']= ($params['start']>=0) ? $params['start'] : 0 ;
-
-
-include  (MAIL_SUPERV_PATH.'include/save_info.php'); 	   
-$maxipage=(int) (	$nbip  / $params['per_page']) ;
+ $params['start']= ($params['start']>=0) ? $params['start'] : 0 ;
 //=======================================================================================	
+ include  (MAIL_SUPERV_PATH.'include/save_info.php'); 	   
+  $maxipage=(int) (	$nbip  / $params['per_page']) ;
 	$f_action  = $my_base_url.'&amp;tab=mail_black_liste' ;
 	$champs_ip=array();
 	$champs_bl=array();
 	if (!empty($liste_ip))		$champs_ip=array_keys($liste_ip[0]);
-	if (!empty($liste_bl))      $champs_bl=array_keys($liste_bl[0]);
+	if (!empty($liste_bl))  $champs_bl=array_keys($liste_bl[0]);
 	   $smile_bonjour=MAIL_SUPERV_PATH."smilies/mouche.gif" ; 
 	   $img_logo=MAIL_SUPERV_PATH."smilies/logo.png" ; 
@@ -514,8 +457,8 @@
                         'F_ACTION' => $f_action ,
 						
-                        'no_mail_list' => ($mails_options[no_mail_list] == 'on') ? 'checked="checked"' : '' ,
-                        'no_connect' => ($mails_options[no_connect] == 'on') ? 'checked="checked"' : '' ,
-                        'set_auto' => ($mails_options[set_auto] == 'on') ? 'checked="checked"' : '' ,
-                        'set_id' => ($mails_options[set_id] == 'on') ? 'checked="checked"' : '' ,
+                        'no_mail_list' => ($mails_options['no_mail_list'] == 'on') ? 'checked="checked"' : '' ,
+                        'no_connect' => ($mails_options['no_connect'] == 'on') ? 'checked="checked"' : '' ,
+                        'set_auto' => ($mails_options['set_auto'] == 'on') ? 'checked="checked"' : '' ,
+                        'set_id' => ($mails_options['set_id'] == 'on') ? 'checked="checked"' : '' ,
                         'IP' =>  $ip ,						
                         'PAYS' =>  $pays  ,
@@ -526,9 +469,9 @@
 		 			)
 				);			 
-	 //===============================================================	
-	 	
-				 
-	 	$template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_black_liste.tpl')));
-		$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+	 //===============================================================					 
+  $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_black_liste.tpl')));
+  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+      
+
    break; 
 
@@ -585,5 +528,5 @@
 	}
 	if ( $modif == true ) 	{ 
-				sauve_donnees();
+				mail_supervisor::sauve_donnees();
  				$modif = false ;
  		}
@@ -593,19 +536,7 @@
 		 $infos_message .= "\n".'Spams : '.$mails_donnees['nb_spams']. '  \\  ' . $mails_donnees['nb_spams_maxi'];
 		}
-		
-
-		  
-		if  ($infos_message != "")  {
-		   array_push($page['infos'],  $infos_message);
-		   $infos_message="";
-		 }
-		 
-		if  ($erreur_message != "")  {
-	
-		  array_push($page['errors'], $erreur_message);
-		  $erreur_message="";
-	
-		 
-		 }		 
+
+
+	 mail_supervisor::affiche_message();
 //========================================================================	
 ?>
