Ignore:
Timestamp:
Mar 15, 2011, 3:39:19 PM (13 years ago)
Author:
cljosse
Message:

[Mail supervisor] add class.

File:
1 edited

Legend:

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

    r8917 r9702  
    2222// +-----------------------------------------------------------------------+
    2323
    24 if (!defined('PHPWG_ROOT_PATH'))
    25 {
    26   die('Hacking attempt!');
    27 }
    28 
     24if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    2925if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    3026
    31     define ("check_mailto", 0);
    32         define ("check_header_carbon",1);
    33         define ("check_header_text",2);
    34     define ("no_mail_list", 3);
    35         define ("no_connect",4);        // empeche l'ip de se connecter au site.
    36         define ("set_auto",5);          // Test a l'ouverture et enregistrement
    37     define ("ip",6);                    // dernirre adresse IP
    38         define ("set_id",7);            // enregistrment nouvel
    39  
    40  
    41  if (!isset($_COOKIE[session_name()]))
    42 {
    43 
    44 
    45 
    46 }
    47 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    48 include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
    49 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     27global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
     28// if (!isset($_COOKIE[session_name()])){}
     29
    5030global $lang ;
    51 
    52 include_once (MAIL_SUPERV_PATH.'include/function_test_send.php');
    53     load_language('plugin.lang', MAIL_SUPERV_PATH);
    54 global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
    55          
    56 //==========================================================
    57 function sauve_options()
    58 {
    59 global $mails_options ;
    60  if ( isset($mails_options) )
    61         {
    62          
    63          while ( count($mails_options) < 10 )
    64            {
    65          
    66               $mails_options[]='?';
    67            }
    68            
    69                 $valeurs = implode( ',',$mails_options);
    70  
    71                
    72                 $query = '
    73                 UPDATE '.CONFIG_TABLE.'
    74                 SET value="'. $valeurs . '"
    75                 WHERE param = "mail_superv"
    76                 LIMIT 1';
    77                         pwg_query($query);
    78          
    79         }
    80 }
    81 //=================================================================================
    82 function sauve_donnees()
    83 {
    84 
    85 global $mails_donnees,$superv_champs,$superv_type,$erreur_message ;
    86 //=====================================================================
    87         $clefs = $superv_champs ;
    88         $valeurs = array();
    89 
    90 foreach ( $clefs as $champ)
    91    {
    92      $champ = trim($champ);
    93      
    94          if ( isset($mails_donnees[  $champ ]) ) {
    95            $sep= (is_string($mails_donnees[ $champ ])) ? '"' : '' ;
    96        array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_donnees[  $champ ] . $sep)  ;
    97          }else{
    98          
    99             array_push($valeurs , "`".$champ."`" . ' = ' .  "0"  )  ;
    100          }
    101          
    102     }
    103 $valeurs = implode(", ",$valeurs) ;
    104 //=====================================================================
    105 $query = '
    106         UPDATE '.MAIL_SUPERV_TABLE.'
    107         SET '. $valeurs .'
    108                 WHERE `id` = 1 LIMIT 1 ';
    109                 ;
    110         ob_start();
    111                 $ret=  pwg_query($query)    ;
    112                 $m= ob_get_contents();
    113         ob_end_clean() ;
    114         $erreur_message .= $m ;
    115 
    116 }
    117          
    118 //=================================================================================
    119 function affiche_message()
    120 {
    121  global $template,$infos_message,$erreur_message, $user ,$ip;
    122 
    123 global $mails_options,$conf,$lang ;
    124 
    125 $mails_options = explode("," , $conf['mail_superv']);
    126                 if (!isset($ip)) {
    127                        if (getenv("HTTP_CLIENT_IP"))
    128                                             {    $ip=getenv("HTTP_CLIENT_IP");  }
    129                                         else{   $ip=getenv("REMOTE_ADDR");      }
    130                            }
    131 //  unset ($_SESSION['pwg_'.'action_spam']);
    132      $action_spam = pwg_get_session_var('action_spam') ;
    133     if  ($action_spam == null) { $action_spam = kill_list();  }
    134        
    135         if (is_bool($action_spam)) $action_spam =($action_spam == true) ? "true" : "false" ;
    136           if ($action_spam == "true" )
    137                  { 
    138                   $erreur_message = $ip . " "  . $action_spam  ;
    139                   pwg_set_session_var('action_spam', "true");
    140                   $erreur_message .= "<BR />".l10n('Sv_is_a_spam') ;
    141                  if ($mails_options[no_connect] == 'on' ){
    142                         //[status] => guest
    143                         //[status] => normal
    144                         //[status] => webmaster
    145                         if ($user['status'] != 'webmaster'  )
    146                                 if (!isset($_GET['admin'])) {
    147                                                  die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!');
    148                                 }elseif   ($_GET['admin'] != 'piwigo')
    149                                         {
    150                                                  die('blacklist Hacking attempt!');
    151                                         }
    152                                 unset ($_SESSION['pwg_'.'action_spam']);
    153            }
    154              }else{
    155                    pwg_set_session_var('action_spam', "false");
    156                  }
    157        
    158  
    159 // }     
    160 
    161  //==============================================================
    162   if (isset($erreur_message))
    163                 {       
    164  
    165                 if ($erreur_message <> "")
    166                         {
    167                             $erreur_message = str_replace("\n",'<br />',$erreur_message) ;
    168                                 $template->assign('errors',$erreur_message);
    169                                 $erreur_message = "";
    170                         }
    171                 }
    172                
    173        
    174   if (isset($infos_message))
    175                 {       
    176                
    177                 if ($infos_message <> "")
    178                         {
    179                                 $infos_message = str_replace("\n",'<br />',$infos_message) ;
    180                                 $template->assign('infos',$infos_message);
    181                                 $infos_message = "";
    182                         }
    183                 }
    184                 //=============================================================
    185        
    186        
    187 return;         
    188                
    189 }
    190 
    191 function Get_geo()
    192 {
    193 global $ip,$pays,$region,$ville, $latitude ,$longitude,$mails_options;
    194          //===================================================================================
    195         $info_geo = pwg_get_session_var('info_geo');
    196         print_r($info_geo );
    197         if (count($info_geo) > 0) 
    198         {
    199                
    200                 $pays  = $info_geo[0];
    201                 $region  = $info_geo[1];
    202                 $ville  = $info_geo[2];
    203                 $latitude = $info_geo[3];
    204                 $longitude = $info_geo[4];
    205                 $ip = $info_geo[5];
    206                 return true;
    207         }
    208 //=======================================================================
    209 
    210  if (isset($_POST['pays'])) {
    211                         $pays = isset($_POST['pays']) ? $_POST['pays'] : "";
    212                         $region =  isset($_POST['region']) ? $_POST['region'] :"";                             
    213                         $ville = (isset($_POST['ville']))   ? $_POST['ville']: "";
    214                         $latitude =  isset($_POST['latitude']) ? $_POST['latitude'] : "";       
    215                         $longitude =  isset($_POST['longitude']) ? $_POST['longitude'] : "";
    216                                
    217                         $info_geo = array(   $pays ,$region , $ville ,$latitude, $longitude,$_SERVER['REMOTE_ADDR']  );
    218                         pwg_set_session_var('info_geo', $info_geo);
    219                         return true;
    220  
    221  }else{
    222 
    223             $result="";
    224 ?>
    225 <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js" type="text/javascript" >
    226 </script>         
    227 <script language="JavaScript" type="text/javascript">
    228             var pays     =  geoip_country_name();
    229                         var ville     =  geoip_city();
    230                         var region    =  geoip_region_name() ;
    231                         var latitude  =  geoip_latitude() ;
    232                         var longitude =  geoip_longitude() ;
    233                        
    234 </script>
    235 <form action="" method="post" name="form_connexion" id="form_connexion" style="visibility:hidden">
    236 <script language="JavaScript" type="text/javascript">                   
    237                 document.write ("<input name=\"pays\"  type=\"text\" value =  "+ pays + "  id = \"pays\"  > ");
    238                 document.write ("<input name=\"ville\"  type=\"text\" value = "+ ville + "  id = \"ville\"   >  ");
    239                 document.write ("<input name=\"region\"  type=\"text\" value =  "+ region + "   id = \"region\"   > ");
    240                 document.write ("<input name=\"latitude\"  type=\"text\" value =  "+ latitude + " id = \"latitude\"   > ");
    241                 document.write ("<input name=\"longitude\"  type=\"text\" value = "+ longitude + " id = \"longitude\"  >  ");
    242 </script>       
    243 
    244 </form >       
    245 <script language="JavaScript" type="text/javascript">
    246   document.getElementById("form_connexion").submit();
    247 </script>
    248 <?php   
    249    
    250  }
    251 //=====================================================================================         
    252 }
    253 
    254 //=================================================================================
    255 function Get_Datas()
    256 {
    257 global $superv_champs ;
    258 $champs = implode(",",$superv_champs );
    259     $query = "SELECT ".$champs."
    260     FROM ".MAIL_SUPERV_TABLE."
    261         ;";
    262                          $result = @pwg_query($query);
    263  
    264         if (!$result) {
    265                                         verif_base();
    266                                         $result = @pwg_query($query);
    267                                         }
    268 
    269                                        
    270     $data = mysql_fetch_array($result,MYSQL_ASSOC);
    271         //====================================================================================
    272 
    273         $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );
    274  $next_day = ($next_day >0) ? $next_day :  (604800  + time()) ;
    275         $data['rest_mail'] =    $next_day - time() ;
    276 
    277         $next_day = Str_To_Time( $data['nb_spams_periode'],$data['date_spam']);
    278         $next_day = ($next_day >0) ? $next_day :  (172800  + time()) ;
    279         $data['rest_spam'] =  $next_day - time() ;
    280 
    281 
    282         $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']);       
    283         $next_day = ($next_day >0) ? $next_day :  (172800 + time()) ;
    284        
    285         if ($data['quarantaine'] == 'true' ) {
    286                         $data['reste'] =   ( $next_day )-time() ;
    287         }else{
    288                         $data['reste'] = 0;
    289         }
    290        
    291          return $data;
    292 }
     31global $template ;
    29332//===============================================
    294 
    29533function corrige_header($Carbonne,$headers,$args,$cl_list_mail)
    29634        {
     
    30139                if ( count($args[$Carbonne]) > 0 )
    30240                {
    303                         if ($mails_options[check_header_carbon] == 'on') {
     41                        if ($mails_options['check_header_carbon'] == 'on') {
    30442                                        $cl_list_mail  =  str_replace(","," , ",get_strict_email_list(implode(',', $args[$Carbonne])))." \n"  ;
    30543                                        $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', $Carbonne.': '.$cl_list_mail, $headers);
     
    36199$retour=str_replace("+0","+",$retour);
    362100//================================================================================================   
    363 
    364 
    365101return $retour;
    366 
    367 }       
    368 
    369 function memo_var($variables)
    370 {
    371                 ob_start();
    372                 echo '<pre>';
    373                 print_r($variables);
    374                 echo '</pre>';
    375                 $m= ob_get_contents();
    376 
    377         ob_end_clean();
    378                 return $m;
    379                
    380 }
    381    
     102}         
    382103
    383104       
    384 function verif_base()
    385 {
    386 
    387 global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
    388     load_language('plugin.lang', MAIL_SUPERV_PATH);
    389 //==============================================================================               
    390     create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    391         ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
    392 //==============================================================================               
    393         create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
    394         ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type)  ;
    395 //==============================================================================               
     105function verif_base(){
     106  global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
     107  load_language('plugin.lang', MAIL_SUPERV_PATH);
     108  //==============================================================================             
     109  create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
     110  ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
     111  //==============================================================================             
     112  create_table(mail_superv_TABLE,$superv_champs,$superv_type) ;
     113  ajust_table(mail_superv_TABLE,$superv_champs,$superv_type)  ;
     114  //==============================================================================             
    396115    $valeurs= array (   1,
    397                                                 0,
    398                            time(),
     116                                                          0,
     117                                   time(),
    399118                         2000,
    400          '"604800"' ,
     119                  '"604800"' ,
    401120                            0,
    402                   time(),
     121                       time(),
    403122                           10,
    404           '"172800"',
    405                        '"false"',
    406                 time(),
    407           '"172800"',
    408           '"Init"',
     123                   '"172800"',
     124                    '"false"',
     125                       time(),
     126                   '"172800"',
     127                     '"Init"',
    409128   '"'.l10n('Sv_supervisor').'"',
    410129        '"'.l10n('hello').'"',
    411          )
    412         ;
    413 //==================================================================================
    414         ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ;
    415        
    416 
    417 }
     130         );
     131        ajout_ligne(mail_superv_TABLE,$superv_champs, $valeurs,false ) ;
     132}
     133//=================================================================================
     134
    418135
    419136//=========================================
     
    434151{
    435152global $conf ;
    436 
    437153  $query = '
    438154SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    447163    LEFT JOIN '.USER_GROUP_TABLE.' AS ug
    448164      ON u.'.$conf['user_fields']['id'].' = ug.user_id
    449   WHERE ug.group_id='.$group_id.' ';
    450 
    451 
    452  
     165  WHERE ug.group_id='.$group_id.' ';
    453166 $groups=array();
    454   $datas = pwg_query($query);
    455  
    456  
    457   if (!empty($datas))
    458   {
     167  $datas = pwg_query($query);
     168 
     169  if (!empty($datas)) {
    459170    while ($group = mysql_fetch_array($datas,MYSQL_ASSOC))
    460     {
    461 
    462        
     171    {   
    463172      if (!empty($group['email']))
    464       {
    465         array_push($groups, format_email($group['username'], $group['email'] ));
     173      {         array_push($groups, format_email($group['username'], $group['email'] ));
    466174      }
    467175    }
     
    472180//=================================================================================
    473181
    474 function create_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
     182function create_table($nom_table,$champs,$types)  //mail_superv_TABLE
    475183{
    476184        $i=0;
    477185        $valeurs=array();
    478 foreach ( $champs as $champ)
    479    {
    480         $champ = trim($champ);
    481                 array_push($valeurs , " `".$champ."`" . '  ' . $types[ $i] )  ;
    482                 $i +=1;
     186  foreach ( $champs as $champ) {
     187      $champ = trim($champ);
     188      array_push($valeurs , " `".$champ."`" . '  ' . $types[ $i] )  ;
     189      $i +=1;
    483190    }
    484191
     
    495202         
    496203}
    497 function ajust_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
     204function ajust_table($nom_table,$champs,$types)  //mail_superv_TABLE
    498205{
    499206global $infos_message ;
     
    514221        if ( count($valeurs) == 0) return ;
    515222       
    516   $infos_message .=  "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . memo_var($valeurs) . "<br />" ;
     223  $infos_message .=  "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . mail_supervisor::Memo_Var($valeurs) . "<br />" ;
    517224       
    518225     $valeurs=implode(", ",$valeurs) ;
     
    556263global $mails_donnees,$infos_message,$erreur_message,$page;
    557264
    558 if (!is_numeric($mails_donnees['nb_mails_periode']))
    559 {
    560  $periode = Str_To_Time( $mails_donnees['nb_mails_periode'],0);
    561  $mails_donnees['nb_mails_periode']= ($periode > 0) ? $periode : '604800' ;
     265if (!is_numeric($mails_donnees['nb_mails_periode'])){
     266  $periode = Str_To_Time( $mails_donnees['nb_mails_periode'],0);
     267  $mails_donnees['nb_mails_periode']= ($periode > 0) ? $periode : '604800' ;
    562268 }
    563 
    564 if (!is_numeric($mails_donnees['nb_spams_periode']))
    565 {
    566  
    567  $periode=Str_To_Time( $mails_donnees['nb_spams_periode'],0);
    568  $mails_donnees['nb_spams_periode']= ($periode > 0) ? $periode : '172800' ; ;
     269if (!is_numeric($mails_donnees['nb_spams_periode'])){
     270  $periode=Str_To_Time( $mails_donnees['nb_spams_periode'],0);
     271  $mails_donnees['nb_spams_periode']= ($periode > 0) ? $periode : '172800' ; ;
    569272 }
    570 if (!is_numeric($mails_donnees['quarantaine_periode']))
    571 {
    572  $periode=Str_To_Time( $mails_donnees['quarantaine_periode'],0);
    573  $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ;
     273if (!is_numeric($mails_donnees['quarantaine_periode'])){
     274  $periode=Str_To_Time( $mails_donnees['quarantaine_periode'],0);
     275  $mails_donnees['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ;
    574276 }
    575 
    576         if  ($infos_message != "")  {
    577                    array_push($page['infos'],  $infos_message);
    578                    $infos_message="";
    579                  }
    580                  
    581                 if  ($erreur_message != "")  {
    582                   array_push($page['errors'], $erreur_message);
    583                   $erreur_message ="";
    584                  }     
     277    if  ($infos_message != "")  {
     278        array_push($page['infos'],  $infos_message);
     279        $infos_message="";
     280    }           
     281    if  ($erreur_message != "")  {
     282        array_push($page['errors'], $erreur_message);
     283        $erreur_message ="";
     284    }   
    585285                 
    586286}
     
    730430        $sep=" ";
    731431        $chaine = trim($chaine);
     432    if ($chaine=="") return ;
    732433        $existe = (strpos($sep.$sep,$chaine )===false) ;
    733434         while  ($existe ){
    734435         $str_temp = str_replace($sep.$sep, $sep, $chaine ); 
    735436                if($str_temp == $chaine ) return $chaine ;
    736 //                      $erreur_message .= memo_var($str_temp) ;
     437//                      $erreur_message .= mail_supervisor::Memo_Var($str_temp) ;
    737438                $chaine  = $str_temp;
    738439                        $existe =  (strpos($sep.$sep,$chaine )===false) ;
     
    740441        return $chaine;
    741442}
    742 
    743 
    744 
    745 function kill_list()
    746 {
    747  //==================== TEST black_liste ============================================   
    748  global $pays,$region,$ville,$ip ;
    749  global $erreur_message,$infos_message,$conf;   
    750  global $conf, $user, $page;
    751  global $mails_options ;
    752  global $superv_bl_champs,$superv_bl_type ;
    753  global $nb ;
    754  
    755 if (count($mails_options) < 7 ) return false ;
    756    
    757      $champs=implode(',',$superv_bl_champs);
    758      $query = "
    759                 SELECT ".$champs.",COUNT(`ip`) as total
    760                 FROM `".MAIL_BLACK_LISTE_TABLE."`
    761                     WHERE '".$ip."' LIKE `ip`
    762                         GROUP by `ip`
    763                 ;";     
    764                  $result = @pwg_query($query);
    765         if (!$result) {
    766                                         verif_base();
    767                                         $result = @pwg_query($query);
    768                                 }
    769         $datas = mysql_fetch_array($result,MYSQL_ASSOC);
    770         $nb = $datas['total'];
    771 //=======================================================================       
    772 
    773 if ($mails_options[set_auto] == 'nonoui') // ne plus tester automatiquement .
    774 {
    775  // $ip="94.102.63.13"; ' Spammeurs
    776  // $ip="94.102.63.15";
    777  // $mail=matusowraber93813@gmail.com ;
    778  // $username=fretgpsolodens ;
    779 global $user_name,$mail_adresse;
    780 
    781   if (test_spam($ip,$user['username'] ,$user['email']))
    782   {
    783 
    784   if ($nb==0) {
    785         $valeurs=array( 'NULL',
    786                             "'".$ip."'",
    787                                         "'".$pays."'",
    788                                         "'".$region."'",       
    789                                         "'".$ville."'",
    790                                         "'".$user['email']."'",
    791                                         "'".$user['username']."'",     
    792                                         $nb+1
    793         );
    794           ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;     
    795         }else{ 
    796        
    797         $nb +=1;
    798        
    799                  $query ="
    800                         UPDATE " . MAIL_BLACK_LISTE_TABLE . "
    801                         SET ";
    802                     if (isset($_POST['pays'])) 
    803                  $query .= "   
    804                         `pays` = '". $pays ."',
    805                         `region` = '" . $region ."',
    806                         `ville` = '" . $ville . "',
    807                        
    808                         ";
    809                        
    810                  $query .= "
    811                     `adresse` = '".$user['email']."',           
    812                         `fai` = '".$user['username']."',               
    813                         `nb` = " . $nb . "
    814                     WHERE '".$ip."' like `ip`
    815                 ";
    816                
    817                                 pwg_query($query );     
    818         }
    819           $erreur_message .=  $mails_options[ip] ." ".$user['username']." ".$user['email'] . ' -----> ' . l10n('Sv_black_list') ;
    820         // die($nb." ".$ip." ".$user['username']." ".$user['email']); 
    821         return true ;   
    822 
    823     }
    824  
    825 }
     443//==================== TEST black_liste ============================================   
     444function kill_list() {
     445  global $pays,$region,$ville,$ip ;
     446  global $erreur_message,$infos_message,$conf; 
     447  global $conf, $user, $page;
     448  global $mails_options ;
     449  global $superv_bl_champs,$superv_bl_type ;
     450  global $nb ;
     451  if (!isset($ip)) {
     452    if (getenv("HTTP_CLIENT_IP"))   {
     453      $ip=getenv("HTTP_CLIENT_IP");
     454    }else{
     455      $ip=getenv("REMOTE_ADDR");
     456    }
     457  }
     458  $champs=implode(',',$superv_bl_champs);
     459   $query = "SELECT ".$champs.",COUNT(`ip`) as total
     460  FROM `".MAIL_BLACK_LISTE_TABLE."`
     461                WHERE '".$ip."' LIKE `ip`
     462                GROUP by `ip`
     463  ;";   
     464        $result = @pwg_query($query);
     465         if (!$result) {
     466                        verif_base();
     467                        $result = @pwg_query($query);
     468                        }
     469          $datas = mysql_fetch_array($result,MYSQL_ASSOC);
     470        $nb = $datas['total']|0;
     471    //=======================================================================   
     472    if ($mails_options['set_auto'] == 'on') { 
     473      global $user_name,$mail_adresse;
     474
     475       if (isset($nb) && $nb>0) {
     476       //if (test_spam($ip,$user['username'] ,$user['email']))  // ne plus tester automatiquement .
     477            if ($nb==0) {
     478                  $valeurs=array( 'NULL',
     479                           "'".$ip."'",
     480                                                "'".$pays."'",
     481                                                "'".$region."'",       
     482                                                "'".$ville."'",
     483                                                "'".$user['email']."'",
     484                                                "'".$user['username']."'",     
     485                                                $nb+1
     486                    );
     487                  ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;     
     488                }else{ 
     489            mail_supervisor::Get_geo();   
     490            $nb +=1;   
     491                         $query ="UPDATE " . MAIL_BLACK_LISTE_TABLE . " SET ";
     492                         if (isset($_POST['pays']))     
     493                         $query .= "`pays` = '". $pays ."',
     494                                `region` = '" . $region ."',
     495                                `ville` = '" . $ville . "',                     
     496                                ";                     
     497                         $query .= "`adresse` = '".$user['email']."',           
     498                                `fai` = '".$user['username']."',               
     499                                `nb` = " . $nb . "
     500                         WHERE '".$ip."' like `ip` ";           
     501                                       pwg_query($query );     
     502                }
     503             $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_black_liste') ;
     504       // die($nb." ".$ip." ".$user['username']." ".$user['email']); 
     505 
     506       return true ;   
     507      } 
     508    }
    826509 //==============================================================================
    827  if ( $mails_options[ip] == $ip ) return ($nb > 0) ;   
    828    $mails_options[ip] =   $ip ; 
    829    sauve_options();
    830  
     510
     511 if ( $mails_options['ip'] == $ip ) return ($nb > 0) ;   
     512   $ip0= $mails_options['ip'] ;
     513   $mails_options['ip'] = $ip ; 
     514   mail_supervisor::sauve_options(); 
    831515        if (  $nb > 0 )
    832516        {
     
    848532            $row  = mysql_fetch_row(pwg_query($query));
    849533            $nb =  ($row[7]);
    850       $erreur_message .= $ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 
     534        $erreur_message .= $ip0 . ' | ' .$ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 
    851535 
    852536         if ($nb == 0)
     
    858542                                        "'".$ville."'",
    859543                                        "'".$user['email']."'",         
    860                                "'".$user['username']."'",               
     544                          "'".$user['username']."'",           
    861545                                        1
    862546              );
     
    883567                                pwg_query($query );     
    884568                                }
    885         //================================================================================     
    886                
    887569        }
    888  
    889 
    890 return ($nb > 0) ;
     570 return ($nb > 0) ;
    891571}
    892572//=====================================================================================
    893573function test_spam($ip =0,$user_name ='', $mail_adresse = "")
    894574{
    895         $buffer="";
    896         global $page,$infos_message;
    897 
    898 // fretgpsolodens
    899         $src =  "http://www.stopforumspam.com/api?";
    900         $type=array();
    901         $result="";
    902 if (strlen($ip)>3) {
    903 //==================  Verifie si l'IP est correct  ================================
    904 if (clj_is_ip($ip)){     
     575 $buffer="";
     576 global $page,$infos_message;
     577 $src =  "http://www.stopforumspam.com/api?";
     578 $type=array();
     579 $result="";
     580 $ip= sup_double_espace($ip);
     581 if (strlen($ip)>3) {
     582   //==================  Verifie si l'IP est correct  ================================
     583   if (clj_is_ip($ip)){     
    905584     
    906 } else { 
    907 //==================  Verifie si l'adresse mail est correcte  ================================
    908       if( clj_is_mail($ip) ){ 
    909                           $mail_adresse=$ip ;
     585   } else { 
     586   //==================  Verifie si l'adresse mail est correcte  ================================
     587         if( clj_is_mail($ip) ){ 
     588                         $mail_adresse=$ip ;
     589                 $ip="";
     590            }
     591            else
     592            {
     593   //==================  Login  ================
     594              $user_name=$ip;
    910595              $ip="";
    911          }
    912          else
    913          {
    914 //==================  Login  ================
    915            $user_name=$ip;
    916            $ip="";
    917          }
    918 }   
    919 //=============================================================================
    920 }
    921 
    922 $user_name=str_replace(" ","%20",trim($user_name));
    923 if ($user_name==l10n('Sv_guest')) $user_name="";
    924 $user_name="";  // ne plus tester sur le login.
    925 $mail_adresse =str_replace(" ","%20",trim($mail_adresse));
    926 
    927 if ( strlen($user_name) > 3)      $type[]="username=$user_name" ;
    928 if ( strlen($mail_adresse) > 3)   $type[]="email=".$mail_adresse ;
    929 if ( strlen($ip) > 3)   $type[]="ip=".$ip ;
    930 
    931          foreach  ( $type as $fil )
    932      {   
    933           $resultat="";
    934            if (  clj_fetchRemote($src.$fil , $resultat,1))
    935                   {
    936                     $result .= $resultat.'<br />'  ;
    937                   }  else {
    938                  
    939                   }
    940                  
    941       }
    942 
    943 return !(strpos(  $result ,'yes' ) === false) ;
     596            }
     597   }   
     598   //=============================================================================
     599 }
     600
     601 $user_name=str_replace(" ","%20",trim($user_name));
     602 if ($user_name==l10n('Sv_guest')) $user_name="";
     603 $user_name="";  // ne plus tester sur le login.
     604 $mail_adresse =str_replace(" ","%20",trim($mail_adresse));
     605 if ( strlen($user_name) > 3)     $type[]="username=$user_name" ;
     606 if ( strlen($mail_adresse) > 3)   $type[]="email=".$mail_adresse ;
     607 if ( strlen($ip) > 3)   $type[]="ip=".$ip ;
     608 foreach  ( $type as $fil ) {   
     609  $resultat="";
     610  if (  clj_fetchRemote($src.$fil , $resultat,1))
     611   $result .= $resultat.'<br />'  ;               
     612 }
     613
     614 return !(strpos(  $result ,'yes' ) === false) ;
    944615 
    945616}
     
    1044715}
    1045716
    1046  function Get_Version_plugins($dir)
    1047   {
    1048         $path = $dir;
    1049           $plg_data = implode( '', file($path.'main.inc.php') );
    1050           if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
    1051           {
    1052             $plugin['name'] = trim( $val[1] );
    1053           }
    1054           if (preg_match("|Version: (.*)|", $plg_data, $val))
    1055           {
    1056             $plugin['version'] = trim($val[1]);
    1057           }
    1058           if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
    1059           {
    1060             $plugin['uri'] = trim($val[1]);
    1061           }
    1062           if ($desc = load_language('description.txt', $path.'/', array('return' => true)))
    1063           {
    1064             $plugin['description'] = trim($desc);
    1065           }
    1066           elseif ( preg_match("|Description: (.*)|", $plg_data, $val) )
    1067           {
    1068             $plugin['description'] = trim($val[1]);
    1069           }
    1070           if ( preg_match("|Author: (.*)|", $plg_data, $val) )
    1071           {
    1072             $plugin['author'] = trim($val[1]);
    1073           }
    1074           if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
    1075           {
    1076             $plugin['author uri'] = trim($val[1]);
    1077           }
    1078           if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid='))
    1079           {
    1080             list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']);
    1081             if (is_numeric($extension)) $plugin['extension'] = $extension;
    1082           }
    1083           // IMPORTANT SECURITY !
    1084           $plugin = array_map('htmlspecialchars', $plugin);
    1085 
    1086          return $plugin ;
    1087 
    1088   }
    1089 
    1090 
    1091717
    1092718?>
Note: See TracChangeset for help on using the changeset viewer.