Code:
<?php
/**
* @package: RN Admin Module - WB_BlocksManager
* @version: 1.0
* @file: blocks_manager.php
* @copyright: WB_BlocksManager v0.2 (c) 2003 Paulo Ferreira http://www.phpnuke-belgique.org
* @modifications: Easy Position Change, Block Position by Module, Multi Add/Remove of Selected Blocks
* @modifications: (c) 2004 James Johnston http://www.phpnuke-belgique.org
* @Updated for PHPNuke 7.4: (c) 2004 spcdata http://www.nextnet.se
* @Updated for RavenNuke(tm) v25x: (c) 2013 by neralex - http://www.media.soefm.de
* @license: http://opensource.org/licenses/gpl-license.php GNU Public License
*/
if (!defined('ADMIN_FILE')) {die('Illegal File Access');}
if (!defined('PHP_EOL')) define('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");
$centerblocks_only_for_home = 0; # set to 0 to have the option every time
if (is_mod_admin('admin')) {
if (!isset($op)) $op = '';
if (!isset($wb_name)) $wb_name = '';
if (!isset($bidrep)) $bidrep = '';
switch($op) {
case 'BlocksManager':
BlocksManager($wb_name);
break;
case 'BlocksManager_Add':
csrf_check();
BlocksManager_Add($bida, $title, $wb_name);
break;
case 'BlocksManager_Remove':
csrf_check();
BlocksManager_Remove($bidr, $title, $wb_name);
break;
case 'BlocksManager_BlockPosition':
csrf_check();
BlocksManager_BlockPosition($bid, $title, $position);
break;
case 'BlocksManager_FixWeight':
csrf_check();
BlocksManager_FixWeight($wb_name);
break;
case 'BlocksManager_BlockOrder':
csrf_check();
BlocksManager_BlockOrder($weightrep, $weight, $bidrep, $bidori, $title);
break;
}
} else {
echo 'Access Denied';
}
die();
/*********************************************************/
/* Blocks_Manager Functions */
/*********************************************************/
function BlocksManager($wb_name) {
global $admin_file, $prefix, $db, $currentlang, $multilingual, $centerblocks_only_for_home;
$table = $db->sql_fetchrow($db->sql_query('SHOW TABLES LIKE \'' . $prefix . '_blocks_manager\''));
if (isset($table['0'])) {
$blma_css = '<style type="text/css">' . PHP_EOL
. '.noborder {border:none;}' . PHP_EOL
. '.valign_top {vertical-align:top;}' . PHP_EOL
. '.valign_bottom {vertical-align:bottom;}' . PHP_EOL
. '.valign_middle {vertical-align:middle;}' . PHP_EOL
. '.blma_maintable {border-top:1px solid; border-bottom:1px solid; width:100%; border-spacing:0px;}' . PHP_EOL
. '.blma_maintable td:first-child {border-left:1px solid;}' . PHP_EOL
. '.blma_maintable td {padding:0; border-top:1px solid; border-top:1px solid; border-right:1px solid; display:table-cell; vertical-align:middle; text-align:center; padding:2px 0 2px 0;}' . PHP_EOL
. '.blma_maintable img {border:none;}' . PHP_EOL
. '.blma_maintable tr:first-child {font-weight:bold;border-bottom:1px solid;}' . PHP_EOL
. '.blma_maintable tr:first-child td {border-top:none;}' . PHP_EOL
. '.blma_addnewtable {border:none; border-spacing:0px; width:80%;}' . PHP_EOL
. '.blma_addnewtable td {display:table-cell; text-align:center;}' . PHP_EOL
. '</style>' . PHP_EOL;
addCSSToHead($blma_css, 'inline');
include_once 'header.php';
GraphicAdmin();
OpenTable();
echo '<div class="text-center thick">' , _BLOCKMGR_BLOCKSADMIN_MANAGER , '</div>' , PHP_EOL;
CloseTable();
echo '<br />' , PHP_EOL;
OpenTable();
$wb_url = $admin_file . '.php?op=BlocksManager&wb_name=';
# added query to catch the current main-module (HOME)
$row2 = $db->sql_fetchrow($db->sql_query('SELECT `main_module` FROM `' . $prefix . '_main`'));
$main_module = $row2['main_module'];
$result = $db->sql_query('SELECT `mid`, `title`, `custom_title`, `active`, `view`, `inmenu` FROM `' . $prefix . '_modules` WHERE `active` = 1 ORDER BY `title` ASC');
echo '<div class="text-center">' , PHP_EOL;
if ($db->sql_numrows($result) > 0) {
echo '<form action="' , $admin_file , '.php" method="post">' , PHP_EOL
, _BLOCKMGR_MODULEDROP , ' ' , PHP_EOL
, '<select name="wb_name" size="1" onchange="top.location.href=this.options[this.selectedIndex].value">' , PHP_EOL;
while (list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) {
echo '<option value="' , $wb_url , $title , '"' , ($wb_name == $title ? ' selected="selected"' : '') , '>' , $title , '</option>' , PHP_EOL;
if ($wb_name == '') {
$wb_name = $title;
}
} # end of while
echo '</select>' , PHP_EOL
, '</form>' , PHP_EOL
, '</div>' , PHP_EOL
, '<br />' , PHP_EOL;
} else {
echo 'No active modules found!' , PHP_EOL
, '</div>' , PHP_EOL;
CloseTable();
include_once 'footer.php';
exit;
}
echo '<table class="blma_maintable">' , PHP_EOL
, '<tr>' , PHP_EOL
, '<td>' , _TITLE , '</td>' , PHP_EOL
, '<td colspan="2">' , _POSITION , '</td>' , PHP_EOL
, '<td colspan="2">' , _WEIGHT , '</td>' , PHP_EOL
, '<td>' , _TYPE , '</td>' , PHP_EOL
, '<td>' , _STATUS , '</td>' , PHP_EOL
, '<td>' , _VIEW , '</td>' , PHP_EOL;
if ($multilingual == 1) {
echo '<td>' , _LANGUAGE , '</td>' , PHP_EOL;
}
#echo '<td>' , _FUNCTIONS , '</td>' , PHP_EOL;
echo '</tr>' , PHP_EOL;
$i = 0;
$sql = 'SELECT b.`bid`, b.`bkey`, b.`title`, b.`url`, m.`bposition`, m.`weight`, b.`active`, b.`blanguage`, b.`blockfile`, b.`view` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`bid` = m.`bid` AND m.`title` = \'' . $db->sql_escape_string($wb_name) . '\' ORDER BY m.`bposition`, m.`weight` ASC';
$result1 = $db->sql_query($sql);
if ($db->sql_numrows($result1) > 0) {
while (list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result1)) {
$weight1 = $weight - 1;
$weight3 = $weight + 1;
$res = $db->sql_query('SELECT `bid` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `weight` = \'' . $weight1 . '\' AND `bposition` = \'' . $bposition . '\'');
list($bid1) = $db->sql_fetchrow($res);
$con1 = $bid1;
$res2 = $db->sql_query('SELECT `bid` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `weight` = \'' . $weight3 . '\' AND `bposition` = \'' . $bposition . '\'');
list($bid2) = $db->sql_fetchrow($res2);
$con2 = $bid2;
echo '<tr>' , PHP_EOL
, '<td>' , $title , '</td>' , PHP_EOL;
if ($bposition == 'l') {
$bposition = _LEFT . '</td>' . PHP_EOL
. '<td>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=r">'
. '<img src="images/center_l.gif" alt="' . _RIGHTBLOCK . '" title="' . _RIGHTBLOCK . '" />'
. '</a>' . PHP_EOL;
if (($centerblocks_only_for_home == 1 && $wb_name == $main_module) || $centerblocks_only_for_home == 0) {
$bposition .= '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=c">'
. '<img src="images/up.gif" alt="' . _CENTERUP . '" title="' . _CENTERUP . '" />'
. '</a>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=d">'
. '<img src="images/down.gif" alt="' . _CENTERDOWN . '" title="' . _CENTERDOWN . '" />'
. '</a>' . PHP_EOL;
}
} elseif ($bposition == 'r') {
$bposition = _RIGHT . '</td>' . PHP_EOL
. '<td>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=l">'
. '<img src="images/center_r.gif" alt="' . _LEFTBLOCK . '" title="' . _LEFTBLOCK . '" />'
. '</a>' . PHP_EOL;
if (($centerblocks_only_for_home == 1 && $wb_name == $main_module) || $centerblocks_only_for_home == 0) {
$bposition .= '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=c">'
. '<img src="images/up.gif" alt="' . _CENTERUP . '" title="' . _CENTERUP . '" />'
. '</a>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=d">'
. '<img src="images/down.gif" alt="' . _CENTERDOWN . '" title="' . _CENTERDOWN . '" />'
. '</a>' . PHP_EOL;
}
} elseif ($bposition == 'c') {
$bposition = _CENTERUP . '</td>' . PHP_EOL
. '<td>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=l">'
. '<img src="images/center_r.gif" alt="' . _LEFTBLOCK . '" title="' . _LEFTBLOCK . '" />'
. '</a>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=r">'
. '<img src="images/center_l.gif" alt="' . _RIGHTBLOCK . '" title="' . _RIGHTBLOCK . '" />'
. '</a>' . PHP_EOL;
if (($centerblocks_only_for_home == 1 && $wb_name == $main_module) || $centerblocks_only_for_home == 0) {
$bposition .= '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=d">'
. '<img src="images/down.gif" alt="' . _CENTERDOWN . '" title="' . _CENTERDOWN . '" />'
. '</a>' . PHP_EOL;
}
} elseif ($bposition == 'd') {
$bposition = _CENTERDOWN . '</td>' . PHP_EOL
. '<td>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=l">'
. '<img src="images/center_r.gif" alt="' . _LEFTBLOCK . '" title="' . _LEFTBLOCK . '" />'
. '</a>' . PHP_EOL
. '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=r">'
. '<img src="images/center_l.gif" alt="' . _RIGHTBLOCK . '" title="' . _RIGHTBLOCK . '" />'
. '</a>' . PHP_EOL;
if (($centerblocks_only_for_home == 1 && $wb_name == $main_module) || $centerblocks_only_for_home == 0) {
$bposition .= '<a class="rn_csrf" href="' . $admin_file . '.php?op=BlocksManager_BlockPosition&bid=' . $bid . '&title=' . $wb_name . '&position=c">'
. '<img src="images/up.gif" alt="' . _CENTERUP . '" title="' . _CENTERUP . '" />'
. '</a>' . PHP_EOL;
}
}
echo '<td>' , $bposition , '</td>' , PHP_EOL
, '<td>' , $weight , '</td>' , PHP_EOL
, '<td>' , PHP_EOL
, '<a class="rn_csrf" href="' , $admin_file , '.php?op=BlocksManager_BlockOrder&weight=' , $weight , '&bidori=' , $bid , '&weightrep=' , $weight1 , ($con1 != '' ? '&bidrep=' . $con1 : '') , '&title=' , $wb_name , '"><img src="images/up.gif" alt="' , _BLOCKUP , '" title="' , _BLOCKUP , '" /></a>' , PHP_EOL
, '<a class="rn_csrf" href="' , $admin_file , '.php?op=BlocksManager_BlockOrder&weight=' , $weight , '&bidori=' , $bid , '&weightrep=' , $weight3 , ($con2 != '' ? '&bidrep=' . $con2 : '') , '&title=' , $wb_name , '"><img src="images/down.gif" alt="' , _BLOCKDOWN , '" title="' , _BLOCKDOWN , '" /></a>' , PHP_EOL
, '</td>' , PHP_EOL;
if ($bkey == '') {
if ($url == '') {
$type = 'HTML';
} elseif ($url != '') {
$type = 'RSS/RDF';
}
if ($blockfile != '') {
$type = _BLOCKFILE2;
}
} elseif ($bkey != '') {
$type = _BLOCKSYSTEM;
}
echo '<td>' , $type , '</td>' , PHP_EOL;
$block_act = $active;
if ($active == 1) {
$active = _ACTIVE;
$change = _DEACTIVATE;
} elseif ($active == '0') {
$active = '<em>' . _INACTIVE . '</em>';
$change = _ACTIVATE;
}
echo '<td>' , $active , '</td>' , PHP_EOL;
if ($view == '0') {
$who_view = _MVALL;
} elseif ($view == 1) {
$who_view = _MVUSERS;
} elseif ($view == 2) {
$who_view = _MVADMIN;
} elseif ($view == 3) {
$who_view = _MVANON;
}
echo '<td>' , $who_view , '</td>' , PHP_EOL;
if ($multilingual == 1) {
if ($blanguage == '') {
$blanguage = _ALL;
} else {
$blanguage = ucfirst($blanguage);
}
echo '<td>' , $blanguage , '</td>' , PHP_EOL;
}
/*echo '<td>';
if ($bkey == '') {
echo '<a href="' , $admin_file , '.php?op=BlocksManager_Delete&bid=' , $bid , '&title=' , $wb_name , '">' , _DELETE , '</a>';
} elseif ($bkey != '') {
echo _DELETE;
}
echo '</td>' , PHP_EOL; */
echo '</tr>' , PHP_EOL;
$wb_tabblocks[$i] = $bid;
$i++;
} # end of while
} else {
echo '<tr>' , PHP_EOL
, '<td colspan="' , ($multilingual == 1 ? '9' : '8') , '">' , _BLOCKMGR_NOENTRIES , '</td>' , PHP_EOL
, '</tr>' , PHP_EOL;
}
echo '</table>' , PHP_EOL
, '<br />' , PHP_EOL
, '<div class="text-center">[ <a class="rn_csrf" href="' , $admin_file , '.php?op=BlocksManager_FixWeight&wb_name=' , $wb_name , '">' , _FIXBLOCKS , '</a> ]</div>' , PHP_EOL
, '<br />' , PHP_EOL;
CloseTable();
echo '<br />' , PHP_EOL;
OpenTable();
echo '<div class="text-center thick">' , _BLOCKMGR_ADDNEWBLOCK_MANAGER , '</div>' , PHP_EOL
, '<br />' , PHP_EOL
, '<form name="BM_EDIT" action="' , $admin_file , '.php" method="post">' , PHP_EOL
, '<table class="blma_addnewtable centered">' , PHP_EOL
, '<tr>' , PHP_EOL
# List all inactive Blocks for selected module
, '<td class="valign_top">' , PHP_EOL
, '<span class="thick">' , _BLOCKMGR_ACTIVE_BLOCKS , '</span><br />' , PHP_EOL;
$result = $db->sql_query('SELECT `bid`, `title` FROM `' . $prefix . '_blocks` ORDER BY `title` ASC');
if ($db->sql_numrows($result) > 0) {
echo '<select name="bida[]" size="10" multiple="multiple">' , PHP_EOL;
while (list($bid, $title) = $db->sql_fetchrow($result)) {
$ii = 0;
$wb_affiche = 1;
while ($ii < $i) {
if ($wb_tabblocks[$ii] == $bid) {
$wb_affiche = 0;
}
$ii++;
} # end of while
if ($wb_affiche == 1) {
echo '<option value="' , $bid , '">' , $title , '</option>' , PHP_EOL;
}
}
echo '</select>' , PHP_EOL
, '<br /><br />' , PHP_EOL
, '<input type="submit" value="' , _BLOCKMGR_ADD_BLOCK , '" onclick="document.BM_EDIT.op.value=\'BlocksManager_Add\';" />' , PHP_EOL;
} else {
echo _BLOCKMGR_NOENTRIES , PHP_EOL;
}
echo '</td>' , PHP_EOL
# List all active Modules
, '<td class="valign_top">' , PHP_EOL
, '<span class="thick">' , _BLOCKMGR_MODULES , '</span><br />' , PHP_EOL;
$result = $db->sql_query('SELECT `mid`, `title`, `custom_title`, `active`, `view`, `inmenu` FROM `' . $prefix . '_modules` WHERE `active` = 1 ORDER BY `title` ASC');
if ($db->sql_numrows($result) > 0) {
echo '<select name="title[]" size="10" multiple="multiple">' , PHP_EOL;
while (list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) {
echo '<option value="' , $title , '"' , ($wb_name == $title ? ' selected="selected"' : '') , '>' , $title , '</option>' , PHP_EOL;
if ($wb_name == '') {
$wb_name = $title;
}
} # end of while
echo '</select>' , PHP_EOL
, '<br />' , PHP_EOL;
} else {
echo _BLOCKMGR_NOENTRIES , PHP_EOL;
}
echo '</td>' , PHP_EOL
# List all active Blocks for selected module
, '<td class="valign_top">' , PHP_EOL
, '<span class="thick">' , _BLOCKMGR_INACTIVE_BLOCKS , '</span><br />' , PHP_EOL;
$result = $db->sql_query('SELECT b.`bid`, b.`title` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`bid` = m.`bid` AND m.`title` = \'' . $db->sql_escape_string($wb_name) . '\' ORDER BY `title` ASC');
if ($db->sql_numrows($result) > 0) {
echo '<select name="bidr[]" size="10" multiple="multiple">' , PHP_EOL;
while (list($bid, $title) = $db->sql_fetchrow($result)) {
echo '<option value="' , $bid , '">' , $title , '</option>' , PHP_EOL;
} # end of while
echo '</select>' , PHP_EOL
, '<br />' , PHP_EOL
, '<input type="submit" value="' , _BLOCKMGR_REMOVE_BLOCK , '" onclick="document.BM_EDIT.op.value=\'BlocksManager_Remove\';" />' , PHP_EOL;
} else {
echo _BLOCKMGR_NOENTRIES , PHP_EOL;
}
echo '</td>' , PHP_EOL
, '</tr>' , PHP_EOL
, '</table>' , PHP_EOL
, '<br />' , PHP_EOL
, '<input type="hidden" name="wb_name" value="' , $wb_name , '" />' , PHP_EOL
, '<input type="hidden" name="op" value="BlocksManager_Add" />' , PHP_EOL
, '</form>' , PHP_EOL;
CloseTable();
include_once 'footer.php';
} else {
$visit_table = $db->sql_fetchrow($db->sql_query('SHOW TABLES LIKE \'' . $prefix . '_blocks_manager\''));
if (!isset($visit_table['0'])) {
include_once 'header.php';
GraphicAdmin();
OpenTable();
echo '<div class="text-center">' , PHP_EOL;
$createtable = 'CREATE TABLE IF NOT EXISTS `' . $prefix . '_blocks_manager` (
`bid` int(10) NOT NULL DEFAULT \'0\',
`title` varchar(255) NOT NULL DEFAULT \'0\',
`bposition` char(1) NOT NULL DEFAULT \'\',
`weight` int(10) NOT NULL DEFAULT \'1\',
KEY title (`title`)
) ENGINE=MyISAM ;';
$qry = $db->sql_query($createtable);
if ($qry) {
echo 'create blocks manager db-table = done!<br />' , PHP_EOL;
} else {
echo 'create blocks manager db-table = failed!<br />' , PHP_EOL;
}
echo '<br /><a href="' , $admin_file , '.php?op=BlocksManager">Lets go!</a><br />' , PHP_EOL
, '</div>' , PHP_EOL;
CloseTable();
include_once 'footer.php';
}
}
}
function BlocksManager_Add($bid, $title, $wb_name) {
global $prefix, $db, $admin_file;
if ($wb_name != '') {
foreach ($title as $tKey => $tValue) {
if ($tValue != '') {
foreach ($bid as $bKey => $bValue) {
if (is_numeric($bValue)) {
$result = $db->sql_query('SELECT `bid`, `bposition`, `weight`, `title` FROM `' . $prefix . '_blocks` WHERE `bid` = \'' . $bValue . '\'');
list($bid, $bposition, $weight, $block_title) = $db->sql_fetchrow($result);
if ($bid != '') {
$tValue = $db->sql_escape_string(htmlspecialchars_decode(check_html($tValue, 'nohtml'), ENT_QUOTES));
$db->sql_query('INSERT INTO `' . $prefix . '_blocks_manager` VALUES (\'' . $bValue . '\', \'' . $tValue . '\', \'' . $bposition . '\', \'' . $weight . '\')');
}
}
}
}
}
Header('Location: ' . $admin_file . '.php?op=BlocksManager&wb_name=' . $wb_name); exit;
} else {
Header('Location: ' . $admin_file . '.php'); exit;
}
}
function BlocksManager_Remove($bid, $title, $wb_name) {
global $prefix, $db, $admin_file;
if ($wb_name != '') {
foreach ($title as $tKey => $tValue) {
if ($tValue != '') {
foreach ($bid as $bKey => $bValue) {
if (is_numeric($bValue)) {
$db->sql_query('DELETE FROM `' . $prefix . '_blocks_manager` WHERE `bid` = \'' . $bValue . '\' AND `title` = \'' . $db->sql_escape_string($tValue) . '\'');
}
}
}
}
Header('Location: ' . $admin_file . '.php?op=BlocksManager&wb_name=' . $wb_name); exit;
} else {
Header('Location: ' . $admin_file . '.php'); exit;
}
}
function BlocksManager_FixWeight($wb_name) {
global $prefix, $db, $admin_file;
if ($wb_name != '') {
$leftpos = 'l';
$rightpos = 'r';
$centeruppos = 'c';
$centerdnpos = 'd';
# Fix Left Block Weights
$result = $db->sql_query('SELECT `bid`, `title` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bposition` = \'' . $db->sql_escape_string($leftpos) . '\' ORDER BY `weight` ASC');
if ($db->sql_numrows($result) > 0) {
$weight = 0;
while (list($bid, $title) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weight . '\' WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bid` = \'' . $bid . '\'');
} # end of while
}
# Fix Right Block Weights
$result = $db->sql_query('SELECT `bid` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bposition` = \'' . $db->sql_escape_string($rightpos) . '\' ORDER BY `weight` ASC');
if ($db->sql_numrows($result) > 0) {
$weight = 0;
while (list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weight . '\' WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bid` = \'' . $bid . '\'');
} # end of while
}
# Fix Center Up Block Weights
$result = $db->sql_query('SELECT `bid` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bposition` = \'' . $db->sql_escape_string($centeruppos) . '\' ORDER BY `weight` ASC');
if ($db->sql_numrows($result) > 0) {
$weight = 0;
while (list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weight . '\' WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bid` = \'' . $bid . '\'');
} # end of while
}
# Fix Center Down Block Weights
$result = $db->sql_query('SELECT `bid` FROM `' . $prefix . '_blocks_manager` WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bposition` = \'' . $db->sql_escape_string($centerdnpos) . '\' ORDER BY `weight` ASC');
if ($db->sql_numrows($result) > 0) {
$weight = 0;
while (list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weight . '\' WHERE `title` = \'' . $db->sql_escape_string($wb_name) . '\' AND `bid` = \'' . $bid . '\'');
} # end of while
}
Header('Location: ' . $admin_file . '.php?op=BlocksManager&wb_name=' . $wb_name); exit;
} else {
Header('Location: ' . $admin_file . '.php'); exit;
}
}
function BlocksManager_BlockPosition($bid, $title, $position) {
global $prefix, $db, $admin_file;
if (is_numeric($bid) && ($position == 'l' || $position == 'r' || $position == 'c' || $position == 'd') && $title != '') {
$title = $db->sql_escape_string(htmlspecialchars_decode(check_html($title, 'nohtml'), ENT_QUOTES));
$db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `bposition` = \'' . $db->sql_escape_string($position) . '\' WHERE `bid` = \'' . $bid . '\' AND `title` = \'' . $title . '\'');
Header('Location: ' . $admin_file . '.php?op=BlocksManager&wb_name=' . $title); exit;
} else {
Header('Location: ' . $admin_file . '.php'); exit;
}
}
function BlocksManager_BlockOrder($weightrep, $weight, $bidrep, $bidori, $title) {
global $prefix, $db, $admin_file;
if (is_numeric($weightrep) && is_numeric($weight) && is_numeric($bidori) && $title != '') {
if (is_numeric($bidrep)) {
$result = $db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weight . '\' WHERE `bid` = \'' . $bidrep . '\' AND `title` = \'' . $title . '\'');
}
$result2 = $db->sql_query('UPDATE `' . $prefix . '_blocks_manager` SET `weight` = \'' . $weightrep . '\' WHERE `bid` = \'' . $bidori . '\' AND `title` = \'' . $title . '\'');
Header('Location: ' . $admin_file . '.php?op=BlocksManager&wb_name=' . $title); exit;
} else {
Header('Location: ' . $admin_file . '.php'); exit;
}
}
|