<?php

$clean = fopen('error_log', 'w'); fwrite($clean,''); fclose($clean);
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

only_reg();

$set['title']='Hapus Status';
include_once 'sys/inc/thead.php';
aut();

if (!isset($_GET['id']) && !is_numeric($_GET['id'])){header("Location: index.php?".SID);
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `status_list` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1",$db), 0)==0)
{
header("Location: index.php?".SID);
exit;
}
$status=mysql_fetch_array(mysql_query("select * from `status_list` where `id`='".intval($_GET['id'])."';"));

if (($user['level'] < 4) && ($user['id'] !=$status['id_user']))
{
$set['title']='Kesalahan !!';
include_once '../sys/inc/thead.php';
aut();
echo "Kamu tidak diperbolehkan akses halaman ini!";
include_once 'sys/inc/tfoot.php';
exit();
}


if (isset($_GET['del']))
{

if (isset($_GET['ok']))
{
$q_f=mysql_query("SELECT * FROM `status_files` WHERE `id_status` = '".$status['id']."'");
while ($file = mysql_fetch_assoc($q_f))
{
mysql_query("DELETE FROM `status_files` WHERE `id` = '$file[id]' LIMIT 1");
unlink(H.'status/files/'.$file['id'].'.frf');
}
mysql_query("DELETE FROM `status_komm` WHERE `id_status` = '".$status['id']."' LIMIT 1");

$q_i=mysql_query("SELECT * FROM `status_img` WHERE `id_status` = '".$status['id']."'");
while ($img = mysql_fetch_assoc($q_i))
{
mysql_query("DELETE FROM `status_img` WHERE `id` = '$img[id]' LIMIT 1");
unlink(H.'status/img/'.$img['id'].'.jpg');
}
mysql_query("DELETE FROM `status_list` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");
msg('Status telah dihapus.');
header("Location: index.php?".SID);
exit;
}
else
{
echo "<div class='acw apm'><b>Hapus Status</b></div>";
echo "<div class='acw apm'>Yakin ingin menghapus status ini ?<br /><a href='?id=".intval($_GET['id'])."&amp;del&amp;ok'><button type='button' class='btn btnC'>Hapus</button></a> <a href='" . htmlspecialchars(getenv('HTTP_REFERER')) . "'><span>Batalkan</span></a>";
echo "</div>";
}
}


include_once 'sys/inc/tfoot.php';

?>
