Ignore:
Timestamp:
Nov 6, 2009, 1:52:37 PM (14 years ago)
Author:
cljosse
Message:

[mail_supervisor] Fix Bug 'session_start() ' ???

Location:
extensions/Mail_supervisor/include
Files:
2 edited

Legend:

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

    r4206 r4220  
    4949
    5050global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ;
    51           $superv_champs = array(
    52                        "id",
    53                                         "nb_mails",
    54                                         "date_mail",
    55                                         "nb_mails_maxi",               
    56                                         "nb_mails_periode",     
    57                                         "nb_spams",
    58                                         "date_spam",   
    59                                         "nb_spams_maxi",       
    60                                         "nb_spams_periode",     
    61                                         "quarantaine",
    62                                         "date_quarantaine",
    63                                         "quarantaine_periode", 
    64                                         "message",
    65                                         "message_test",
    66                                     "header_text",
    67                                
    68                                         );
    69                                        
    70         $superv_type = array(
    71                         " SMALLINT( 5 ) NOT NULL DEFAULT '0'"      ,
    72                                         "INT NOT NULL DEFAULT '0'"  ,
    73                                         "INT NOT NULL DEFAULT '0'"  ,
    74                                         "INT NOT NULL DEFAULT '2000'",         
    75                                         "TEXT"  ,       
    76                                         "INT NOT NULL DEFAULT '0'",
    77                                         "INT NOT NULL DEFAULT '0'",     
    78                                         "INT NOT NULL DEFAULT '10'",   
    79                                         "TEXT"  ,       
    80                                         "TEXT" ,
    81                                         "INT NOT NULL DEFAULT '0'",
    82                                         "TEXT"  ,       
    83                                         "TEXT"  ,
    84                                         "TEXT"  ,
    85                                         "TEXT"  ,
    86                                        
    87                                         );             
    88                                        
    89  
    90           $superv_bl_champs = array(
    91                                         "id",
    92                                         "ip",
    93                                         "pays",
    94                                         "region",               
    95                                         "ville",       
    96                                         "adresse",
    97                                         "fai", 
    98                                         "nb"
    99                                         );
    100                                        
    101         $superv_bl_type = array(
    102                         " smallint(5) UNSIGNED NOT NULL auto_increment ",
    103                                         "TEXT"  ,
    104                                         "TEXT"  ,
    105                                         "TEXT"  ,
    106                                         "TEXT"  ,
    107                                         "TEXT"  ,
    108                                         "TEXT"  ,
    109                                         " smallint(5) UNSIGNED "
    110                                         );                                                                                                                                     
    111 
    112 vérif_base() ;
    113        
     51         
    11452//==========================================================
    11553function sauve_options()
     
    13674global $mails_données,$superv_champs,$superv_type,$erreur_message ;
    13775//=====================================================================
    138         ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
    13976        $clefs = $superv_champs ;
    14077        $valeurs = array();
     
    176113$mails_options = explode("," , $conf['mail_superv']);
    177114
    178 
    179  if ( !isset($_POST['submit']) ) {
     115 if ( count($_POST)==5 || count($_POST)==0 ) {
     116   
     117
    180118        if (kill_list())
    181119                 {
     
    227165function Get_geo()
    228166{
    229 Global $pays,$region,$ville , $erreur_message;
     167global $pays,$region,$ville , $erreur_message;
    230168if (!isset($_POST['submit']))
    231169{
     
    263201function Get_Datas()
    264202{
    265         ob_start();
    266                 $data=Lire_datas();
    267                         $m= ob_get_contents();
    268         ob_end_clean();
    269        
    270         if (strlen($m)>0) {
    271           vérif_base() ;
    272           $data=Lire_datas();
    273         }
    274     return $data;
    275 }
    276 
    277 function Lire_datas()
    278 {
    279 
    280 
    281  $query = "
    282     SELECT *
     203global $superv_champs ;
     204$champs = implode(",",$superv_champs );
     205    $query = "SELECT ".$champs."
    283206    FROM ".MAIL_SUPERV_TABLE."
    284207        ;";
    285     $data = mysql_fetch_array(pwg_query($query),MYSQL_ASSOC);
     208                         $result = @pwg_query($query);
     209 
     210        if (!$result) {
     211                                        vérif_base();
     212                                        $result = @pwg_query($query);
     213                                        }
     214
     215                                       
     216    $data = mysql_fetch_array($result,MYSQL_ASSOC);
    286217        //====================================================================================
    287218        $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );;
     
    383314global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
    384315    load_language('plugin.lang', MAIL_SUPERV_PATH);
    385 
    386         create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
    387 
     316//==============================================================================               
     317    create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
     318        ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
     319//==============================================================================               
     320        create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
    388321        ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type)  ;
    389322//==============================================================================               
     
    409342        ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ;
    410343       
    411    create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    412         ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
    413 }
    414 
    415 
     344
     345}
     346
     347//=========================================
    416348function Get_colonnes_de($table)
    417349{
    418   $columns_of = array();
    419350    $query = 'DESC '.$table.';';
    420351    $result = mysql_query($query);
    421     $columns_of[$table] = array();
     352    $columns_of= array();
    422353    while ($row = mysql_fetch_row($result))
    423354    {
    424       array_push($columns_of[$table], $row[0]);
     355      array_push($columns_of, $row[0]);
    425356    }
    426357 
     
    495426function ajust_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
    496427{
    497 return ;
    498      create_table($nom_table,$champs,$types) ;
    499        
    500          
    501          $table = mysql_fetch_array(pwg_query('SELECT * FROM '.$nom_table),MYSQL_ASSOC);
    502 
    503  $result = mysql_query('SELECT * FROM '.$nom_table);
    504 
    505 $row = mysql_fetch_row($result) ;
    506         echo $nom_table . "  " . memo_var($row) . count($row) ;
    507 
    508 if (count($row)> 1) return ;
    509 
    510 
    511     $nb = Get_colonnes_de($nom_table);
    512         $table=$nb[$nom_table];         
    513 $data =         $types ;
    514 $i=0;
    515  $valeurs=array();
    516  
    517 
     428global $infos_message ;
     429$colonnes = Get_colonnes_de($nom_table);
     430        $data =         $types ;
     431        $i=0;
     432        $valeurs=array();
    518433foreach ( $champs as $champ)
    519434   {
    520435     $champ = trim($champ);
    521           if (!in_array( $champ,$table)) {
     436          if (!in_array( $champ,$colonnes)) {
    522437         array_push($valeurs , " ADD `".$champ."`" . '  ' . $data[  $i] )  ;
    523438         }
     
    525440         
    526441    }
     442//=============================================================================
    527443        if ( count($valeurs) == 0) return ;
    528444       
    529 $valeurs=implode(", ",$valeurs) ;
     445  $infos_message .=  "AJUSTE TABLE : ". $nom_table . "<BR />" . "NB (col) : ". count($colonnes) . memo_var($valeurs) . "<BR />" ;
     446       
     447     $valeurs=implode(", ",$valeurs) ;
    530448        //===============================================================================
    531        
    532449                $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ;
    533450                        if (   pwg_query($query)) return ;           
    534        
    535451                die($query);
    536 
    537 
    538 }
    539 
     452}
     453//==============================================================================       
    540454function ajout_ligne($nom_table,$champs,$valeurs,$force)
    541455{
    542456  if (!$force) {
    543457     $query = "
    544                 SELECT COUNT(`id`) as total
     458                SELECT `id` , COUNT(`id`) as total
    545459                FROM `".$nom_table."`
    546460                ;";     
    547 //==============================================================================               
    548                 list($count) = mysql_fetch_row(pwg_query($query));
     461          list($count) = mysql_fetch_row(pwg_query($query));
     462
     463               
    549464}else{
    550465
     
    655570{
    656571 //==================== TEST black_liste ============================================   
    657  Global $pays,$region,$ville,$erreur_message,$infos_message,$conf;     
     572 global $pays,$region,$ville,$ip ;
     573 global $erreur_message,$infos_message,$conf;   
    658574  global $conf, $user, $page;
    659575  global $mails_options ;
    660576   global $superv_bl_champs,$superv_bl_type ;
    661 
    662  
    663 if (count($mails_options) < 6 ) return false ;
    664  
    665 $ip = $_SERVER['REMOTE_ADDR'] ;
    666  
    667  
    668  
     577   global $nb ;
     578
     579
     580 
     581if (count($mails_options) < 7 ) return false ;
     582
     583    $ip = $_SERVER['REMOTE_ADDR'] ;
    669584        if ( !isset($_POST['pays'])) {
    670        
    671585        if ( !isset($_POST['ip_black_test'])) {    Get_Geo();           }
    672                  
    673586                 return ;       
    674                 }  else{
    675                   $pays = isset($_POST['pays']) ? $_POST['pays'] : $pays="" ;
    676                   $ville = (isset($_POST['ville']))   ? $_POST['ville']: $ville="" ;
    677                   $region =  isset($_POST['region']) ? $_POST['region'] : $region="" ; 
    678          
    679         }
    680  
    681 
    682  
     587                }  else {
     588                       $pays = (isset($_POST['pays'])) ? $_POST['pays'] : "" ;
     589                       $ville = (isset($_POST['ville']))   ? $_POST['ville'] : "" ;
     590                       $region = ( isset($_POST['region'])) ? $_POST['region'] : "" ;   
     591        }
     592 
     593     $champs=implode(',',$superv_bl_champs);
    683594     $query = "
    684                 SELECT *,COUNT(`id`) as total
     595                SELECT ".$champs.",COUNT(`id`) as total
    685596                FROM `".MAIL_BLACK_LISTE_TABLE."`
    686597                    WHERE `ip` LIKE '".$ip."'
    687598                ;";     
    688                  $datas = mysql_fetch_array(pwg_query($query),MYSQL_ASSOC);
     599                 $result = @pwg_query($query);
     600 
     601        if (!$result) {
     602                                        vérif_base();
     603                                        $result = @pwg_query($query);
     604                                        }
     605         $datas = mysql_fetch_array($result,MYSQL_ASSOC);
     606
    689607                 $nb = $datas['total'];
    690608if ($mails_options[5] == 'on')
     
    693611  if (test_spam($ip))
    694612  {
    695  
    696613        $valeurs=array( 'NULL',
    697614                            "'".$ip."'",
     
    703620                                        1
    704621        );
    705         ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ; 
     622          ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ;       
    706623          $erreur_message .= $ip.$mails_options[6] . ' -----> ' . l10n('black_list') ;
    707624        return true ;   
  • extensions/Mail_supervisor/include/save_info.php

    r4190 r4220  
    77if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    88
    9 //include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
    10 include_once (MAIL_SUPERV_PATH.'include/constants.php');
    11 include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    129
    13     $info_ip = (isset($info_ip)) ? $info_ip : '' ;
    14     $info_ip = (isset($_POST['info1'])) ? $_POST['info1'] : $info_ip ;
    15     $info_ip = (isset($_POST['info'])) ? $_POST['info'] : $info_ip ;
    16     $info_ip .= ":";
    17  
    18    $val=explode(":",$info_ip);
    19    $info_ip = trim($val[0]) ;
    20    $ip_black = trim($val[1]) ;
    21  
    22   if (isset($_POST['ip_black']))
    23    $ip_black = ($ip_black == "" ) ? $_POST['ip_black'] : $ip_black ;
    24 global $n ;
     10   
    2511
    26 Global $pays,$region,$ville ;
    27  
    28 switch ($info_ip)
     12
     13switch (strtolower($info_ip))
    2914 {
    3015
    31   case 'ajout':
    32   $n +=1;
    33 //echo " |$n] ". (( isset($_POST['info']) ) ? " POST  :".$_POST['info'] : "" ).(( isset($_POST['info1']) ) ? " POST   1 :".$_POST['info1'] : "" )."|";   
     16  case  'ajout' :
    3417 
     18
    3519 if (!($ip_black == '')) {
    36     create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    37         ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
    38 
    3920   $query = "
    40                 SELECT COUNT(`id`) as total
     21                SELECT `ip`
    4122                FROM `".MAIL_BLACK_LISTE_TABLE."`
    4223                    WHERE ip = '".$ip_black."'
    4324                ;";     
    44 
    45                
    4625//==============================================================================               
    4726list($count) = mysql_fetch_row(pwg_query($query));
    4827//==============================================================================       
    49        
    5028        $valeurs=array( 'NULL',
    5129                            "'".$ip_black."'",
     
    7654  }
    7755//================ Liste Black liste =================
    78   create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    79 
    8056  $query = "
    8157    SELECT *,  COUNT(`ip`) as total ,   `ip` as blacklist, `ip` as U_DELETE
    82  
    8358    FROM ".MAIL_BLACK_LISTE_TABLE."
    8459                GROUP by ip
     
    12196                               
    12297
    123 
    124 
    125 
    126 
    127 
    12898?>
Note: See TracChangeset for help on using the changeset viewer.