prepare('SELECT MIN(id) as first_id FROM admins'); $result = $stmt->execute(); $firstId = $result->fetchArray()['first_id']; if ($_SESSION['admin_id'] != $firstId) { $_SESSION['error_message'] = "Accès non autorisé. Seul le premier administrateur peut consulter les logs."; header('Location: admin.php'); exit; } // Supprimer les logs de plus d'un mois $db->exec('DELETE FROM admin_logs WHERE created_at < datetime("now", "-1 month")'); // Tableau de traduction des actions $actionTranslations = [ 'ADD_USER' => 'Ajouter un utilisateur', 'EDIT_USER' => 'Modifier un utilisateur', 'DELETE_USER' => 'Supprimer un utilisateur', 'CREATE_FOLDER' => 'Créer un dossier', 'EDIT_FOLDER' => 'Modifier un dossier', 'DELETE_FOLDER' => 'Supprimer un dossier', 'CREATE_PRIVATE_FOLDER' => 'Créer un dossier privé', 'EDIT_PRIVATE_FOLDER' => 'Modifier un dossier privé', 'DELETE_PRIVATE_FOLDER' => 'Supprimer un dossier privé', 'UPLOAD_IMAGES' => 'Téléverser des images', 'DELETE_IMAGES' => 'Supprimer des images', 'MOVE_IMAGES' => 'Déplacer des images', 'UPLOAD_PRIVATE_IMAGES' => 'Téléverser des images privées', 'DELETE_PRIVATE_IMAGES' => 'Supprimer des images privées', 'GENERATE_SHARE_LINK' => 'Générer un lien de partage', 'CLEAN_EXPIRED_KEYS' => 'Nettoyer les clés expirées', 'DELETE_SHARE_KEY' => 'Supprimer une clé de partage', 'UPDATE_SETTINGS' => 'Modifier les paramètres' ]; // Pagination $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $perPage = 50; $offset = ($page - 1) * $perPage; // Filtres $actionType = isset($_GET['action_type']) ? $_GET['action_type'] : ''; $adminFilter = isset($_GET['admin']) ? intval($_GET['admin']) : 0; $dateRange = isset($_GET['date_range']) ? $_GET['date_range'] : ''; // Construction de la requête $whereClause = []; $params = []; if ($actionType) { $whereClause[] = 'action_type = :action_type'; $params[':action_type'] = $actionType; } if ($adminFilter) { $whereClause[] = 'admin_id = :admin_id'; $params[':admin_id'] = $adminFilter; } if ($dateRange) { switch ($dateRange) { case '24h': $whereClause[] = 'created_at >= datetime("now", "-1 day")'; break; case '48h': $whereClause[] = 'created_at >= datetime("now", "-2 days")'; break; case '72h': $whereClause[] = 'created_at >= datetime("now", "-3 days")'; break; case '1week': $whereClause[] = 'created_at >= datetime("now", "-7 days")'; break; } } $whereSQL = !empty($whereClause) ? 'WHERE ' . implode(' AND ', $whereClause) : ''; // Récupérer le nombre total de logs $countQuery = "SELECT COUNT(*) as total FROM admin_logs $whereSQL"; $stmt = $db->prepare($countQuery); foreach ($params as $key => $value) { $stmt->bindValue($key, $value); } $total = $stmt->execute()->fetchArray()['total']; $totalPages = ceil($total / $perPage); // Récupérer les logs $query = "SELECT l.*, a.username FROM admin_logs l LEFT JOIN admins a ON l.admin_id = a.id $whereSQL ORDER BY l.created_at DESC LIMIT :limit OFFSET :offset"; $stmt = $db->prepare($query); $stmt->bindValue(':limit', $perPage, SQLITE3_INTEGER); $stmt->bindValue(':offset', $offset, SQLITE3_INTEGER); foreach ($params as $key => $value) { $stmt->bindValue($key, $value); } $logs = []; $result = $stmt->execute(); while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $logs[] = $row; } function getLogActionClass($actionType) { if (strpos(strtolower($actionType), 'create') !== false || strpos(strtolower($actionType), 'add') !== false || strpos(strtolower($actionType), 'upload') !== false || strpos(strtolower($actionType), 'generate') !== false) { return 'log-action-create'; } if (strpos(strtolower($actionType), 'edit') !== false || strpos(strtolower($actionType), 'update') !== false || strpos(strtolower($actionType), 'modify') !== false || strpos(strtolower($actionType), 'move') !== false) { return 'log-action-edit'; } if (strpos(strtolower($actionType), 'delete') !== false || strpos(strtolower($actionType), 'remove') !== false || strpos(strtolower($actionType), 'clean') !== false) { return 'log-action-delete'; } return ''; } // Récupérer la liste des admins pour le filtre $admins = []; $result = $db->query('SELECT id, username FROM admins ORDER BY username'); while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $admins[] = $row; } // Récupérer les types d'actions uniques pour le filtre $actionTypes = []; $result = $db->query('SELECT DISTINCT action_type FROM admin_logs ORDER BY action_type'); while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $actionTypes[] = $row['action_type']; } $config = getSiteConfig(); ?> Logs administrateurs - <?php echo htmlspecialchars($config['site_title']); ?>

Logs administrateurs

Retour
Date Administrateur Action Description Chemin
1): ?>