コード例 #1
0
ファイル: class.LoadAvg.php プロジェクト: javinc/loadavg
 public function getDateRange()
 {
     /* 
      * Grab the current period if a period has been selected
      * TODO: if min date and no max date then set max date to todays date
      * max date alone does nothing...
      */
     $minDate = $maxDate = false;
     if (isset($_GET['minDate']) && !empty($_GET['minDate'])) {
         $minDate = true;
     }
     if (isset($_GET['maxDate']) && !empty($_GET['maxDate'])) {
         $maxDate = true;
     }
     //for some reason when max date is todays date we cant plot the range ?
     if ($minDate) {
         LoadAvg::$period = true;
         LoadAvg::$period_minDate = date("Y-m-d", strtotime($_GET['minDate']));
         if ($maxDate) {
             LoadAvg::$period_maxDate = date("Y-m-d", strtotime($_GET['maxDate']));
         } else {
             LoadAvg::$period = false;
         }
         //else
         //	LoadAvg::$period_maxDate = self::$current_date;
     }
     //echo "minDate" . LoadAvg::$period_minDate . "<br>";
     //echo "maxDate" . LoadAvg::$period_maxDate . "<br>";
     $currentDate = self::$current_date;
     //dates of all the log files in logs folder
     $dates = self::getDates();
     $dateArray = array();
     //$period is set when we are pulling a range of data
     if (LoadAvg::$period) {
         //here we check that we have log files inside the range
         $loop = 0;
         foreach ($dates as $date) {
             if ($date >= self::$period_minDate && $date <= self::$period_maxDate) {
                 $dateArray[$loop] = $date;
                 $loop++;
             }
         }
     } else {
         $dateArray[0] = $currentDate;
     }
     return $dateArray;
 }