2021-07-10 16:51:15 -04:00
|
|
|
<?php
|
2021-08-09 04:21:39 -04:00
|
|
|
if (!defined('IN_PONEPASTE')) {
|
|
|
|
die('This file may not be accessed directly.');
|
2021-07-10 16:51:15 -04:00
|
|
|
}
|
2021-11-02 08:46:40 -04:00
|
|
|
|
2021-08-09 04:21:39 -04:00
|
|
|
require_once('../includes/common.php');
|
2021-07-10 16:51:15 -04:00
|
|
|
|
2021-11-02 08:46:40 -04:00
|
|
|
use PonePaste\Models\AdminLog;
|
|
|
|
use PonePaste\Models\User;
|
2021-07-10 16:51:15 -04:00
|
|
|
|
2023-02-24 06:26:40 -05:00
|
|
|
function updateAdminHistory(User $admin, int $action) : void {
|
2021-11-02 08:46:40 -04:00
|
|
|
$log = new AdminLog([
|
2021-11-02 19:09:46 -04:00
|
|
|
'user_id' => $admin->id,
|
2021-11-02 08:46:40 -04:00
|
|
|
'action' => $action,
|
|
|
|
'ip' => $_SERVER['REMOTE_ADDR']
|
|
|
|
]);
|
2021-07-10 16:51:15 -04:00
|
|
|
|
2021-11-02 08:46:40 -04:00
|
|
|
$log->save();
|
|
|
|
}
|
2021-07-10 16:51:15 -04:00
|
|
|
|
2021-11-02 08:46:40 -04:00
|
|
|
if ($current_user === null || !$current_user->admin) {
|
|
|
|
header('Location: ..');
|
|
|
|
die();
|
2021-07-10 16:51:15 -04:00
|
|
|
}
|
|
|
|
|
2021-11-02 08:46:40 -04:00
|
|
|
if (!isset($_SESSION['admin_login'])) {
|
2021-07-10 16:51:15 -04:00
|
|
|
header('Location: .');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['logout'])) {
|
|
|
|
if (isset($_SESSION['login']))
|
|
|
|
unset($_SESSION['login']);
|
|
|
|
|
|
|
|
session_destroy();
|
|
|
|
header("Location: .");
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|