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 --- modules/admin/blocks/functions.php | 12 +++++------ modules/admin/pages/functions.php | 19 +++++++---------- modules/download/index.php | 8 ++----- modules/index/index.php | 43 +++++++++++++++++++------------------- modules/news/functions.php | 32 ++++++++++++++++++++-------- modules/newsreel/index.php | 41 ++++++++++++++++++++---------------- modules/page/index.php | 37 +++++++++++++++----------------- 7 files changed, 100 insertions(+), 92 deletions(-) (limited to 'modules') diff --git a/modules/admin/blocks/functions.php b/modules/admin/blocks/functions.php index 660b8e7..0138839 100644 --- a/modules/admin/blocks/functions.php +++ b/modules/admin/blocks/functions.php @@ -21,10 +21,7 @@ function ListBlocks() { global $db; $result = $db->Query("SELECT * FROM bayonet_blocks"); - while(($rows = $db->fetch($result))!=false) - { - $blocks[] = $rows; - } + $blocks = $db->Fetch(); echo ""; foreach($blocks as $block) @@ -116,13 +113,16 @@ function EditBlock($block_id) } //Grab the page from the database according to the $page_id passed to the function. + // {{{ XXX: FIXME -- Re-write this + /* $result = $db->Query("SELECT weight,dir_name,position,active 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; } - + */ + // }}} ?>
Existing Blocks
@@ -170,4 +170,4 @@ function DeleteBlock($block_id) \ No newline at end of file +?> diff --git a/modules/admin/pages/functions.php b/modules/admin/pages/functions.php index 104a19a..fc97ffc 100644 --- a/modules/admin/pages/functions.php +++ b/modules/admin/pages/functions.php @@ -26,10 +26,7 @@ function ListArticles($pageid){ global $db; $result = $db->Query("SELECT article_id,title FROM bayonet_articles WHERE `page_id` = $pageid ORDER BY `weight`"); - while(($row = $db->Fetch($result))!=false) - { - $articles[] = $row; - } + $articles = $db->Fetch($result); echo "
"; @@ -65,12 +62,16 @@ function EditArticle($article_id){ global $db; //Grab the page from the database according to the $article_id passed to the function. + // {{{ XXX: FIXME -- Needs to be re-written + /* $result = $db->Query("SELECT title,text FROM bayonet_articles WHERE article_id = '$article_id'"); while(($row = $db->Fetch($result))!=false) { //We only want one row, so we don't have to $article[]... No foreach necessary. $article = $row; - } + } + */ + // }}} ?>
@@ -87,11 +88,7 @@ function EditArticle($article_id){ function ListPages($pid = NULL) { global $db; - $result = $db->Query("SELECT page_id,title FROM bayonet_pages"); - while(($row = $db->Fetch($result))!=false) - { - $pages[] = $row; - } + $pages = $db->Query("SELECT page_id,title FROM bayonet_pages"); echo 'Select page:
@@ -192,7 +202,8 @@ function displayNews($data){ "; - } + + } } /** This was coded on Coda with a MacBook Pro **/ @@ -212,6 +223,8 @@ function commentForm(){ $cur_user_id = 0; //testing variable, until i get the login system working for this $logged_in = false; + // {{{ XXX: FIXME -- Re-write this + /* $result = $db->Query("SELECT `username`, `avatar` FROM `mybb_users` WHERE `uid` = '$cur_user_id' LIMIT 1"); while(($row = $db->Fetch($result)) != false) { @@ -219,7 +232,8 @@ function commentForm(){ $avatar = $row['avatar']; $logged_in = true; } - + */ + // }}} ?>

Add Your Comment

@@ -257,4 +271,4 @@ function commentForm(){ \ No newline at end of file +?> diff --git a/modules/newsreel/index.php b/modules/newsreel/index.php index 0a986c2..70b9958 100644 --- a/modules/newsreel/index.php +++ b/modules/newsreel/index.php @@ -8,22 +8,21 @@ var slide=new Array(); //declares a new array called banner var x=0; //loop control and array counting variable var timing=7000; //value is in milliseconds, used for 3 seconds on each image Query("SELECT * FROM `bayonet_newsreel` WHERE `visible`= 1 ORDER BY `weight` ASC LIMIT 0,6"); //$get_slides = mysql_query("SELECT * FROM `news_slideshow` WHERE `visible`=1"); - - while($echo_slides = mysql_fetch_array($get_slides)){ - + $row = $db->fetch($result); + + foreach($row as $slide){ echo 'slide['.$x.']=new Image();'; - echo 'slide['.$x.'].src="modules/newsreel/slides/'.$echo_slides['src'].'";'; - if($x==0){ - $startSRC=$echo_slides['src']; - } - $x++; - + echo 'slide['.$x.'].src="modules/newsreel/slides/'.$slide['src'].'";'; + if($x==0){ + $startSRC=$slide['src']; + } + $x++; } - $width = 100/$x; ?> @@ -75,10 +74,9 @@ var timing=7000; //value is in milliseconds, used for 3 seconds on each image nextSlide(x,false) x++; } - + if(x==){ + x=0; + } var timerId=setTimeout("playBanner()", timing); } } @@ -95,16 +93,23 @@ window.onload = init_Slides; //starts the reels movement
newsreel -
- View Comments: Comments + View Comments: Comments Posted on:
+
'.$echo_slidenav['title'].''; $y++; - } + } */ + $result = $db->Query("SELECT * FROM `bayonet_newsreel` WHERE `visible`= 1 ORDER BY `weight` ASC LIMIT 0, 6"); + $row = $db->Fetch($result); + + foreach($row as $link){ + echo "\n"; + $y++; + } ?>
{$link['title']}
diff --git a/modules/page/index.php b/modules/page/index.php index abf559f..1f72925 100644 --- a/modules/page/index.php +++ b/modules/page/index.php @@ -35,12 +35,8 @@ if(isset($_GET['list'])) { if($_GET['list'] == "true") { - $result = $db->Query("SELECT title, page_id FROM bayonet_articles"); - while(($row = $db->Fetch($result)) !== false) - { - $pages[] = $row; - } - mysql_free_result($result); + $results = $db->Query("SELECT title, page_id FROM bayonet_articles"); + $pages = $db->Fetch($results); OpenContent(); echo "
Page Map
"; @@ -68,28 +64,29 @@ if(!isset($_GET['id'])) $id = $_GET['id']; } +// {{{ XXX: FIXME -- Needs to be re-written + $result = $db->Query("SELECT u.username AS author, p.page_created, p.title, p.text FROM `bayonet_pages` AS p LEFT OUTER JOIN `bayonet_users` AS u ON u.user_id = p.author_id WHERE p.page_id = '$id'"); -$proceed = mysql_num_rows($result); +$proceed = $db->Rows($result); if($proceed > 0) { - while(($row = $db->Fetch($result))!==false) - { - $page = $row; + $pages = $db->Fetch($result); OpenContent(); echo "
"; - $aresult = $db->Query("SELECT * FROM `bayonet_articles` WHERE `page_id` = $id ORDER BY `weight` ASC"); - while(($article = $db->Fetch($aresult))!==false) - { - $articleTitle = $article['title']; - echo '

'.$articleTitle.'

'; + //$aresult = $db->Query("SELECT * FROM `bayonet_page` WHERE `page_id` = $id ORDER BY `weight` ASC"); + //$article = $db->Fetch($aresult); + foreach($pages as $page) + { + echo '

'.$page['title'].'

'; //echo "

".$article['title']."

"; - echo bbcode_format($article['text']); - } - echo "
"; + echo bbcode_format($page['text']); + echo ""; + } + CloseContent(); - } + ?> @@ -100,4 +97,4 @@ else ReportError("Page does not exist.
\n"); } -?> \ No newline at end of file +?> -- cgit