diff options
Diffstat (limited to 'admin/post/delete.php')
-rw-r--r-- | admin/post/delete.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/admin/post/delete.php b/admin/post/delete.php new file mode 100644 index 0000000..82e71da --- /dev/null +++ b/admin/post/delete.php @@ -0,0 +1,72 @@ +<?php +#=============================================================================== +# DEFINE: Administration +#=============================================================================== +define('ADMINISTRATION', TRUE); +define('AUTHENTICATION', TRUE); + +#=============================================================================== +# INCLUDE: Main configuration +#=============================================================================== +require_once '../../core/application.php'; + +#=============================================================================== +# TRY: Post\Exception +#=============================================================================== +try { + $Post = Post\Factory::build(HTTP::GET('id')); + $Attribute = $Post->getAttribute(); + + if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'delete')) { + try { + if($Attribute->databaseDELETE($Database)) { + HTTP::redirect(Application::getAdminURL('post/')); + } + } catch(PDOException $Exception) { + $messages[] = $Exception->getMessage(); + } + } + + #=============================================================================== + # TRY: Template\Exception + #=============================================================================== + try { + $FormTemplate = Template\Factory::build('post/form'); + $FormTemplate->set('HTML', $Post->getHTML()); + $FormTemplate->set('FORM', [ + 'TYPE' => 'DELETE', + 'INFO' => $messages ?? [], + 'DATA' => [ + 'ID' => $Attribute->get('id'), + 'BODY' => $Attribute->get('body'), + 'TIME_INSERT' => $Attribute->get('time_insert'), + 'TIME_UPDATE' => $Attribute->get('time_update'), + ], + 'TOKEN' => Application::getSecurityToken() + ]); + + $DeleteTemplate = Template\Factory::build('post/delete'); + $DeleteTemplate->set('HTML', $FormTemplate); + + $MainTemplate = Template\Factory::build('main'); + $MainTemplate->set('NAME', $Language->text('title_post_delete')); + $MainTemplate->set('HTML', $DeleteTemplate); + echo $MainTemplate; + } + + #=============================================================================== + # CATCH: Template\Exception + #=============================================================================== + catch(Template\Exception $Exception) { + $Exception->defaultHandler(); + } +} + +#=============================================================================== +# CATCH: Post\Exception +#=============================================================================== +catch(Post\Exception $Exception) { + Application::exit(404); +} +?> + |