Ignore:
Timestamp:
Oct 28, 2009, 10:49:00 AM (14 years ago)
Author:
cljosse
Message:

[mail_supervisor] addition of a bad book

Location:
extensions/Mail_supervisor/include
Files:
1 added
3 edited

Legend:

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

    r4029 r4132  
    33
    44if (!defined('MAIL_SUPERV_TABLE')) define('MAIL_SUPERV_TABLE', $prefixeTable.'mail_superv');
     5if (!defined('MAIL_BLACK_LISTE_TABLE')) define('MAIL_BLACK_LISTE_TABLE', $prefixeTable.'mail_black_list');
    56if (!defined('FREE_MAIL_TABLE')) define('FREE_MAIL_TABLE', $prefixeTable.'free_mail');
     7
    68?>
  • extensions/Mail_supervisor/include/fonctions.php

    r4065 r4132  
    2626  die('Hacking attempt!');
    2727}
    28 if (!defined('MAIL_SUPERV_DIR')) define('MAIL_SUPERV_DIR' , basename(dirname(__FILE__)));
     28
    2929if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    3030
    3131
     32 if (!isset($_COOKIE[session_name()]))
     33{
     34
     35
     36
     37}
    3238include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    3339include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
    34 
     40include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    3541global $lang ;
    3642
    37 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     43
    3844include_once (MAIL_SUPERV_PATH.'include/function_test_send.php');
    3945
    40 global $period_search,$period_match,$lang ;
    41 
    4246
    4347    load_language('plugin.lang', MAIL_SUPERV_PATH);
    44         $period_search=array("W","D","H","M","S");
    45         array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde'));
    46         array_push($period_search,l10n('Week').'s',l10n('Day').'s',l10n('Hour').'s',l10n('Minute').'s',l10n('Seconde').'s');
    47        
    48        
    49         $period_match=array(' week',' day',' hour',' minute',' seconde');       
    50         array_push($period_match,'week','day','hour','minute','seconde');
    51         array_push($period_match,'week','day','hour','minute','seconde');
    52        
    53 
     48
     49
     50global  $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       
     113//==========================================================
    54114function sauve_options()
    55115{
     
    66126function sauve_données()
    67127{
    68 global $mails_données ;
    69 
     128global $mails_données,$superv_champs,$superv_type,$erreur_message ;
     129//=====================================================================
     130        ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
     131        $clefs = $superv_champs ;
     132        $valeurs = array();
     133
     134foreach ( $clefs as $champ)
     135   {
     136     $champ = trim($champ);
     137     
     138         if ( isset($mails_données[  $champ ]) ) {
     139           $sep= (is_string($mails_données[ $champ ])) ? '"' : '' ;
     140       array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_données[  $champ ] . $sep)  ;
     141         }else{
     142         
     143            array_push($valeurs , "`".$champ."`" . ' = ' .  "0"  )  ;
     144         }
     145    }
     146$valeurs = implode(", ",$valeurs) ;
     147//=====================================================================
    70148$query = '
    71149        UPDATE '.MAIL_SUPERV_TABLE.'
    72         SET `nb_mails`         = '.$mails_données['nb_mails'].',
    73                         `date_mail`        = '.$mails_données['date_mail'].',
    74                         `nb_mails_maxi`    = '.$mails_données['nb_mails_maxi'].',       
    75                         `nb_mails_periode`    = "'.$mails_données['nb_mails_periode'].'",       
    76                                        
    77                         `nb_spams`         = '.$mails_données['nb_spams'].',
    78                         `date_spam`        = '.$mails_données['date_spam'].',
    79                         `nb_spams_maxi`    = '.$mails_données['nb_spams_maxi'].',       
    80                         `nb_spams_periode`    = "'.$mails_données['nb_spams_periode'].'",       
    81                                                                
    82                         `quarantaine`      = "'.$mails_données['quarantaine'].'",
    83                         `date_quarantaine` = '.$mails_données['date_quarantaine'].',
    84                        
    85                         `quarantaine_periode`    = "'.$mails_données['quarantaine_periode'].'",                         
    86                        
    87                         `message`          = "'.$mails_données['message'].'",
    88                         `message_test`     = "'.$mails_données['message_test'].'",
    89                         `header_text`      = "'.$mails_données['header_text'].'"
    90                 WHERE `id` =1 LIMIT 1 ';
    91                
    92 
    93     if (  pwg_query($query)) return;
    94        
    95         vérif_base() ;
    96         if (  pwg_query($query)) return;
    97 
    98        
    99         ;
    100 
    101 
    102 }
     150        SET '. $valeurs .'
     151                WHERE `id` = 1 LIMIT 1 ';
     152                ;
     153        ob_start();
     154                $ret=  pwg_query($query)    ;
     155                $m= ob_get_contents();
     156        ob_end_clean() ;
     157        $erreur_message .= $m ;
     158
     159}
     160         
    103161//=================================================================================
    104162function affiche_message()
    105163{
    106  global $template,$infos_message,$erreur_message ;;
    107  
     164 global $template,$infos_message,$erreur_message, $user ;;
     165
     166       
    108167  if (isset($erreur_message))
    109168                {       
     
    129188                }
    130189                               
    131                
     190        if (kill_list() && $user['status'] == 'guest')
     191        if (!isset($_GET['admin'])) {
     192           die('blacklist Hacking attempt!');
     193          }else{
     194          if   ($_GET['admin'] != 'piwigo')
     195                        {
     196                        die('blacklist Hacking attempt!');
     197                        }
     198          }
     199         
    132200               
    133201}
     
    138206function Get_Datas()
    139207{
    140 ob_start();
    141 
    142         $data=Lire_datas();
    143 
    144 
     208        ob_start();
     209                $data=Lire_datas();
    145210                        $m= ob_get_contents();
    146211        ob_end_clean();
    147212       
    148213        if (strlen($m)>0) {
    149         vérif_base() ;
    150         $data=Lire_datas();
     214          vérif_base() ;
     215          $data=Lire_datas();
    151216        }
    152217    return $data;
     
    155220function Lire_datas()
    156221{
    157 global $period_search,$period_match ;
    158  if (!isset($period_search)) {
    159         $period_search=array("W","D","H","M","S");
    160         array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde'));
    161         array_push($period_search,l10n('Week').'s',l10n('Day').'s',l10n('Hour').'s',l10n('Minute').'s',l10n('Seconde').'s');
    162        
    163        
    164         $period_match=array(' week',' day',' hour',' minute',' seconde');       
    165         array_push($period_match,'week','day','hour','minute','seconde');
    166         array_push($period_match,'week','day','hour','minute','seconde');
    167         }
     222
    168223
    169224 $query = "
     
    171226    FROM ".MAIL_SUPERV_TABLE."
    172227        ;";
    173     $data = mysql_fetch_array(pwg_query($query));
     228    $data = mysql_fetch_array(pwg_query($query),MYSQL_ASSOC);
    174229        //====================================================================================
    175     $mails_periode = "+" . trim( str_replace($period_search, $period_match, $data['nb_mails_periode']));
    176  
    177         $next_day = $data['date_mail'] + strtotime(  $mails_periode,0);;
     230        $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );;
    178231        $data['rest_mail']=    $next_day - time() ;
    179  
    180                                
    181         $spams_periode="+".str_replace($period_search, $period_match, $data['nb_spams_periode']);
    182         $next_day = $data['date_spam'] + strtotime(  $spams_periode,0);
    183         $data['rest_spam']=  $next_day -time() ;
    184 
    185  
    186         $quarantaine_periode="+".str_replace($period_search, $period_match, $data['quarantaine_periode']);
    187         $next_day = $data['date_quarantaine'] + strtotime( $quarantaine_periode,0);     
    188        
    189         if ($data['quarantaine']) {
    190         $data['reste'] =   ( $next_day )-time() ;
     232
     233        $next_day =  + Str_To_Time( $data['nb_spams_periode'],$data['date_spam']);
     234        $data['rest_spam']=  $next_day - time() ;
     235
     236
     237        $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']);       
     238       
     239        if ($data['quarantaine'] == 'true' ) {
     240                        $data['reste'] =   ( $next_day )-time() ;
    191241        }else{
    192         $data['reste'] = 0;
     242                        $data['reste'] = 0;
    193243        }
    194244       
     
    225275{
    226276
    227 
    228 
    229 $delta=(7*24*60*60) ;
    230 $week = (int) ($int/$delta);
    231 
    232 $int= $int-($week*$delta) ; 
    233 
    234 
    235 $delta=(24*60*60) ;
    236 $day= (int) ($int/$delta);
    237 $int=$int-($day*$delta);
    238 
    239 $delta=(60*60) ;
    240 $heures=(int) ($int/$delta);
    241 $int=$int-($heures*$delta);
    242 
    243 $delta=(60) ;
    244 $minutes=(int) ($int/$delta);
    245 $int= $int - ($minutes*$delta);
    246 
    247 
    248 $secondes=(int) ($int);
    249 
    250 $day      = substr ('00'.    $day,-2,2);   
    251 $heures   = substr ('00'. $heures,-2,2);   
    252 $minutes  = substr ('00'.$minutes,-2,2);
    253 $secondes = substr ('00'.$secondes,-2,2);
     277        $delta=(7*24*60*60) ;
     278        $week = (int) ($int/$delta);
     279        $int= $int-($week*$delta) ; 
     280
     281        $delta=(24*60*60) ;
     282        $day= (int) ($int/$delta);
     283        $int=$int-($day*$delta);
     284
     285        $delta=(60*60) ;
     286        $heures=(int) ($int/$delta);
     287        $int=$int-($heures*$delta);
     288
     289        $delta=(60) ;
     290        $minutes=(int) ($int/$delta);
     291        $int= $int - ($minutes*$delta);
     292
     293        $secondes=(int) ($int);
     294        $day      = substr ('00'.    $day,-2,2);   
     295        $heures   = substr ('00'. $heures,-2,2);   
     296        $minutes  = substr ('00'.$minutes,-2,2);
     297        $secondes = substr ('00'.$secondes,-2,2);
    254298
    255299   
     
    278322{
    279323
    280 global $lang;
    281  load_language('plugin.lang', MAIL_SUPERV_PATH);
    282 
    283 $q = "
    284     CREATE TABLE IF NOT EXISTS ".MAIL_SUPERV_TABLE." (
    285                 `id` SMALLINT( 5 ) NOT NULL DEFAULT '0',
    286                
    287                 `nb_mails` INT NOT NULL DEFAULT '0',
    288                 `date_mail` INT NOT NULL DEFAULT '0',
    289                 `nb_mails_maxi` INT NOT NULL DEFAULT '2000',           
    290                 `nb_mails_periode` TEXT  ,     
    291                
    292                 `nb_spams` INT NOT NULL DEFAULT '0',
    293                 `date_spam` INT NOT NULL DEFAULT '0',   
    294                
    295                 `nb_spams_maxi` INT NOT NULL DEFAULT '10',     
    296                 `nb_spams_periode` TEXT  ,     
    297                
    298                 `quarantaine` TEXT ,
    299                 `date_quarantaine` INT NOT NULL DEFAULT '0',
    300                 `quarantaine_periode` TEXT  ,   
    301                        
    302                
    303                 `message` TEXT  ,
    304                 `message_test` TEXT  ,
    305                 `header_text` TEXT ,
    306         PRIMARY KEY  (`id` )
    307          )
    308   ;";
    309   pwg_query($q);
    310  
    311     $nb = Get_colonnes_de(MAIL_SUPERV_TABLE);
    312         $table=$nb[MAIL_SUPERV_TABLE];   
    313 //================================================================================     
    314     if (!in_array( "nb_mails",$table)) {       
    315                 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails` INT NOT NULL default '0' ";
    316                            pwg_query($query);            } 
    317         if (!in_array( "date_mail",$table)) {   
    318           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_mail` INT NOT NULL default '0' ";
    319                            pwg_query($query);            }
    320         if (!in_array( "nb_mails_maxi",$table)) {       
    321           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails_maxi` INT NOT NULL default '2000' ";
    322                            pwg_query($query);            }
    323         if (!in_array( "nb_mails_periode",$table)) {   
    324           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_mails_periode` TEXT ";
    325                            pwg_query($query);            }
    326                                                    
    327                                                    
    328     if (!in_array( "nb_spams",$table)) {       
    329                 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams` INT NOT NULL default '0' ";
    330                            pwg_query($query);            } 
    331         if (!in_array( "date_spam",$table)) {   
    332           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_spam` INT NOT NULL default '0' ";
    333                            pwg_query($query);            }                         
    334                            
    335     if (!in_array( "nb_spams_maxi",$table)) {   
    336                 $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams_maxi` INT NOT NULL default '10' ";
    337                            pwg_query($query); 
    338         if (!in_array( "nb_spams_periode",$table)) {   
    339           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `nb_spams_periode` TEXT ";
    340                            pwg_query($query);            }                                   } 
    341                                                        
    342                 if (!in_array( "quarantaine",$table)) {
    343           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `quarantaine` TEXT  , ";
    344                            pwg_query($query);            }     
    345                            
    346                 if (!in_array( "date_quarantaine",$table)) {   
    347           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `date_quarantaine` INT NOT NULL default '0'    ";
    348                            pwg_query($query);   
    349                                     }   
    350                 if (!in_array( "quarantaine_periode",$table)) {
    351           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `quarantaine_periode` TEXT ";
    352                            pwg_query($query);            }                                         
    353                                
    354                 if (!in_array( "message",$table)) {     
    355           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `message` TEXT   ";
    356                            pwg_query($query);            }     
    357                            
    358                 if (!in_array( "message_test",$table)) {       
    359           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `message_test` TEXT   ";
    360                            pwg_query($query);            }                                 
    361                            
    362                 if (!in_array( "header_text",$table)) {
    363           $query = "ALTER TABLE `".MAIL_SUPERV_TABLE."` ADD `header_text` TEXT   ";
    364                            pwg_query($query);            }             
    365                                                                        
    366 //-------------------------------------------------------                           
    367 
    368       $query = "
    369                 SELECT COUNT(`id`) as total
    370                 FROM `".MAIL_SUPERV_TABLE."`
    371                          
    372                 ;";     
     324global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
     325    load_language('plugin.lang', MAIL_SUPERV_PATH);
     326        create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
     327        ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type)  ;
    373328//==============================================================================               
    374 list($count) = mysql_fetch_row(pwg_query($query));
    375 
    376 
    377   if ($count == 0)
    378   {
    379          $next_day = time()  ;
    380          $date_quarantaine=time();
    381 
    382          
    383            $q = '
    384     INSERT INTO '.MAIL_SUPERV_TABLE.' (id,
    385         nb_mails,date_mail,nb_mails_maxi,nb_mails_periode,
    386         nb_spams,date_spam,nb_spams_maxi,nb_spams_periode,
    387          quarantaine, date_quarantaine,quarantaine_periode,
    388          message_test,
    389          message,header_text)
    390     VALUES (1,
    391         0,
    392         '.time().',
    393         2000,
    394         "1 '.l10n('Week').'",
    395        
    396         0,
    397         '.time().',
    398         10,
    399         "2 '.l10n('Day').'",
    400        
    401         false,
    402         '.time().',
    403         "2 '.l10n('Day').'",
    404        
    405         "Init.",
    406         "'.l10n('supervisor').'",
    407          "'.l10n('hello').'"
     329    $valeurs= array (   1,
     330                                                0,
     331                           time(),
     332                         2000,
     333         '"1 '.l10n('Week').'"' ,
     334                            0,
     335                  time(),
     336                           10,
     337          '"2 '.l10n('Day').'"',
     338                       '"false"',
     339                time(),
     340          '"2 '.l10n('Day').'"',
     341       
     342                      '"Init"',
     343   '"'.l10n('supervisor').'"',
     344        '"'.l10n('hello').'"',
    408345         )
    409          ;';
    410 
    411 
    412         pwg_query($q);
    413        
    414         }
     346        ;
     347
     348        ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ;
     349
    415350}
    416351
     
    426361      array_push($columns_of[$table], $row[0]);
    427362    }
     363 
    428364  return $columns_of;
    429365}
     
    456392  if (!empty($datas))
    457393  {
    458     while ($group = mysql_fetch_array($datas))
     394    while ($group = mysql_fetch_array($datas,MYSQL_ASSOC))
    459395    {
    460396
     
    469405 
    470406}
     407//=================================================================================
     408
     409function create_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
     410{
     411/*    $nb = Get_colonnes_de($nom_table);
     412        $table=$nb[$nom_table];         */
     413        $data =         $types ;
     414        $i=0;
     415        $valeurs=array();
     416
     417
     418       
     419foreach ( $champs as $champ)
     420   {
     421        $champ = trim($champ);
     422                array_push($valeurs , " `".$champ."`" . '  ' . $data[  $i] )  ;
     423                         
     424                $i +=1;
     425    }
     426        if ( count($valeurs) == 0) return ;
     427    $valeurs=implode(", ",$valeurs) ;
     428        //===============================================================================
     429                $query = "CREATE TABLE IF NOT EXISTS  `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY  (`id` ) ) ;"; 
     430                         if ( pwg_query($query) ) return ; 
     431                                die($query);         
     432         
     433}
     434function ajust_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
     435{
     436
     437    $nb = Get_colonnes_de($nom_table);
     438        $table=$nb[$nom_table];         
     439$data =         $types ;
     440$i=0;
     441 $valeurs=array();
     442 
     443
     444foreach ( $champs as $champ)
     445   {
     446     $champ = trim($champ);
     447          if (!in_array( $champ,$table)) {
     448         array_push($valeurs , " ADD `".$champ."`" . '  ' . $data[  $i] )  ;
     449         }
     450         $i +=1;
     451         
     452    }
     453        if ( count($valeurs) == 0) return ;
     454       
     455$valeurs=implode(", ",$valeurs) ;
     456        //===============================================================================
     457       
     458                $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ;
     459                        if (   pwg_query($query)) return ;           
     460       
     461                die($query);
     462
     463
     464}
     465
     466function ajout_ligne($nom_table,$champs,$valeurs,$force)
     467{
     468
     469       
     470
     471  if (!$force) {
     472     $query = "
     473                SELECT COUNT(`id`) as total
     474                FROM `".$nom_table."`
     475                ;";     
     476//==============================================================================               
     477                list($count) = mysql_fetch_row(pwg_query($query));
     478
     479}else{
     480
     481        $count = 0 ;
     482}
     483 
     484  if ($count == 0)
     485  {
     486  $n_champs=implode(",",$champs);
     487  $n_valeurs=implode(",",$valeurs);
     488 
     489
     490       
     491           $query = "
     492        INSERT INTO `".$nom_table."` (". $n_champs.")
     493        VALUES ( ".     $n_valeurs .")";
     494               
     495                if (pwg_query($query)) return ;
     496                die($query);
     497               
     498  }
     499}
     500//=====================================================================
     501
     502function Str_To_Time( $ajout,$init_date)
     503{
     504//========================================================
     505
     506$a_ajouter=$ajout ;
     507
     508        $period_search=array("W","D","H","M","S");
     509                       array_push($period_search,l10n('Week').'s',l10n('Day').'s',l10n('Hour').'s',l10n('Minute').'s',l10n('Seconde').'s');
     510                               array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde'));
     511
     512
     513       
     514        $period_match = array(' week ',' day ',' hour ',' minute ',' seconde ');       
     515                        array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
     516                        array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
     517       
     518
     519       
     520$a_ajouter = "+ " .  str_replace($period_search, $period_match, $a_ajouter) ;
     521
     522
     523       
     524$a_ajouter=trimUltime($a_ajouter);
     525$v1 = array('- ','+ ','week','day','hour','minute','seconde',' -',' +',' ');
     526$v2 = array('-','+', (7*24*60*60) ,  (24*60*60),  (60*60),  60,1,'|-','|+',"*" );
     527$new_valeur =  str_replace($v1,$v2,$a_ajouter) ;
     528$new_valeur =  str_replace('++','+',$new_valeur ) ;
     529
     530$new_valeur = explode( "|",$new_valeur );
     531$p = $init_date ;
     532
     533        //$new_valeur = $a_ajouter + $init_date ;
     534        foreach($new_valeur as $nv)
     535        {
     536                        $p += matheval($nv) ;
     537         
     538        }
     539return  $p ;
     540 
     541}
     542//=====================================================================================
     543function matheval($equation)
     544  {
     545    $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation);
     546   
     547    $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation);
     548   
     549    $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation);
     550 
     551    $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation);
     552       
     553    if ( $equation == "" )
     554    {
     555      $return = 0;
     556    }
     557    else
     558    {
     559         
     560      eval("\$return=" . $equation . ";" );
     561    }
     562    return $return;
     563  }
     564
     565//======================================================================================
     566function trimUltime($chaine){
     567        $chaine = trim($chaine);
     568        $chaine = str_replace("\t", " ", $chaine);
     569        $chaine = eregi_replace("[ ]+", " ", $chaine);
     570        return $chaine;
     571}
     572
     573
     574function kill_list()
     575{
     576
     577
     578 //==================== TEST black_liste ============================================           
     579     $query = "
     580                SELECT *,COUNT(`id`) as total
     581                FROM `".MAIL_BLACK_LISTE_TABLE."`
     582                    WHERE ip='".$_SERVER['REMOTE_ADDR']."'
     583                ;";     
     584//==============================================================================               
     585        $row = mysql_fetch_row(pwg_query($query));
     586        if (count($row) > 0)
     587        {
     588       
     589        $nb =  ($row[7])+1;
     590                $pays = isset($_POST['pays']) ? $_POST['pays'] : $pays="" ;
     591                $ville = (isset($_POST['ville']))   ? $_POST['ville']: $ville="" ;
     592                $region =  isset($_POST['region']) ? $_POST['region'] : $region="" ;
     593               
     594         $query ="
     595                        UPDATE " . MAIL_BLACK_LISTE_TABLE . "
     596                        SET ";
     597                if (isset($_POST['pays']))     
     598                 $query .= "   
     599                        `pays` = '". $pays ."',
     600                        `region` = '" . $region ."',
     601                        `ville` = '" . $ville . "',
     602                        ";
     603                 $query .= "           
     604                        `nb` = " . $nb . "
     605                          WHERE ip = '".$_SERVER['REMOTE_ADDR']."' ;
     606                ";
     607                                pwg_query($query );
     608        //================================================================================     
     609               
     610        }
     611return (count($row) > 0) ;
     612}
    471613
    472614?>
  • extensions/Mail_supervisor/include/function_test_send.php

    r4054 r4132  
    2626  die('Hacking attempt!');
    2727}
    28 if (!defined('MAIL_SUPERV_DIR')) define('MAIL_SUPERV_DIR' , basename(dirname(__FILE__)));
    29 if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
     28
     29
    3030
    3131function test_envoie($message,$group_name,$group_id)
Note: See TracChangeset for help on using the changeset viewer.