Files
ops-Gazelle/sections/comments/post_handle.php

32 lines
794 B
PHP

<?php
/** @phpstan-var \Gazelle\User $Viewer */
declare(strict_types=1);
namespace Gazelle;
if ($Viewer->disablePosting()) {
Error403::error('Your posting privileges have been removed.');
}
authorize();
$page = $_REQUEST['page'] ?? null;
if (!in_array($page, ['artist', 'collages', 'requests', 'torrents'])) {
Error403::error();
}
$pageId = (int)($_REQUEST['pageid'] ?? 0);
if (!$pageId) {
Error404::error();
}
$commentMan = new Manager\Comment();
$comment = $commentMan->create($Viewer, $page, $pageId, $_POST['quickpost']);
$subscription = new \Gazelle\User\Subscription($Viewer);
if (isset($_POST['subscribe']) && !$subscription->isSubscribedComments($page, $pageId)) {
$subscription->subscribeComments($page, $pageId);
}
header('Location: ' . $comment->location());