From 21608260d1b8a7bab9f8bab60bdc506af25985e6 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Fri, 8 Jan 2010 00:54:15 +0000 Subject: Fixed GetBlocks() passing a bad result to mysqli fetch. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@455 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- includes/functions.php | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'includes/functions.php') diff --git a/includes/functions.php b/includes/functions.php index 30997c6..5d3dc7d 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -420,9 +420,9 @@ function ReportError($message) function ReportHack($message) { //WriteLog($message,BAYONET_LOG_HACK); - OpenTable(); - echo "Hack Attempt{$message}"; - CloseTable(); + OpenContent(); + echo "
Hacking Attempt
{$message}
"; + CloseContent(); } /** @@ -584,6 +584,23 @@ function UnderConstruction($message = NULL, $flag = BAYONET_SITE) echo "
"; } +/** + * valid_result() + * + * Determine if a mysqli result is valid. + * Can be used on normal objects to check if they are empty. + * + * @param mixed $p_result + * @return + */ +function valid_result($p_result) +{ + if(is_object($p_result) && count($p_result) <= 1) + return false; + else + return true; +} + /** * GetBlocks() * @@ -600,10 +617,17 @@ function GetBlocks($position = BLOCK_LEFT) { global $config; global $db; + + $query = sprintf("SELECT block_id, active, weight, position, dir_name, title FROM bayonet_blocks WHERE active = 1 AND position = %d ORDER BY weight", (int)$position); + $result = $db->Query($query); - $result = $db->Query("SELECT block_id, active, weight, position, dir_name, title FROM `bayonet_blocks` WHERE `position` = $position AND `active` = 1 ORDER BY weight"); - $blocks = $db->Fetch($result); + /* Is the result valid? */ + if($db->Rows($result) < 1) + return false; + $blocks = $db->Fetch($result); + if(empty($blocks)) return; + foreach($blocks as $block) { $load = 'blocks/'.$block['dir_name'].'/index.php'; -- cgit