Файл: vsime.com/lenta/inc/act_delete.php
Строк: 72
<?
$links_hist['name'] = "$user[nick] / Лента";
$links_hist['link'] = "/lenta/";
$lenta = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id` = '".intval($_GET['id'])."' AND `id_user` = '$user[id]' AND `trash` = '0'"));
if ($lenta == NULL)
{
$title .= ' - Ошибка!';
ex_head();
$error[] = 'Запись не найдена.';
show_errors();
ex_foot();
}
$lenta_stday_time = mktime(0,0,0, date('m', $lenta['time']), date('d', $lenta['time']), date('Y', $lenta['time']));
$lenta_ntday_time = $lenta_stday_time+(3600*24);
if ($lenta['type']=='file')
{
$files_lenta[$lenta['id']] = array();
$file = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$lenta[id_object]'"));
if (mysqli_result("SELECT COUNT(*) FROM `files` WHERE `id` = '$file[id_dir]' AND `type` = 'dir'")!=0)
{
$dir = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$file[id_dir]' AND `type` = 'dir'"));
} else {
$dir = array();
$dir['id'] = 0;
}
$query_files = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir[id]' AND `type` = 'file' AND `id_user` = '$user[id]' AND (`time` > '$lenta_stday_time' OR `time` = '$lenta_stday_time') AND (`time` < '$lenta_ntday_time' OR `time` = '$lenta_ntday_time') AND `trash` = '0' ORDER BY `time` DESC");
while ($lenta_files = mysqli_fetch_array($query_files))
{
$files_lenta[$lenta['id']][] = $lenta_files['id'];
$no_ilist[$lenta_files['id']] = 0;
}
}
if ($lenta['type']=='foto')
{
$fotos_lenta[$lenta['id']] = array();
$foto = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$lenta[id_object]'"));
if (mysqli_result("SELECT COUNT(*) FROM `foto` WHERE `id` = '$foto[id_dir]' AND `type` = 'dir'")!=0)
{
$dir = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$foto[id_dir]' AND `type` = 'dir'"));
} else {
$dir = array();
$dir['id'] = 0;
}
$query_fotos = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir[id]' AND `type` = 'foto' AND `id_user` = '$user[id]' AND (`time` > '$lenta_stday_time' OR `time` = '$lenta_stday_time') AND (`time` < '$lenta_ntday_time' OR `time` = '$lenta_ntday_time') AND `trash` = '0' ORDER BY `time` DESC");
while ($lenta_fotos = mysqli_fetch_array($query_fotos))
{
$fotos_lenta[$lenta['id']][] = $lenta_fotos['id'];
$no_ilist[$lenta_fotos['id']] = 0;
}
}
$title .= ' - Удалить запись';
ex_head();
$ank = profile($lenta['id_ank']);
if ($lenta['type'] == 'diary' || $lenta['type'] == 'topic')
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta[id]'");
}
if ($lenta['type']=='file')
{
foreach ($files_lenta[$lenta['id']] AS $key => $lenta_id)
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta_id' AND `trash` = '0'");
}
}
if ($lenta['type']=='foto')
{
foreach ($fotos_lenta[$lenta['id']] AS $key => $lenta_id)
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta_id' AND `trash` = '0'");
}
}
msg_sess("Запись удалена");
header("Location: ?act=user&");
exit();
?>