mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
chore: move updateAdminHistory to AdminLog.php
This commit is contained in:
parent
f1b2e10c72
commit
894613e257
5 changed files with 16 additions and 20 deletions
|
@ -26,4 +26,15 @@ class AdminLog extends Model {
|
|||
public function user() {
|
||||
return $this->belongsto(User::class);
|
||||
}
|
||||
|
||||
public static function updateAdminHistory(User $admin, int $action, string $message = null) : void {
|
||||
$log = new AdminLog([
|
||||
'user_id' => $admin->id,
|
||||
'action' => $action,
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'message' => $message
|
||||
]);
|
||||
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,18 +331,3 @@ function pp_setup_pagination() : array {
|
|||
|
||||
return [$per_page, $current_page];
|
||||
}
|
||||
|
||||
function pp_output_paginator(int $per_page, int $current_page) : void {
|
||||
|
||||
}
|
||||
|
||||
function updateAdminHistory(User $admin, int $action, string $message = null) : void {
|
||||
$log = new AdminLog([
|
||||
'user_id' => $admin->id,
|
||||
'action' => $action,
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'message' => $message
|
||||
]);
|
||||
|
||||
$log->save();
|
||||
}
|
|
@ -88,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
</div>';
|
||||
}
|
||||
|
||||
updateAdminHistory($current_user, AdminLog::ACTION_EDIT_CONFIG);
|
||||
AdminLog::updateAdminHistory($current_user, AdminLog::ACTION_EDIT_CONFIG);
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ $flashes = getFlashes();
|
|||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if (pp_password_verify($_POST['password'], $current_user->admin_password_hash)) {
|
||||
updateAdminHistory($current_user, AdminLog::ACTION_LOGIN);
|
||||
AdminLog::updateAdminHistory($current_user, AdminLog::ACTION_LOGIN);
|
||||
$_SESSION['admin_login'] = true;
|
||||
if (isset($_SESSION['redirect_back'])) {
|
||||
flashSuccess('You have been logged in. Please try your action again.');
|
||||
|
@ -29,7 +29,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
}
|
||||
exit();
|
||||
} else {
|
||||
updateAdminHistory($current_user, AdminLog::ACTION_FAIL_LOGIN);
|
||||
AdminLog::updateAdminHistory($current_user, AdminLog::ACTION_FAIL_LOGIN);
|
||||
$msg = '<div class="paste-alert alert6" style="text-align:center;">
|
||||
Wrong Password
|
||||
</div>';
|
||||
|
|
|
@ -35,7 +35,7 @@ if (isset($_POST['hide'])) {
|
|||
$paste->save();
|
||||
$redis->del('ajax_pastes'); /* Expire from Redis so it doesn't show up anymore */
|
||||
|
||||
updateAdminHistory($current_user, AdminLog::ACTION_HIDE_PASTE, 'Paste ' . $paste->id . ' ' . ($is_hidden ? 'hidden' : 'unhidden') . '.');
|
||||
AdminLog::updateAdminHistory($current_user, AdminLog::ACTION_HIDE_PASTE, 'Paste ' . $paste->id . ' ' . ($is_hidden ? 'hidden' : 'unhidden') . '.');
|
||||
flashSuccess('Paste ' . ($is_hidden ? 'hidden' : 'unhidden') . '.');
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ if (isset($_POST['hide'])) {
|
|||
|
||||
$paste->save();
|
||||
$redis->del('ajax_pastes'); /* Expire from Redis so it doesn't show up anymore */
|
||||
updateAdminHistory($current_user, AdminLog::ACTION_BLANK_PASTE, 'Paste ' . $paste->id . 'blanked.');
|
||||
AdminLog::updateAdminHistory($current_user, AdminLog::ACTION_BLANK_PASTE, 'Paste ' . $paste->id . 'blanked.');
|
||||
|
||||
flashSuccess('Paste contents blanked.');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue