From 01a1dd09a8ee02250905a80d2662bfe811c09f09 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 28 Dec 2013 17:29:38 +0100 Subject: Minz : refactorisation ModelArray et Log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Utilisation de fonctions natives de PHP comme file_put_contents et var_export Évite de garder un descripteur de fichier ouvert tout le temps Et ModelTxt n'est plus utilisé --- app/Models/LogDAO.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'app/Models/LogDAO.php') diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php index 06855ec66..e57e0b1b9 100644 --- a/app/Models/LogDAO.php +++ b/app/Models/LogDAO.php @@ -1,21 +1,23 @@ readLine ()) !== false) { - if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) { - $myLog = new FreshRSS_Log (); - $myLog->_date ($matches[1]); - $myLog->_level ($matches[2]); - $myLog->_info ($matches[3]); - $logs[] = $myLog; + $handle = @fopen(LOG_PATH . self::$filename, 'r'); + if ($handle) { + while (($line = fgets($handle)) !== false) { + if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) { + $myLog = new FreshRSS_Log (); + $myLog->_date ($matches[1]); + $myLog->_level ($matches[2]); + $myLog->_info ($matches[3]); + $logs[] = $myLog; + } } + fclose($handle); } - return $logs; + return array_reverse($logs); } } -- cgit v1.2.3