From d526decc4884710ae7fafe7aa5171e7f59b24292 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 27 Dec 2009 15:44:57 +0000 Subject: MySQL -> MySQLi Fixed memory leaks after Fetching arrays Removed all while loops that interfaced with $db->Fetch() Rewrote RSS module Fixed syntax error in donations module Fixed link structure for news module Reverting to old page display method git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@402 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/admins/functions.php | 5 +- admin/announcements/functions.php | 8 +-- admin/blocks/functions.php | 12 +--- admin/calendar/functions.php | 25 ++++---- admin/functions.php | 7 +-- admin/index.php | 2 +- admin/modules/functions.php | 11 +--- admin/navigation/functions.php | 5 +- admin/news/functions.php | 39 ++++++++----- admin/newsreel/functions.php | 47 +++++++++------ admin/newsreel/updateDB.php | 3 +- admin/pages/functions.php | 116 +++++++++++++++++--------------------- 12 files changed, 133 insertions(+), 147 deletions(-) (limited to 'admin') diff --git a/admin/admins/functions.php b/admin/admins/functions.php index 8987322..563b507 100644 --- a/admin/admins/functions.php +++ b/admin/admins/functions.php @@ -44,10 +44,7 @@ { global $db; $result = $db->Query("SELECT `user_id`, `username`, `level` FROM `bayonet_users` ORDER BY `level` DESC, `username` ASC"); - while(($rows = $db->fetch($result))!=false) - { - $admins[] = $rows; - } + $admins = $db->fetch($result); $num = 1; OpenTable("300px"); diff --git a/admin/announcements/functions.php b/admin/announcements/functions.php index 2e55125..917e342 100644 --- a/admin/announcements/functions.php +++ b/admin/announcements/functions.php @@ -52,11 +52,9 @@ function EditAnnouncements() //Grab the page from the database according to the $article_id passed to the function. $result = $db->Query("SELECT title,text FROM bayonet_announcements WHERE announcement_id = 0"); - while(($row = $db->Fetch($result))!=false) - { - //We only want one row, so we don't have to $article[]... No foreach necessary. - $announcement = $row; - } + /** FIXME - this probably broke. */ + $announcement = $db->Fetch($result); + ?>
diff --git a/admin/blocks/functions.php b/admin/blocks/functions.php index ad7daa0..aaa7f36 100644 --- a/admin/blocks/functions.php +++ b/admin/blocks/functions.php @@ -21,10 +21,8 @@ function ListBlocks() { global $db; $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY `active` DESC, `weight` ASC, `position`"); - while(($rows = $db->fetch($result))!=false) - { - $blocks[] = $rows; - } + $blocks = $db->Fetch($result); + echo "
"; foreach($blocks as $block) @@ -121,11 +119,7 @@ function EditBlock($block_id) //Grab the page from the database according to the $page_id passed to the function. $result = $db->Query("SELECT weight,dir_name,position,active,title FROM bayonet_blocks WHERE block_id = '$block_id'"); - while(($row = $db->Fetch($result))!=false) - { - //We only want one row, so we don't have to $block[]... No foreach necessary. - $block = $row; - } + $block = $db->FetchRow($result); ?> diff --git a/admin/calendar/functions.php b/admin/calendar/functions.php index 8d1d6a1..9983870 100644 --- a/admin/calendar/functions.php +++ b/admin/calendar/functions.php @@ -90,25 +90,26 @@ echo "
Existing Blocks
"; $result = $db->Query("SELECT * FROM bayonet_events WHERE `date` = '$date' ORDER BY `time`"); - while(($row = $db->Fetch($result))!=false) + $row = $db->Fetch($result); + foreach($row as $event) { $tmp = true; - $datetime = date_create($date.' '.$row['time']); - $time = date_format($datetime, 'g:ia'); //gets time in hour:minutes am|pm + $datetime = date_create($date.' '.$event['time']); + $time = date_format($datetime, 'g:ia'); //gets time in hour:minutes am|pm ?> - - + + - + @@ -116,7 +117,6 @@ "; @@ -391,10 +391,9 @@ $db->Query("UPDATE `bayonet_events` SET `title` = '$title', `text` = '$text', `c } */ global $db; $result = $db->Query("SELECT title,color FROM bayonet_events WHERE `date` = '$sqlDate' LIMIT 1"); - while(($row = $db->Fetch($result))!=false) - { - $isEvent = true; - } + $events = $db->Fetch($result); + $isEvent = empty($events) ? false : true; + if($useCurDate) echo ""; else diff --git a/admin/functions.php b/admin/functions.php index 07bc20b..9b950c4 100644 --- a/admin/functions.php +++ b/admin/functions.php @@ -526,12 +526,7 @@ function GetBlocks($position = BLOCK_LEFT) $db->Select_db($config['sql']['database']); $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY weight, position"); - //$result = mysql_query("SELECT * FROM bayonet_blocks ORDER BY weight, position"); - while(($row = $db->Fetch($result))!==false) - { - $blocks[] = $row; - } - $db->Free($result); + $blocks = $db->Fetch($result); foreach($blocks as $block) { diff --git a/admin/index.php b/admin/index.php index fea8112..754ef89 100644 --- a/admin/index.php +++ b/admin/index.php @@ -22,7 +22,7 @@ session_start(); include '../includes/debug.php'; include '../includes/config.php'; include '../includes/sql.class.php'; -include 'functions.php'; +include '../includes/functions.php'; $db = new Bayonet_SQL(); $db->Connect( diff --git a/admin/modules/functions.php b/admin/modules/functions.php index 619efc7..3c44b5a 100644 --- a/admin/modules/functions.php +++ b/admin/modules/functions.php @@ -21,10 +21,7 @@ function ListModules() { global $db; $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY `active` DESC, `weight` ASC, `position`"); - while(($rows = $db->fetch($result))!=false) - { - $blocks[] = $rows; - } + $blocks = $db->fetch($result); echo "
         - Edit + Edit  |  - Delete + Delete




There are no events posted for this day.
"; foreach($blocks as $block) @@ -121,11 +118,7 @@ function EditModule($module_id) //Grab the page from the database according to the $page_id passed to the function. $result = $db->Query("SELECT weight,dir_name,position,active,title FROM bayonet_blocks WHERE block_id = '$block_id'"); - while(($row = $db->Fetch($result))!=false) - { - //We only want one row, so we don't have to $block[]... No foreach necessary. - $block = $row; - } + $block = $db->Fetch($result) ?> diff --git a/admin/navigation/functions.php b/admin/navigation/functions.php index 29aa10f..2287944 100644 --- a/admin/navigation/functions.php +++ b/admin/navigation/functions.php @@ -26,10 +26,7 @@ function ListNavigation(){ global $db; $result = $db->Query("SELECT `nav_id`, `title`, `weight` FROM `bayonet_navigation` ORDER BY `weight`"); - while(($row = $db->Fetch($result))!=false) - { - $data[] = $row; - } + $data = $db->Fetch($result); echo "|0|Home|0|
"; diff --git a/admin/news/functions.php b/admin/news/functions.php index 1f9e34a..75b52e3 100644 --- a/admin/news/functions.php +++ b/admin/news/functions.php @@ -25,19 +25,22 @@ function ListNews(){ "FROM `bayonet_news` AS n ". "INNER JOIN `bayonet_news_categories` AS c ON c.category_id = n.category_id ". "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = n.author_id ORDER BY `date` DESC"); - while($row = $db->Fetch($result)){ - $newsBody = $row['message']; - echo "
"; - echo "{$row['title']} | {$row['catname']}  
"; - if(($len = strlen($newsBody))>150) - echo substr($newsBody, 0, 150)."..."; - else - echo $newsBody; - echo '
'; - echo "Posted By: {$row['author']} on ".date('D M j, Y g:i a T', strtotime($row['date'])); - echo '

'; + $row = $db->Fetch($result); + foreach($row as $news) + { + $newsBody = $news['message']; + echo ""; + echo "{$row['title']} | {$row['catname']}  
"; + if(($len = strlen($newsBody))>150) + echo substr($newsBody, 0, 150)."..."; + else + echo $newsBody; + echo '
'; + echo "Posted By: {$row['author']} on ".date('D M j, Y g:i a T', strtotime($news['date'])); + echo '

'; } + } function EditNews($news_id){ @@ -51,7 +54,7 @@ function EditNews($news_id){ } $result = $db->Query("SELECT `author_id`, `title`, `message`, `date`, `category_id` FROM `bayonet_news` WHERE `news_id` = '$news_id' LIMIT 1"); - $row = $db->Fetch($result); + $row = $db->FetchRow($result); ?>

Edit News

@@ -118,12 +121,22 @@ function EditNews($news_id){ echo ""; } diff --git a/admin/newsreel/functions.php b/admin/newsreel/functions.php index 8423b9b..9dece93 100644 --- a/admin/newsreel/functions.php +++ b/admin/newsreel/functions.php @@ -58,22 +58,24 @@ $(document).ready(function(){ function EditOrder(){ global $db; - - echo "
+ ?> +
Existing Blocks
- +
News Reel Order
-