Changeset 6700

Show
Ignore:
Timestamp:
10/02/08 22:41:57 (2 months ago)
Author:
jmathis
Message:

improve gmt management

Location:
trunk/centreon/www/include/configuration/configGenerate
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/include/configuration/configGenerate/DB-Func.php

    r6646 r6700  
    1515 * For information : contact@centreon.com 
    1616 */ 
     17 
     18        /* 
     19         * Compute values for time range 
     20         */ 
     21         
     22        function ComputeGMTTime($day, $daybefore, $dayafter, $gmt, $conf) { 
     23                global $PeriodBefore, $PeriodAfter, $Period; 
     24                $tabPeriod = split(";", $conf); 
     25                foreach ($tabPeriod as $period) { 
     26                        /* 
     27                         * Match hours 
     28                         */ 
     29                        preg_match("/([0-9]*)\:([0-9]*)\-([0-9]*):([0-9]*)/", $period, $tabValue); 
     30 
     31                        if ($gmt < 0) { 
     32                                $tabValue[1] += $gmt; 
     33                                $tabValue[3] += $gmt; 
     34                                 
     35                                if ($tabValue[1] < 0 && $tabValue[3] < 0) {                              
     36                                        $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".$tabValue[2]."-".(24 + $tabValue[3]).":".$tabValue[4].";"; 
     37                                } else if ($tabValue[1] < 0 && $tabValue[3] > 0) { 
     38                                        $Period[$day] .= "00:00-".((24 + $tabValue[3]) % 24).":".$tabValue[4].";"; 
     39                                        $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".$tabValue[2]."-24:00;"; 
     40                                } else { 
     41                                        $Period[$day] .= ($tabValue[1] < 0 ? 24 + $tabValue[1] : $tabValue[1]).":".$tabValue[2]."-".($tabValue[3] <= 0 ? 24 + $tabValue[3] : $tabValue[3]).":".$tabValue[4].";";                                         
     42                                } 
     43                        } else if ($gmt > 0) { 
     44                                $tabValue[1] += $gmt; 
     45                                $tabValue[3] += $gmt; 
     46                                if ($tabValue[1] > 24 && $tabValue[3] > 24) {                            
     47                                        $PeriodAfter[$dayafter] .= ($tabValue[1] % 24).":".$tabValue[2]."-".($tabValue[3] % 24).":".$tabValue[4].";"; 
     48                                } else if ($tabValue[1] < 24 && $tabValue[3] > 24) { 
     49                                        $Period[$day] .= $tabValue[1].":".$tabValue[2]."-"."24:00;"; 
     50                                        $PeriodAfter[$dayafter] .= "00:00-".($tabValue[3] % 24).":".$tabValue[4].";"; 
     51                                } else { 
     52                                        $Period[$day] .= $tabValue[1].":".$tabValue[2]."-".$tabValue[3].":".$tabValue[4].";";                                    
     53                                } 
     54                        } else if ($gmt == 0) { 
     55                                $Period[$day] .= $tabValue[1].":".$tabValue[2]."-".$tabValue[3].":".$tabValue[4].";"; 
     56                        }                
     57                } 
     58        } 
     59         
    1760 
    1861        function isHostOnThisInstance($host_id, $instance_id){ 
  • trunk/centreon/www/include/configuration/configGenerate/genTimeperiods.php

    r6668 r6700  
    5757                $i++; 
    5858                unset($timePeriod); 
    59         } 
    60          
    61         /* 
    62          * Generate custom Timeperiod for GMT 
    63          */ 
    64         function AdjustToGmt($value, $gmt) { 
    65                 $value += $gmt; 
    66                 if ($value <= 0) 
    67                         $value = "00"; 
    68                 if ($value >= 24) 
    69                         $value = "24"; 
    70                 return $value; 
    71         }  
    72          
    73         /* 
    74          * Compute values for time range 
    75          */ 
    76          
    77         function ComputeGMTTime($day, $daybefore, $dayafter, $gmt, $conf) { 
    78                 global $PeriodBefore, $PeriodAfter, $Period; 
    79                 $tabPeriod = split(";", $conf); 
    80                 foreach ($tabPeriod as $period) { 
    81                         /* 
    82                          * Match hours 
    83                          */ 
    84                         preg_match("/([0-9]*)\:([0-9]*)\-([0-9]*):([0-9]*)/", $period, $tabValue); 
    85  
    86                         if ($gmt < 0) { 
    87                                 $tabValue[1] += $gmt; 
    88                                 $tabValue[3] += $gmt; 
    89                                  
    90                                 if ($tabValue[1] < 0 && $tabValue[3] < 0) {                              
    91                                         $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".$tabValue[2]."-".(24 + $tabValue[3]).":".$tabValue[4].";"; 
    92                                 } else if ($tabValue[1] < 0 && $tabValue[3] > 0) { 
    93                                         $Period[$day] .= "00:00-".((24 + $tabValue[3]) % 24).":".$tabValue[4].";"; 
    94                                         $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".$tabValue[2]."-24:00;"; 
    95                                 } else { 
    96                                         $Period[$day] .= ($tabValue[1] < 0 ? 24 + $tabValue[1] : $tabValue[1]).":".$tabValue[2]."-".($tabValue[3] <= 0 ? 24 + $tabValue[3] : $tabValue[3]).":".$tabValue[4].";";                                         
    97                                 } 
    98                         } else if ($gmt > 0) { 
    99                                 $tabValue[1] += $gmt; 
    100                                 $tabValue[3] += $gmt; 
    101                                 if ($tabValue[1] > 24 && $tabValue[3] > 24) {                            
    102                                         $PeriodAfter[$dayafter] .= ($tabValue[1] % 24).":".$tabValue[2]."-".($tabValue[3] % 24).":".$tabValue[4].";"; 
    103                                 } else if ($tabValue[1] < 24 && $tabValue[3] > 24) { 
    104                                         $Period[$day] .= $tabValue[1].":".$tabValue[2]."-"."24:00;"; 
    105                                         $PeriodAfter[$dayafter] .= "00:00-".($tabValue[3] % 24).":".$tabValue[4].";"; 
    106                                 } else { 
    107                                         $Period[$day] .= $tabValue[1].":".$tabValue[2]."-".$tabValue[3].":".$tabValue[4].";";                                    
    108                                 } 
    109                         } else if ($gmt == 0) { 
    110                                 $Period[$day] .= $tabValue[1].":".$tabValue[2]."-".$tabValue[3].":".$tabValue[4].";"; 
    111                         }                
    112                 } 
    113         } 
    114          
     59        }        
     60                 
    11561        $GMTList = $oreon->CentreonGMT->listGTM; 
    11662        foreach ($GMTList as $gmt => $value) {