Ignore:
Timestamp:
Feb 15, 2010, 3:51:00 PM (14 years ago)
Author:
cljosse
Message:

[Mail_supervisor] Fix Bug when the user is not french.

File:
1 edited

Legend:

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

    r4880 r4888  
    157157                if ($erreur_message <> "")
    158158                        {
    159                             $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
     159                            $erreur_message = str_replace("\n",'<br />',$erreur_message) ;
    160160                                $template->assign('errors',$erreur_message);
    161                                 $erreur_message="";
     161                                $erreur_message = "";
    162162                        }
    163163                }
     
    169169                if ($infos_message <> "")
    170170                        {
    171                                 $infos_message=str_replace("\n",'<br />',$infos_message) ;
     171                                $infos_message = str_replace("\n",'<br />',$infos_message) ;
    172172                                $template->assign('infos',$infos_message);
    173                                 $infos_message="";
     173                                $infos_message = "";
    174174                        }
    175175                }
     
    262262    $data = mysql_fetch_array($result,MYSQL_ASSOC);
    263263        //====================================================================================
    264        
    265         $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );;
    266         $data['rest_mail']=    $next_day - time() ;
     264
     265        $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );
     266 $next_day = ($next_day >0) ? $next_day :  (604800  + time()) ;
     267        $data['rest_mail'] =    $next_day - time() ;
    267268
    268269        $next_day = Str_To_Time( $data['nb_spams_periode'],$data['date_spam']);
    269         $data['rest_spam']=  $next_day - time() ;
     270        $next_day = ($next_day >0) ? $next_day :  (172800  + time()) ;
     271        $data['rest_spam'] =  $next_day - time() ;
    270272
    271273
    272274        $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']);       
     275        $next_day = ($next_day >0) ? $next_day :  (172800 + time()) ;
    273276       
    274277        if ($data['quarantaine'] == 'true' ) {
     
    309312function int_to_heure($int)
    310313{
     314global $lang,$mails_données ;
     315
     316$v0=Date_to_numeric(l10n('Day') );
     317
     318
    311319
    312320        $delta=(7*24*60*60) ;
     
    331339        $minutes  = substr ('00'.$minutes,-2,2);
    332340        $secondes = substr ('00'.$secondes,-2,2);
    333 
    334    
    335 if ($week > 0 )
    336 {
    337         return $week. " " .l10n('Sv_Week'). " " .  $day . " " .l10n('Sv_Day'). "s ". $heures . " ". l10n('Sv_Hour'). "s " .    $minutes. " " .l10n('Sv_Minute'). "s ".  $secondes." " .l10n('Sv_Seconde')."s";
    338 }
    339 return $day . " " .l10n('Sv_Day'). "s ". $heures . " ". l10n('Sv_Hour'). "s " . $minutes. " " .l10n('Sv_Minute'). "s ".  $secondes." " .l10n('Sv_Seconde')."s";
     341       
     342$retour="";
     343$Week=explode(" ",l10n('Week %d'));
     344$Week= ($Week[0]);
     345
     346if ($week > 0 ) $retour .= "+" . $week ." " . $Week ;
     347if ($day  > 0) $retour .= "+" . $day ." " .l10n('Day');
     348if ($heures > 0) $retour .= "+" . $heures." " .l10n('Hour');
     349if ($minutes > 0) $retour .= "+" . $minutes." " .l10n('Minute');
     350if ($secondes > 0) $retour .= "+" . $secondes." " .l10n('Second');
     351$retour=str_replace("+0","+",$retour);
     352//================================================================================================   
     353
     354
     355return $retour;
    340356
    341357}       
     
    372388                           time(),
    373389                         2000,
    374          '"1 '.l10n('Sv_Week').'"' ,
     390         '"604800"' ,
    375391                            0,
    376392                  time(),
    377393                           10,
    378           '"2 '.l10n('Sv_Day').'"',
     394          '"172800"',
    379395                       '"false"',
    380396                time(),
    381           '"2 '.l10n('Sv_Day').'"',
    382        
    383                       '"Init"',
     397          '"172800"',
     398          '"Init"',
    384399   '"'.l10n('Sv_supervisor').'"',
    385         '"'.l10n('Sv_hello').'"',
     400        '"'.l10n('hello').'"',
    386401         )
    387402        ;
     
    528543}
    529544//=====================================================================
    530 
    531 function Str_To_Time( $ajout,$init_date)
    532 {
    533 //========================================================
    534   global $erreur_message,$infos_message;
    535 
    536    
    537 $a_ajouter = strtolower($ajout) ;
    538 if (strlen($a_ajouter) <4) $a_ajouter=$a_ajouter." " ;
    539  $period_search=array("s ","j ","h ","m ","s ");
    540  array_push($period_search,"w ","d ","h ","m ","s ");
    541 array_push($period_search,l10n('Sv_Week').'s',l10n('Sv_Day').'s',l10n('Sv_Hour').'s',l10n('Sv_Minute').'s',l10n('Sv_Seconde').'s');
    542 array_push($period_search,l10n('Sv_Week'),l10n('Sv_Day'),l10n('Sv_Hour'),l10n('Sv_Minute'),l10n('Sv_Seconde'));
    543        
    544 $period_match = array(' week ',' day ',' hour ',' minute ',' seconde ');
    545                 array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');     
    546                     array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
    547                     array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
    548        
    549 
    550        
    551 $a_ajouter = "+ " .  str_replace($period_search, $period_match, $a_ajouter) ;
     545function vérif_mails_données()
     546{
     547global $mails_données,$infos_message,$erreur_message,$page;
     548
     549if (!is_numeric($mails_données['nb_mails_periode']))
     550{
     551 $periode = Str_To_Time( $mails_données['nb_mails_periode'],0);
     552 $mails_données['nb_mails_periode']= ($periode > 0) ? $periode : '604800' ;
     553 }
     554
     555if (!is_numeric($mails_données['nb_spams_periode']))
     556{
     557 
     558 $periode=Str_To_Time( $mails_données['nb_spams_periode'],0);
     559 $mails_données['nb_spams_periode']= ($periode > 0) ? $periode : '172800' ; ;
     560 }
     561if (!is_numeric($mails_données['quarantaine_periode']))
     562{
     563 $periode=Str_To_Time( $mails_données['quarantaine_periode'],0);
     564 $mails_données['quarantaine_periode']= ($periode > 0) ? $periode : '172800' ;
     565 }
     566
     567        if  ($infos_message != "")  {
     568                   array_push($page['infos'],  $infos_message);
     569                   $infos_message="";
     570                 }
     571                 
     572                if  ($erreur_message != "")  {
     573                  array_push($page['errors'], $erreur_message);
     574                  $erreur_message ="";
     575                 }     
     576                 
     577}
     578//=======================================================================
     579function Date_to_numeric( $Valeurs )
     580{
     581global $lang,$erreur_message,$infos_message;
     582
     583$a_ajouter = $Valeurs ;
     584
     585
     586if (!isset($lang['Sv_second'])) {
     587$Week=explode(" ",l10n('Week %d'));
     588$Week= ($Week[0]);
     589
     590$lang['Sv_week'] = $Week;
     591$lang['Sv_day'] =   l10n('Day')  ;
     592$lang['Sv_hour'] =   l10n('Hour')  ;
     593$lang['Sv_minute'] =   l10n('Minute') ;
     594$lang['Sv_second'] =   l10n('Second');
     595
     596$lang['Sv_'. $lang['Sv_week']] = 'week';
     597$lang['Sv_'. $lang['Sv_day']] = 'day';
     598$lang['Sv_'. $lang['Sv_hour']] = 'hour';
     599$lang['Sv_'. $lang['Sv_minute']] = 'minute';
     600$lang['Sv_'. $lang['Sv_second']] = 'second';
     601
     602}
     603//--- traduction --> anglais ---
     604
     605 //========= suppression numéric et symbole ==========
     606$new_valeur =( preg_replace("/[0-9+\-.*\/()%]/"," ",$a_ajouter));
     607$nv =  trim( sup_double_espace($new_valeur)) ;
     608 
     609 
     610 
     611        $conv['week']= (7*24*60*60);
     612        $conv['day']= (24*60*60);
     613        $conv['hour']=  (60*60) ;
     614        $conv['minute']=  60 ;
     615        $conv['second']= 1;
     616
     617  $nv = explode(" ", $nv );
     618 
     619  foreach($nv as $nv1)
     620  {
     621  if (!isset($lang['Sv_'. $nv1]) ) {
     622  //==== au cas pluriel ===
     623 
     624   $nv0 =  substr($nv1, 0,-1) ;   
     625  $a_ajouter= str_replace( $nv1,$nv0,   $a_ajouter);
     626  $nv1 = $nv0 ;
     627   
     628  }
     629 
     630  if (!isset($lang['Sv_'. $nv1]) ) {
     631    $erreur_message .= $nv1. " ".l10n('not_found')."<br />"; 
     632        //  die($erreur_message);
     633         
     634  }else {
     635    ob_start(); 
     636         $match = $conv[strtolower($lang['Sv_'. $nv1])] ;
     637         $a_ajouter = str_replace($nv1," ". $match  ." ",$a_ajouter) ;
     638                 $erreur_message .= ob_get_contents();
     639    ob_end_clean();
     640        }       
     641         
     642  }
     643
     644$a_ajouter = "+ " .   $a_ajouter ;
    552645$a_ajouter=sup_double_espace($a_ajouter);
    553 
    554 $v1 = array('- ','+ ','week','day','hour','minute','seconde',' -',' +',' ');
    555 $v2 = array('-','+', (7*24*60*60) ,  (24*60*60),  (60*60),  60,1,'|-','|+',"*" );
    556 
     646$v1 = array('- ','+ ',' -', ' +', ' ');
     647$v2 = array('-' ,'+' ,'|-', '|+', "*");
    557648
    558649$new_valeur =  str_replace($v1,$v2,$a_ajouter) ;
    559650$new_valeur =  str_replace('++','+',$new_valeur ) ;
    560 
    561 $new_valeur = explode( "|",$new_valeur );
     651                       
     652return   $new_valeur;
     653}
     654//=====================================================================
     655function Str_To_Time( $ajout,$init_date)
     656{
     657//========================================================
     658  global $erreur_message,$infos_message,$user;
     659  global $lang;
     660 
     661  $ajout=ucwords ($ajout);
     662 
     663 
     664if (is_numeric($ajout))
     665 $valeur=   $ajout ;
     666else
     667{
     668 $valeur= Date_to_numeric( $ajout) ;
     669 
     670 }
     671 
     672$new_valeur = explode( "|", $valeur );
     673
    562674$p = $init_date ;
    563675$n0=0;
     676$erreur = false;
     677
    564678        //$new_valeur = $a_ajouter + $init_date ;
    565679        foreach($new_valeur as $nv)
     
    570684                 }else {
    571685                    $erreur_message .=   "[" . $ajout . "] --> " . l10n('Sv_syntax_error') . " : " .  $nv ."<br />";
     686                        $erreur = true;
    572687                 }
    573688                       
    574689         
    575690        }
    576        
    577 return  $p ;
     691        if ($erreur) $p = -1000 ;
     692return    intval($p) ;
    578693 
    579694}
     
    9081023}
    9091024
    910        
     1025 function Get_Version_plugins($dir)
     1026  {
     1027        $path = $dir;
     1028          $plg_data = implode( '', file($path.'main.inc.php') );
     1029          if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
     1030          {
     1031            $plugin['name'] = trim( $val[1] );
     1032          }
     1033          if (preg_match("|Version: (.*)|", $plg_data, $val))
     1034          {
     1035            $plugin['version'] = trim($val[1]);
     1036          }
     1037          if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
     1038          {
     1039            $plugin['uri'] = trim($val[1]);
     1040          }
     1041          if ($desc = load_language('description.txt', $path.'/', array('return' => true)))
     1042          {
     1043            $plugin['description'] = trim($desc);
     1044          }
     1045          elseif ( preg_match("|Description: (.*)|", $plg_data, $val) )
     1046          {
     1047            $plugin['description'] = trim($val[1]);
     1048          }
     1049          if ( preg_match("|Author: (.*)|", $plg_data, $val) )
     1050          {
     1051            $plugin['author'] = trim($val[1]);
     1052          }
     1053          if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
     1054          {
     1055            $plugin['author uri'] = trim($val[1]);
     1056          }
     1057          if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid='))
     1058          {
     1059            list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']);
     1060            if (is_numeric($extension)) $plugin['extension'] = $extension;
     1061          }
     1062          // IMPORTANT SECURITY !
     1063          $plugin = array_map('htmlspecialchars', $plugin);
     1064
     1065         return $plugin ;
     1066
     1067  }
    9111068?>
Note: See TracChangeset for help on using the changeset viewer.