<?php
define('NTLCMS', 1);
$module = 'delete';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');

################################################################################
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
################################################################################

$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT) : '0';
				
$control = DB :: run() -> query("select * from `sites` where `login` = ? and `id` = ? limit 1", array($ilogin, $id)) -> fetch(PDO::FETCH_OBJ);				
				
if ($control -> status == '3'){				
header('Location: '.URL.'/site');
$_SESSION['fail'] = 'Действие запрещено!';
exit;
}				
				
if (isset($_GET['id'])){
if (DB :: run() -> querySingle("select count(`id`) from `sites` where `login` = ? and `id` = ?", array($ulogin, $id))){					
DB :: run() -> query("delete from `sites` where `login` = ? and `id` = ? limit 1", array($ilogin, $id));
$_SESSION['success'] = 'Площадка успешно удалена!';
header('Location: '.URL.'/site');
} else {
$_SESSION['fail'] = 'Площадка не удалена!';
header('Location: '.URL.'/site');
}
}

?>