function getSummarizationStatesFromFile($file)
 {
     if (file_exists($file)) {
         $fileHandle = fopen($file, 'r');
         if (!$fileHandle) {
             return false;
         }
     } else {
         return array();
     }
     //--- include used methods ---//
     include_once $this->csvManagerPath;
     if (!class_exists('csvManager')) {
         throw new Exception('Unable to include "csvManager".');
         return false;
     }
     $csvReader = new csvManager();
     $csvReader->delimiter = $this->logDelimiter;
     $states = array();
     $rowCount = 0;
     $missingDateColumnCount = 0;
     $missingStateColumnCount = 0;
     $firstRow = fgetcsv($fileHandle, $csvReader->rowLength, $csvReader->delimiter);
     while ($row = $csvReader->fgetcsv_assoc($fileHandle, $firstRow)) {
         $rowCount++;
         if (!isset($row[$this->dateColumnLabel])) {
             $missingDateColumnCount++;
             continue;
         } else {
             if (!isset($row[$this->stateColumnLabel])) {
                 $missingStateColumnCount++;
                 continue;
             }
         }
         $states[$this->dateColumnLabel] = $row[$this->stateColumnLabel];
     }
     fclose($fileHandle);
     if ($missingDateColumnCount) {
         $message = $missingDateColumnCount . ' of ' . $rowCount . ' column' . ($rowCount > 1 ? 's' : '') . ' without date column found in "' . $file . '"';
         if ($rowCount && $missingDateColumnCount / $rowCount > 0.5) {
             throw new Exception($message);
         } else {
             trigger_error($message, E_USER_WARNING);
         }
     }
     if ($missingStateColumnCount) {
         $message = $missingStateColumnCount . ' of ' . $rowCount . ' column' . ($rowCount > 1 ? 's' : '') . ' without date state found in "' . $file . '"';
         if ($rowCount && $missingStateColumnCount / $rowCount > 0.5) {
             throw new Exception($message);
         } else {
             trigger_error($message, E_USER_WARNING);
         }
     }
     return $states;
 }
 private function readDataLevel($identifier, &$time = NULL)
 {
     if (!file_exists($this->warningLevelFile)) {
         return 0;
     } else {
         $handle = fopen($this->warningLevelFile, 'r');
         if (!$handle) {
             trigger_error('Unable to read warning level file "' . $this->warningLevelFile . '".', E_USER_WARNING);
             return -1;
         }
         if (!(include_once $this->libPath . 'class.csvManager.inc.php')) {
             trigger_error('Unable to include "csvManager". Not error level data read.', E_USER_WARNING);
             return -1;
         }
         $csv = new csvManager();
         $head = fgetcsv($handle, $csv->rowLength, $csv->delimiter);
         if (!in_array('id', $head) || !in_array('level', $head) || !in_array('time', $head)) {
             trigger_error('File "' . $this->warningLevelFile . '" exists but has invalid head.', E_USER_WARNING);
             return -1;
         }
         if (!$head) {
             trigger_error('File "' . $this->warningLevelFile . '" exists but is empty.', E_USER_NOTICE);
             return 0;
         }
         $result = 0;
         while ($row = $csv->fgetcsv_assoc($handle, $head)) {
             if (isset($row['id']) && isset($row['level']) && isset($row['time'])) {
                 if ($row['id'] == $identifier) {
                     $result = $row['level'];
                     if ($time !== NULL) {
                         $time = $row['time'];
                     }
                     break;
                 }
             } else {
                 trigger_error('File "' . $this->warningLevelFile . '" has a row in wrong format.', E_USER_NOTICE);
             }
         }
         fclose($handle);
         return $result;
     }
 }