Location: PHPKode > projects > ZompLog > admin/schredder.php
<?php
ob_start();
/* Written by Gerben Schmidt, http://scripts.zomp.nl */
include_once("functions.php");
include('config.php');
include('session.php');
include('header.php');

if(!$_SESSION["loggedIn"]){
	echo "You are not authorized to acces this page";
	exit();
	}

// generic plugin delete function
if($_POST[plugintable]){
foreach($HTTP_POST_VARS['id'] as $id){
$mytable = $_POST[plugintable];
$query = mysql_query("DELETE FROM $mytable WHERE (id = $id)");
}
header("Location: plugins.php?message=3");
ob_end_flush;
}

// users table
if($_GET[tablename] == $table_users)
{
$query = mysql_query("DELETE FROM $table_users WHERE (id = $_GET[id])");
header("Location: users.php?message=3");
ob_end_flush;
}

if($_GET[tablename] == $table_plugins)
{
$query = mysql_query("DELETE FROM $table_plugins WHERE name = '$_GET[name]'");
header("Location: plugins.php?message=3");
ob_end_flush;
}

if($_GET['table'] == $table){ //table for posts

/*
// delete images that belong to this post (activate for very old versions)
$query = "SELECT * FROM $table WHERE id = '$_GET[id]'";
$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
$entry = mysql_fetch_array($result,MYSQL_ASSOC);

if($entry[image]){
$images = explode(";", $entry[image]);
foreach($images as $image){
$path1 = "../thumbs/$image";
$path2 = "../upload/$image";
unlink($path1);
unlink($path2);
}
}
*/

$query = "SELECT * FROM $table_files WHERE entry_id = '$_GET[id]'";
$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
while($image = mysql_fetch_array($result)){
$path1 = "../thumbs/$image[name]";
$path2 = "../upload/$image[name]";

unlink($path1);
unlink($path2);
}


// delete post
$query = mysql_query("DELETE FROM $table WHERE id = '$_GET[id]'");

header("Location: entry.php?message=3");
ob_end_flush;
}


if($_GET['tablename'] == $table_files){ //table for files

$query = "SELECT * FROM $table_files WHERE id = '$_GET[fileid]'";
$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
while($image = mysql_fetch_array($result)){
$path1 = "../thumbs/$image[name]";
$path2 = "../upload/$image[name]";

unlink($path1);
unlink($path2);
}

// delete file
$query = mysql_query("DELETE FROM $table_files WHERE id = '$_GET[fileid]'");

if($_GET['pageid']){
header("Location: editor_pages.php?id=$_GET[pageid]&message=3");
}
else
{
header("Location: editor.php?id=$_GET[id]&message=3");
}
ob_end_flush;
}

if($_GET[table] == $table_pages){ //table for pages
$query = mysql_query("DELETE FROM $table_pages WHERE id = $_GET[id] LIMIT 1");
header("Location: page.php?message=3");
ob_end_flush;
}

if($_GET[tablename] == $table_comments){ //table for comments
$query = mysql_query("DELETE FROM $table_comments WHERE id = $_GET[id] LIMIT 1");
header("Location: comments.php?message=3");
ob_end_flush;
}


if($_GET[table] == $table_cat){ //table for comments
$query = mysql_query("DELETE FROM $table_cat WHERE id = $_GET[id] LIMIT 1");
header("Location: category.php?message=3");
ob_end_flush;
}

if($_GET['unlink_file']){
unlink('../'.$_GET['dir'].'/'.$_GET['unlink_file']);
header("Location: ".$_SERVER['HTTP_REFERER']);
ob_end_flush;
}

if($_GET['unlink_both']){
unlink('../upload/'.$_GET['unlink_both']);
unlink('../thumbs/'.$_GET['unlink_both']);
header("Location: ".$_SERVER['HTTP_REFERER']);
ob_end_flush;
}

include('footer.php');
?>
Return current item: ZompLog