LogDAO.php 689 B

12345678910111213141516171819202122232425
  1. <?php
  2. class FreshRSS_LogDAO {
  3. public static function lines() {
  4. $logs = array ();
  5. $handle = @fopen(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.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. public static function truncate() {
  21. file_put_contents(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log', '');
  22. }
  23. }