remove comments public status changing #1

This commit is contained in:
ghost 2023-09-14 20:42:03 +03:00
parent 26d2a06b9a
commit 7c054557f3
2 changed files with 0 additions and 86 deletions

View File

@ -165,84 +165,6 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
break;
case 'public':
// Yggdrasil connections only
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
{
$response->success = false;
$response->message = _('Yggdrasil connection required for this action');
}
// Init session
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
{
$response->success = false;
$response->message = _('Could not init user session');
}
// Get user
else if (!$user = $db->getUser($userId))
{
$response->success = false;
$response->message = _('Could not init user info');
}
// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}
// Magnet comment exists
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
{
$response->success = false;
$response->message = _('Requested magnet comment not found');
}
// Access allowed
else if (!($user->address == $db->getUser($magnetComment->userId)->address || in_array($user->address, MODERATOR_IP_LIST))) {
$response->success = false;
$response->message = _('Access denied');
}
// Validate callback
else if (empty($_GET['callback']))
{
$response->success = false;
$response->message = _('Callback required');
}
// Validate base64
else if (!$callback = (string) @base64_decode($_GET['callback']))
{
$response->success = false;
$response->message = _('Invalid callback encoding');
}
// Request valid
else
{
if ($magnetComment->public)
{
$db->updateMagnetCommentPublic($magnetComment->magnetCommentId, false);
}
else{
$db->updateMagnetCommentPublic($magnetComment->magnetCommentId, true);
}
// Redirect to edit page
header(
sprintf('Location: %s', $callback)
);
}
break;
case 'new':
// Yggdrasil connections only

View File

@ -397,14 +397,6 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
</span>
<?php } ?>
<small>
<a class="float-right margin-l-12"
href="<?php echo WEBSITE_URL ?>/action.php?target=comment&toggle=public&magnetCommentId=<?php echo $magnetComment->magnetCommentId ?>&callback=<?php echo base64_encode(sprintf('%s/magnet.php?magnetId=%s#comment-%s', WEBSITE_URL, $magnetComment->magnetId, $magnetComment->magnetCommentId)) ?>">
<?php if ($magnetComment->public) { ?>
<?php echo _('hide') ?>
<?php } else { ?>
<?php echo _('show') ?>
<?php } ?>
</a>
<?php if (in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
<a class="float-right margin-l-12"
href="<?php echo WEBSITE_URL ?>/action.php?target=comment&toggle=approved&magnetCommentId=<?php echo $magnetComment->magnetCommentId ?>&callback=<?php echo base64_encode(sprintf('%s/magnet.php?magnetId=%s#comment-%s', WEBSITE_URL, $magnetComment->magnetId, $magnetComment->magnetCommentId)) ?>">