Index: extensions/Mail_supervisor/admin/index.php
===================================================================
--- extensions/Mail_supervisor/admin/index.php	(revision 4020)
+++ extensions/Mail_supervisor/admin/index.php	(revision 4020)
@@ -0,0 +1,32 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: extensions/Mail_supervisor/admin/mail_superv_admin.php
===================================================================
--- extensions/Mail_supervisor/admin/mail_superv_admin.php	(revision 4020)
+++ extensions/Mail_supervisor/admin/mail_superv_admin.php	(revision 4020)
@@ -0,0 +1,152 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+load_language('plugin.lang', MAIL_SUPERV_PATH);
+include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+
+global $args, $conf_mail ;
+
+$mails_options = explode("," , $conf['mail_superv']);
+$mails_données=Get_Datas();
+
+	$search=array("D","H","M","S","W");
+	$replace=array(" day"," Hour"," minute"," second"," week");		
+		
+
+
+if ( isset($_POST['test_envoie']) ) {
+test_envoie();
+		
+  } 	
+//=============================================================
+
+
+if ( isset($_POST['raz']) ) {
+	$mails_données['date_quarantaine']=time();
+	$mails_données['nb_mails'] = 0  ;
+	$mails_données['nb_spams'] = 0  ;
+	$mails_données['date_mail'] = time();
+	$mails_données['date_spam'] = time();
+	$mails_données['reste'] = 0;
+	
+	 $query = '
+        UPDATE '.MAIL_SUPERV_TABLE.'
+        SET `nb_mails`         = 0,
+			`date_mail`        = '.time().',
+			`nb_mails_maxi`    = '.$mails_données['nb_mails_maxi'].',	
+			`nb_mails_periode`    = "'.$mails_données['nb_mails_periode'].'",	
+					
+			`nb_spams`         = 0,
+			`date_spam`        = '.time().',
+			`nb_spams_maxi`    = '.$mails_données['nb_spams_maxi'].',
+			`nb_spams_periode`    = "'.$mails_données['nb_spams_periode'].'",		
+								
+			`quarantaine`      = "false",
+			`date_quarantaine` = '.time().',
+			
+			`message`          = "'.$mails_données['message'].'",
+			`header_text`      = "'.$mails_données['header_text'].'"
+		WHERE `id` =1 LIMIT 1 ';
+		
+
+      pwg_query($query);
+	
+	array_push($page['infos'], l10n('save_config'));
+	}
+	
+if ( isset($_POST['submit']) )
+{
+	
+			
+//Options
+  $mails_options[0] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : '' ;
+  $mails_options[1] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : '' ;
+  $mails_options[2] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : '' ;
+  $mails_options[3] = isset($_POST['mail_superv_admin']) ? $_POST['mail_superv_admin'] : '' ;
+  $mails_options[4] = isset($_POST['superv_guest']) ? $_POST['superv_guest'] : '' ;
+  
+//données  
+$mails_données['nb_mails_maxi'] = isset($_POST['nb_mails_maxi']) ? $_POST['nb_mails_maxi'] :  $mails_données['nb_mails_maxi']  ;
+$mails_données['nb_mails_periode'] = isset($_POST['nb_mails_periode']) ? $_POST['nb_mails_periode'] :  $mails_données['nb_mails_periode']  ;
+$mails_données['nb_spams_maxi'] = isset($_POST['nb_spams_maxi']) ? $_POST['nb_spams_maxi'] :  $mails_données['nb_spams_maxi']  ;
+$mails_données['nb_spams_periode'] = isset($_POST['nb_spams_periode']) ? $_POST['nb_spams_periode'] :  $mails_données['nb_spams_periode']  ;
+
+$mails_données['message'] = isset($_POST['content']) ? $_POST['content'] :  $mails_données['message']  ;
+$mails_données['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] :  $mails_données['header_text']  ;
+  //===========================================================================================================
+	$query = '
+    UPDATE '.CONFIG_TABLE.'
+    SET value="'.$mails_options[0]. ',' .$mails_options[1]. ',' .$mails_options[2].',' .$mails_options[3]. ',' .$mails_options[4]. '"
+    WHERE param="mail_superv"
+    LIMIT 1';
+	 pwg_query($query);
+
+
+         $query = '
+        UPDATE '.MAIL_SUPERV_TABLE.'
+        SET `nb_mails`         = '.$mails_données['nb_mails'].',
+			`date_mail`        = '.$mails_données['date_mail'].',
+			`nb_mails_maxi`    = '.$mails_données['nb_mails_maxi'].',	
+			`nb_mails_periode`    = "'.$mails_données['nb_mails_periode'].'",	
+					
+			`nb_spams`         = '.$mails_données['nb_spams'].',
+			`date_spam`        = '.$mails_données['date_spam'].',
+			`nb_spams_maxi`    = '.$mails_données['nb_spams_maxi'].',	
+			`nb_spams_periode`    = "'.$mails_données['nb_spams_periode'].'",	
+								
+			`quarantaine`      = "'.$mails_données['quarantaine'].'",
+			`date_quarantaine` = '.$mails_données['date_quarantaine'].',
+			
+			`message`          = "'.$mails_données['message'].'",
+			`header_text`      = "'.$mails_données['header_text'].'"
+		WHERE `id` =1 LIMIT 1 ';
+		
+
+      pwg_query($query);
+	  
+   //===========================================================================================================
+
+array_push($page['infos'], l10n('save_config'));
+
+}
+
+	
+	$rest_mail=  $mails_données['date_mail']-time() ; 
+	$rest_mail= "'".int_to_heure($rest_mail)."'";  	
+				
+	$rest_spam=  $mails_données['date_spam']-time() ;
+	$rest_spam= "'".int_to_heure($rest_spam)."'";  	
+
+$template->assign(
+  					array(
+   'check_mailto' => $mails_options[0] == 'on' ? 'checked="checked"' : '' ,
+   'check_header_carbons' => $mails_options[1] == 'on' ? 'checked="checked"' : '' ,
+   'check_header_text' => $mails_options[2] == 'on' ? 'checked="checked"' : '' ,
+   'free_admin' => $mails_options[3] == 'on' ? 'checked="checked"' : '' ,
+   'free_guest' => $mails_options[4] == 'on' ? 'checked="checked"' : '' ,
+   
+   	'nb_mails' => $mails_données['nb_mails'] ,
+   	'date_mail' => "'".date('Y-M-d H:m:s',$mails_données['date_mail'])."'" ,
+   	'nb_mails_maxi' => $mails_données['nb_mails_maxi'] ,	
+	'nb_mails_periode' => "'".$mails_données['nb_mails_periode']."'" ,	
+ 	'time_mails_reste' => ( $rest_mail ) ,	
+	
+  	'nb_spams' => $mails_données['nb_spams'] ,
+	'date_spam' => "'".date('Y-M-d H:m:s',$mails_données['date_spam'])."'" ,
+	'nb_spams_maxi' => $mails_données['nb_spams_maxi'] ,	
+	 'nb_spams_periode' => "'".$mails_données['nb_spams_periode']."'" ,
+	 'time_spams_reste' => ($rest_spam) ,	
+	 
+  	'date_quarantaine' => "'".date('Y-M-d H:m:s',$mails_données['date_quarantaine'])."'" ,
+  'reste' => int_to_heure($mails_données['reste']),
+ 
+    'message' => $mails_données['message'] ,
+	'header_text' => "'".$mails_données['header_text']."'" ,
+		 				)
+				);	
+
+$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');
+
+
+?>
Index: extensions/Mail_supervisor/admin/mail_superv_admin.tpl
===================================================================
--- extensions/Mail_supervisor/admin/mail_superv_admin.tpl	(revision 4020)
+++ extensions/Mail_supervisor/admin/mail_superv_admin.tpl	(revision 4020)
@@ -0,0 +1,67 @@
+<div class="titrePage">
+	<h2>{'supervisor'|translate}</h2>
+</div>
+  <span>{'Howto'|translate}</span>
+<form action="" method="post" name="form">
+  <fieldset>
+    <legend>{'free_admin_titre'|translate}</legend>
+    <table>
+<tr><td><input type="checkbox" name="check_mailto" value="on" {$check_mailto} />&nbsp;{'check_mailto'|translate}</td></tr>
+<tr><td><input type="checkbox" name="check_header_carbon" value="on" {$check_header_carbons} />&nbsp;{'check_header_carbon'|translate}</td></tr>
+<tr>
+<td><input type="checkbox" name="check_header_text" value="on" {$check_header_text} />&nbsp;{'check_header_text'|translate}</td>
+<td><input type="text" name="header_text"  value={$header_text} /></td>
+
+
+
+</tr><tr>
+<td>{'free_nb'|translate}</td><td> </td><td>{'free_depuis_le'|translate}</td><td>{'free_nb_maxi'|translate}</td>
+</tr>
+<tr>
+
+<td><input type="text" name="nb_mails"  value={$nb_mails} /></td>
+	   
+<td>{'free_mails'|translate}</td>	   
+	   <td><input type="text" name="date_mail"  value={$date_mail} /></td>
+	   <td><input type="text" name="nb_mails_maxi" size="10%" value={$nb_mails_maxi} /></td>
+	    <td><input type="text" name="nb_mails_periode" size="10%" value={$nb_mails_periode} /></td>
+		<td><input type="text" name="time_mails_reste" size="50%" value={$time_mails_reste} /></td>  
+		 </tr> 
+ 
+	   <tr>  
+	   <td><input type="text" name="nb_spams"  value={$nb_spams} /></td>
+	   <td>{'free_spams'|translate}</td>
+
+	   <td><input type="text" name="date_spam"  value={$date_spam} /></td>
+	   <td><input type="text" name="nb_spams_maxi" size="10%" value={$nb_spams_maxi} /></td>
+	    <td><input type="text" name="nb_spams_periode" size="10%" value={$nb_spams_periode} /></td>
+		<td><input type="text" name="time_spams_reste" size="50%" value={$time_spams_reste} /></td>  
+						
+
+	    </tr> 
+		
+	   <tr>  
+
+	   <td>{'free_quarantaine'|translate}</td>
+	    <td><input type="text" name="reste"  value={$reste} /></td>
+		 <td>{'free_heures'|translate}</td>
+		   
+		 <td><input type="text" name="date_quarantaine"  value={$date_quarantaine} />
+		
+	 <input class="submit" type="submit" name="raz" value="raz" />
+	     </td></tr> 		
+	   
+    </table>
+
+	      <fieldset>
+    <legend>{'free_admin_description'|translate}</legend>
+	       <table >
+           <tr><td><textarea name="content"  rows="18" cols="100">{$message}</textarea></td>         </tr> 
+		 
+           </table>
+		     </fieldset>
+      <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}" />
+	  <input class="submit" type="submit" name="test_envoie" value="{'test'|translate}" />
+	  </p> 
+</fieldset>
+</form>
Index: extensions/Mail_supervisor/include/constants.php
===================================================================
--- extensions/Mail_supervisor/include/constants.php	(revision 4020)
+++ extensions/Mail_supervisor/include/constants.php	(revision 4020)
@@ -0,0 +1,5 @@
+<?php
+global $prefixeTable;
+if (!defined('MAIL_SUPERV_TABLE')) define('MAIL_SUPERV_TABLE', $prefixeTable.'mail_superv');
+if (!defined('FREE_MAIL_TABLE')) define('FREE_MAIL_TABLE', $prefixeTable.'free_mail');
+?>
Index: extensions/Mail_supervisor/include/fonctions.php
===================================================================
--- extensions/Mail_supervisor/include/fonctions.php	(revision 4020)
+++ extensions/Mail_supervisor/include/fonctions.php	(revision 4020)
@@ -0,0 +1,251 @@
+<?php
+load_language('plugin.lang', MAIL_SUPERV_PATH);
+include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+
+function sauve_options()
+{
+global $mails_options ;
+	$query = '
+    UPDATE '.CONFIG_TABLE.'
+    SET value="'.$mails_options[0]. ',' .$mails_options[1]. ',' .$mails_options[2].',' .$mails_options[3]. ',' .$mails_options[4]. '"
+    WHERE param="mail_superv"
+    LIMIT 1';
+ pwg_query($query);
+
+}
+//=================================================================================
+function sauve_données()
+{
+global $mails_données ;
+        $query = '
+        UPDATE '.MAIL_SUPERV_TABLE.'
+        SET `nb_mails`         = '.$mails_données['nb_mails'].',
+			`date_mail`        = '.$mails_données['date_mail'].',
+			`nb_mails_maxi`    = '.$mails_données['nb_mails_maxi'].',	
+			`nb_mails_periode` = "'.$mails_données['nb_mails_periode'].'",	
+				
+			`nb_spams`         = '.$mails_données['nb_spams'].',
+			`date_spam`        = '.$mails_données['date_spam'].',
+			`nb_spams_maxi`    = '.$mails_données['nb_spams_maxi'].',	
+			`nb_spams_periode` = "'.$mails_données['nb_spams_periode'].'",	
+								
+			`quarantaine`      = "'.$mails_données['quarantaine'].'",
+			`date_quarantaine` = '.$mails_données['date_quarantaine'].',
+			
+			`message`          = "'.$mails_données['message'].'",
+			`header_text`      = "'.$mails_données['header_text'].'"
+		WHERE `id` =1 LIMIT 1 ';
+      pwg_query($query);
+}
+//=================================================================================
+function affiche_message()
+{
+ global $template,$infos_message,$erreur_message ;;
+  
+  if (isset($erreur_message))
+		{	
+ 
+		if ($erreur_message <> "")
+			{
+			$erreur_message=str_replace("\n",'<br />',$erreur_message) ;
+			$erreur_message=sprintf(l10n('free_message "%s"'), $erreur_message  )	;
+   				$template->assign('errors',$erreur_message);
+				$erreur_message="";
+			}
+  		}
+		
+	
+  if (isset($infos_message))
+		{	
+		
+		if ($infos_message <> "")
+			{
+	$infos_message=str_replace("\n",'<br />',$infos_message) ;
+   				$template->assign('infos',$infos_message);
+				$infos_message="";
+			}
+  		}
+				
+		
+		
+}
+
+
+
+//=================================================================================
+function Get_Datas()
+{
+
+	 $query = "
+    SELECT *
+    FROM ".MAIL_SUPERV_TABLE."
+  	;";
+    $data = mysql_fetch_array(pwg_query($query));
+	$data['reste']=   ($data['date_quarantaine']-time())  ;
+	$data['reste_mail']=   ($data['date_mail']-time())  ;
+	$data['reste_spam']=   ($data['date_spam']-time())  ;
+
+    return $data;
+}
+
+//=================================================================================
+function corrige_header($Carbonne,$headers)
+	{
+	global $mails_options,$conf_mail,$mailto;
+
+		$splitter="|".$Carbonne.":(.*)\n|U";
+		preg_match_all($splitter,$headers, $out,PREG_PATTERN_ORDER);
+		$val=array();
+		$match=array("<",">");
+		$string=array("","") ;
+		foreach($out as $messages)
+		{
+		$val[]=  $messages[0] ;
+		}
+ 
+
+	$val[1]=  str_replace( $match,$string,$val[0] ) ;
+	$src=$val[0];
+	
+	$splitter="|\"(.*)\"|U";
+	preg_match_all($splitter,$val[1], $out,PREG_PATTERN_ORDER);
+	$string=array();
+	$string = array_fill( 0, count($out), '');
+	$dest = str_replace($out[0], $string, $val[1]) ;
+ if ($mailto <>"" ) {	
+	 $dest=str_replace($mailto.',', '', $dest) ;
+	 $dest=str_replace($mailto, '', $dest) ;
+	
+} 
+
+
+	$headers = str_replace( $src,$dest, $headers) ;
+	return $headers;
+
+		
+	}
+	
+function int_to_heure($int)
+{
+$week= (int) ($int/(3600*24*7)); 
+$int=$int-($week*(3600*24*7));  
+
+$day= (int) ($int/(3600*24));   
+$int=$int-($day*(3600*24));
+
+$heures=(int) ($int/3600);
+
+$int=$int-($heures*(3600));
+
+$minutes=(int) ($int/60);
+$int= $int - ($minutes*(60));
+
+$secondes=(int) ($int);
+
+$heures= substr ('00'. $heures,-2,2);   
+$day= substr ('00'.  $day,-2,2);   
+$minutes=substr ('00'.$minutes,-2,2);
+$secondes=substr ('00'.$secondes,-2,2);
+if ($week > 0 )
+{
+return $week. " " .l10n('Week'). " " .  $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ".  $secondes." " .l10n('seconde')."s";
+}
+return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('minute'). "s ".  $secondes." " .l10n('seconde')."s";
+
+}	
+
+function memo_var($variables)
+{
+   		ob_start();
+		echo '<pre>';
+		print_r($variables);
+		echo '</pre>';
+ 	  	$m= ob_get_contents();
+
+    	ob_end_clean();
+		return $m;
+		
+}
+
+function test_envoie()
+{
+global $infos_message,$erreur_message ,$conf,$user ;
+$admins = array();
+  $query = '
+select
+  U.'.$conf['user_fields']['username'].' as username,
+  U.'.$conf['user_fields']['email'].' as mail_address
+from
+  '.USERS_TABLE.' as U,
+  '.USER_INFOS_TABLE.' as I
+where
+  I.user_id =  U.'.$conf['user_fields']['id'].' and
+  I.status in (\'webmaster\',  \'admin\') and
+  I.adviser = \'false\' and
+  '.$conf['user_fields']['email'].' is not null and
+  I.user_id <> '.$user['id'].'
+order by
+  username
+';
+//==================================================================================
+
+  $datas = pwg_query($query);
+  
+  
+  if (!empty($datas))
+  {
+    while ($admin = mysql_fetch_array($datas))
+    {
+      if (!empty($admin['mail_address']))
+      {
+     	array_push($admins, format_email($admin['username'], $admin['mail_address']));
+	
+      }
+    }
+  }
+
+  if (count($admins) > 0)
+  {
+  
+  ob_start();
+  	$erreur_message ="";
+  	$infos_message =   memo_var($admins);
+ //===========================================================
+  	$args = array();
+  	
+  	$args['Bcc']=$admins;
+	
+  $message_texte="Bonjour.";
+  $message_html="Test";
+ 
+/*
+ 	$limite = "_parties_".generate_key(32);; 
+ //	$limite=$conf_mail['boundary_key'];
+  		$nom ='piwigo_logo_sombre_214x100.png'; 
+		$typemime='image/jpeg';
+
+  $attachement = "-----=".$limite."\n"; 
+  $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 
+  $attachement .= "Content-Transfer-Encoding: base64\n"; 
+  $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 
+  $fd = fopen( $fichier, "r" ); 
+  $contenu = fread( $fd, filesize( $fichier ) ); 
+  fclose( $fd ); 
+  $attachement .= chunk_split(base64_encode($contenu)); 
+  $attachement .= "\n\n\n-----=".$limite."\n"; 
+  */
+ 
+//==========================================================================
+
+ $args['subject']="Plugin Piwigo TEST";
+ $args['content']="TEST ";
+
+   $infos_message ="TEST ENVOIE [admin].".memo_var($admins);
+        $ret= pwg_mail( "", $args); 
+  	  	$m= ob_get_contents();
+    	ob_end_clean();
+		$erreur_message .=$m;
+	}
+}
+
+?>
Index: extensions/Mail_supervisor/index.php
===================================================================
--- extensions/Mail_supervisor/index.php	(revision 4020)
+++ extensions/Mail_supervisor/index.php	(revision 4020)
@@ -0,0 +1,32 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: extensions/Mail_supervisor/language/fr_FR/index.php
===================================================================
--- extensions/Mail_supervisor/language/fr_FR/index.php	(revision 4020)
+++ extensions/Mail_supervisor/language/fr_FR/index.php	(revision 4020)
@@ -0,0 +1,1 @@
+<?php// +-----------------------------------------------------------------------+// | PhpWebGallery - a PHP based picture gallery                           |// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |// +-----------------------------------------------------------------------+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $// | last modifier : $Author: rub $// | revision      : $Revision: 1912 $// +-----------------------------------------------------------------------+// | This program is free software; you can redistribute it and/or modify  |// | it under the terms of the GNU General Public License as published by  |// | the Free Software Foundation                                          |// |                                                                       |// | This program is distributed in the hope that it will be useful, but   |// | WITHOUT ANY WARRANTY; without even the implied warranty of            |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |// | General Public License for more details.                              |// |                                                                       |// | You should have received a copy of the GNU General Public License     |// | along with this program; if not, write to the Free Software           |// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |// | USA.                                                                  |// +-----------------------------------------------------------------------+// Recursive call$url = '../';header( 'Request-URI: '.$url );header( 'Content-Location: '.$url );header( 'Location: '.$url );exit();?>
Index: extensions/Mail_supervisor/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/Mail_supervisor/language/fr_FR/plugin.lang.php	(revision 4020)
+++ extensions/Mail_supervisor/language/fr_FR/plugin.lang.php	(revision 4020)
@@ -0,0 +1,27 @@
+<?php
+$lang['Howto'] = 'Gestion des parametres de surveillance d\' envoie des mails.';
+$lang['free_admin_titre'] = 'Administration de Free mail';
+$lang['free_admin_description'] = 'Dernier message reçu. ';
+$lang['mail_superv_save_config'] = 'Données sauvegardées';
+
+$lang['check_mailto'] = 'Envoyer une copie vers le WebMaster.';
+$lang['check_header_carbon'] = 'Modifier le code  Bcc , Ccc   dans le header';
+$lang['check_header_text'] = 'Ajouter un bloc "texte" dans l\'entête du mail.';
+
+$lang['free_admin'] = 'Exclure l\'administrateur des envoies.';
+$lang['free_guest'] = 'Exclure le guest des des envoies.';
+
+$lang['free_mails'] = ' mails ';
+$lang['free_depuis_le'] = ' depuis le :';
+$lang['free_spams'] = ' spams ';
+$lang['free_nb'] = ' Nombre ';
+$lang['free_nb_maxi'] = ' Nombre maxi ';
+$lang['free_quarantaine'] = 'Vous êtes en quarantaine pour : ';
+$lang['free_heures'] = ' Heures ';
+$lang['free_date'] = ' Date : ';
+$lang['free_valid "%s"'] = ' Valide :  "%s" !';
+$lang['free_message "%s"'] = ' Erreur : <br /> "%s"  <br />!';
+
+$lang['supervisor'] = 'Superviseur de MAILS';
+
+?>
Index: extensions/Mail_supervisor/language/index.php
===================================================================
--- extensions/Mail_supervisor/language/index.php	(revision 4020)
+++ extensions/Mail_supervisor/language/index.php	(revision 4020)
@@ -0,0 +1,1 @@
+<?php// +-----------------------------------------------------------------------+// | PhpWebGallery - a PHP based picture gallery                           |// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |// +-----------------------------------------------------------------------+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $// | last modifier : $Author: rub $// | revision      : $Revision: 1912 $// +-----------------------------------------------------------------------+// | This program is free software; you can redistribute it and/or modify  |// | it under the terms of the GNU General Public License as published by  |// | the Free Software Foundation                                          |// |                                                                       |// | This program is distributed in the hope that it will be useful, but   |// | WITHOUT ANY WARRANTY; without even the implied warranty of            |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |// | General Public License for more details.                              |// |                                                                       |// | You should have received a copy of the GNU General Public License     |// | along with this program; if not, write to the Free Software           |// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |// | USA.                                                                  |// +-----------------------------------------------------------------------+// Recursive call$url = '../';header( 'Request-URI: '.$url );header( 'Content-Location: '.$url );header( 'Location: '.$url );exit();?>
Index: extensions/Mail_supervisor/main.inc.php
===================================================================
--- extensions/Mail_supervisor/main.inc.php	(revision 4020)
+++ extensions/Mail_supervisor/main.inc.php	(revision 4020)
@@ -0,0 +1,231 @@
+<?php
+/*
+Plugin Name: Mail supervisor
+Version: 1.0.0
+Description:  Mail supervisor surveille l'envoie des mails. 
+Plugin URI: http://piwigo.org/ext 
+Author: cljosse
+Author URI:http://cljosse.e3b.org
+*/
+// http://piwigo.org/ext/extension_view.php?eid=309
+// 4019
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+define('mail_superv_DIR' , basename(dirname(__FILE__)));
+define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+include_once (MAIL_SUPERV_PATH.'include/constants.php'); 
+include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
+
+/*
+EVENT_HANDLER_PRIORITY_NEUTRAL  */
+
+add_event_handler('send_mail', 'clj_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 1 , 6);
+
+function clj_mail($result, $mailto, $subject, $content, $headers, $args)
+{
+    global $conf, $user, $lang_info,  $conf_mail,$mails_options,$mails_données , $template,$page ,$erreur_message; 
+	// lecture config table -------------
+
+
+	$mails_options = explode("," , $conf['mail_superv']);
+	
+	// lecture données       -------------
+    $mails_données = Get_Datas();
+	
+	$nb_mails	  =	$mails_données['nb_mails'] ;
+	$next_day  =  $mails_données['date_mail'] ;
+	
+	$reste =    $mails_données['reste'] ;
+	$reste_mail =    $mails_données['reste_mail'] ;
+	$reste_spam =    $mails_données['reste_spam'] ;
+	
+ $mails_données['quarantaine'] =    ( $mails_données['reste'] >0 ) ? "true" : "false" ;
+ 
+
+    $match=array("<",">");
+    $string=array("&lt;","&gt;") ;
+	$search=array("D","H","M","S","W");
+	$replace=array(" day"," Hour"," minute"," second"," week");
+	
+$header_message='<pre>
+Destinataire :'.$mailto.'
+Headers      :
+'.str_replace( $match,$string, $headers).'
+Sujet        :'.$subject.'
+</pre>'; 
+
+  $nb_destinataires=0;
+ if (mailto<>"" )  $nb_destinataires +=1; 
+   //================= réécriture de l'entête ===============================
+
+if ($mails_options[0] == 'on') {
+ 	if ($mailto=="")	$mailto=$conf_mail['email_webmaster'];
+}
+if ($mails_options[1] == 'on') { 
+   		if (!empty($args['Cc']))
+  		{
+		  $nb_destinataires += count($args['Cc']);
+		  $headers= corrige_header('Cc:',$headers);
+  		}
+  		if (!empty($args['Bcc']))
+  		{
+		  $nb_destinataires += count($args['Bcc']);
+		  $headers	= corrige_header('Bcc',$headers);
+		}
+
+  }
+
+if ($mails_options[2]=='on')   {
+
+        $texte = "This is a multi-part message in MIME format.\n"; 
+	
+     	$texte .= "-----=".$conf_mail['boundary_key']."\n"; 
+      	$texte .= "Ceci est un message est au format MIME.\n"; 
+       	$texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 
+       	$texte .= 'Content-Transfer-Encoding: 8bit'."\n\n";  
+       	$texte .= $mails_données['header_text']; // A voir texte brut...
+	   
+	   	$texte .= "\n\n"; 
+	
+	  	$content =$texte .$content ;
+}
+
+	
+$ret=false;
+ if (    ($mails_données['quarantaine']=="false") ) 
+  {
+ 	//======== Non mise en quarantaine =============
+
+   		ob_start();
+   	  		$ret = mail($mailto, 'Plugin'.$subject, $content, $headers);
+ 	  		$message = ob_get_contents();
+    	ob_end_clean();
+		
+			$mails_données['message']=$message;	
+			$est_un_spam =!(strpos(strtolower($message), 'spam') === false);
+     		if ($est_un_spam == false) {
+	           //--- Non détection de spam ------------------
+    			 if ($mails_données['nb_mails']==0) {
+	       			$date_mail=time();
+					
+					$mails_periode="+".str_replace( $search, $replace, $mails_données['nb_mails_periode']);
+					$next_day =  strtotime($mails_periode,time());
+           			$mails_données['date_mail'] =  $next_day;
+	 			} 	
+	 			$next_day = time() + (0); 
+ 				$mails_données['date_quarantaine'] = $next_day ;
+ 	    		$mails_données['nb_mails'] += 1;
+	  // teste limite atteinte :
+	
+	  if (($mails_données['nb_mails'] >= $mails_données['nb_mails_maxi'])) 
+			{
+			$erreur_message .= "ALERTE !!! DANGER DE MISE EN QUARANTAINE PAR VOTRE FAI <br />" ;
+			$erreur_message .=  "Vous avez d&eacute;pass&eacute; le nombre de mails admissibles par semaine. <br /> <br />";
+			$erreur_message .='Date du premier mail: ' . date('d-M-Y H:m:s',$mails_données['date_mail']);
+			$rest_mail=  $mails_données['date_mail']-time() ; 
+			$erreur_message .= '<br />Encore : '. int_to_heure($rest_mail) ;
+			
+				if ( (float) $rest_mail <= 0)
+					{
+					$mails_periode="+".str_replace( $search, $replace, $mails_données['nb_mails_periode']);
+					$next_day =  strtotime($mails_periode,time());
+           			$mails_données['date_mail'] =  $next_day;
+				
+					}
+			
+			
+			}
+			if ($ret==false) { 	
+       			//=============== La fonction mail à retournée false=========================		
+				$erreur_message .= '<br />---- La fonction mail &agrave; retourn&eacute;e [false]  ------<br />';
+					$erreur_message .='-------- MESSAGE erreur : -------------<br />';
+					$erreur_message .=$message ;				// Bad recipient address syntax 
+ 				$pos1 = strpos(strtolower($message), 'bad recipient address syntax');
+				if (  !($pos1 === false) ){
+				$erreur_message .='D&eacute;tection de : Bad recipient address syntax .';
+ 					$erreur_message .='V&eacuterifiez les destinataires: (Bcc,Cc,To)<br />';
+ 					}
+					$erreur_message .='mailto:   "'.$mailto.'"<br />';
+
+					$erreur_message .='--------HEADERS -----------------<br />
+					';
+					$erreur_message .=$headers ;
+					
+
+				}
+			
+ 		}else{
+		//--- Détection de spam ------------------
+ 			
+			if ($mails_données['nb_spams']==0) {  $mails_données['date_spam']= time(); 	}
+			$mails_données['nb_spams'] += $nb_destinataires;
+			
+			$est_un_spam =!(strpos(strtolower($message), 'trop de spam') === false);
+			
+			if ( $est_un_spam ) { 
+			    $mails_données['quarantaine']=true;
+				 $spams_periode="+".str_replace($search, $replace, $mails_données['nb_spams_periode']);
+				
+					$next_day =  strtotime(  $spams_periode);
+					
+			//	$next_day =  strtotime('+2 day');
+		 		$mails_données['date_quarantaine']= $next_day       ;			
+			}
+			else
+			{
+	 		$mails_données['quarantaine']= ($mails_données['nb_spams'] >= $mails_données['nb_spams_maxi']);
+       		}
+        	//	$next_day = time() + (2 * 24 * 60 * 60);
+			if ($mails_données['quarantaine']) 
+				{
+				$erreur_message .= "ALERTE !!! DANGER DE MISE EN QUARANTAINE  <br />" ;
+				$erreur_message .=  "Vous avez d&eacute;pass&eacute; le nombre de spmas admissibles. <br /> <br />";
+				}
+	    		$erreur_message .="<br> Detection $message <br />".
+				"Nombre de spams d&eacute;tect&eacutes; ".$mails_données['nb_spams'];
+ 			}
+ 
+  	}else{
+		//======== Mise en quarantaine       =============
+$erreur_message =  '<br />
+Nous sommes le :       '. date('d-M-Y H:m:s') ."<br />";
+
+		if 	($reste >= 0) {
+$erreur_message .=
+"MISE EN QUARANTAINE !"."<br />".
+"Nombre de spams envoy&eacute;s :". $mails_données['nb_spams']."<br />".
+"Depuis le               :". date('d-M-Y H:m:s',$mails_données['date_spam'])."<br />".		
+"Il vous reste encore ". int_to_heure($mails_données['reste'])  . " avant le d&eacute;blocage par votre FAI<br />
+  qui devrait avoir lieu le ".date('d-M-Y H:m:s',$mails_données['date_quarantaine'])."." ;
+		
+		}
+			
+	  	$erreur_message .=  '</pre>'.
+	   	'
+	  
+	  '.
+	"Dernier message re&ccedil;u.:<br />". $mails_données['message']. "<br /> ";
+	  $ret = "break";
+ }
+
+  sauve_données();
+ $ret=true;
+ 
+ return $ret ;
+ 
+}
+
+//==========================================================================================
+function admin_menu($menu)
+{
+    array_push($menu, array('NAME' => 'Mail_Superv',
+      'URL' => get_admin_plugin_menu_link(MAIL_SUPERV_PATH . 'admin/mail_superv_admin.php')));
+    return $menu;
+}
+
+
+add_event_handler('get_admin_plugin_menu_links', 'admin_menu');
+//add_event_handler('loc_end_page_tail', 'affiche_message');
+add_event_handler('loc_after_page_header', 'affiche_message');
+
+?>
Index: extensions/Mail_supervisor/maintain.inc.php
===================================================================
--- extensions/Mail_supervisor/maintain.inc.php	(revision 4020)
+++ extensions/Mail_supervisor/maintain.inc.php	(revision 4020)
@@ -0,0 +1,170 @@
+<?php
+
+if(!defined("MAIL_SUPERV_PATH"))
+  define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+include_once (MAIL_SUPERV_PATH.'include/constants.php');
+include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
+
+function plugin_install()
+{
+
+  $q = '
+    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
+    VALUES ("mail_superv","off,on,off ,off,off","Parametres du plugin Mail superviseur")
+  ;';
+  pwg_query($q);
+
+
+vérif_base();
+
+}
+
+
+
+function plugin_uninstall()
+{
+  global $conf;
+
+  if (isset($conf['mail_superv']))
+  {
+
+    $q = '
+      DELETE FROM '.CONFIG_TABLE.'
+      WHERE param="mail_superv"
+    ;';
+
+    pwg_query($q);
+
+
+
+  $q = 'DROP TABLE '.MAIL_SUPERV_TABLE.';';
+   pwg_query( $q );
+   }
+  
+}
+
+
+function vérif_base()
+{
+
+$q = "
+    CREATE TABLE IF NOT EXISTS ".MAIL_SUPERV_TABLE." (
+		`id` SMALLINT( 5 ) NOT NULL DEFAULT '0',
+		
+		`nb_mails` INT NOT NULL DEFAULT '0',
+		`date_mail` INT NOT NULL DEFAULT '0',
+		`nb_mails_maxi` INT NOT NULL DEFAULT '2000',		
+		`nb_mails_periode` TEXT  ,	
+		
+		`nb_spams` INT NOT NULL DEFAULT '0',
+		`date_spam` INT NOT NULL DEFAULT '0',	
+		
+		`nb_spams_maxi` INT NOT NULL DEFAULT '10',	
+		`nb_spams_periode` TEXT  ,	
+		
+		`quarantaine` TEXT NOT NULL ,
+		`date_quarantaine` INT NOT NULL DEFAULT '0',
+			
+		
+		`message` TEXT NOT NULL , 
+		`header_text` TEXT NOT NULL , 
+      	PRIMARY KEY  (`id` )
+   	 )
+  ;";
+  pwg_query($q);
+  
+    $nb = Get_colonnes_de(MAIL_SUPERV_TABLE);
+	$table=$nb[MAIL_SUPERV_TABLE];	 
+//================================================================================	
+    if (!in_array( "nb_mails",$table)) {	
+		$query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails` INT NOT NULL default '0' ";
+			   pwg_query($query);            }  
+	if (!in_array( "date_mail",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_mail` INT NOT NULL default '0' ";
+			   pwg_query($query);            } 
+		    
+	if (!in_array( "nb_mails_maxi",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails_maxi` INT NOT NULL default '2000' ";
+			   pwg_query($query);            } 
+			   	   		   
+    if (!in_array( "nb_spams",$table)) {	
+		$query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams` INT NOT NULL default '0' ";
+			   pwg_query($query);            }  
+	if (!in_array( "date_spam",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_spam` INT NOT NULL default '0' ";
+			   pwg_query($query);            } 			   
+			    
+    if (!in_array( "nb_spams_maxi",$table)) {	
+		$query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams_maxi` INT NOT NULL default '10' ";
+			   pwg_query($query);            }  
+			   				
+		if (!in_array( "quarantaine",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `quarantaine` TEXT NOT NULL , ";
+			   pwg_query($query);            } 	
+			   
+		if (!in_array( "date_quarantaine",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_quarantaine` INT NOT NULL default '0'    ";
+			   pwg_query($query);            } 				   
+			   	
+		if (!in_array( "message",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `message` TEXT   ";
+			   pwg_query($query);            } 	
+			   
+		if (!in_array( "header_text",$table)) {	
+	  $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `header_text` TEXT   ";
+			   pwg_query($query);            } 		
+		   			    			   	
+		   			    
+      $query = "
+    		SELECT COUNT(*)
+    		FROM ".MAIL_SUPERV_TABLE."
+  		;";
+//==============================================================================		
+  list($count) = mysql_fetch_row(pwg_query($query));
+  if ($count == 0)
+  {
+	 $next_day = time()  ;
+	 $date_quarantaine=time();
+	   $q = '
+    INSERT INTO '.MAIL_SUPERV_TABLE.' (id,
+	nb_mails,date_mail,nb_mails_maxi,nb_mails_periode,
+	nb_spams,date_spam,nb_spams_maxi,nb_spams_periode,
+	 quarantaine, date_quarantaine,message,header_text)
+    VALUES (1,
+	0,
+	'.time().',
+	2000,
+	"1W",
+	
+	0,
+	'.time().',
+	10,
+	"2D",
+	
+	false,
+	'.time().',
+	
+	"Init.",
+	 "'.l10n('hello').'"
+	 )
+ 	 ;';
+
+
+	pwg_query($q);
+	
+ 	} 
+}
+function Get_colonnes_de($table)
+{
+  $columns_of = array();
+    $query = 'DESC '.$table.';';
+    $result = mysql_query($query);
+    $columns_of[$table] = array();
+    while ($row = mysql_fetch_row($result))
+    {
+      array_push($columns_of[$table], $row[0]);
+    }
+  return $columns_of;
+}
+?>
