Location: PHPKode > projects > Exero CMS > upload/admin/blocks.php
<?
/*========================================*\
| Exero CMS                                |
|==========================================|
|          http://ecms.getox.net           |
|https://sourceforge.net/projects/exerocms/|
|==========================================|
|     Exero CMS is released under the      |
|     GNU General Public License (GPL)     |
| opensource.org/licenses/gpl-license.php  |
\*========================================*/

require("global.php");
if(!checkadminsession()) {
	print_login();
	exit;
}

if(!adminpermissions("manageblocks")) {
	print_no_permission();
	exit;
}

if($_REQUEST['do'] == "") {
	print_cp_header("Block Manager");
	
	print_topmenu(array("blocks.php?do=create" => "New Block", "items.php?do=create" => "New Item", "items.php" => "Manage Items"),"14","bold");
	
	print_table_header("Active Blocks","2","0","1","100%","2");
	print_blockmanager_head();
	$getblocks = $db->query("SELECT * FROM ".TABLE_PREFIX."blocks WHERE active='1' ORDER BY title ASC");
	while($blockinfo = $db->fetch_array($getblocks)) {
		print_blockmanager_row($blockinfo['title'],$blockinfo['id'],$blockinfo['active']);
	}
	print_table_footer();
	
	print_table_header("Inactive Blocks","2","0","1","100%","0");
	print_blockmanager_head();
	$getblocks = $db->query("SELECT * FROM ".TABLE_PREFIX."blocks WHERE active='0' ORDER BY title ASC");
	while($blockinfo = $db->fetch_array($getblocks)) {
		print_blockmanager_row($blockinfo['title'],$blockinfo['id'],$blockinfo['active']);
	}
	print_table_footer();
		
	print_cp_footer();
} else if($_REQUEST['do'] == "activate") {
	$db->query("UPDATE ".TABLE_PREFIX."blocks SET active='1' WHERE id='".$db->real_escape_string($_REQUEST['id'])."'");
	print_redirect("blocks.php","Block Activated","Block Activated.");
} else if($_REQUEST['do'] == "deactivate") {
	$db->query("UPDATE ".TABLE_PREFIX."blocks SET active='0' WHERE id='".$db->real_escape_string($_REQUEST['id'])."'");
	print_redirect("blocks.php","Block Deactivated","Block Deactivated.");
} else if($_REQUEST['do'] == "create") {
	if($_POST['action'] == "submit") {
		$db->query("INSERT INTO ".TABLE_PREFIX."blocks VALUES(
		'',
		'".$db->real_escape_string($_POST['ident'])."',
		'".$db->real_escape_string($_POST['title'])."',
		'".$db->real_escape_string($_POST['side'])."',
		'1',
		'".$db->real_escape_string($_POST['displayorder'])."',
		'',
		'',
		'".implode(',',$_POST['groupaccess'])."',
		'".$db->real_escape_string($_POST['status'])."'
		)");
		print_redirect("blocks.php","Block Created","Block Created.");
	} else {
		print_cp_header("New Block");
		
		print_form_header("blocks.php?do=create","submit");
		print_form_hiddenfield("action","submit");
		print_table_header("Create Block","2");
		print_form_textbox("Title","title");
		print_form_textbox("Identification","ident");
		print_form_textbox("Display Order","displayorder");
		print_form_select("Side","side",'',array("left"=>"Left","right"=>"Right"),'',"0");
		print_form_multiselect("Group Access","groupaccess[]","",grouparray(),'');
		print_form_submit("Submit","2","0");
		print_table_footer();
		print_form_footer();
		
		print_cp_footer();
	}
} else if($_REQUEST['do'] == "edit") {
	if($_POST['action'] == "submit") {
		$db->query("UPDATE  ".TABLE_PREFIX."blocks SET
		ident='".$db->real_escape_string($_POST['ident'])."',
		title='".$db->real_escape_string($_POST['title'])."',
		displayorder='".$db->real_escape_string($_POST['displayorder'])."',
		side='".$db->real_escape_string($_POST['side'])."',
		groupaccess='".implode(',',$_POST['groupaccess'])."',
		status='".$db->real_escape_string($_POST['status'])."'
		WHERE id='".$_POST['blockid']."'");
		print_redirect("blocks.php","Block Saved","Block Saved.");
	} else {
		$blockinfo = $db->query_first("SELECT * FROM blocks WHERE id='".$db->real_escape_string($_REQUEST['block'])."' LIMIT 1");
		print_cp_header("Edit Block ".$blockinfo['title']);
		
		print_form_header("blocks.php?do=edit","submit");
		print_form_hiddenfield("action","submit");
		print_form_hiddenfield("blockid",$_REQUEST['block']);
		print_table_header("Edit Block","2");
		print_form_textbox("Title","title",$blockinfo['title']);
		print_form_textbox("Identification","ident",$blockinfo['ident']);
		print_form_textbox("Display Order","displayorder",$blockinfo['displayorder']);
		print_form_select("Side","side",'',array("left"=>"Left","right"=>"Right"),$blockinfo['side'],"0");
		print_form_multiselect("Group Access","groupaccess[]","hi",grouparray(),$blockinfo['groupaccess']);
		print_form_select("Status<br /><em>If this is set to Hidden, and selected in the Show Hidden Blocks option in Block Settings on the Manage Modules page, It will only be viewable on that Module.</em>","status",'',array("1"=>"Viewable","0"=>"Hidden"),$blockinfo['status'],"0");
		print_form_submit("Submit","2","0");
		print_table_footer();
		print_form_footer();
		
		print_cp_footer();
	}
} else if($_REQUEST['do'] == "delete") {
	$db->query("DELETE FROM ".TABLE_PREFIX."blocks WHERE id='".$db->real_escape_string($_REQUEST['id'])."'");
	print_redirect("blocks.php","Block Deleted","Block Deleted.");
}
?>
Return current item: Exero CMS