Location: PHPKode > projects > V-CMS > V-CMS_1.0_Beta_1/process_d.php
<body style="margin:10px;">
<?php
# V-CMS - A simple web-based content management system
#
# V-CMS is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# V-CMS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with V-CMS.  If not, see <http://www.gnu.org/licenses/>.
#
# http://cmsclone.sourceforge.net
# V-CMS, Copyright 2010, VyReN, LLC
#
# File originally from Jpmaster77's login system

if(!$session->isAdmin()){
die;
}
if (isset($_REQUEST["de"])) {
//Confirm Delete
	switch ($_REQUEST["item"]) {
		case "1":
			$table = "domains";
			$item = "domain";
			$therow = "Name";
			break;
		case "2":
			$table = "pages";
			$item = "page";
			$therow = "Name";
			break;
		case "3":
			$table = "users";
			$item = "editor";
			$therow = "name";
			break;
	}
	$q = "SELECT * FROM " . $table . " WHERE ID = \"" . mysql_real_escape_string($_REQUEST["de"]) . "\"";
	$result = mysql_query($q);
	while ($row = mysql_fetch_array($result)) {
		$the_name = $row[$therow];
	}
	echo "<h2>" . DELETE_TEXT . " " . $item . "</h2><br><table><tr><td colspan=\"2\">" . DELETE_ARE_YOU_SURE_TEXT . " " . $item . ": " . $the_name . "?</td></tr><tr><td colspan=\"2\" height=\"5px\"></td></tr><tr><td>";
	echo "<h1>[<a href=\"#\" onClick=\"parent.$('.delete_lightbox').colorbox.close(); return false;\">" . NO_TEXT . "</a>]</h1></td><td align=\"right\">";
	echo "[<a href=index.php?page=p2_d&popup=1&de2=" . $_REQUEST["de"] . "&item=" . $_REQUEST["item"] . ">" . YES_TEXT . "</a>]</td></tr></table>";
	?>
	
</div></div></div>
      <!-- end div#content -->

      <!-- end div#sidebar -->
	<?php
}
else if (isset($_REQUEST["de2"])) {
//Delete!
	switch ($_REQUEST["item"]) {
		case "1":
			$table = "domains";
			$item = "domain";
			$therow = "ID";
			//Check if logged in user has permission to work with this domain, if not die.
			$q = "SELECT * FROM permissions WHERE Type = \"Domain\" AND UserID = \"" . $session->user_db_id . "\" AND Permission = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
			$result = mysql_query($q);
			if (!mysql_num_rows($result)) {
			 die;
			 }
			 //Cleanup any leftover permissions
			 $q = "DELETE FROM permissions WHERE Type = \"Domain\" AND Permission = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
			 $result = mysql_query($q);
			 
			break;
		case "2":
			$table = "pages";
			$item = "page";
			$therow = "ID";
			$q = "SELECT * FROM permissions WHERE Type = \"Page\" AND UserID = \"" . $session->user_db_id . "\" AND Permission = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
			$result = mysql_query($q);
			if (!mysql_num_rows($result)) {
			 die;
			 }	
			 //Cleanup any leftover permissions
			 $q = "DELETE FROM permissions WHERE Type = \"Page\" AND Permission = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
			 $result = mysql_query($q);			 
			break;
		case "3":
			$table = "users";
			$item = "editor";
			$therow = "ID";
			$q = "SELECT * FROM users WHERE ID = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\" AND parent = \"" . $session->user_db_id . "\"";
			$result = mysql_query($q);
			if (!mysql_num_rows($result)) {
			 die;
			 }
			 //Cleanup any leftover permissions
			  $q = "DELETE FROM permissions WHERE UserID = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
			 $result = mysql_query($q);
			break;
	}
	$q = "DELETE FROM " . $table . " WHERE " . $therow . " = \"" . mysql_real_escape_string($_REQUEST["de2"]) . "\"";
	$result = mysql_query($q);
	echo "<script>parent.$('.delete_lightbox').colorbox.close();</script>";
}
?>
Return current item: V-CMS