Im almost done with the script but no matter what i do I cant get it to delet entries you can see here if you want to look at it http://www.toxicsugar.net/3/buttonboard.php Jusy log into the control panel and you can see (the password is on the main page)
I just want to be able to delete entries
here is the admin code:
<center><html>
<head>
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
include("config.php");
if (!$action || !$pass) {
$section = "Login";
$content = <<< HTML
Administrative Areas Login:
<form action="admin.php?action=login" method="post">
<input type="password" class="input" name="pass"><br>
<input type="submit" class="button" value="submit">
</form>
HTML;
}
if ($action == "login") {
if ($pass == "$wm_pass") {
$section = "Logged In";
$content = <<< HTML
You are now logged into the buttonboard administative panel<br>
<a href="admin.php?action=signed&pass=$pass">Manage entries</a><br><br>
HTML;
}
if ($pass != "$wm_pass") {
$section = "Error";
$content = <<< HTML
Wrong login password. Please try again:
<form action="admin.php?action=login" method="post">
<input type="password" class="input" name="pass"><br>
<input type="submit" class="button" value="submit">
</form>
HTML;
}
}
if ($action == "signed" && $pass == "$wm_pass") {
$section = "<font size=3>Buttonboard control panel</font><br><a href=\"admin.php?action=signed&pass=$pass\">Main</a>";
$content = "";
if ($max) {} else { $max="20"; }
if ($min) {} else { $min="0"; }
$gb = file ("entries.db");
$count = "0"; while (list ($key, $val) = each ($gb)) {
if ($key >= $min && $key <= $max) {
$tosplit = "|";
$contarr = explode($tosplit,$val);
$website = $contarr[1];
$image = $contarr[2];
$ip = $contarr[3];
$ban = $contarr[4];
$content .= <<< HTML
<a href="$website" target=blank_><img src="$image" border=0><a/><br> $ip<br><a
href="admin.php?action=delete&id=$website&id2=$ip&pass=$pass">Delete</a>
<a href="admin.php?action=ban&id=$ip&id2=$image&pass=$pass">Ban</a><br>
<img src=http://www.toxicsugar.net/plugit/skins/1/p3.gif><br><br>
HTML;
}
$count++;
}
$content .= <<< HTML
<center>
HTML;
if ($min > 0) {
$n_max = $max - 10;
$n_min = $min - 10;
$content .= <<< HTML
<a href="admin.php?action=signed&max=$n_max&min=$n_min&pass=$pass"><b>previous</b></a>
HTML;
}
if ($count > $max) {
$n_max = $max + 10;
$n_min = $min + 10;
$content .= <<< HTML
<a href="admin.php?action=signed&max=$n_max&min=$n_min&pass=$pass"><b>more</b></a>
HTML;
$content .= <<< HTML
</center>
HTML;
}
}
if ($action == "delete" && $pass == $wm_pass) {
$datafile = "entries.db";
$file=file("$datafile");
while(list(,$value)=each($file)){
list($website, $image, $ip)=split( "|", $value);
if ($id == "$ip" && $id2 == "$image") {
$old = "|$website|$image|$ip|\n";
$new = "";
$fp = fopen("entries.db", "r");
$data = fread($fp, filesize("entries.db"));
fclose($fp);
$data = str_replace($old, $new, $dat);
$dafile = fopen("entries.db", "w");
fputs($dafile, $data);
fclose($dafile);
$content = <<< HTML
Success, the site $website is now removed from the board<br>
<a href="admin.php?action=signed&pass=$pass"><--back</a>
HTML;
}
}
}
// attempt to ban ip address
if ($action == "ban" && $pass == "$wm_pass") {
$old = fopen ("banned.db", "r");
$old2 = fread ($old, filesize ("banned.db"));
fclose ($old);
$new = "$id|";
$fp = fopen ("banned.db", "w");
fwrite ($fp, "$new\n$old2");
fclose ($fp);
echo "$id is now banned from the buttonbaord <br><a href=\"admin.php?action=signed&pass=$pass\"><--back</a>";
}
// end ban ip attempt
echo "<b>$section</b><br>$content";
?>
<a href="buttonboard.php"><--Back</a> <br>
<?php include ("footer.php"); ?>