Ignore:
Timestamp:
Apr 16, 2011, 3:53:31 PM (13 years ago)
Author:
cljosse
Message:

[extensions] mail_supervisor fix bug in design

Location:
extensions/Mail_supervisor/include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Mail_supervisor/include/constants.php

    r9702 r10419  
    55if (!defined('MAIL_BLACK_LISTE_TABLE')) define('MAIL_BLACK_LISTE_TABLE', $prefixeTable.'mail_black_list');
    66if (!defined('Sv_MAIL_TABLE')) define('Sv_MAIL_TABLE', $prefixeTable.'Sv_mail');
    7 global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
     7global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
    88$superv_champs = array(
    99  "id",
    1010  "nb_mails",
    1111  "date_mail",
    12   "nb_mails_maxi",             
    13   "nb_mails_periode",   
     12  "nb_mails_maxi",
     13  "nb_mails_periode",
    1414  "nb_spams",
    15   "date_spam", 
    16   "nb_spams_maxi",     
    17   "nb_spams_periode",   
     15  "date_spam",
     16  "nb_spams_maxi",
     17  "nb_spams_periode",
    1818  "quarantaine",
    1919  "date_quarantaine",
    20   "quarantaine_periode",       
    21   "message", 
    22   "message_test", 
    23   "header_text",                               
    24                 );     
    25                                                                        
    26         $superv_type = array(
    27                         " SMALLINT( 5 ) NOT NULL DEFAULT '0'"      ,
    28                                         "INT NOT NULL DEFAULT '0'"  ,
    29                                         "INT NOT NULL DEFAULT '0'"  ,
    30                                         "INT NOT NULL DEFAULT '2000'",         
    31                                         "TEXT"  ,       
    32                                         "INT NOT NULL DEFAULT '0'",
    33                                         "INT NOT NULL DEFAULT '0'",     
    34                                         "INT NOT NULL DEFAULT '10'",   
    35                                         "TEXT"  ,       
    36                                         "TEXT" ,
    37                                         "INT NOT NULL DEFAULT '0'",
    38                                         "TEXT"  ,       
    39                                         "TEXT"  ,
    40                                         "TEXT"  ,
    41                                         "TEXT"  ,
    42                                        
    43                                         );             
    44                                        
    45  
    46           $superv_bl_champs = array(
    47                                         "id",
    48                                         "ip",
    49                                         "pays",
    50                                         "region",               
    51                                         "ville",       
    52                                         "adresse",
    53                                         "fai", 
    54                                         "nb"
    55                                         );
    56                                        
    57         $superv_bl_type = array(
    58                         " smallint(5) UNSIGNED NOT NULL auto_increment ",
    59                                         "TEXT"  ,
    60                                         "TEXT"  ,
    61                                         "TEXT"  ,
    62                                         "TEXT"  ,
    63                                         "TEXT"  ,
    64                                         "TEXT"  ,
    65                                         " smallint(5) UNSIGNED "
    66                                         );                                                                                                                                     
     20  "quarantaine_periode",
     21  "message",
     22  "message_test",
     23  "header_text",
     24        );
     25
     26    $superv_type = array(
     27                    " SMALLINT( 5 ) NOT NULL DEFAULT '0'"      ,
     28                    "INT NOT NULL DEFAULT '0'"  ,
     29                    "INT NOT NULL DEFAULT '0'"  ,
     30                    "INT NOT NULL DEFAULT '2000'",
     31                    "TEXT"  ,
     32                    "INT NOT NULL DEFAULT '0'",
     33                    "INT NOT NULL DEFAULT '0'",
     34                    "INT NOT NULL DEFAULT '10'",
     35                    "TEXT"  ,
     36                    "TEXT" ,
     37                    "INT NOT NULL DEFAULT '0'",
     38                    "TEXT"  ,
     39                    "TEXT"  ,
     40                    "TEXT"  ,
     41                    "TEXT"  ,
     42
     43                    );
     44
     45
     46      $superv_bl_champs = array(
     47                    "id",
     48                    "ip",
     49                    "pays",
     50                    "region",
     51                    "ville",
     52                    "adresse",
     53                    "fai",
     54                    "nb"
     55                    );
     56
     57    $superv_bl_type = array(
     58                    " smallint(5) UNSIGNED NOT NULL auto_increment ",
     59                    "TEXT"  ,
     60                    "TEXT"  ,
     61                    "TEXT"  ,
     62                    "TEXT"  ,
     63                    "TEXT"  ,
     64                    "TEXT"  ,
     65                    " smallint(5) UNSIGNED "
     66                    );
    6767
    6868?>
  • extensions/Mail_supervisor/include/fonctions.php

    r10385 r10419  
    2626
    2727
    28 global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
     28global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
    2929// if (!isset($_COOKIE[session_name()])){}
    3030
     
    3232global $template ;
    3333//===============================================
    34 function corrige_header($Carbonne,$headers,$args,$cl_list_mail,$mailto="")      {
     34function corrige_header($Carbonne,$headers,$args,$cl_list_mail,$mailto="")  {
    3535  global $mails_options,$conf_mail,$infos_message;
    3636  if (!empty($args[$Carbonne]) && count($args[$Carbonne]) > 0 ){
    37     $cl_list_mail  =  str_replace(","," , ",get_strict_email_list(implode(',', $args[$Carbonne])))." \n"  ; 
     37    $cl_list_mail  =  str_replace(","," , ",get_strict_email_list(implode(',', $args[$Carbonne])))." \n"  ;
    3838    $cl_liste_dest = implode(', ', $args[$Carbonne])." \n";
    39     if ($mails_options['check_header_carbon'] == 'on') {   
    40         $headers = preg_replace('/.*'.$Carbonne.':(.*).\n/i', $Carbonne.': '.  $cl_list_mail, $headers);         
    41     } 
    42     $ret->list_mail = $cl_list_mail ;         
     39    if ($mails_options['check_header_carbon'] == 'on') {
     40        $headers = preg_replace('/.*'.$Carbonne.':(.*).\n/i', $Carbonne.': '.  $cl_list_mail, $headers);
     41    }
     42    $ret->list_mail = $cl_list_mail ;
    4343  } else {
    4444    // Raz Bcc, Cc dans headers
    4545    $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', "" , $headers);
    46     $ret->list_mail = "" ; 
    47   }
    48   $ret->headers = $headers ; 
    49   return $ret;         
    50 }
    51        
     46    $ret->list_mail = "" ;
     47  }
     48  $ret->headers = $headers ;
     49  return $ret;
     50}
     51
    5252function int_to_heure($int){
    5353  global $lang,$mails_donnees ;
     
    5656
    5757
    58         $delta=(7*24*60*60) ;
    59         $week = (int) ($int/$delta);
    60         $int= $int-($week*$delta) ; 
    61 
    62         $delta=(24*60*60) ;
    63         $day= (int) ($int/$delta);
    64         $int=$int-($day*$delta);
    65 
    66         $delta=(60*60) ;
    67         $heures=(int) ($int/$delta);
    68         $int=$int-($heures*$delta);
    69 
    70         $delta=(60) ;
    71         $minutes=(int) ($int/$delta);
    72         $int= $int - ($minutes*$delta);
    73 
    74         $secondes=(int) ($int);
    75         $day      = substr ('00'.    $day,-2,2);   
    76         $heures   = substr ('00'. $heures,-2,2);   
    77         $minutes  = substr ('00'.$minutes,-2,2);
    78         $secondes = substr ('00'.$secondes,-2,2);
    79        
     58    $delta=(7*24*60*60) ;
     59    $week = (int) ($int/$delta);
     60    $int= $int-($week*$delta) ;
     61
     62    $delta=(24*60*60) ;
     63    $day= (int) ($int/$delta);
     64    $int=$int-($day*$delta);
     65
     66    $delta=(60*60) ;
     67    $heures=(int) ($int/$delta);
     68    $int=$int-($heures*$delta);
     69
     70    $delta=(60) ;
     71    $minutes=(int) ($int/$delta);
     72    $int= $int - ($minutes*$delta);
     73
     74    $secondes=(int) ($int);
     75    $day      = substr ('00'.    $day,-2,2);
     76    $heures   = substr ('00'. $heures,-2,2);
     77    $minutes  = substr ('00'.$minutes,-2,2);
     78    $secondes = substr ('00'.$secondes,-2,2);
     79
    8080  $retour="";
    8181  $Week=explode(" ",l10n('Week %d'));
     
    8888  if ($secondes > 0) $retour .= "+" . $secondes." " .l10n('Second');
    8989  $retour=str_replace("+0","+",$retour);
    90   //================================================================================================   
     90  //================================================================================================
    9191  return $retour;
    92 }         
    93 
    94        
     92}
     93
     94
    9595function verif_base(){
    9696  global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
    9797  load_language('plugin.lang', MAIL_SUPERV_PATH);
    98   //==============================================================================             
     98  //==============================================================================
    9999  create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    100   ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ; 
    101   //==============================================================================             
     100  ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
     101  //==============================================================================
    102102  create_table(mail_superv_TABLE,$superv_champs,$superv_type) ;
    103103  ajust_table(mail_superv_TABLE,$superv_champs,$superv_type)  ;
    104   //==============================================================================             
    105     $valeurs= array (   1,
    106                                                           0,
    107                                    time(),
    108                          2000,
    109                   '"604800"' ,
    110                             0,
    111                        time(),
    112                            10,
    113                    '"172800"',
    114                     '"false"',
    115                        time(),
    116                    '"172800"',
    117                      '"Init"',
     104  //==============================================================================
     105    $valeurs= array (   1,
     106                                  0,
     107                       time(),
     108                     2000,
     109              '"604800"' ,
     110                        0,
     111                   time(),
     112                       10,
     113               '"172800"',
     114                '"false"',
     115                   time(),
     116               '"172800"',
     117                 '"Init"',
    118118   '"'.l10n('Sv_supervisor').'"',
    119         '"'.l10n('hello').'"',
    120         );
    121         ajout_ligne(mail_superv_TABLE,$superv_champs, $valeurs,false ) ;
     119    '"'.l10n('hello').'"',
     120    );
     121    ajout_ligne(mail_superv_TABLE,$superv_champs, $valeurs,false ) ;
    122122}
    123123//=================================================================================
     
    134134      array_push($columns_of, $row[0]);
    135135    }
    136  
     136
    137137  return $columns_of;
    138138}
     
    152152    LEFT JOIN '.USER_GROUP_TABLE.' AS ug
    153153      ON u.'.$conf['user_fields']['id'].' = ug.user_id
    154   WHERE ug.group_id='.$group_id.' '; 
     154  WHERE ug.group_id='.$group_id.' ';
    155155 $groups=array();
    156   $datas = pwg_query($query); 
    157  
     156  $datas = pwg_query($query);
     157
    158158  if (!empty($datas)) {
    159     while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)){     
    160       if (!empty($group['email'])){ 
     159    while ($group = mysql_fetch_array($datas,MYSQL_ASSOC)){
     160      if (!empty($group['email'])){
    161161         array_push($groups, format_email($group['username'], $group['email'] ));
    162162      }
    163163    }
    164   } 
     164  }
    165165  return $groups ;
    166  
     166
    167167}
    168168//=================================================================================
     
    170170function create_table($nom_table,$champs,$types)  //mail_superv_TABLE
    171171{
    172         $i=0;
    173         $valeurs=array();
     172    $i=0;
     173    $valeurs=array();
    174174  foreach ( $champs as $champ) {
    175175      $champ = trim($champ);
     
    179179
    180180
    181        
    182         if ( count($valeurs) == 0) return ;
     181
     182    if ( count($valeurs) == 0) return ;
    183183
    184184    $valeurs=implode(", ",$valeurs) ;
    185         //===============================================================================
    186                 $query = "CREATE TABLE IF NOT EXISTS  `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY  (`id` ) ) ENGINE=MyISAM  ;";   
    187                          if ( pwg_query($query) ) return ; 
    188                                 die("ERREUR CREATION ".$query);         
    189      
    190          
     185    //===============================================================================
     186        $query = "CREATE TABLE IF NOT EXISTS  `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY  (`id` ) ) ENGINE=MyISAM  ;";
     187             if ( pwg_query($query) ) return ;
     188                die("ERREUR CREATION ".$query);
     189
     190
    191191}
    192192function ajust_table($nom_table,$champs,$types)  //mail_superv_TABLE
     
    194194global $infos_message ;
    195195$colonnes = Get_colonnes_de($nom_table);
    196         $data =         $types ;
    197         $i=0;
    198         $valeurs=array();
     196    $data =     $types ;
     197    $i=0;
     198    $valeurs=array();
    199199foreach ( $champs as $champ)
    200200   {
    201201     $champ = trim($champ);
    202           if (!in_array( $champ,$colonnes)) {
     202      if (!in_array( $champ,$colonnes)) {
    203203         array_push($valeurs , " ADD `".$champ."`" . '  ' . $data[  $i] )  ;
    204         }
    205         $i +=1;
    206          
    207     }
    208 //============================================================================= 
    209         if ( count($valeurs) == 0) return ;
    210        
     204    }
     205    $i +=1;
     206
     207    }
     208//=============================================================================
     209    if ( count($valeurs) == 0) return ;
     210
    211211  $infos_message .=  "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . mail_supervisor::Memo_Var($valeurs) . "<br />" ;
    212        
     212
    213213     $valeurs=implode(", ",$valeurs) ;
    214         //===============================================================================
    215                 $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ;
    216                         if (   pwg_query($query)) return ;           
    217                 die($query);
    218 }
    219 //==============================================================================       
     214    //===============================================================================
     215        $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ;
     216            if (   pwg_query($query)) return ;
     217        die($query);
     218}
     219//==============================================================================
    220220function ajout_ligne($nom_table,$champs,$valeurs,$force)
    221221{
    222222  if (!$force) {
    223223     $query = "
    224                 SELECT `id` , COUNT(`id`) as total
    225                 FROM `".$nom_table."` GROUP by  `id`
    226                 ;";     
    227           list($count) = mysql_fetch_row(pwg_query($query));
    228 
    229                
     224            SELECT `id` , COUNT(`id`) as total
     225            FROM `".$nom_table."` GROUP by  `id`
     226        ;";
     227      list($count) = mysql_fetch_row(pwg_query($query));
     228
     229
    230230}else{
    231231
    232         $count = 0 ;
    233 }
    234  
     232        $count = 0 ;
     233}
     234
    235235  if ($count == 0)
    236236  {
    237237      $n_champs=implode(",",$champs);
    238238      $n_valeurs=implode(",",$valeurs);
    239            $query = "
    240         INSERT INTO `".$nom_table."` (". $n_champs.")
    241         VALUES ( ".     $n_valeurs .")";
    242                
    243                 if (pwg_query($query)) return ;
    244                 die($query);
    245                
     239       $query = "
     240        INSERT INTO `".$nom_table."` (". $n_champs.")
     241        VALUES ( ". $n_valeurs .")";
     242
     243        if (pwg_query($query)) return ;
     244        die($query);
     245
    246246  }
    247247}
     
    260260if (!is_numeric($mails_donnees['quarantaine_periode'])){
    261261  $periode=Str_To_Time( $mails_donnees['quarantaine_periode'],0);
    262   $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ; 
     262  $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ;
    263263 }
    264264    if  ($infos_message != "")  {
    265265        array_push($page['infos'],  $infos_message);
    266266        $infos_message="";
    267     }           
     267    }
    268268    if  ($erreur_message != "")  {
    269269        array_push($page['errors'], $erreur_message);
    270270        $erreur_message ="";
    271     }   
    272                  
     271    }
     272
    273273}
    274274//=======================================================================
     
    295295  $lang['Sv_'. $lang['Sv_second']] = 'second';
    296296
    297 } 
    298 //--- traduction --> anglais --- 
     297}
     298//--- traduction --> anglais ---
    299299
    300300 //========= suppression numeric et symbole ==========
    301 $new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter)); 
     301$new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter));
    302302$nv =  trim( sup_double_espace($new_valeur)) ;
    303  
    304  
    305  
    306         $conv['week']= (7*24*60*60);
    307         $conv['day']= (24*60*60);
    308         $conv['hour']=  (60*60) ;
    309         $conv['minute']=  60 ;
    310         $conv['second']= 1;
     303
     304
     305
     306    $conv['week']= (7*24*60*60);
     307    $conv['day']= (24*60*60);
     308    $conv['hour']=  (60*60) ;
     309    $conv['minute']=  60 ;
     310    $conv['second']= 1;
    311311
    312312  $nv = explode(" ", $nv );
    313  
     313
    314314  foreach($nv as $nv1){
    315315    if (!isset($lang['Sv_'. $nv1]) ) {
    316     //==== au cas pluriel === 
    317       $nv0 =  substr($nv1, 0,-1) ;   
     316    //==== au cas pluriel ===
     317      $nv0 =  substr($nv1, 0,-1) ;
    318318      $a_ajouter= str_replace( $nv1,$nv0,   $a_ajouter);
    319       $nv1 = $nv0 ;     
    320     } 
     319      $nv1 = $nv0 ;
     320    }
    321321    if (!isset($lang['Sv_'. $nv1]) ) {
    322       $erreur_message .= $nv1. " ".l10n('not_found')."<br />"; 
    323           //  die($erreur_message);       
     322      $erreur_message .= $nv1. " ".l10n('not_found')."<br />";
     323      //  die($erreur_message);
    324324    }else {
    325       ob_start(); 
     325      ob_start();
    326326      $match = $conv[strtolower($lang['Sv_'. $nv1])] ;
    327327      $a_ajouter = str_replace($nv1," ". $match  ." ",$a_ajouter) ;
    328328      $erreur_message .= ob_get_contents();
    329329      ob_end_clean();
    330           }               
     330      }
    331331  }
    332332
     
    338338  $new_valeur =  str_replace($v1,$v2,$a_ajouter) ;
    339339  $new_valeur =  str_replace('++','+',$new_valeur ) ;
    340                        
     340
    341341  return   $new_valeur;
    342342}
     
    347347  global $erreur_message,$infos_message,$user;
    348348  global $lang;
    349  
     349
    350350  $ajout=ucwords ($ajout);
    351  
    352  
     351
     352
    353353if (is_numeric($ajout))
    354354 $valeur=   $ajout ;
     
    356356{
    357357 $valeur= Date_to_numeric( $ajout) ;
    358  
     358
    359359 }
    360  
     360
    361361$new_valeur = explode( "|", $valeur );
    362362
     
    365365$erreur = false;
    366366
    367         //$new_valeur = $a_ajouter + $init_date ;
    368         foreach($new_valeur as $nv)
    369         {
    370         $return = matheval($nv) ;
    371                 if (strpos("error",$return)===false) {
    372                     $p += $return ;
    373                 }else {
    374                     $erreur_message .=   "[" . $ajout . "] --> " . l10n('Sv_syntax_error') . " : " .  $nv ."<br />";
    375                         $erreur = true;
    376                 }
    377                        
    378          
    379         }
    380         if ($erreur) $p = -1000 ;
     367    //$new_valeur = $a_ajouter + $init_date ;
     368    foreach($new_valeur as $nv)
     369    {
     370    $return = matheval($nv) ;
     371        if (strpos("error",$return)===false) {
     372            $p += $return ;
     373        }else {
     374            $erreur_message .=   "[" . $ajout . "] --> " . l10n('Sv_syntax_error') . " : " .  $nv ."<br />";
     375            $erreur = true;
     376        }
     377
     378
     379    }
     380    if ($erreur) $p = -1000 ;
    381381return    intval($p) ;
    382  
     382
    383383}
    384384//=====================================================================================
    385 function matheval($equation) 
    386   { 
     385function matheval($equation)
     386  {
    387387
    388388  $return="error";
    389389
    390  
    391     $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); 
    392     $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); 
    393     $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); 
    394     $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); 
    395        
    396     if ( $equation == "" ) 
    397     { 
    398       $return = 0; 
    399     }     else  { 
    400        @eval("\$return=" . $equation . ";" ); 
    401     }
    402  return $return; 
    403    
    404   } 
     390
     391    $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation);
     392    $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation);
     393    $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation);
     394    $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation);
     395
     396    if ( $equation == "" )
     397    {
     398      $return = 0;
     399    }     else  {
     400       @eval("\$return=" . $equation . ";" );
     401    }
     402 return $return;
     403
     404  }
    405405
    406406//======================================================================================
    407407function sup_double_espace($chaine){
    408408global $erreur_message;
    409         $str_temp = $chaine." ";
    410         $sep=" ";
    411         $chaine = trim($chaine);
     409    $str_temp = $chaine." ";
     410    $sep=" ";
     411    $chaine = trim($chaine);
    412412    if ($chaine=="") return ;
    413         $existe = (strpos($sep.$sep,$chaine )===false) ;
    414         while  ($existe ){
    415          $str_temp = str_replace($sep.$sep, $sep, $chaine ); 
    416                 if($str_temp == $chaine ) return $chaine ;
    417 //                      $erreur_message .= mail_supervisor::Memo_Var($str_temp) ;
    418                 $chaine  = $str_temp;
    419                         $existe =  (strpos($sep.$sep,$chaine )===false) ;
    420                 }
    421         return $chaine;
    422 }
    423 //==================== TEST black_liste ============================================   
     413    $existe = (strpos($sep.$sep,$chaine )===false) ;
     414    while  ($existe ){
     415         $str_temp = str_replace($sep.$sep, $sep, $chaine );
     416            if($str_temp == $chaine ) return $chaine ;
     417//          $erreur_message .= mail_supervisor::Memo_Var($str_temp) ;
     418            $chaine  = $str_temp;
     419            $existe =  (strpos($sep.$sep,$chaine )===false) ;
     420        }
     421    return $chaine;
     422}
     423//==================== TEST black_liste ============================================
    424424function kill_list() {
    425425  global $pays,$region,$ville,$ip ;
    426   global $erreur_message,$infos_message,$conf; 
     426  global $erreur_message,$infos_message,$conf;
    427427  global $conf, $user, $page;
    428428  global $mails_options ;
    429   global $superv_bl_champs,$superv_bl_type ; 
    430   global $nb ; 
     429  global $superv_bl_champs,$superv_bl_type ;
     430  global $nb ;
    431431  if (!isset($ip)) {
    432432    if (getenv("HTTP_CLIENT_IP"))   {
     
    437437  }
    438438  $champs=implode(',',$superv_bl_champs);
    439    $query = "SELECT ".$champs.",COUNT(`ip`) as total 
    440   FROM `".MAIL_BLACK_LISTE_TABLE."` 
    441                 WHERE '".$ip."' LIKE `ip`
    442                 GROUP by `ip`
    443   ;";   
    444         $result = @pwg_query($query);
    445         if (!$result) {
    446                         verif_base();
    447                         $result = @pwg_query($query);
    448                         }
    449           $datas = mysql_fetch_array($result,MYSQL_ASSOC);
    450         $nb = $datas['total']|0;
    451     //=======================================================================   
    452     if ($mails_options['set_auto'] == 'on') { 
     439   $query = "SELECT ".$champs.",COUNT(`ip`) as total
     440  FROM `".MAIL_BLACK_LISTE_TABLE."`
     441        WHERE '".$ip."' LIKE `ip`
     442        GROUP by `ip`
     443  ;";
     444    $result = @pwg_query($query);
     445    if (!$result) {
     446            verif_base();
     447            $result = @pwg_query($query);
     448            }
     449      $datas = mysql_fetch_array($result,MYSQL_ASSOC);
     450    $nb = $datas['total']|0;
     451    //=======================================================================
     452    if ($mails_options['set_auto'] == 'on') {
    453453      global $user_name,$mail_adresse;
    454454
    455455       if (isset($nb) && $nb>0) {
    456        //if (test_spam($ip,$user['username'] ,$user['email']))  // ne plus tester automatiquement . 
     456       //if (test_spam($ip,$user['username'] ,$user['email']))  // ne plus tester automatiquement .
    457457            if ($nb==0) {
    458                   $valeurs=array( 'NULL',
    459                            "'".$ip."'",
    460                                                 "'".$pays."'",
    461                                                 "'".$region."'",       
    462                                                 "'".$ville."'",
    463                                                 "'".$user['email']."'",
    464                                                 "'".$user['username']."'",     
    465                                                 $nb+1
    466                     );
    467                   ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;     
    468                 }else{ 
    469             mail_supervisor::Get_geo();   
    470             $nb +=1;   
    471                          $query ="UPDATE " . MAIL_BLACK_LISTE_TABLE . " SET ";
    472                          if (isset($_POST['pays']))     
    473                          $query .= "`pays` = '". $pays ."',
    474                                 `region` = '" . $region ."',
    475                                 `ville` = '" . $ville . "',                     
    476                                 ";                     
    477                          $query .= "`adresse` = '".$user['email']."',           
    478                                 `fai` = '".$user['username']."',               
    479                                 `nb` = " . $nb . "
    480                          WHERE '".$ip."' like `ip` ";           
    481                                        pwg_query($query );     
    482                 }
    483              $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_black_liste') ;
    484        // die($nb." ".$ip." ".$user['username']." ".$user['email']); 
    485  
    486        return true ;   
    487       } 
     458              $valeurs=array( 'NULL',
     459                   "'".$ip."'",
     460                            "'".$pays."'",
     461                            "'".$region."'",
     462                            "'".$ville."'",
     463                            "'".$user['email']."'",
     464                            "'".$user['username']."'",
     465                            $nb+1
     466                );
     467              ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;
     468            }else{
     469            mail_supervisor::Get_geo();
     470            $nb +=1;
     471                 $query ="UPDATE " . MAIL_BLACK_LISTE_TABLE . " SET ";
     472                 if (isset($_POST['pays']))
     473                 $query .= "`pays` = '". $pays ."',
     474                    `region` = '" . $region ."',
     475                    `ville` = '" . $ville . "',
     476                    ";
     477                 $query .= "`adresse` = '".$user['email']."',
     478                    `fai` = '".$user['username']."',
     479                    `nb` = " . $nb . "
     480                 WHERE '".$ip."' like `ip` ";
     481                       pwg_query($query );
     482            }
     483         $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_black_liste') ;
     484       // die($nb." ".$ip." ".$user['username']." ".$user['email']);
     485
     486       return true ;
     487      }
    488488    }
    489489 //==============================================================================
    490490
    491  if ( $mails_options['ip'] == $ip ) return ($nb > 0) ;   
     491 if ( $mails_options['ip'] == $ip ) return ($nb > 0) ;
    492492   $ip0= $mails_options['ip'] ;
    493    $mails_options['ip'] = $ip ; 
    494    mail_supervisor::sauve_options(); 
    495         if (  $nb > 0 )
    496         {
    497                $query = "
    498                 SELECT ".$champs.",COUNT(`id`) as total
    499                 FROM `".MAIL_BLACK_LISTE_TABLE."`
    500                     WHERE '".$ip."' = `ip`
    501                         GROUP by `ip`
    502                 ;";     
    503                 $result = @pwg_query($query);
    504  
    505         if (!$result) {
    506                                         verif_base();
    507                                         $result = @pwg_query($query);
    508                                         }
    509             $datas = mysql_fetch_array($result,MYSQL_ASSOC);
    510                  $nb = $datas['total'];
    511                  
    512             $row  = mysql_fetch_row(pwg_query($query));
    513             $nb =  ($row[7]);
    514         $erreur_message .= $ip0 . ' | ' .$ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 
    515  
    516         if ($nb == 0)
    517                 {
    518                         $valeurs=array( 'NULL',
    519                             "'".$ip."'",
    520                                         "'".$pays."'",
    521                                         "'".$region."'",       
    522                                         "'".$ville."'",
    523                                         "'".$user['email']."'",         
    524                           "'".$user['username']."'",           
    525                                         1
    526               );
    527                   ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ;       
    528                  
    529                 } else {
    530                   $nb += 1;
    531         $query ="
    532                         UPDATE " . MAIL_BLACK_LISTE_TABLE . "
    533                         SET ";
    534                 if (isset($_POST['pays']))     
    535                  $query .= "   
    536                         `pays` = '". $pays ."',
    537                         `region` = '" . $region ."',
    538                         `ville` = '" . $ville . "',
    539                         ";
    540                  $query .= "   
    541                     `adresse` = '".$user['email']."',
    542                         `fai` = '".$user['username']."',                       
    543                         `nb` = " . $nb . "
    544                     WHERE '".$ip."' = `ip`
    545                 ";
    546                
    547                                 pwg_query($query );     
    548                                 }
    549         }
     493   $mails_options['ip'] = $ip ;
     494   mail_supervisor::sauve_options();
     495    if (  $nb > 0 )
     496    {
     497           $query = "
     498            SELECT ".$champs.",COUNT(`id`) as total
     499            FROM `".MAIL_BLACK_LISTE_TABLE."`
     500            WHERE '".$ip."' = `ip`
     501            GROUP by `ip`
     502        ;";
     503        $result = @pwg_query($query);
     504
     505    if (!$result) {
     506                    verif_base();
     507                    $result = @pwg_query($query);
     508                    }
     509        $datas = mysql_fetch_array($result,MYSQL_ASSOC);
     510         $nb = $datas['total'];
     511
     512        $row  = mysql_fetch_row(pwg_query($query));
     513        $nb =  ($row[7]);
     514        $erreur_message .= $ip0 . ' | ' .$ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> ';
     515
     516    if ($nb == 0)
     517        {
     518            $valeurs=array( 'NULL',
     519                    "'".$ip."'",
     520                    "'".$pays."'",
     521                    "'".$region."'",
     522                    "'".$ville."'",
     523                    "'".$user['email']."'",
     524              "'".$user['username']."'",
     525                    1
     526          );
     527          ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ;
     528
     529        } else {
     530          $nb += 1;
     531    $query ="
     532            UPDATE " . MAIL_BLACK_LISTE_TABLE . "
     533            SET ";
     534        if (isset($_POST['pays']))
     535         $query .= "
     536            `pays` = '". $pays ."',
     537            `region` = '" . $region ."',
     538            `ville` = '" . $ville . "',
     539            ";
     540         $query .= "
     541            `adresse` = '".$user['email']."',
     542            `fai` = '".$user['username']."',
     543            `nb` = " . $nb . "
     544            WHERE '".$ip."' = `ip`
     545            ";
     546
     547                pwg_query($query );
     548                }
     549    }
    550550 return ($nb > 0) ;
    551551}
     
    558558 $result="";
    559559 $ip= sup_double_espace($ip);
    560  if (strlen($ip)>3) { 
     560 if (strlen($ip)>3) {
    561561   //==================  Verifie si l'IP est correct  ================================
    562    if (clj_is_ip($ip)){     
    563      
    564    } else { 
    565    //==================  Verifie si l'adresse mail est correcte  ================================ 
    566          if( clj_is_mail($ip) ){ 
    567                         $mail_adresse=$ip ;
    568                  $ip="";
    569             }
    570             else
    571             {
    572    //==================  Login  ================ 
    573               $user_name=$ip;
    574               $ip="";
    575             }
    576    }   
     562   if (clj_is_ip($ip)){
     563
     564   } else {
     565   //==================  Verifie si l'adresse mail est correcte  ================================
     566         if( clj_is_mail($ip) ){
     567            $mail_adresse=$ip ;
     568             $ip="";
     569        }
     570        else
     571        {
     572   //==================  Login  ================
     573          $user_name=$ip;
     574          $ip="";
     575        }
     576   }
    577577   //=============================================================================
    578578 }
     
    582582 $user_name="";  // ne plus tester sur le login.
    583583 $mail_adresse =str_replace(" ","%20",trim($mail_adresse));
    584  if ( strlen($user_name) > 3)     $type[]="username=$user_name" ;
     584 if ( strlen($user_name) > 3)     $type[]="username=$user_name" ;
    585585 if ( strlen($mail_adresse) > 3)   $type[]="email=".$mail_adresse ;
    586  if ( strlen($ip) > 3)   $type[]="ip=".$ip ; 
    587  foreach  ( $type as $fil ) {   
     586 if ( strlen($ip) > 3)   $type[]="ip=".$ip ;
     587 foreach  ( $type as $fil ) {
    588588  $resultat="";
    589589  if (  clj_fetchRemote($src.$fil , $resultat,1))
    590    $result .= $resultat.'<br />'  ;               
     590   $result .= $resultat.'<br />'  ;
    591591 }
    592592
    593593 return !(strpos(  $result ,'yes' ) === false) ;
    594  
     594
    595595}
    596596//==================================================================
    597597function lire_fichier_distant($fichier){
    598598  $buffer="";
    599   $handle =  @fopen($fichier,"r"); 
     599  $handle =  @fopen($fichier,"r");
    600600  if ($handle) {
    601     while (!feof($handle)) { 
     601    while (!feof($handle)) {
    602602        $buffer .= fgets($handle, 4096);
    603                   }   
    604                           fclose($handle);
    605           }
    606                                  
     603          }
     604              fclose($handle);
     605      }
     606
    607607  return  $buffer ;
    608608
     
    611611function clj_is_ip($ip){
    612612if (preg_match("/^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9])\.){1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9])\.){2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))$/",$ip))    return true ;
    613                  
     613
    614614}
    615615
    616616function clj_is_mail($mail)
    617 {     
    618 
    619  if(preg_match('/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/' ,$mail)) return true ;     
    620   if(preg_match('/#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#/' ,$mail)) return true ;   
    621 }         
    622 
    623  
     617{
     618
     619 if(preg_match('/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/' ,$mail)) return true ;
     620  if(preg_match('/#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#/' ,$mail)) return true ;
     621}
     622
     623
    624624function clj_fetchRemote($src, &$dest, $timeout=1, $user_agent='Piwigo', $step=0)
    625625{
     
    628628
    629629  if ($src=="") return ;
    630  
     630
    631631  if (!url_is_remote($src))
    632632  {
    633  
     633
    634634    $content = @file_get_contents($src);
    635635    if ($content !== false)
     
    643643    }
    644644  }
    645  
     645
    646646  // After 3 redirections, return false
    647647  if ($step > 3) return false;
  • extensions/Mail_supervisor/include/function_test_send.php

    r9702 r10419  
    2323
    2424if ( !defined('PHPWG_ROOT_PATH'))   die('Hacking attempt!');
    25 function test_envoie($message,$group_name,$group_id){   
     25function test_envoie($message,$group_name,$group_id){
    2626  global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$args,$lang ;
    27         $mailto="";     
     27    $mailto="";
    2828 load_language('plugin.lang', MAIL_SUPERV_PATH);
    29  
     29
    3030//==================================================================================
    3131if (!isset($infos_message))
    32         {
    33         $infos_message = "";
    34         }
     32    {
     33        $infos_message = "";
     34    }
    3535if (!isset($erreur_message))
    36         {
    37         $erreur_message = '';
    38         }
     36    {
     37        $erreur_message = '';
     38    }
    3939if (!isset($mails_donnees))
    40         {
    41         $mails_donnees = mail_supervisor::Get_Datas();
    42         }               
     40    {
     41        $mails_donnees = mail_supervisor::Get_Datas();
     42    }
    4343if (!isset($conf_mail))
    4444  {
    45         $conf_mail = get_mail_configuration();
     45        $conf_mail = get_mail_configuration();
    4646  }
    47           if (isset($args))
    48   { 
     47      if (isset($args))
     48  {
    4949    $infos_message=mail_supervisor::Memo_Var($args);
    5050  }else{
    51         $args = array();
    52         }
     51    $args = array();
     52    }
    5353//=====================================================================================================
    5454
    55  
     55
    5656
    5757$groups=get_liste($group_id);
     
    6262       $args['Bcc']=$groups;
    6363   }   else {
    64        $mailto = $conf_mail['formated_email_webmaster']; 
    65    } 
    66    
     64       $mailto = $conf_mail['formated_email_webmaster'];
     65   }
     66
    6767$args['from'] =(function_exists('get_user_language_desc')) ? get_user_language_desc($conf_mail['formated_email_webmaster']):$conf_mail['formated_email_webmaster'];
    6868$message_html =$message;
    6969      if (function_exists('get_user_language_desc') and isset($message) and $message <> '')
    7070        $message = get_user_language_desc($message)."\n\n";
    71  
    72         //==================================================================
    73         $message_texte=sprintf(
     71
     72    //==================================================================
     73    $message_texte=sprintf(
    7474        l10n('Sv_message_texte %s %s %s %s'),
    7575        format_date( date("Y-m-d H:i:s")),
    76                 $group_name,
    77                 $message,
    78                 $args['from']
    79         );     
    80         //==================================================================
    81         $message_html .= "</br>" . $message . "</br>" . $message_texte;
     76        $group_name,
     77        $message,
     78        $args['from']
     79        );
     80    //==================================================================
     81    $message_html .= "</br>" . $message . "</br>" . $message_texte;
    8282 //==========================================================================
    8383
    84         $args['subject']="Plugin Piwigo TEST";
    85         $args['content']=$message_html;
    86                 $infos_message .="To :" . $mailto;
    87                
    88         $ret= pwg_mail($mailto , $args); 
    89         if ( $group_name <> '' or $mailto <> '' )
    90         {       
    91                 if ($group_name<>'') {
    92                 $infos_message .=  '<br />'.  sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />';
    93                         }
    94                         if ($mailto <> '') {
    95                                 $infos_message .=  '<br />'.  sprintf( l10n('Sv_mail_sent_to'), $mailto ).'<br />';
    96                                 }
    97                  
    98         }else{
    99                $infos_message .='<br />'.l10n('Sv_no_receiver_available') ;
    100         }
     84        $args['subject']="Plugin Piwigo TEST";
     85        $args['content']=$message_html;
     86        $infos_message .="To :" . $mailto;
     87
     88        $ret= pwg_mail($mailto , $args);
     89    if ( $group_name <> '' or $mailto <> '' )
     90    {
     91        if ($group_name<>'') {
     92        $infos_message .=  '<br />'.  sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />';
     93            }
     94            if ($mailto <> '') {
     95                $infos_message .=  '<br />'.  sprintf( l10n('Sv_mail_sent_to'), $mailto ).'<br />';
     96                }
     97
     98    }else{
     99           $infos_message .='<br />'.l10n('Sv_no_receiver_available') ;
     100    }
    101101}
    102102//===============================================================================================================
     
    105105
    106106    $mails_donnees = mail_supervisor::Get_Datas();
    107           if (!isset($conf_mail))
     107      if (!isset($conf_mail))
    108108  {
    109109    $conf_mail = get_mail_configuration();
     
    112112 load_language('plugin.lang', MAIL_SUPERV_PATH);
    113113
    114                 $nom ='piwigo_logo_sombre_214x100.png';
    115                 $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ;
    116                 $typemime='image/jpeg';
    117                                
    118                 $fd = fopen( $fichier, "r" );
    119                 $contenu = fread( $fd, filesize( $fichier ) );
    120                 fclose( $fd );
    121                 $piecejointe  = chunk_split(base64_encode($contenu));
    122                
    123                
    124         $from=$args['from'];
     114        $nom ='piwigo_logo_sombre_214x100.png';
     115        $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ;
     116        $typemime='image/jpeg';
     117
     118        $fd = fopen( $fichier, "r" );
     119        $contenu = fread( $fd, filesize( $fichier ) );
     120        fclose( $fd );
     121        $piecejointe  = chunk_split(base64_encode($contenu));
     122
     123
     124    $from=$args['from'];
    125125$to="";
    126126
     
    128128        l10n('Sv_message_texte %s %s %s'),
    129129        format_date( date("Y-m-d H:i:s")),
    130                 $to,
    131                 $from
    132         );     
    133                
    134  
    135   $message_html =       '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />';
    136   ob_start();   
    137  
     130        $to,
     131        $from
     132        );
     133
     134
     135  $message_html =   '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />';
     136  ob_start();
     137
    138138  echo str_replace("\n","<br />",$message_texte);
    139        
     139
    140140  $message_html .= ob_get_contents()."\n";
    141141  //ob_flush();
    142142  ob_end_clean();
    143143
    144   $limite=$conf_mail['boundary_key'];   
    145   $headers =   date("Y-m-d H:i:s") ."\n"; 
     144  $limite=$conf_mail['boundary_key'];
     145  $headers =   date("Y-m-d H:i:s") ."\n";
    146146
    147147  //=======================================================================================
     
    149149    $headers.= "Reply-To: ".$args['from']."\n";
    150150    $nb_destinataires=0;
    151     $destinataire = $conf_mail['email_webmaster']; 
     151    $destinataire = $conf_mail['email_webmaster'];
    152152    if (!empty($args['Cc'])){
    153153      $nb_destinataires += count($args['Cc']);
    154154      $to= explode(',', $args['Cc']);
    155       $headers  .= get_strict_email_list($to) ;             
    156         }
    157     if (!empty($args['Bcc'])){ 
    158       $nb_destinataires += count($args['Bcc']); 
     155      $headers  .= get_strict_email_list($to) ;
     156    }
     157    if (!empty($args['Bcc'])){
     158      $nb_destinataires += count($args['Bcc']);
    159159      $to = implode(',', $args['Bcc']);
    160       $headers  .= 'Bcc :'.get_strict_email_list($to)."\n" ;               
     160      $headers  .= 'Bcc :'.get_strict_email_list($to)."\n" ;
    161161    }
    162162
     
    166166    $headers.= 'MIME-Version: 1.0'."\n";
    167167    $headers.= 'X-Mailer: Piwigo Mailer'."\n";
    168     //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML 
    169     $texte = "This is a multi-part message in MIME format.\n"; 
    170     $texte .= "-----=".$limite."\n"; 
    171     $texte .= "Ceci est un message est au format MIME.\n"; 
    172     $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 
    173     $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
    174     $texte .= $message_texte ; 
    175     $texte .= "\n\n";           
    176     $texte .= "-----=".$limite."\n"; 
    177     $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; 
    178     $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
    179     $texte .= $message_html; 
    180     $texte .= "\n\n"; 
    181     $attachement = "-----=".$limite."\n"; 
    182     $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 
    183     $attachement .= "Content-Transfer-Encoding: base64\n"; 
    184     $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 
    185     $attachement .= $piecejointe; 
    186     $attachement .= "\n\n\n-----=".$limite."\n"; 
     168    //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML
     169    $texte = "This is a multi-part message in MIME format.\n";
     170    $texte .= "-----=".$limite."\n";
     171    $texte .= "Ceci est un message est au format MIME.\n";
     172    $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n";
     173    $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n";
     174    $texte .= $message_texte ;
     175    $texte .= "\n\n";
     176    $texte .= "-----=".$limite."\n";
     177    $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n";
     178    $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n";
     179    $texte .= $message_html;
     180    $texte .= "\n\n";
     181    $attachement = "-----=".$limite."\n";
     182    $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n";
     183    $attachement .= "Content-Transfer-Encoding: base64\n";
     184    $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n";
     185    $attachement .= $piecejointe;
     186    $attachement .= "\n\n\n-----=".$limite."\n";
    187187    $ret=false;
    188188    ob_start();
    189     $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); 
     189    $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers);
    190190    $message =  ob_get_contents() ;
    191191  //ob_flush();
     
    195195    $infos_message =  "-------------------";
    196196  }
    197   return  $ret; 
     197  return  $ret;
    198198}
    199199?>
  • extensions/Mail_supervisor/include/save_info.php

    r9702 r10419  
    44switch (strtolower($info_ip))
    55 {
    6   case  'ajout' : 
     6  case  'ajout' :
    77 $ip_black=str_replace("*","%",$ip_black);
    88 if (!($ip_black == '')) {
    99   $query = "
    10                 SELECT `ip`
    11                 FROM `".MAIL_BLACK_LISTE_TABLE."`
    12                     WHERE  '".$ip_black."' LIKE ip
    13                 ;";     
    14         //==============================================================================               
     10            SELECT `ip`
     11            FROM `".MAIL_BLACK_LISTE_TABLE."`
     12            WHERE  '".$ip_black."' LIKE ip
     13        ;";
     14    //==============================================================================
    1515  list($count) = mysql_fetch_row(pwg_query($query));
    16   //==============================================================================     
     16  //==============================================================================
    1717  $valeurs=array( 'NULL',
    18                             "'".$ip_black."'",
    19                                                  "'".$pays."'",
    20                                                  "'".$region."'",       
    21                                                  "'".$ville."'",
    22                                                  '"adresse"',
    23                                                  '"fai" ',
    24                                                  $count + 1
    25                 );
    26         ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,($count==0)) ;   
     18                    "'".$ip_black."'",
     19                             "'".$pays."'",
     20                             "'".$region."'",
     21                             "'".$ville."'",
     22                             '"adresse"',
     23                             '"fai" ',
     24                             $count + 1
     25            );
     26    ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,($count==0)) ;
    2727 }
    28  
     28
    2929 break;
    3030 //================================================================================================
    3131  case 'raz':
    3232    $ip_black=str_replace('*',"%",$ip_black);
    33                 $query = "DELETE FROM `".MAIL_BLACK_LISTE_TABLE."` WHERE `ip`  like '%".$ip_black."%' ";
    34                         pwg_query($query);
    35    
     33        $query = "DELETE FROM `".MAIL_BLACK_LISTE_TABLE."` WHERE `ip`  like '%".$ip_black."%' ";
     34            pwg_query($query);
     35
    3636    unset ($_SESSION['pwg_'.'action_spam']);
    3737   break;
    38    
    39     default:                           
     38
     39    default:
    4040   break;
    41    
    42   } 
     41
     42  }
    4343//================ Liste Black liste =================
    4444  $query = "
    45      SELECT *,  COUNT(`ip`) as total ,  `ip` as blacklist, `ip` as U_DELETE
     45     SELECT *,  COUNT(`ip`) as total ,  `ip` as blacklist, `ip` as U_DELETE
    4646     FROM ".MAIL_BLACK_LISTE_TABLE."
    47      GROUP by ip 
     47     GROUP by ip
    4848     ;";
    49         $liste_bl = array();
     49    $liste_bl = array();
    5050 $result = pwg_query($query);
    51                 while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   {
    52                         array_push($liste_bl,$row);
    53                                 }         
    54 //================ Liste IP ==============             
    55 $req = mysql_query('SELECT count(distinct(`IP`)) FROM '.HISTORY_TABLE.'    '); 
     51        while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   {
     52                array_push($liste_bl,$row);
     53                }
     54//================ Liste IP ==============
     55$req = mysql_query('SELECT count(distinct(`IP`)) FROM '.HISTORY_TABLE.'    ');
    5656$nbip =  array_pop(mysql_fetch_row($req)) ;
    5757
    58         $query = 'SELECT DISTINCT       H.`id`,
     58    $query = 'SELECT DISTINCT   H.`id`,
    5959            H.`date`,
    6060            H.`time`,
    6161            H.`user_id`,
    62             H.`IP`, 
    63             COUNT(H.`IP`) as total 
    64             FROM '.HISTORY_TABLE.'  AS H 
    65             WHERE  "'.$ip.'"not LIKE H.`IP`     ';//
    66         if (count($liste_bl)>0){
    67         $query .= '     AND  H.`IP` not IN ( SELECT `ip`
     62            H.`IP`,
     63            COUNT(H.`IP`) as total
     64            FROM '.HISTORY_TABLE.'  AS H
     65            WHERE  "'.$ip.'"not LIKE H.`IP`     ';//
     66    if (count($liste_bl)>0){
     67    $query .= ' AND  H.`IP` not IN ( SELECT `ip`
    6868    FROM '.MAIL_BLACK_LISTE_TABLE.' ) ';
    69         }
    70  
    71         $query .= '     
    72         GROUP by H.`IP`
    73         ORDER by `id` DESC
    74         LIMIT '.(int)($params['per_page']*$params['start']).','.(int)$params['per_page'].'     
    75         '   ;
     69    }
    7670
    77         $result = pwg_query($query);
    78         $liste_ip=array();
    79         while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   {
     71    $query .= '
     72    GROUP by H.`IP`
     73    ORDER by `id` DESC
     74    LIMIT '.(int)($params['per_page']*$params['start']).','.(int)$params['per_page'].'
     75    '   ;
    8076
    81                   array_push($liste_ip, $row);
    82                                 }
     77    $result = pwg_query($query);
     78    $liste_ip=array();
     79    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   {
     80
     81              array_push($liste_ip, $row);
     82                }
    8383
    8484?>
Note: See TracChangeset for help on using the changeset viewer.