Logging cleanup.
This commit is contained in:
parent
d1fad37022
commit
16a7e20441
27 changed files with 220 additions and 213 deletions
public-legacy
|
@ -71,7 +71,7 @@ while($canResetPassword) {
|
|||
$msz->usersCtx->passwords->updateUserPassword($userInfo, $passwordNew);
|
||||
$msz->usersCtx->totps->deleteUserTotp($userInfo);
|
||||
|
||||
$msz->createAuditLog('PASSWORD_RESET', [], $userInfo);
|
||||
$msz->logsCtx->createUserLog($userInfo, 'PASSWORD_RESET');
|
||||
|
||||
$msz->authCtx->recoveryTokens->invalidateToken($tokenInfo);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
Template::throwError(403);
|
||||
|
||||
$msz->changelog->deleteChange($changeInfo);
|
||||
$msz->createAuditLog('CHANGELOG_ENTRY_DELETE', [$changeInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('CHANGELOG_ENTRY_DELETE', [$changeInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-changelog-changes'));
|
||||
return;
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
}
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'CHANGELOG_ENTRY_CREATE' : 'CHANGELOG_ENTRY_EDIT',
|
||||
[$changeInfo->id]
|
||||
[$changeInfo->id],
|
||||
);
|
||||
|
||||
Tools::redirect($msz->urls->format('manage-changelog-change', ['change' => $changeInfo->id]));
|
||||
|
|
|
@ -27,7 +27,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
Template::throwError(403);
|
||||
|
||||
$msz->changelog->deleteTag($tagInfo);
|
||||
$msz->createAuditLog('CHANGELOG_TAG_DELETE', [$tagInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('CHANGELOG_TAG_DELETE', [$tagInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-changelog-tags'));
|
||||
return;
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$msz->changelog->updateTag($tagInfo, $name, $description, $archive);
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'CHANGELOG_TAG_CREATE' : 'CHANGELOG_TAG_EDIT',
|
||||
[$tagInfo->id]
|
||||
[$tagInfo->id],
|
||||
);
|
||||
|
||||
if($isNew) {
|
||||
|
|
|
@ -14,7 +14,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
$rTopicId = !empty($_POST['topic_redir_id']) && is_scalar($_POST['topic_redir_id']) ? trim((string)$_POST['topic_redir_id']) : '';
|
||||
$rTopicURL = !empty($_POST['topic_redir_url']) && is_scalar($_POST['topic_redir_url']) ? trim((string)$_POST['topic_redir_url']) : '';
|
||||
|
||||
$msz->createAuditLog('FORUM_TOPIC_REDIR_CREATE', [$rTopicId]);
|
||||
$msz->logsCtx->createAuthedLog('FORUM_TOPIC_REDIR_CREATE', [$rTopicId]);
|
||||
$msz->forumCtx->topicRedirects->createTopicRedirect($rTopicId, $msz->authInfo->userInfo, $rTopicURL);
|
||||
Tools::redirect($msz->urls->format('manage-forum-topic-redirs'));
|
||||
return;
|
||||
|
@ -25,7 +25,7 @@ if(!empty($_GET['m']) && $_GET['m'] === 'explode') {
|
|||
throw new \Exception("Request verification failed.");
|
||||
|
||||
$rTopicId = !empty($_GET['t']) && is_scalar($_GET['t']) ? (string)$_GET['t'] : '';
|
||||
$msz->createAuditLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
|
||||
$msz->logsCtx->createAuthedLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
|
||||
$msz->forumCtx->topicRedirects->deleteTopicRedirect($rTopicId);
|
||||
Tools::redirect($msz->urls->format('manage-forum-topic-redirs'));
|
||||
return;
|
||||
|
|
|
@ -94,9 +94,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$sCurrent[] = $string;
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'EMOTICON_CREATE' : 'EMOTICON_EDIT',
|
||||
[$emoteInfo->id]
|
||||
[$emoteInfo->id],
|
||||
);
|
||||
|
||||
Tools::redirect($msz->urls->format('manage-general-emoticon', ['emote' => $emoteInfo->id]));
|
||||
|
|
|
@ -20,20 +20,20 @@ if(CSRF::validateRequest() && !empty($_GET['emote'])) {
|
|||
|
||||
if(!empty($_GET['delete'])) {
|
||||
$msz->emotesCtx->emotes->deleteEmote($emoteInfo);
|
||||
$msz->createAuditLog('EMOTICON_DELETE', [$emoteInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('EMOTICON_DELETE', [$emoteInfo->id]);
|
||||
} else {
|
||||
if(isset($_GET['order'])) {
|
||||
$order = !empty($_GET['order']) && is_scalar($_GET['order']) ? (string)$_GET['order'] : '';
|
||||
$offset = $order === 'i' ? 10 : ($order === 'd' ? -10 : 0);
|
||||
$msz->emotesCtx->emotes->updateEmoteOrderOffset($emoteInfo, $offset);
|
||||
$msz->createAuditLog('EMOTICON_ORDER', [$emoteInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('EMOTICON_ORDER', [$emoteInfo->id]);
|
||||
}
|
||||
|
||||
if(isset($_GET['alias'])) {
|
||||
$alias = !empty($_GET['alias']) && is_scalar($_GET['alias']) ? (string)$_GET['alias'] : '';
|
||||
if($msz->emotesCtx->emotes->checkEmoteString($alias) === '') {
|
||||
$msz->emotesCtx->emotes->addEmoteString($emoteInfo, $alias);
|
||||
$msz->createAuditLog('EMOTICON_ALIAS', [$emoteInfo->id, $alias]);
|
||||
$msz->logsCtx->createAuthedLog('EMOTICON_ALIAS', [$emoteInfo->id, $alias]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('global')->check(Perm::G_LOGS_VIEW))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = Pagination::fromInput($msz->auditLog->countLogs(), 50);
|
||||
$pagination = Pagination::fromInput($msz->logsCtx->logs->countLogs(), 50);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$logs = iterator_to_array($msz->auditLog->getLogs(pagination: $pagination));
|
||||
$logs = iterator_to_array($msz->logsCtx->logs->getLogs(pagination: $pagination));
|
||||
$userInfos = [];
|
||||
$userColours = [];
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ if($valueInfo === null)
|
|||
Template::throwError(404);
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
||||
$msz->createAuditLog('CONFIG_DELETE', [$valueInfo->name]);
|
||||
$msz->logsCtx->createAuthedLog('CONFIG_DELETE', [$valueInfo->name]);
|
||||
$msz->config->removeValues($valueInfo->name);
|
||||
Tools::redirect($msz->urls->format('manage-general-settings'));
|
||||
return;
|
||||
|
|
|
@ -74,7 +74,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$applyFunc = $msz->config->setString(...);
|
||||
}
|
||||
|
||||
$msz->createAuditLog($isNew ? 'CONFIG_CREATE' : 'CONFIG_UPDATE', [$sName]);
|
||||
$msz->logsCtx->createAuthedLog($isNew ? 'CONFIG_CREATE' : 'CONFIG_UPDATE', [$sName]);
|
||||
$applyFunc($sName, $sValue);
|
||||
Tools::redirect($msz->urls->format('manage-general-settings'));
|
||||
return;
|
||||
|
|
|
@ -27,7 +27,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
Template::throwError(403);
|
||||
|
||||
$msz->news->deleteCategory($categoryInfo);
|
||||
$msz->createAuditLog('NEWS_CATEGORY_DELETE', [$categoryInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('NEWS_CATEGORY_DELETE', [$categoryInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-news-categories'));
|
||||
return;
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$msz->news->updateCategory($categoryInfo, $name, $description, $hidden);
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'NEWS_CATEGORY_CREATE' : 'NEWS_CATEGORY_EDIT',
|
||||
[$categoryInfo->id]
|
||||
[$categoryInfo->id],
|
||||
);
|
||||
|
||||
if($isNew) {
|
||||
|
|
|
@ -28,7 +28,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
Template::throwError(403);
|
||||
|
||||
$msz->news->deletePost($postInfo);
|
||||
$msz->createAuditLog('NEWS_POST_DELETE', [$postInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('NEWS_POST_DELETE', [$postInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-news-posts'));
|
||||
return;
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$msz->news->updatePost($postInfo, $category, $title, $body, $featured);
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'NEWS_POST_CREATE' : 'NEWS_POST_EDIT',
|
||||
[$postInfo->id]
|
||||
[$postInfo->id],
|
||||
);
|
||||
|
||||
if($isNew && $postInfo->featured) {
|
||||
|
|
|
@ -22,7 +22,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
}
|
||||
|
||||
$msz->usersCtx->bans->deleteBans($banInfo);
|
||||
$msz->createAuditLog('BAN_DELETE', [$banInfo->id, $banInfo->userId]);
|
||||
$msz->logsCtx->createAuthedLog('BAN_DELETE', [$banInfo->id, $banInfo->userId]);
|
||||
Tools::redirect($msz->urls->format('manage-users-bans', ['user' => $banInfo->userId]));
|
||||
return;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
severity: $severity, modInfo: $modInfo
|
||||
);
|
||||
|
||||
$msz->createAuditLog('BAN_CREATE', [$banInfo->id, $userInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('BAN_CREATE', [$banInfo->id, $userInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-users-bans', ['user' => $userInfo->id]));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ if($hasUserId) {
|
|||
Template::throwError(403);
|
||||
|
||||
$msz->usersCtx->modNotes->deleteNotes($noteInfo);
|
||||
$msz->createAuditLog('MOD_NOTE_DELETE', [$noteInfo->id, $noteInfo->userId]);
|
||||
$msz->logsCtx->createAuthedLog('MOD_NOTE_DELETE', [$noteInfo->id, $noteInfo->userId]);
|
||||
Tools::redirect($msz->urls->format('manage-users-notes', ['user' => $noteInfo->userId]));
|
||||
return;
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$msz->usersCtx->modNotes->updateNote($noteInfo, $title, $body);
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'MOD_NOTE_CREATE' : 'MOD_NOTE_UPDATE',
|
||||
[$noteInfo->id, $userInfo->id]
|
||||
[$noteInfo->id, $userInfo->id],
|
||||
);
|
||||
|
||||
// this is easier
|
||||
|
|
|
@ -148,9 +148,9 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
);
|
||||
}
|
||||
|
||||
$msz->createAuditLog(
|
||||
$msz->logsCtx->createAuthedLog(
|
||||
$isNew ? 'ROLE_CREATE' : 'ROLE_UPDATE',
|
||||
[$roleInfo->id]
|
||||
[$roleInfo->id],
|
||||
);
|
||||
|
||||
if($canEditPerms) {
|
||||
|
|
|
@ -62,7 +62,7 @@ if(CSRF::validateRequest() && $canEdit) {
|
|||
}
|
||||
|
||||
if($allowToImpersonate) {
|
||||
$msz->createAuditLog('USER_IMPERSONATE', [$userInfo->id, $userInfo->name]);
|
||||
$msz->logsCtx->createAuthedLog('USER_IMPERSONATE', [$userInfo->id, $userInfo->name]);
|
||||
|
||||
$tokenBuilder = $msz->authInfo->tokenInfo->toBuilder();
|
||||
$tokenBuilder->setImpersonatedUserId($userInfo->id);
|
||||
|
|
|
@ -20,7 +20,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && !empty($_GET['delete'])) {
|
|||
}
|
||||
|
||||
$msz->usersCtx->warnings->deleteWarnings($warnInfo);
|
||||
$msz->createAuditLog('WARN_DELETE', [$warnInfo->id, $warnInfo->userId]);
|
||||
$msz->logsCtx->createAuthedLog('WARN_DELETE', [$warnInfo->id, $warnInfo->userId]);
|
||||
Tools::redirect($msz->urls->format('manage-users-warnings', ['user' => $warnInfo->userId]));
|
||||
return;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$userInfo, $body, modInfo: $modInfo
|
||||
);
|
||||
|
||||
$msz->createAuditLog('WARN_CREATE', [$warnInfo->id, $userInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('WARN_CREATE', [$warnInfo->id, $userInfo->id]);
|
||||
Tools::redirect($msz->urls->format('manage-users-warnings', ['user' => $userInfo->id]));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ if($isVerifiedRequest && !empty($_POST['current_password'])) {
|
|||
$errors[] = $msz->usersCtx->users->validateEMailAddressText($checkMail);
|
||||
} else {
|
||||
$msz->usersCtx->users->updateUser(userInfo: $userInfo, emailAddr: $_POST['email']['new']);
|
||||
$msz->createAuditLog('PERSONAL_EMAIL_CHANGE', [$_POST['email']['new']]);
|
||||
$msz->logsCtx->createAuthedLog('PERSONAL_EMAIL_CHANGE', [$_POST['email']['new']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ if($isVerifiedRequest && !empty($_POST['current_password'])) {
|
|||
$errors[] = UserPasswordsData::validateUserPasswordText($checkPassword);
|
||||
} else {
|
||||
$msz->usersCtx->passwords->updateUserPassword($userInfo, $_POST['password']['new']);
|
||||
$msz->createAuditLog('PERSONAL_PASSWORD_CHANGE');
|
||||
$msz->logsCtx->createAuthedLog('PERSONAL_PASSWORD_CHANGE');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ if(isset($_POST['action']) && is_string($_POST['action'])) {
|
|||
&& ($msz->usersCtx->passwords->getUserPassword($userInfo)?->verifyPassword($_POST['password'] ?? ''))) {
|
||||
switch($_POST['action']) {
|
||||
case 'data':
|
||||
$msz->createAuditLog('PERSONAL_DATA_DOWNLOAD');
|
||||
$msz->logsCtx->createAuthedLog('PERSONAL_DATA_DOWNLOAD');
|
||||
|
||||
$timeStamp = floor(time() / 3600) * 3600;
|
||||
$fileName = sprintf('msz-user-data-%d-%d.zip', $userInfo->id, $timeStamp);
|
||||
|
|
|
@ -11,10 +11,10 @@ if($currentUser === null)
|
|||
Template::throwError(401);
|
||||
|
||||
$loginHistoryPagination = Pagination::fromInput($msz->authCtx->loginAttempts->countAttempts(userInfo: $currentUser), 5, 'hp');
|
||||
$accountLogPagination = Pagination::fromInput($msz->auditLog->countLogs(userInfo: $currentUser), 10, 'ap');
|
||||
$accountLogPagination = Pagination::fromInput($msz->logsCtx->logs->countLogs(userInfo: $currentUser), 10, 'ap');
|
||||
|
||||
$loginHistory = iterator_to_array($msz->authCtx->loginAttempts->getAttempts(userInfo: $currentUser, pagination: $loginHistoryPagination));
|
||||
$auditLogs = iterator_to_array($msz->auditLog->getLogs(userInfo: $currentUser, pagination: $accountLogPagination));
|
||||
$auditLogs = iterator_to_array($msz->logsCtx->logs->getLogs(userInfo: $currentUser, pagination: $accountLogPagination));
|
||||
|
||||
Template::render('settings.logs', [
|
||||
'login_history_list' => $loginHistory,
|
||||
|
|
|
@ -20,7 +20,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
if($sessionId === 'all') {
|
||||
$activeSessionKilled = true;
|
||||
$msz->authCtx->sessions->deleteSessions(userInfos: $currentUser);
|
||||
$msz->createAuditLog('PERSONAL_SESSION_DESTROY_ALL');
|
||||
$msz->logsCtx->createAuthedLog('PERSONAL_SESSION_DESTROY_ALL');
|
||||
} else {
|
||||
try {
|
||||
$sessionInfo = $msz->authCtx->sessions->getSession(sessionId: $sessionId);
|
||||
|
@ -33,7 +33,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
|
||||
$activeSessionKilled = $sessionInfo->id === $activeSessionId;
|
||||
$msz->authCtx->sessions->deleteSessions(sessionInfos: $sessionInfo);
|
||||
$msz->createAuditLog('PERSONAL_SESSION_DESTROY', [$sessionInfo->id]);
|
||||
$msz->logsCtx->createAuthedLog('PERSONAL_SESSION_DESTROY', [$sessionInfo->id]);
|
||||
}
|
||||
|
||||
if($activeSessionKilled) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue