Location: PHPKode > projects > PHPEcho CMS > modules/admin/modules/blockmanage.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Anas Husseini
*   |     License:       GPL
*   |     Last updated:  17.03.07
*   |     For version:   2.0-rc2  
*   |     Desc:          Module for working with blocks
*   |        
*   +--------------------------------------------
*/

if( !ADMIN_LOAD )
{
    die( "Base not loaded!" );
}

$mlang = $core->getlang("admin_blockmanage");

if (@$_POST['id'] && $_POST['action'])
{
	switch ($_POST['action'])
	{
		case 'off':
		    $q = "UPDATE `".PREFIX."blocks` SET `status`='OFF', `side` = '".addslashes ($_POST['side'])."' WHERE `id`=".addslashes($_POST['id']);
		    break;
		case 'on': 
		    $q = "UPDATE `".PREFIX."blocks` SET `status`='ON', `side` = '".addslashes ($_POST['side'])."' WHERE `id`=".addslashes($_POST['id']);
		    break;
		default: 
		    break;
	}
	query ($q, 1);
	echo $mlang['005'];
	redirect ("index.php?module=admin&act=blockmanage");	
}
elseif (@$_GET['id'])
{
	// Editing the status of a selected block

	$block = query ("SELECT * FROM `".PREFIX."blocks` WHERE `id`=".addslashes($_GET['id']), 4);
	
	if ($block['id'] == addslashes($_GET['id']))
	{
		echo "<form action='index.php?module=admin&act=blockmanage' method='post'>";
		echo "<input type=hidden name='id' value=".$block['id']."><br>";
		echo "<table width='60%' class='title'><tr><td width='80%' class='title'>".$block['display_name']."</td>";
		echo "<td class='title'><select name='action'>";
		echo "<option value='on'>ON</option>";
		echo "<option value='off'>OFF</option>";
		echo "</select>
        <select name='side'>
        <option value='r'>Right</option>
        <option value='l'>Left</option>
        <option value='d'>Down</option>
        </select>
        </td></tr></table><br>";	
		echo "<input type=submit value='".$mlang['004']."'></form>";
	}
	else
		echo $mlang['003'];
}
else
{ 
	// Display the blocks and their status

	$blocks = query ("select * from `".PREFIX."blocks`", 1);

	echo "<br><table width='100%'>";
	echo "<tr><td width='5%' class='title'><center>#</center></td>";
	echo "<td width='80%' class='title'>&nbsp;".$mlang['001']."</td>";
	echo "<td width='15%' class='title'><center>".$mlang['002']."</center></td></tr>";

	while ($block = mysql_fetch_array ($blocks) )
	{
		echo "<tr><td width='5%' class='border'><center>".$block['id']."</center></td>";
		echo "<td width='80%' class='border'>&nbsp;<a href='index.php?module=admin&act=blockmanage&id="
				.$block['id']."'>".$block['display_name']."</a></td>";
		echo "<td width='15%' class='border'><center>".$block['status']."</center></td></tr>";
	}
	echo "</table><br>";
}

?>
Return current item: PHPEcho CMS