aboutsummaryrefslogtreecommitdiff
path: root/app/Models/LogDAO.php
diff options
context:
space:
mode:
authorGravatar Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> 2023-03-26 14:17:22 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-26 14:17:22 +0200
commit5f898dcc5ee244e4adbd6aa83b607c844d432fb6 (patch)
tree3511bcb3f78d053f4488e70000ab55fee7bb688a /app/Models/LogDAO.php
parentdf24fa2207f56909084c613495b6f235b351c640 (diff)
Modernize Constants and use new constant for string 'currentUser' (#5089)
* Modernize Constants and use new constant 'currentUser' * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Update app/Controllers/userController.php * Update app/Controllers/userController.php * Update app/Controllers/userController.php * Update app/Models/Auth.php * Update p/api/greader.php * Update p/api/greader.php * Update p/api/greader.php * Update app/Models/Context.php * Update app/Models/LogDAO.php * Update lib/Minz/Log.php * Update p/api/greader.php * Update app/layout/header.phtml * Update app/views/helpers/export/articles.phtml * Update cli/do-install.php * Remarque's from Alkarex * Remarque's from Alkarex * Refactor using new Minz_User class * Consistent naming of public constants --------- Co-authored-by: Luc <sanchezluc+freshrss@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models/LogDAO.php')
-rw-r--r--app/Models/LogDAO.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php
index 787945af4..6e5bf171b 100644
--- a/app/Models/LogDAO.php
+++ b/app/Models/LogDAO.php
@@ -1,9 +1,15 @@
<?php
class FreshRSS_LogDAO {
- public static function lines() {
+
+ private static function logPath(): string {
+ return USERS_PATH . '/' . (Minz_User::name() ?? Minz_User::INTERNAL_USER) . '/' . LOG_FILENAME;
+ }
+
+ /** @return array<FreshRSS_Log> */
+ public static function lines(): array {
$logs = array();
- $handle = @fopen(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_FILENAME), 'r');
+ $handle = @fopen(self::logPath(), 'r');
if ($handle) {
while (($line = fgets($handle)) !== false) {
if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
@@ -19,8 +25,8 @@ class FreshRSS_LogDAO {
return array_reverse($logs);
}
- public static function truncate() {
- file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_FILENAME), '');
+ public static function truncate(): void {
+ file_put_contents(self::logPath(), '');
if (FreshRSS_Auth::hasAccess('admin')) {
file_put_contents(ADMIN_LOG, '');
file_put_contents(API_LOG, '');