<?
$page = "admin_entrydelete.php";
include "admin_header.php";

if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "main"; }
if(isset($_POST['p'])) { $p = (int) $_POST['p']; } elseif(isset($_GET['p'])) { $p = (int) $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "dd"; }



if($task == "dodelete") {
$e_id = $_POST['e_id'];
if($submit != "$admin_entrydelete4") {
$entry = mysql_fetch_assoc(mysql_query("SELECT author_u_id, w_id FROM bhost_entries WHERE e_id='$e_id'"));
mysql_query("DELETE FROM bhost_entries WHERE e_id='$e_id'");
mysql_query("DELETE FROM bhost_comments WHERE e_id='$e_id'");
mysql_query("DELETE FROM bhost_trackbacks WHERE e_id='$e_id'");
// DECREMENT NUM_ENTRIES IN BHOST_USERS
mysql_query("UPDATE bhost_users SET num_entries=num_entries-1 WHERE u_id='$entry[u_id]'");
mysql_query("UPDATE bhost_weblogs SET num_entries=num_entries-1 WHERE w_id='$entry[w_id]'");
}
header("Location: admin_entries.php?p=$p&s=$s");
exit();
}




if($task == "main") {
if(isset($_GET['e_id'])) { $e_id = $_GET['e_id']; }
if($e_id == "") { exit(); }

$getentry = mysql_query("SELECT e_id FROM bhost_entries WHERE e_id='$e_id'");
if(mysql_num_rows($getentry) == 0) { exit(); }
$entry = mysql_fetch_assoc($getentry);

echo $head;
echo "
<h2>$admin_entrydelete1</h2>
$admin_entrydelete2
<br><br>
<form action='admin_entrydelete.php' method='POST'>
<input type='submit' name='submit' class='button' value='$admin_entrydelete3'>
<input type='submit' name='submit' class='button' value='$admin_entrydelete4'>
<input type='hidden' name='e_id' value='$e_id'>
<input type='hidden' name='task' value='dodelete'>
<input type='hidden' name='p' value='$p'>
<input type='hidden' name='s' value='$s'>
</form>
";
echo $foot;
}

?>