diff options
author | Thomas Lange <code@nerdmind.de> | 2017-02-24 21:27:59 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-02-24 21:27:59 +0100 |
commit | 52b077a48c743ba4d08ac00520a0bf1ef6deef5f (patch) | |
tree | b4205c194167e0e03e273957cdd0aab3be9fdf01 /admin/user/delete.php | |
download | blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.gz blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.xz blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.zip |
Initial commit.v1.0
Diffstat (limited to 'admin/user/delete.php')
-rw-r--r-- | admin/user/delete.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/admin/user/delete.php b/admin/user/delete.php new file mode 100644 index 0000000..ed8f925 --- /dev/null +++ b/admin/user/delete.php @@ -0,0 +1,72 @@ +<?php +#=============================================================================== +# DEFINE: Administration +#=============================================================================== +define('ADMINISTRATION', TRUE); +define('AUTHENTICATION', TRUE); + +#=============================================================================== +# INCLUDE: Main configuration +#=============================================================================== +require_once '../../core/application.php'; + +#=============================================================================== +# TRY: User\Exception +#=============================================================================== +try { + $User = User\Factory::build(HTTP::GET('id')); + $Attribute = $User->getAttribute(); + + if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'delete')) { + try { + if($Attribute->databaseDELETE($Database)) { + HTTP::redirect(Application::getAdminURL('user/')); + } + } catch(PDOException $Exception) { + $messages[] = $Exception->getMessage(); + } + } + + #=============================================================================== + # TRY: Template\Exception + #=============================================================================== + try { + $FormTemplate = Template\Factory::build('user/form'); + $FormTemplate->set('HTML', $User->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('user/delete'); + $DeleteTemplate->set('HTML', $FormTemplate); + + $MainTemplate = Template\Factory::build('main'); + $MainTemplate->set('NAME', $Language->text('title_user_delete')); + $MainTemplate->set('HTML', $DeleteTemplate); + echo $MainTemplate; + } + + #=============================================================================== + # CATCH: Template\Exception + #=============================================================================== + catch(Template\Exception $Exception) { + $Exception->defaultHandler(); + } +} + +#=============================================================================== +# CATCH: User\Exception +#=============================================================================== +catch(User\Exception $Exception) { + Application::exit(404); +} +?> + |