prepare("TRUNCATE TABLE action_logs"); $stmt->execute(); // Regenerate CSRF token $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); // Redirect back to panel.php header("Location: panel.php"); exit(); } // Handle pagination parameters passed from logs.php $per_page = isset($_GET['per_page']) ? (int)$_GET['per_page'] : 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) $page = 1; // Count total logs $count_stmt = $conn->query("SELECT COUNT(*) AS total FROM action_logs"); $total_logs = (int)$count_stmt->fetchColumn(); // Calculate offset $offset = ($page - 1) * $per_page; // Fetch logs with LIMIT and OFFSET $stmt = $conn->prepare("SELECT * FROM action_logs ORDER BY action_time DESC LIMIT :limit OFFSET :offset"); $stmt->bindValue(':limit', $per_page, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $logs = $stmt->fetchAll(PDO::FETCH_ASSOC);