From 2b31e8a6f30ebcd145b3394ac1a2ef8a768924ac Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Fri, 8 Jan 2010 03:10:43 +0000 Subject: The download module mostly works/looks the way it should. Bayonet_SQL now checks for a valid result, and if it is invalid just return. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@460 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- includes/functions.php | 4 +-- includes/sql.class.php | 26 ++++++++++++++++++++ modules/download/index.php | 61 ++++++++++++++++++++++++---------------------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 5d3dc7d..09fc456 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -621,9 +621,7 @@ function GetBlocks($position = BLOCK_LEFT) $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); - /* Is the result valid? */ - if($db->Rows($result) < 1) - return false; + $blocks = $db->Fetch($result); if(empty($blocks)) return; diff --git a/includes/sql.class.php b/includes/sql.class.php index 6bda00f..c32de63 100644 --- a/includes/sql.class.php +++ b/includes/sql.class.php @@ -53,6 +53,14 @@ class Bayonet_SQL return mysqli_select_db($GLOBALS['___mysqli_ston'], $db); } + private function validResult($p_result) + { + if($this->Rows($p_result) > 0) + return true; + else + return false; + } + public function Query($str) { global $db_queries; @@ -78,6 +86,12 @@ class Bayonet_SQL $db_fetches++; decho('Fetching result'); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return array(); + } + while ($row = mysqli_fetch_array($p_result, MYSQLI_ASSOC)) { $result[] = $row; @@ -94,6 +108,12 @@ class Bayonet_SQL decho("Fetching object result"); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return (object)array(); + } + while ($row = mysqli_fetch_object($p_result, $class)) { if($no_array == true) @@ -121,6 +141,12 @@ class Bayonet_SQL decho("Fetching single row"); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return array(); + } + while ($row = mysqli_fetch_assoc($p_result)) { $result = $row; } diff --git a/modules/download/index.php b/modules/download/index.php index 0c0ed2e..b819e8d 100644 --- a/modules/download/index.php +++ b/modules/download/index.php @@ -92,40 +92,43 @@ $categoryList = getCategoryList(); echo "\n\n"; CloseContent(); +echo "
"; //spacer between div tags -OpenContent(); -echo "
" . getCategoryName($category) . "
\n"; -echo "
\n"; - +if(isset($category)) +{ OpenContent(); - echo "
Files
\n"; - echo "
\n"; - - if(empty($downloads)) - { - echo "No downloads available.\n"; - return; - } - - foreach($downloads as $file) - { - $download_full_path = $download_absolute_path . $file['filename']; + echo "
" . getCategoryName($category) . "
\n"; + echo "
\n"; + + OpenContent(); + echo "
Files
\n"; + echo "
\n"; + + if(empty($downloads)) + { + echo "No downloads available.\n"; + return; + } - if(!file_exists($download_full_path)) $broken = "(Broken link detected)"; - echo "

"; - echo LinkInternal($file['name'], $file['filename'], $download_relative_path) . " $broken
\n"; - echo "Filename: {$file['filename']}
\n"; - printf("Size: %.2fKB
\n", filesize($download_full_path) / 1024); - echo "MD5 Hash: " . md5_file($download_full_path) . "
\n"; - echo "Description: {$file['description']}
\n"; - echo "

"; + foreach($downloads as $file) + { + $download_full_path = $download_absolute_path . $file['filename']; + + if(!file_exists($download_full_path)) $broken = "(Broken link detected)"; + echo "

"; + echo LinkInternal($file['name'], $file['filename'], $download_relative_path) . " $broken
\n"; + echo "Filename: {$file['filename']}
\n"; + printf("Size: %.2fKB
\n", filesize($download_full_path) / 1024); + echo "MD5 Hash: " . md5_file($download_full_path) . "
\n"; + echo "Description: {$file['description']}
\n"; + echo "

"; + + } + //logQueueFlush(FORCE); - } - //logQueueFlush(FORCE); - + echo "
\n
"; echo "
\n
"; - echo "\n"; - +} CloseContent(); CloseContent(); ?> -- cgit