Index: tensions/free_mail/main.inc.php =================================================================== --- /extensions/free_mail/main.inc.php (revision 3979) +++ (revision ) @@ -1,394 +1,0 @@ -'; -print_r($headers) ; -echo '' ; -} - -add_event_handler('send_mail_to', 'clj_send_mail_to'); -function clj_send_mail_to($mailto) -{ -echo '
'; -//print_r($mailto) ; -echo '' ; -} - -add_event_handler('send_mail_content', 'clj_send_mail_content'); -function clj_send_mail_content($content) -{ -echo '
'; -//print_r($content) ; -echo '' ; -} - -*/ -// 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 '
'; - print_r($mailto) ; - print_r( $to); -echo '' ; - - -} -EVENT_HANDLER_PRIORITY_NEUTRAL */ - -add_event_handler('send_mail', 'clj_send_mail',1 , 6); - -function clj_send_mail($result, $mailto, $subject, $content, $headers, $args) -{ - global $conf, $user, $lang_info, $conf_mail; - - $infos=Get_données(); - -$nbenv = $infos->nbenv ; -$next_day = $infos->next_day ; -$reste = $infos->reste ; -$quarantaine = $infos->quarantaine ; -$admins = $infos->admins ; - -$ret="Attente de déblocage SPAMS " ; - - - //================= réécriture de l'entête =============================== - -if (!isset( $mailto)){ echo 'erreur maito absent'; exit(); } -if (empty( $mailto)) { - /* -echo '
-------------------------------------------------------------------- -CONF_MAIL -'; - print_r($conf_mail) ; - echo '-------------------------------------------------------------------- -ARGS -'; - print_r($args) ; -echo '' ; -*/ - -//$mailto=$conf_mail['email_webmaster']; - //$mailto=""; - - $headers = 'From: '.$args['from']."\n"; - $headers.= 'Reply-To: '.$args['from']."\n"; - - if (!empty($args['Cc'])) - { - // $headers.= 'Cc: '.implode(',', $args['Cc'])." \n"; - $headers.= 'Cc: '.implode(',', $admins)." \n"; - } - if (!empty($args['Bcc'])) - { - // $headers.= 'Bcc: '.implode(',', $args['Bcc'])." \n"; - $headers.= 'Bcc: '.implode(',', $admins)." \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"; - /* - echo '-------------------------------------------------------------------- -headers -'; - print_r($headers) ; -echo '' ; - */ - } - - - $ret=false; - if ( $reste <=0 ) { - ob_start(); - $ret = mail($mailto, $subject, $content, $headers); - $message = ob_get_contents()."\n"; - - - //ob_flush(); - ob_end_clean(); -//Trop de spam -$pos = strpos($message, 'spam'); - $query = ' - UPDATE '.FREE_MAIL_TABLE.' - SET message="'. $message.'. " - ;'; - pwg_query($query); - -if ($pos === false) { - if ($nbenv==0) { - $dateenv=time(); - $query = ' - UPDATE '.FREE_MAIL_TABLE.' - SET dateenv="'. $dateenv.'" - ;'; - pwg_query($query); - } - $next_day = time() + (0); //20 secondes - $query = ' - UPDATE '.FREE_MAIL_TABLE.' - SET date_check="'. $next_day .'" - ;'; - pwg_query($query); - - $nbenv += 1; - $query = ' - UPDATE '.FREE_MAIL_TABLE.' - SET nbenv="'. $nbenv.'" - ;'; - pwg_query($query); - - - if ($ret) { - - return $ret; - - } - echo ''; - echo ' - ---- La fonction mail à retournée [false] ------ - '; - - -echo 'mailto: '.$mailto.' -'; - echo ' - -------- MESSAGE ----------------- - '; - print_r($message) ; - echo ' - --------HEADERS ----------------- - '; - print_r($headers) ; - echo ' - --------CONTENT ----------------- - '; - print_r($content) ; - echo '' ; - 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); - $reste=($next_day-time()) /3600 ; - exit(); - } - - - -}else{ - - /* echo ''; -print_r ($headers); -print_r($content ); -echo ''; -*/ - - -if ($reste >= 1) { - echo ''; - print "Attention il ya eu un défaut d'envoie de mails encore - ". (int ) $reste . "H - avant le déblocage." ; - } - else{echo '' ; - - - } - - -} - -//================================================================================= -function Get_colonne_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; -} - -function Get_données() -{ -global $conf, $user; - - $nb = Get_colonne_de(FREE_MAIL_TABLE); - $table=$nb[FREE_MAIL_TABLE]; -//================================================================================ - if (!in_array( "nbenv",$table)) { - $query = "ALTER TABLE `".FREE_MAIL_TABLE."` ADD `nbenv` smallint(5) NOT NULL default '0' "; - pwg_query($query); } - if (!in_array( "dateenv",$table)) { - $query = "ALTER TABLE `".FREE_MAIL_TABLE."` ADD `dateenv` INT NOT NULL default '0' "; - pwg_query($query); } - if (!in_array( "quarantaine",$table)) { - $query = "ALTER TABLE `".FREE_MAIL_TABLE."` ADD `quarantaine` bool NOT NULL "; - pwg_query($query); } - if (!in_array( "message",$table)) { - $query = "ALTER TABLE `".FREE_MAIL_TABLE."` ADD `message` TEXT "; - pwg_query($query); } - $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,nbenv, date_check,dateenv, quarantaine,message) - VALUES (1,0,"'. $next_day.'","'. $next_day.'" ,false,".") - ;'; - pwg_query($q); - } - - - $query = " - SELECT * - FROM ".FREE_MAIL_TABLE." - ;"; - $data = mysql_fetch_array(pwg_query($query)); - // limite 2000 par semaine. - - $infos->nbenv = $data['nbenv']; - $infos->next_day = $data['date_check']; - - $infos->reste =(float) ( $data['date_check'] - time())/3600 ; - - $infos->quarantaine = $data['quarantaine']; - $infos->message = $data['message']; -//============================================================ - - $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'])); - $temp= $admin['mail_address'] ; - array_push($admins,$temp); - } - } - } - - if (count($admins) > 0) - { - - } -$infos->admins = $admins ; - return $infos; -//======================================================================== - echo ''; - print "Il faut attendre au minimun 20 sec avent un deuxième envoie encore avant le déblocage." ; - } - - echo ''; - echo ' - RETOUR - '; - - echo "Dernier message :".$message. " reçu."; - - exit(); - - echo 'ARGS: '; - print_r($args) ; - echo ' - ---------------------------------------------------- - MAIL TO: - ' ; - print_r($mailto) ; - - echo ' - ---------------------------------------------------- - HEADER - ' ; - print_r($headers) ; - echo ' - ---------------------------------------------------- - content - ' ; - - print_r($content) ; - echo ''; -echo FREE_MAIL_TABLE; -echo ' ------------ ADMINS ---------------------------------------- -'; -print_r ($admins); -echo ' -------------------------------------------------------------------- -'; -print_r ($infos); -echo ''; - - - - -} - -?>