diff options
Diffstat (limited to 'handler/PostId.php')
-rw-r--r-- | handler/PostId.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/handler/PostId.php b/handler/PostId.php new file mode 100644 index 0000000..ec9f750 --- /dev/null +++ b/handler/PostId.php @@ -0,0 +1,20 @@ +<?php + +namespace handler; + +class PostId extends \RequestHandler { + + public function get(): \Response { + list($post_id) = $this->input('i:id'); + + $post = posts_getPost($post_id); + if (!$post || (!$post->visible && !\admin::isAdmin())) + throw new \NotFoundException(); + + if ($post->shortName != '') + return new \RedirectResponse($post->getUrl()); + + throw new \NotFoundException(); + } + +}
\ No newline at end of file |