Changeset 4132 for extensions


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
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/Mail_supervisor/admin/mail_superv_admin.php

    r4065 r4132  
     1
    12<?php
    23// +-----------------------------------------------------------------------+
     
    2627  die('Hacking attempt!');
    2728}
    28 if (!defined('MAIL_SUPERV_DIR')) define('MAIL_SUPERV_DIR' , basename(dirname(__FILE__)));
     29
    2930if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    3031
    3132
    32 
    33 
    34 
    3533// +-----------------------------------------------------------------------+
    3634// | Check Access and exit when user status is not ok                      |
    3735// +-----------------------------------------------------------------------+
    38 check_status(ACCESS_ADMINISTRATOR);
     36//check_status(ACCESS_ADMINISTRATOR);
    3937
    4038global $user, $lang, $conf, $errors,$mails_données;
    4139global $args, $conf_mail,$infos_message,$erreur_message ;
    4240
    43 include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
     41
    4442include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    4543
     
    4745include_once (MAIL_SUPERV_PATH.'include/constants.php');
    4846include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    49 
     47include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    5048$my_base_url = get_admin_plugin_menu_link(__FILE__);
    5149
     
    5452 load_language('plugin.lang', MAIL_SUPERV_PATH);
    5553
    56  
     54
    5755$mails_options = explode("," , $conf['mail_superv']);
    5856$mails_données=Get_Datas();
     
    7371               l10n('Tab_set'),
    7472               $my_base_url.'&amp;tab=mail_superv_admin');
     73                           
    7574$tabsheet->add('mail_superv_test',
    7675               l10n('Tab_test'),
    7776               $my_base_url.'&amp;tab=mail_superv_test');
     77                           
     78$tabsheet->add( 'mail_black_liste',
     79               l10n('blackliste'),
     80                           $my_base_url.'&amp;tab=mail_black_liste');
     81 
     82                                                   
    7883$tabsheet->add('mail_superv_help',$tabhelp
    7984              ,
    8085               $my_base_url.'&amp;tab=mail_superv_help');
     86                           
     87                           
    8188$tabsheet->select($page['tab']);
    8289$tabsheet->assign();
     
    95102
    96103                $modif=false ;
     104
     105
    97106//================================================================================
    98107switch ($page['tab'])
    99108 {
    100     
     109   
    101110// *************************************************************************
    102111//                         initialisation                                  |
     
    133142       
    134143        $mails_données['reste'] = 0;
    135         $mails_données['quarantaine']=false;
     144        $mails_données['quarantaine']='false';
    136145       
    137146     sauve_données();
     
    175184    $reste= $mails_données['reste'];   
    176185
    177 $quarantaine= $mails_données['quarantaine'];   
     186$quarantaine = ($mails_données['quarantaine'] == 'true') ? true : false ;;     
     187
     188         
     189       
    178190$PHPWG_VERSION=PHPWG_VERSION;
    179191
     
    198210         'time_spams_reste' => "'".int_to_heure($rest_spam)."'" ,       
    199211         
    200          'quarantaine' => $mails_données['quarantaine'] ,
     212         'quarantaine' => $quarantaine ,
    201213        'date_quarantaine' => "'".date(l10n('formatdate'),time()+$reste)."'" ,
    202214        'quarantaine_periode' => "'".$mails_données['quarantaine_periode']."'" ,
     
    262274  $result = pwg_query($query);
    263275//----------------------------------------------------------------     
    264   while ($row = mysql_fetch_array($result))
     276  while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    265277  {
    266278    $groups[$row['id']] = $row['name'];
     
    290302   break;
    291303// *************************************************************************
     304//              BLACK LISTE                                         |
     305// *************************************************************************   
     306     case 'mail_black_liste':
     307
     308   load_language('help/plugin.lang', MAIL_SUPERV_PATH);
     309 
     310          $aff_nb=false;
     311          $smile_bonjour=MAIL_SUPERV_PATH."smilies/bonjour.gif" ;
     312      $template->assign(
     313                                        array(
     314                                        'smile_bonjour' => $smile_bonjour ,
     315                                        )
     316                        );             
     317        $aff_nb = false;
     318        ;
     319         $liste_bl=array();
     320         $liste_ip=array();
     321
     322                $ip_black="";
     323                $info_ip ="";
     324
     325                include  (MAIL_SUPERV_PATH.'include/save_info.php');
     326               
     327$fonction_raz = $my_base_url.'&amp;tab=mail_black_liste&amp;info=raz:';
     328$fonction_set = $my_base_url.'&amp;tab=mail_black_liste&amp;info=ajout:';
     329$f_action  = $my_base_url.'&amp;tab=mail_black_liste' ;
     330                // array_keys($liste_bl[0]);array_keys($liste_ip[0])
     331        $champs_ip=array();
     332        $champs_bl=array();
     333       
     334                 if (!empty($liste_ip))
     335                $champs_ip=array_keys($liste_ip[0]);
     336               
     337                 if (!empty($liste_bl))
     338        $champs_bl=array_keys($liste_bl[0]);
     339 
     340               
     341                  $smile_bonjour=MAIL_SUPERV_PATH."smilies/mouche.gif" ;
     342      $template->assign(
     343                                        array(
     344                                        'smile_bonjour' => $smile_bonjour ,
     345
     346                                'champs_ip' => $champs_ip ,                                     
     347                                                'liste_ip' => $liste_ip,
     348                                                'champs_bl' =>  $champs_bl       ,     
     349                                                'liste_bl' => $liste_bl ,
     350                                'conf_admin_layout' => $conf['admin_layout'] ,
     351                                                'ip_black' => $ip_black ,
     352                                                'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
     353                                                'fonction_raz' => $fonction_raz ,
     354                                                'fonction_set' => $fonction_set ,
     355                                                'F_ACTION' => $f_action ,
     356                                                'IP' => $_SERVER['REMOTE_ADDR'],
     357                                        )
     358                                );                       
     359         //===============================================================                       
     360                $template->set_filenames(array('plugin_admin_content' => realpath(MAIL_SUPERV_PATH . 'admin/mail_black_liste.tpl')));
     361                $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     362   break;
     363
     364// *************************************************************************
    292365//                      AIDE                                               |
    293366// *************************************************************************   
     
    310383   break;
    311384 //====================================================================
    312 
    313  
    314  }
     385  }
    315386//================================================================================
    316387
     
    350421                }
    351422               
     423
    352424                 
    353425                if  ($infos_message != "") 
  • extensions/Mail_supervisor/admin/mail_superv_admin.tpl

    r4059 r4132  
    3434           <td><input type="text" name="date_mail"  value={$date_mail} /></td>
    3535           <td><input type="text" name="nb_mails_maxi" size="10%" value={$nb_mails_maxi} /></td>
    36             <td><input type="text" name="nb_mails_periode" size="10%" value={$nb_mails_periode} /></td>
     36            <td><input type="text" name="nb_mails_periode" size="30%" value={$nb_mails_periode} /></td>
    3737                <td><input type="text" name="time_mails_reste" size="50%" value={$time_mails_reste} /></td> 
    3838    </tr>
     
    4444           <td><input type="text" name="date_spam"  value={$date_spam} /></td>
    4545           <td><input type="text" name="nb_spams_maxi" size="10%" value={$nb_spams_maxi} /></td>
    46             <td><input type="text" name="nb_spams_periode" size="10%" value={$nb_spams_periode} /></td>
     46            <td><input type="text" name="nb_spams_periode" size="30%" value={$nb_spams_periode} /></td>
    4747                <td><input type="text" name="time_spams_reste" size="50%" value={$time_spams_reste} /></td> 
    4848            </tr>
     
    6060                        <td><input type="text" name="date_quarantaine"  value={$date_quarantaine} />                    </td><td> </td>
    6161                       
    62                   <td><input type="text" name="quarantaine_periode" size="10%" value={$quarantaine_periode} /></td>
     62                  <td><input type="text" name="quarantaine_periode" size="30%" value={$quarantaine_periode} /></td>
    6363                   <td><input type="text" name="reste" size="50%" value={$reste} /></td>
    6464                {/if}
  • extensions/Mail_supervisor/admin/mail_superv_help.tpl

    r4065 r4132  
     1
    12<div class="instructions" >
    23 
    34<h2>{'Tab_help'|translate}</h2>
    45<fieldset style=" position:relative ; top:15px">
     6  <legend>{'free_admin_titre'|translate}</legend>
    57<div id="instructionFonction" class="instructionBlock" >
    6 
     8 
    79  <div
    810    id="fonction_header"
     
    4749
    4850<ol>
    49   <li><span style="color:#3300FF">{'check_mailto'|translate}</span> </li>
     51  <li ><span class="throw"> {'check_mailto'|translate}</span></li>
    5052   <ul>
    5153 <li>{'hlp_2_1'|translate}</li>
    5254</ul>
    53   <li><span style="color:#3300FF">{'check_header_carbon'|translate}</span></li>
     55  <li ><span  class="throw">{'check_header_carbon'|translate}</span></li>
    5456 
    5557   <ul>
    5658 <li>{'hlp_2_2'|translate}</li>
    5759</ul>
    58   <li><span style="color:#3300FF">{'check_header_text'|translate}</span> </li>
     60  <li><span  class="throw">{'check_header_text'|translate}</span> </li>
    5961  <ul>
    60  <li>{'hlp_2_3'|translate}</span></li>
     62 <li>{'hlp_2_3'|translate}</li>
    6163</ul>
    6264</ol>
     
    8688<ul>
    8789    <ul>     
    88           <li ><i><span style="color:#3300FF">{'free_nb'|translate}</span></i>       {'hlp_3_1'|translate}</li>
    89       <li><i><span style="color:#3300FF">{'free_depuis_le'|translate}</span></i> {'hlp_3_2'|translate}</li>
    90       <li><i><span style="color:#3300FF">{'free_nb_maxi'|translate}</span></i>   {'hlp_3_3'|translate}</li>
    91       <li><i><span style="color:#3300FF">{'periode'|translate}</span></i>   {'hlp_3_4'|translate}
     90          <li ><i><span class="throw">{'free_nb'|translate}</span></i>       {'hlp_3_1'|translate}</li>
     91      <li><i><span class="throw">{'free_depuis_le'|translate}</span></i> {'hlp_3_2'|translate}</li>
     92      <li><i><span class="throw">{'free_nb_maxi'|translate}</span></i>   {'hlp_3_3'|translate}</li>
     93      <li><i><span class="throw">{'periode'|translate}</span></i>   {'hlp_3_4'|translate}
    9294          {'hlp_3_4_0'|translate}
    9395          </li>
    94       <li><i><span style="color:#3300FF">{'reste'|translate}</span></i>          {'hlp_3_5'|translate}</li>
     96      <li><i><span class="throw">{'reste'|translate}</span></i>          {'hlp_3_5'|translate}</li>
    9597 
    9698    </ul>
     
    118120<ul>
    119121
    120       <li><i><span style="color:#FF0000">{'free_quarantaine'|translate}</span></i>   {'hlp_4_1'|translate}</li>
    121       <li><i><span style="color:#3300FF">{'quarantaine'|translate}</span></i>     {'hlp_4_2'|translate}</li>
     122      <li><i><span class="throw">{'free_quarantaine'|translate}</span></i>   {'hlp_4_1'|translate}</li>
     123      <li><i><span  class="throw">{'quarantaine'|translate}</span></i>     {'hlp_4_2'|translate}</li>
    122124
    123125 
     
    143145<ul>
    144146
    145   <li><i>{'free_admin_description'|translate}</i>     {'hlp_5_1'|translate}</li>
     147  <li><i><span  class="throw">{'free_admin_description'|translate}</span></i>     {'hlp_5_1'|translate}</li>
    146148</ul>
    147149
     
    153155 Rédaction en cours....
    154156 </fieldset>
    155 
    156 </div>
     157 
     158 
     159 <fieldset >
     160  <legend>{'test'|translate}</legend>
     161<div id="testFonction" class="instructionBlock" >
     162 
     163  <div
     164    id="test_header"
     165    class="instructionBlockHeaderCollapsed"
     166    onclick="blockToggleDisplay('test_header', 'Fonction1')"
     167  ><span>
     168    {'test'|translate}
     169  </span></div>
     170  <div
     171    id="Fonction1"
     172    class="instructionBlockContent"
     173    style="display:none"
     174  >
     175     
     176    <p></p>
     177  </div> <!-- Fonction -->
     178</div> <!-- Fonctions -->
     179
     180
     181 </fieldset>
     182 
     183<fieldset >
     184  <legend>{'blackliste'|translate}</legend>
     185<div id="blacklisteFonction" class="instructionBlock" >
     186 
     187  <div
     188    id="blackliste_header"
     189    class="instructionBlockHeaderCollapsed"
     190    onclick="blockToggleDisplay('blackliste_header', 'Fonction2')"
     191  ><span>
     192    {'blackliste'|translate}
     193  </span></div>
     194  <div
     195    id="Fonction2"
     196    class="instructionBlockContent"
     197    style="display:none"
     198  >
     199     
     200    <p>{'hlp_7_1'|translate}</p>
     201  </div> <!-- Fonction -->
     202</div> <!-- Fonctions -->
     203
     204
     205 </fieldset></div>
  • extensions/Mail_supervisor/admin/mail_superv_test.tpl

    r4042 r4132  
    3636          <input class="submit" type="submit" name="raffraichir" value="{'refresh'|translate}" />
    3737          <input class="submit" type="submit" name="test_envoie" value="{'test'|translate}" />
     38         
     39       
     40         
    3841          </p>
    3942</fieldset>
  • 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)
  • extensions/Mail_supervisor/language/fr_FR/help/plugin.lang.php

    r4065 r4132  
    4646
    4747$lang['hlp_5_1']='Dernier message renvoyé par la fonction mail().';
    48  
    49          
     48//=====================================================================
     49
     50
     51//======================================================================
     52
     53
     54$lang['hlp_7_1']='Ce module permet de créer une liste noire contenant les adresses IP indésirables.
     55                  Les adresse IP mémorisées dans la liste noire seront blocquées lors de leur tentative de connexions au site.
     56                                  Les jockers (*) pour remplacer un groupe d\'adresse  sont autorisés.
     57                                    Exemple : 94.102.63.*
     58                                  Exclusion de toutes les adresses IP de 94.102.63.0 à 94.102.63.255
     59                                        Exemple : 94.102.*.13
     60                                  Exclusion de toutes les adresses IP de 94.102.0.13 à 94.102.255.13
     61                                 
     62                                 
     63                                  ';     
    5064?>
  • extensions/Mail_supervisor/language/fr_FR/plugin.lang.php

    r4065 r4132  
    1616$lang['nbm_no_mail_to_send'] = 'Pas de mail à envoyer.';
    1717*/
     18$lang['IP_adress'] = 'Votre adresse IP';
     19$lang['liste_ip']="Liste des IP (historique)";
     20$lang['black_liste']="Liste noire des IP";
     21$lang['blackliste']="Liste noire";
     22
    1823$lang['state'] = 'Etat';
    1924$lang['refresh'] = 'Rafraîchir';
  • extensions/Mail_supervisor/main.inc.php

    r4059 r4132  
    259259                        }
    260260 
    261 
    262261 
    263262
     
    280279//add_event_handler('loc_end_page_tail', 'affiche_message');
    281280add_event_handler('loc_after_page_header', 'affiche_message');
    282 
    283281?>
  • extensions/Mail_supervisor/maintain.inc.php

    r4059 r4132  
    2525  die('Hacking attempt!');
    2626}
    27 
    28 
    29 if (!defined('MAIL_SUPERV_DIR')) define('MAIL_SUPERV_DIR' , basename(dirname(__FILE__)));
    3027if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    31 
    3228include_once (MAIL_SUPERV_PATH.'include/constants.php');
    33 
    34 include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    35 
     29 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
     30 
    3631function plugin_install()
    3732{
    3833
     34 
     35  global $superv_bl_champs,$superv_bl_type ;
     36 
    3937// efface free mail
    4038$q = '
    4139  SELECT  count(`id`) as total   FROM `'.PLUGINS_TABLE.'` WHERE `id` LIKE "free_mail"   ;';
    42      $plugs = mysql_fetch_array(pwg_query($q));
     40     $plugs = mysql_fetch_array(pwg_query($q),MYSQL_ASSOC);
    4341         $nb= $plugs['total'];
    4442
    4543  if (count($nb)>=1) {
    46  /*          $q = '
    47 UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE `id` LIKE "free_mail"';
    48         pwg_query($q);
    49    pwg_query( $q );*/
     44                        /*  $q = '
     45                                UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE `id` LIKE "free_mail"';
     46                        pwg_query($q);
     47                                pwg_query( $q );*/
    5048      $q = '
    5149      DELETE FROM '.PLUGINS_TABLE.'
     
    7876  $q = '
    7977    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
    80     VALUES ("mail_superv","on,on,off ,off,off","Parametres du plugin Mail superviseur")
     78    VALUES ("mail_superv","off,off,off ,off,off","Parametres du plugin Mail superviseur")
    8179  ;';
    8280  pwg_query($q);
     81 
    8382
    84 
    85         vérif_base();
     83 
     84  vérif_base();
     85  create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
    8686
    8787}
     
    102102
    103103    pwg_query($q);
    104 
    105 
    106 
    107   $q = 'DROP TABLE '.MAIL_SUPERV_TABLE.';';
     104  }
     105   $q = 'DROP TABLE IF EXISTS  '.MAIL_BLACK_LISTE_TABLE.';';
     106   pwg_query( $q ); 
     107   $q = 'DROP TABLE IF EXISTS '.MAIL_SUPERV_TABLE.';';
    108108   pwg_query( $q );
    109    }
     109   
     110 
    110111 
    111112}
     
    113114function plugin_activate()
    114115{
     116 
    115117
    116118}
Note: See TracChangeset for help on using the changeset viewer.