Compare commits
2 Commits
fa3e75f722
...
457c946946
Author | SHA1 | Date |
---|---|---|
|
457c946946 | |
|
f84a337607 |
|
@ -16,4 +16,12 @@ class NullLogger
|
|||
* @return void
|
||||
*/
|
||||
public function insertLog($userId, string $message, ?string $type = null): void {}
|
||||
|
||||
/**
|
||||
* PSR-3 log stub.
|
||||
* @param string $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*/
|
||||
public function log(string $level, string $message, array $context = []): void {}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,8 @@ if (!$isAjax) {
|
|||
* Handles GET requests to display templates.
|
||||
*/
|
||||
|
||||
if ($userObject->hasRight($userId, 'view config file')) {
|
||||
if ($userObject->hasRight($userId, 'superuser') ||
|
||||
$userObject->hasRight($userId, 'view config file')) {
|
||||
include '../app/templates/config.php';
|
||||
} else {
|
||||
$logObject->insertLog($userId, "Unauthorized: User \"$currentUser\" tried to access \"config\" page. IP: $user_IP", 'system');
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
<i class="fas fa-wrench me-2 text-secondary"></i>
|
||||
<?= htmlspecialchars($config['site_name']) ?> app configuration
|
||||
</h5>
|
||||
<?php if ($userObject->hasRight($userId, 'edit config file')) { ?>
|
||||
<?php if ($userObject->hasRight($userId, 'superuser') ||
|
||||
$userObject->hasRight($userId, 'edit config file')) { ?>
|
||||
<div>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm toggle-edit" <?= !$isWritable ? 'disabled' : '' ?>>
|
||||
<i class="fas fa-edit me-2"></i>Edit
|
||||
|
|
|
@ -65,12 +65,15 @@
|
|||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<h6 class="dropdown-header">system</h6>
|
||||
<?php if ($userObject->hasRight($userId, 'view config file')) {?>
|
||||
<?php if ($userObject->hasRight($userId, 'superuser') ||
|
||||
$userObject->hasRight($userId, 'view config file')) {?>
|
||||
<a class="dropdown-item" href="<?= htmlspecialchars($app_root) ?>?page=config">
|
||||
<i class="fas fa-wrench"></i>Configuration
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($userObject->hasRight($userId, 'superuser') ||
|
||||
$userObject->hasRight($userId, 'view config file') ||
|
||||
$userObject->hasRight($userId, 'edit config file') ||
|
||||
$userObject->hasRight($userId, 'edit whitelist') ||
|
||||
$userObject->hasRight($userId, 'edit blacklist') ||
|
||||
$userObject->hasRight($userId, 'edit ratelimiting')) { ?>
|
||||
|
|
|
@ -67,8 +67,8 @@ class Log {
|
|||
$where_clauses = [];
|
||||
|
||||
// Base query with user join
|
||||
$base_sql = 'SELECT l.*, u.username
|
||||
FROM log l
|
||||
$base_sql = 'SELECT l.*, u.username
|
||||
FROM log l
|
||||
LEFT JOIN user u ON l.user_id = u.id';
|
||||
|
||||
// Add scope condition
|
||||
|
@ -119,4 +119,11 @@ class Log {
|
|||
|
||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// PSR-3 style log method
|
||||
public function log(string $level, string $message, array $context = []): void {
|
||||
$userId = $context['user_id'] ?? null;
|
||||
$scope = $context['scope'] ?? 'system';
|
||||
$this->insertLog($userId, "[$level] " . $message, $scope);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue