LogDAO.php 527 B

123456789101112131415161718192021
  1. <?php
  2. class FreshRSS_LogDAO {
  3. public static function lines($user) {
  4. $logs = array ();
  5. $handle = @fopen(LOG_PATH . '/' . $user . '.log', 'r');
  6. if ($handle) {
  7. while (($line = fgets($handle)) !== false) {
  8. if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
  9. $myLog = new FreshRSS_Log ();
  10. $myLog->_date ($matches[1]);
  11. $myLog->_level ($matches[2]);
  12. $myLog->_info ($matches[3]);
  13. $logs[] = $myLog;
  14. }
  15. }
  16. fclose($handle);
  17. }
  18. return array_reverse($logs);
  19. }
  20. }