8 isset(
$user) or require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
12 header(
"Content-type: application/json");
14 if (!($row = Wrong\Database\Controller::find(
$_POST[
'id'],
'id',
$_POST[
'table']))) {
15 exit(json_encode([
'error' =>
'Ошибка']));
18 if (!
$user->access()->write($row)) {
19 exit(json_encode([
'error' =>
'Недостаточно прав']));
22 if (
$user->access()->is_system($row)) {
23 exit(json_encode([
'error' =>
'Системный функционал удалять нельзя!']));
26 $sth =
$dbh->query(
"DELETE FROM `{$_POST['table']}` WHERE `id` = $row->id LIMIT 1");
27 if (
$sth->rowCount()) {
28 if (
$_POST[
'table'] ==
'crontabs') {
30 $mem->delete($row->id);
32 if (Wrong\Rights\Group::is_one_owner_file($row->file)) {
33 if ($row->file && !Wrong\Database\Controller::find($row->file,
'file',
$table) && !Wrong\File\Path::rm(
$_SERVER[
'DOCUMENT_ROOT'] . $row->file)) {
34 exit(json_encode([
'error' =>
'Неизвестная ошибка! Возможно что-то не так с правами на создание файлов и каталогов.']));
37 if (
$_POST[
'table'] ==
'groups') {
39 foreach ([
'actions',
'modals',
'selects',
'pages',
'users',
'templates'] as
$table) {
40 foreach (
$dbh->query(
"SELECT * FROM `$table`") as $row) {
41 $arr = json_decode($row->groups);
42 if (($key = array_search(
$_POST[
'id'],
$arr)) !==
false) {
44 $arr = array_values(array_unique(array_map(
'intval',
$arr)));
45 $dbh->query(
"UPDATE `$table` SET `groups` = '" . json_encode(
$arr) .
"' WHERE `id` = $row->id");
50 exit(json_encode([
'id' =>
$_POST[
'id'],
'message' =>
$dbh->query(
"SHOW TABLE STATUS WHERE Name = '{$_POST['table']}'")->fetch()->Comment .
' - успешно удалено!']));
53 exit(json_encode([
'error' =>
'Неизвестная ошибка!']));
if(!in_array($_POST['table'], Wrong\Database\Controller::$tables)) $table
Cache класс, отвечающий за кеширование
static delete_all_owner_models($id)
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
if(!($row=Wrong\Database\Controller::find($_POST['id'], 'id', $_POST['table']))) if(! $user->access() ->write($row)) if($user->access() ->is_system($row)) $sth