Location: PHPKode > projects > ProPHP > ProPHP/content/admin/delete.php
<?php
/*****************************************************************
************* BKWORKS PRO PHP V 0.5 BETA 1 ***********************
******************** BRYAN KOOIENGA ******************************
****************** DECEMBER 20, 2007 *****************************
*****************************************************************/

if(!defined("INDEX")) {
	header("location: ../../?view=home"); # If the template isn't calling the script, then head to the homepage.
}

include('include/functions.php');
 
if(! is_admin("$username")) { # If the user's not an admin, then
?>
<h3 align="center">Access is Denied! Only the Administrator has this access!</h3>
<?php
} else { # The user is an admin
	$account = $_GET['account']; # Pull data from the browser
	
	/**********************************************
	*         GET ACCOUNT INFORMATION             *
	**********************************************/
	$query = "SELECT * FROM sites WHERE site_number = '$account'";
	$results = mysql_query($query);
	$user_info = mysql_fetch_array($results);
	
	############# GET USER'S AD INFORMATION ###########
	$query = "SELECT image FROM ads WHERE site_number = '$account'";
	$results = mysql_query($query) or die("Can't select because " . mysql_error());
	while($obj = mysql_fetch_object($results)) {
		$query = "DELETE FROM ads WHERE image = ('"  . $obj -> image . "') AND site_number = ('" . $account . "')";
		mysql_query($query) or die("Can't remove " . $obj -> image . " because " . mysql_error());
		@unlink("ads/$account/" . $obj -> image); # Remove the ad that we just looked up. The @ symbol means that it won't toss an error if it's already gone.
	}
	@delete_directory("ads/" . $account . "/"); # Delete the user directory. Again, the @ symbol means no error if it's already gone.
	$query = "DELETE FROM sites WHERE site_number = ('" . $account . "')"; # Delete the user from the database.
	mysql_query($query) or die("Can't query because " . mysql_error());
	echo "<h3>Success!</h3>
	Account $user_info[site_url] has been deleted.<br>\n
	<a href=\"?view=admin\">Click here</a> to go back to the admin panel.</a>";
}
?>
Return current item: ProPHP