public function indexAction() { if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) { header('Location: /'); exit; } else { $id = explode('/', $_SERVER['REQUEST_URI'], 4)[2]; } if (CommentModel::exists($this->pdo, $id)) { if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $id)) { include '../app/views/editcomment.php'; return; } } else { header('Location: /404'); exit; } }
public function indexAction() { if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) { header('Location: /'); exit; } else { $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2]; } if (CommentModel::exists($this->pdo, $article_id)) { if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') { CommentModel::delete($this->pdo, $article_id); header('Location: /'); exit; } } else { header('Location: /404'); exit; } }