<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program 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 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
if ($acces == 1) {
if($admintest && $adminsecu)  {

	$bid     = $GLOBALS['db']->XMFnum($bid);
	$wb_name = stripslashes($wb_name);
	$ok      = $GLOBALS['db']->XMFbin($ok);
	if ($ok) {
		$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `bposition`, `weight` FROM `".TABLE_BLOCKS."` WHERE `bid`='$bid'"));
		$bposition = stripslashes($row['bposition']);
		$weight    = $GLOBALS['db']->XMFnum($row['weight']);
		$result2 = $GLOBALS['db']->sql_query("SELECT `bid` FROM `".TABLE_BLOCKS."` WHERE `weight`>'$weight' AND `bposition`='$bposition'");
		while ($row2 = $GLOBALS['db']->sql_fetchrow($result2)) {
			$nbid = $GLOBALS['db']->XMFnum($row2['bid']);
			$GLOBALS['db']->sql_query("update `".TABLE_BLOCKS."` set `weight`='$weight' where `bid`='$nbid'");
			$weight++;
			}
		$GLOBALS['db']->sql_query("DELETE FROM `".TABLE_BLOCKS."` WHERE `bid`='$bid'");
		$GLOBALS['db']->sql_query("DELETE FROM `".TABLE_BLOCKSMANAGER."` WHERE `bid`='$bid'");
		$GLOBALS['db']->sql_query("OPTIMIZE TABLE `".TABLE_BLOCKSMANAGER."` ");
			redirect_url("".$admin_file.".php?op=BlocksManager");
		} else {
		$row3 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `title` FROM `".TABLE_BLOCKS."` WHERE `bid`='$bid'"));
		$title = stripslashes($row3['title']);
		OpenHeader(_BLOCKMGR);
		Max_OpenTable();
		echo "<center><font class='title'><b>"._BLOCKSADMIN."</b></font></center>";
		Max_CloseTable();
		br('1');
		Max_OpenTable();
		echo "<center>"._ARESUREDELBLOCK." <i>$title</i>?"
		    ."<br /><br />[ <a href=\"".$admin_file.".php?op=BlocksManager&amp;wb_name=$wb_name\">"._NO."</a> | <a href=\"".$admin_file.".php?op=BlocksManager_DelBlock&amp;wb_name=$wb_name&amp;bid=$bid&amp;ok=1\">"._YES."</a> ]</center>";
		Max_CloseTable();
		CloseFooter();
		}
}
} else {
	echo "Access Denied";
}