Location: PHPKode > scripts > Linker IMG > linker-img/manage/del_category.php
<?php

//=====================================
// LINKER Category Engine
//=====================================
// Filename : del_category.php
// Path  : Manage directory
// last update : 2002/07/13
// Desc : Delete Category
//=====================================

//=====================================
// File include part
//=====================================

include ("./authen.php");
include ("../function/$Sdb_type.php"); 
include ("../function/main_func.php"); 
include ("../$Slang/m_common.php"); 

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
$db2 = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
$db3 = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);


//=====================================
// Delete part
//=====================================

while(list($post, $val)=each($HTTP_POST_VARS)) { 
	
	if ($val=='delete') 	{
	
	if (!$post) 	continue;
	$a++;
	
	$db->query("select path,parent from LINKER_CAT where sid = '$post'");
	$pathrow = $db->nrecord();
	$del_parent = $pathrow[parent];
	$del_path = $pathrow[path];

	if (!$del_path) continue; // prevent all category delete
	$del_path = $del_path . "/"; // sub category path
	
	//----------------------
	// sub category delete
	//----------------------
	
	$db->query("select sid from LINKER_CAT where path like '$del_path%' order by path desc ");

	while ($row = $db->nrecord()) {
		
	$db2->query("select sid,upfile from LINKER_LINK where parent='$row[sid]'");
	
		//Delete comment
		while ($lrow = $db2->nrecord()) {
		$upfile = @unserialize(stripslashes($lrow[upfile]));
		@unlink("../upfile/$upfile[1]");
		@unlink("../upfile/thumb_" . $upfile[1]);
		$db3->query("delete from LINKER_COM where parent = '$lrow[sid]'");
		}
	// Delete Link
	$db2->query("delete  from LINKER_LINK where parent = '$row[sid]'");
	$db2->query("delete from  LINKER_CAT where sid='$row[sid]'");
	}

	//----------------------
	// Delete category
	//----------------------

	$db->query("select sid,upfile from LINKER_LINK where parent = '$post'");

	// Delete Commnet
	while ($row = $db->nrecord()) 	{
	$upfile = @unserialize(stripslashes($row[upfile]));
	@unlink("../upfile/$upfile[1]");
	@unlink("../upfile/thumb_" . $upfile[1]);
	$db2->query("delete from LINKER_COM where parent = '$row[sid]'");
	}
	// Delete Link & cat
	$db->query("delete  from LINKER_LINK where parent = '$post'");
	$db->query("delete from  LINKER_CAT where sid='$post'");

	// Plus sub_cat num
	$db->query("update LINKER_CAT set sub_cat = sub_cat -1 where sid='$del_parent'");
	
	}
}

//=====================================
// Print result
//=====================================

print <<<EOF
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<meta http-equiv='refresh' content='2; url=./view_category.php?type=delete'>
</head>

<body bgcolor="#E9E9E9">
<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<font color="white" size="2"><b>$a $l_del_cat</b></font>
</td></tr></table>

EOF;

?>
Return current item: Linker IMG