Initial commit - Last War messaging system
This commit is contained in:
31
includes/activity_logger.php
Executable file
31
includes/activity_logger.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
function logActivity(int $userId, string $action, string $details): void
|
||||
{
|
||||
$pdo = getDbConnection();
|
||||
|
||||
$username = $_SESSION['username'] ?? 'system';
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO activity_log (user_id, username, action, details, timestamp) VALUES (?, ?, ?, ?, NOW())");
|
||||
$stmt->execute([$userId, $username, $action, $details]);
|
||||
}
|
||||
|
||||
function getActivityLog(?int $limit = 100): array
|
||||
{
|
||||
$pdo = getDbConnection();
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM activity_log ORDER BY timestamp DESC LIMIT ?");
|
||||
$stmt->execute([$limit]);
|
||||
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
function getUserActivity(int $userId, ?int $limit = 50): array
|
||||
{
|
||||
$pdo = getDbConnection();
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM activity_log WHERE user_id = ? ORDER BY timestamp DESC LIMIT ?");
|
||||
$stmt->execute([$userId, $limit]);
|
||||
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
Reference in New Issue
Block a user