Index: /extensions/free_mail/_notes/dwsync.xml
===================================================================
--- /extensions/free_mail/_notes/dwsync.xml	(revision 3912)
+++ /extensions/free_mail/_notes/dwsync.xml	(revision 3912)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<dwsync>
+<file name="main.inc.php" local="128982646800000000" remote="128982646800000000" testing="0" />
+<file name="maintain.inc.php" local="128980947000000000" remote="128980947000000000" testing="0" />
+</dwsync>
Index: /extensions/free_mail/include/_notes/dwsync.xml
===================================================================
--- /extensions/free_mail/include/_notes/dwsync.xml	(revision 3912)
+++ /extensions/free_mail/include/_notes/dwsync.xml	(revision 3912)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<dwsync>
+<file name="constants.php" local="128980889400000000" remote="128980889400000000" testing="0" />
+</dwsync>
Index: /extensions/free_mail/include/constants.php
===================================================================
--- /extensions/free_mail/include/constants.php	(revision 3912)
+++ /extensions/free_mail/include/constants.php	(revision 3912)
@@ -0,0 +1,4 @@
+<?php
+global $prefixeTable;
+define('FREE_MAIL_TABLE', $prefixeTable.'FREE_MAIL');
+?>
Index: /extensions/free_mail/main.inc.php
===================================================================
--- /extensions/free_mail/main.inc.php	(revision 3912)
+++ /extensions/free_mail/main.inc.php	(revision 3912)
@@ -0,0 +1,259 @@
+<?php
+/*
+Plugin Name: Plugin Mail
+Version: 1.03
+Description: Plugin modifie l entete des mails en cas de SPAM
+Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=309
+Author: cljosse
+Author URI:http://cljosse.e3b.org
+*/
+ 
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+define('Free_Mail_DIR' , basename(dirname(__FILE__)));
+define('Free_Mail_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+include_once (Free_Mail_PATH.'include/constants.php'); 
+
+
+/*
+ add_event_handler('send_mail_headers','clj_send_mail_headers' ) ;
+function clj_send_mail_headers($headers)
+{
+echo '<pre>';
+print_r($headers) ;
+echo '</pre>' ;
+}
+
+add_event_handler('send_mail_to', 'clj_send_mail_to');
+function clj_send_mail_to($mailto)
+{
+echo '<pre>';
+//print_r($mailto) ;
+echo '</pre>' ;
+}
+
+add_event_handler('send_mail_content', 'clj_send_mail_content');
+function clj_send_mail_content($content)
+{
+echo '<pre>';
+//print_r($content) ;
+echo '</pre>' ;
+}
+
+*/
+//  trigger_event('send_mail_to', get_strict_email_list($to)),
+// add_event_handler('send_mail_to', 'clj_send_mail_to');
+/*function clj_send_mail_to($mailto)
+{
+
+$to=get_strict_email_list($mailto);
+echo '<pre>';
+ print_r($mailto) ;
+ print_r( $to);
+echo '</pre>' ;
+
+ 
+} 
+  */
+  
+add_event_handler('send_mail', 'clj_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 6);
+
+function clj_send_mail($result, $mailto, $subject, $content, $headers, $args)
+{
+    global $conf, $user, $lang_info,  $conf_mail;
+      $query = "
+    		SELECT COUNT(*)
+    		FROM ".FREE_MAIL_TABLE."
+  		;";
+  list($count) = mysql_fetch_row(pwg_query($query));
+  if ($count == 0)
+  {
+	 $next_day = time()  ;
+	 $date_check='';
+	   $q = '
+    INSERT INTO '.FREE_MAIL_TABLE.' (id, date_check)
+    VALUES (1,"'. $next_day.'")
+ 	 ;';
+  	pwg_query($q);
+ 	} 
+	 $query = "
+    SELECT *
+    FROM ".FREE_MAIL_TABLE."
+  	;";
+    $data = mysql_fetch_array(pwg_query($query));
+    $next_day = $data['date_check'];
+    $next_day =(float) ($next_day -time())/3600 ;
+  
+$ret="Attente de déblocage SPAMS " ;
+$t1='5.0';
+  
+   //================= réécriture de l'entête ===============================
+
+if (!isset( $mailto)){ echo 'erreur maito absent'; exit(); }
+if (empty( $mailto))  { echo 'erreur maito vide'; 
+ /*
+echo '<pre>
+-------------------------------------------------------------------
+CONF_MAIL
+';
+ print_r($conf_mail) ;
+ echo '<pre>
+-------------------------------------------------------------------
+ARGS
+';
+ print_r($args) ;
+echo '</pre>' ;
+*/
+//$mailto=$conf_mail['email_webmaster'];
+ 
+ 
+  $headers = 'From: '.$args['from']."\n";
+  $headers.= 'Reply-To: '.$args['from']."\n";
+
+    if (empty($mailto))
+  {
+    // Add only when to is empty
+    // else mail() add 'To:' on header
+  //  $headers.= 'To: undisclosed-recipients: ;'."\n";
+  }
+  
+  
+   if (!empty($args['Cc']))
+  {
+   // $headers.= 'Cc: '.implode(',', $args['Cc'])." \n";
+	   $headers.=  'Cc: '.$conf_mail['email_webmaster']." \n";
+  }
+ 
+  
+
+  if (!empty($args['Bcc']))
+  {
+    $temp= ' '.implode(',', $args['Bcc'])." \n";
+	//echo $temp;
+	//$headers.=  'Bcc: '.$temp." \n";
+	$temp='Bcc: '.$conf_mail['email_webmaster']." \n";
+   $headers.=  'Bcc: '.$conf_mail['email_webmaster']." \n";
+  }
+
+  $headers.= 'Content-Type: multipart/alternative;'."\n";
+  $headers.= '  boundary="---='.$conf_mail['boundary_key'].'";'."\n";
+  $headers.= '  reply-type=original'."\n";
+  $headers.= 'MIME-Version: 1.0'."\n";
+  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
+ 
+
+;
+ }
+ 
+ 
+        $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 .= $args['content']; // A voir texte brut...
+	   
+	   	$texte .= "\n\n"; 
+	
+	  	$content =$texte .$content ;
+
+		$ret=false;
+		// $t1 =$next_day ;
+ if ( $t1 >=$next_day) {
+   ob_start();
+   $ret = mail($mailto, $subject, $content, $headers);
+   $message = ob_get_contents();
+	//ob_flush();
+   ob_end_clean();
+//Trop de spam
+$pos = strpos($message, 'spam');
+ 
+if ($pos === false) {
+if ($ret) {
+    return $ret;
+	}
+	
+  		echo '<pre>';
+echo 		'mailto:   '.$mailto.'
+';
+		print_r($headers) ;
+		echo '--------------------------------------------
+		';
+		print_r($message) ;
+		
+			print_r($content) ;
+		echo '</pre>' ;
+		exit();
+		
+} else 
+{ 
+ echo $message;
+$ret=false;
+
+   }
+ 
+	
+
+ if ($ret) {
+     return $ret;
+ }else{
+        $next_day = time() + (2 * 24 * 60 * 60);
+        echo "Attention defaut d'envoie de mails " .$ret. "\n" ;
+       $query = '
+        UPDATE '.FREE_MAIL_TABLE.'
+        SET date_check="'. $next_day.'"
+      ;';
+      pwg_query($query);
+	  $next_day=($next_day-time()) /3600 ;
+	    exit();
+ }
+ 
+
+
+}else{
+
+	/* 	echo '<pre>';
+print_r ($headers);
+print_r($content );
+echo '</pre>';	
+*/
+
+	 	echo '<pre>';
+	 	print "Attention il ya eu un d&eacute;faut d'envoie de mails encore 
+	 	". (int)$next_day . "H
+		avant le déblocage."   ;
+	  	echo '</pre>';
+	   	echo '
+	  <a href="admin.php">RETOUR vers admin.php </a>
+	  ';
+	  	echo '<pre>';
+		echo 'ARGS:		';
+		print_r($args) ;
+			echo '
+			----------------------------------------------------
+			MAIL TO: 
+			' ;
+			print_r($mailto) ;
+
+			echo '
+			----------------------------------------------------
+			HEADER
+			' ;
+			print_r($headers) ;
+ 					echo '
+					----------------------------------------------------
+					content	
+			' ;
+			
+			print_r($content) ;
+		echo '</pre>' ;
+	
+     exit();
+ }
+ 
+
+}
+
+
+
+?>
Index: /extensions/free_mail/maintain.inc.php
===================================================================
--- /extensions/free_mail/maintain.inc.php	(revision 3912)
+++ /extensions/free_mail/maintain.inc.php	(revision 3912)
@@ -0,0 +1,52 @@
+<?php
+
+if(!defined("Free_Mail_PATH"))
+  define('Free_Mail_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+include_once (Free_Mail_PATH.'include/constants.php');
+
+function plugin_install()
+{
+  $q = '
+    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
+    VALUES ("free_mail","true;false;false;-1;-1;-1;false;false;;-1;;;false;;","Parametres du plugin free mail")
+  ;';
+  pwg_query($q);
+
+$id=0;
+
+	$q = "
+    CREATE TABLE IF NOT EXISTS ".FREE_MAIL_TABLE." (
+
+      `id`  smallint(5) NOT NULL default '0',
+      `date_check` INT NOT NULL DEFAULT '0' ,
+      PRIMARY KEY  (`id` )
+    )
+  ;";
+  pwg_query($q);
+
+
+  
+}
+
+
+
+function plugin_uninstall()
+{
+  global $conf;
+
+  if (isset($conf['free_mail']))
+  {
+    $q = '
+      DELETE FROM '.CONFIG_TABLE.'
+      WHERE param="free_mail"
+    ;';
+
+    pwg_query($q);
+  }
+
+
+  $q = 'DROP TABLE '.FREE_MAIL_TABLE.';';
+  pwg_query( $q );
+}
+?>
