Files
FreshRSS/app/Models/LogDAO.php
maTh 4214954ea1 Improved: error page (#4465)
* error page: true HTML page

* error page: http500 erorr

* error page: add CSP header

* 'log.txt' replaced by LOG_FILENAME

* use ADMIN_LOG

* log.txt => LOG_FILENAME

* error message: add <title>

* Docs created

* delete: documentation on error message page

* line break added

* added: new line at the end

* typo fixed

* Update lib/lib_rss.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update lib/lib_rss.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Minz HTTP 500

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2022-08-21 22:44:03 +02:00

31 lines
877 B
PHP

<?php
class FreshRSS_LogDAO {
public static function lines() {
$logs = array();
$handle = @fopen(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_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 array_reverse($logs);
}
public static function truncate() {
file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_FILENAME), '');
if (FreshRSS_Auth::hasAccess('admin')) {
file_put_contents(ADMIN_LOG, '');
file_put_contents(API_LOG, '');
file_put_contents(PSHB_LOG, '');
}
}
}