Файл: app/admin/user/clean.php
Строк: 66
<?php
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))
{
Core::go("/");
}
$smarty->header('Управление профилем');
if (filter_has_var(INPUT_POST, 'submit'))
{
if (!empty($_POST['news_comments']) && $_POST['news_comments'] == 1)
{
$db->query("DELETE FROM `news_comments` WHERE `id_user` = '" . $profile['id'] . "'");
}
if (!empty($_POST['minichat']) && $_POST['minichat'] == 1)
{
$db->query("DELETE FROM `minichat` WHERE `id_user` = '" . $profile['id'] . "'");
}
if (!empty($_POST['info']) && $_POST['info'] == 1)
{
$db->query("UPDATE `users` SET `name` = null, `status` = null, ` 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');
}
if (!empty($_POST['mail']) && $_POST['mail'] == 1)
{
$db->query("UPDATE `users_mail` SET `delete` = '" . $profile['id'] . "' WHERE `id_profile` = '" . $profile['id'] . "'");
$db->query("UPDATE `users_mail` SET `delete` = '" . $profile['id'] . "' WHERE `id_user` = '" . $profile['id'] . "'");
}
if (!empty($_POST['notification']) && $_POST['notification'] == 1)
{
$db->query("DELETE FROM `users_notification` WHERE `id_profile` = '" . $profile['id'] . "'");
}
$error = 'Данные очищены';
}
Core::show('error');
$main_title[] = [
'type' => 'title',
'info' => [
'title' => Lang::word('Панель управления')
]
];
$elements[] = [
'type' => 'checkbox',
'br' => 1,
'info' => [
'text' => Lang::word('Комментарии к новостям'),
'value' => 1,
'name' => 'news_comments',
]
];
$elements[] = [
'type' => 'checkbox',
'br' => 1,
'info' => [
'text' => Lang::word('Мини-чат'),
'value' => 1,
'name' => 'minichat',
]
];
$elements[] = [
'type' => 'checkbox',
'br' => 1,
'info' => [
'text' => Lang::word('Личную информацию'),
'value' => 1,
'name' => 'info',
]
];
$elements[] = [
'type' => 'checkbox',
'br' => 1,
'info' => [
'text' => Lang::word('Сообщения'),
'value' => 1,
'name' => 'mail',
]
];
$elements[] = [
'type' => 'checkbox',
'br' => 1,
'info' => [
'text' => Lang::word('Уведомления'),
'value' => 1,
'name' => 'notification',
]
];
$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();