Файл: app/admin/user/delete.php
Строк: 26
<?php
Core::only('level', 4);
if (filter_has_var(INPUT_GET, 'id'))
{
$filter = [
'id' => filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT)
];
$profile = $db->query("SELECT * FROM `users` WHERE `id` = '".$filter['id']."' LIMIT 1")->fetch();
}
if (empty($profile) || $user['level'] < $profile['level'])
{
Core::go("/");
}
$smarty->header('Управление профилем');
if (filter_has_var(INPUT_POST, 'submit'))
{
$db->query("DELETE FROM `news_comments` WHERE `id_user` = '" . $profile['id'] . "'");
$db->query("DELETE FROM `minichat` WHERE `id_user` = '" . $profile['id'] . "'");
$db->query("DELETE FROM `users` WHERE `id` = '" . $profile['id'] . "'");
$db->query("DELETE FROM `users_mail` WHERE `id_profile` = '" . $profile['id'] . "'");
$db->query("DELETE FROM `users_mail` WHERE `id_user` = '" . $profile['id'] . "'");
$db->query("DELETE FROM `users_notification` WHERE `id_profile` = '" . $profile['id'] . "'");
if (file_exists(ROOT . 'upload/photo/' . $profile['id'] . '.png'))
unlink(ROOT . 'upload/photo/' . $profile['id'] . '.png');
if (file_exists(ROOT . 'upload/photo/' . $profile['id'] . '_small.png'))
unlink(ROOT . 'upload/photo/' . $profile['id'] . '_small.png');
Core::go('/admin/');
}
Core::show('warning', 'Вы уверены, что хотите удалить? Восстановить будет невозможно.');
$elements[] = [
'type' => 'submit',
'info' => [
'name' => 'submit',
'value' => Lang::word('Удалить')
]
];
$smarty->assign([
'method' => 'POST',
'action' => '?id=' . $profile['id'],
'el' => $elements
]);
$smarty->display('form.tpl');
$smarty->footer();