feat(logs) displaying logs on account page
This commit is contained in:
@@ -48,9 +48,9 @@ $userDetails = getUserDetails($_SESSION['user_id']);
|
||||
<?php
|
||||
echo $_SESSION['message'] ?? '';
|
||||
unset($_SESSION['message']);
|
||||
?>
|
||||
<h2 class="mb-4">Edit Account</h2>
|
||||
<form method="POST" action="">
|
||||
?>
|
||||
<h2 class="mb-4">Edit Account</h2>
|
||||
<form method="POST" action="">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($userDetails['email']); ?>" placeholder="Enter your email" required>
|
||||
@@ -69,5 +69,28 @@ $userDetails = getUserDetails($_SESSION['user_id']);
|
||||
<small class="form-text text-muted">Leave blank if you do not want to change the password</small>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
$query = $conn->prepare("SELECT logs.ip, logs.date, users.email FROM logs JOIN users ON logs.userId = users.id");
|
||||
$query->execute();
|
||||
$logDetails = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
<table class="table mt-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Date</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($logDetails as $log): ?>
|
||||
<tr>
|
||||
<td><?php echo $log['ip']; ?></td>
|
||||
<td><?php echo $log['date']; ?></td>
|
||||
<td><?php echo $log['email']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -26,6 +26,8 @@ $query = $conn->prepare("SELECT DISTINCT lineId FROM favorites WHERE userId = ?"
|
||||
$query->execute([$_SESSION['user_id']]);
|
||||
$lineIds = $query->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
echo $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
?>
|
||||
|
||||
<div class="px-4 my-5 text-center">
|
||||
|
||||
@@ -12,10 +12,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$_SESSION['first_name'] = $user['first_name'];
|
||||
$_SESSION['is_admin'] = $user['is_admin'];
|
||||
header("Location: /");
|
||||
|
||||
$log = $conn->prepare("INSERT INTO logs (userId, date) VALUES (:userId, :date)");
|
||||
|
||||
$log = $conn->prepare("INSERT INTO logs (userId, date, ip) VALUES (:userId, :date, :ip)");
|
||||
$log->bindParam(':userId', $user['id']);
|
||||
$log->bindParam(':date', date('Y-m-d-H-i-s'));
|
||||
$log->bindParam(':ip', $_SERVER['REMOTE_ADDR']);
|
||||
$log->execute();
|
||||
} else {
|
||||
$errorMessage = "Invalid email or password.";
|
||||
|
||||
@@ -91,11 +91,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (action === 'add') {
|
||||
buttonElement.classList.remove('add-stop', 'btn-success');
|
||||
buttonElement.classList.add('remove-stop', 'btn-danger');
|
||||
buttonElement.textContent = 'Retirer';
|
||||
buttonElement.textContent = 'Revoke';
|
||||
} else {
|
||||
buttonElement.classList.remove('remove-stop', 'btn-danger');
|
||||
buttonElement.classList.add('add-stop', 'btn-success');
|
||||
buttonElement.textContent = 'Ajouter';
|
||||
buttonElement.textContent = 'Add';
|
||||
}
|
||||
buttonElement.removeEventListener('click', arguments.callee);
|
||||
buttonElement.addEventListener('click', arguments.callee);
|
||||
|
||||
Reference in New Issue
Block a user