diff options
author | jhunkeler <jhunkeler@c5b2fb0a-d05d-0410-98c8-828840a80ff6> | 2009-12-27 10:44:57 -0500 |
---|---|---|
committer | jhunkeler <jhunkeler@c5b2fb0a-d05d-0410-98c8-828840a80ff6> | 2009-12-27 10:44:57 -0500 |
commit | d526decc4884710ae7fafe7aa5171e7f59b24292 (patch) | |
tree | 12c07f3ef6ab9bf5a4f278a7b00720996c41667d /modules | |
parent | 07253dc75c69cf585ad39a218f3f2cf97b773987 (diff) | |
download | bayonetcms-d526decc4884710ae7fafe7aa5171e7f59b24292.tar.gz |
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
Diffstat (limited to 'modules')
-rw-r--r-- | modules/admin/blocks/functions.php | 12 | ||||
-rw-r--r-- | modules/admin/pages/functions.php | 19 | ||||
-rw-r--r-- | modules/download/index.php | 8 | ||||
-rw-r--r-- | modules/index/index.php | 43 | ||||
-rw-r--r-- | modules/news/functions.php | 32 | ||||
-rw-r--r-- | modules/newsreel/index.php | 41 | ||||
-rw-r--r-- | modules/page/index.php | 37 |
7 files changed, 100 insertions, 92 deletions
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 "<table align=\"center\"><tr><th colspan=\"3\">Existing Blocks</th></tr>";
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;
}
-
+ */
+ // }}}
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
<table align="center">
@@ -170,4 +170,4 @@ function DeleteBlock($block_id) <?php
}
-?>
\ 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 "<table class=\"cleartable\" width=\"100%\" cellspacing=\"0\">";
@@ -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;
- }
+ }
+ */
+ // }}}
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table class="cleartable">
@@ -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: <select id="pagenames" onchange="gotoEditPage(this.id)">';
echo '<option value="0">- - - - - - - -</option>';
@@ -227,4 +224,4 @@ function DeletePage($page_id) <?php
}
-?>
\ No newline at end of file +?>
diff --git a/modules/download/index.php b/modules/download/index.php index 300bd46..983b6f8 100644 --- a/modules/download/index.php +++ b/modules/download/index.php @@ -26,11 +26,7 @@ $download = NULL; $download_relative_path = "modules/" . basename(dirname(__FILE__)) . "/files/";
$download_absolute_path = dirname(__FILE__) . "/files/";
-$result = $db->Query("SELECT `file_id`, `name`, `description`, `filename` FROM `bayonet_downloads`");
-while(($row = $db->Fetch($result)) !== false)
-{
- $download[] = $row;
-}
+$download = $db->Query("SELECT `file_id`, `name`, `description`, `filename` FROM `bayonet_downloads`");
OpenContent();
echo "<div class=\"contentHeading\">Downloads</div>";
@@ -62,4 +58,4 @@ echo "</div>"; CloseContent();
-?>
\ No newline at end of file +?>
diff --git a/modules/index/index.php b/modules/index/index.php index 7d23bc6..9847cb5 100644 --- a/modules/index/index.php +++ b/modules/index/index.php @@ -7,29 +7,28 @@ * in the config.php array * */ -?> -<?php - - - $result = $db->Query("SELECT `dir_name` FROM `bayonet_modules` ORDER BY `weight` ASC"); - while(($row = $db->Fetch($result))!==false) +$result = $db->Query("SELECT `dir_name` FROM `bayonet_modules` ORDER BY `weight` ASC"); +$modules = $db->Fetch($result); +foreach($modules as $module) +{ + $indexModules[] = $module['dir_name']; +} + +foreach($indexModules as $module) +{ + if(file_exists("modules/" . $module)) { - $indexModules[] = $row['dir_name']; + include 'modules/' . $module . '/index.php'; + decho("Index module loaded: '$module'"); } - - foreach($indexModules as $module) - { - if(file_exists("modules/" . $module)) - { - include 'modules/' . $module . '/index.php'; - } - else - { - OpenContent(); - ReportError("Cannot load module '{$module}' directory.<br>\n"); - CloseContent(); - } - echo "<br />"; + else + { + OpenContent(); + ReportError("Cannot load module '{$module}' directory.<br>\n"); + CloseContent(); } -?>
\ No newline at end of file + echo "<br />"; +} + +?> diff --git a/modules/news/functions.php b/modules/news/functions.php index b76a53e..bd901aa 100644 --- a/modules/news/functions.php +++ b/modules/news/functions.php @@ -31,13 +31,15 @@ function getNewsComments($id){ "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = c.author_id ". "WHERE c.news_id = '$id' ". "ORDER BY date ASC"); + $comments = $db->Fetch($result); + /* while(($row = $db->Fetch($result)) != false) { $comments[] = $row; } $db->Free($result); - + */ return $comments; } @@ -117,7 +119,7 @@ function getNumOfComments($id){ global $db; $result = $db->Query("SELECT `comment_id` FROM `bayonet_news_comments` WHERE `news_id` = '$id'"); - return $db->Rows($result);; + return $db->Rows($result); } /** @@ -142,12 +144,18 @@ function getNews($id = NULL){ } $result = $db->Query($query); + $data = $db->Fetch($result); + //decho($data); + // {{{ XXX: FIXME -- Re-write + /* while(($row = $db->Fetch($result)) != false) { $data[] = $row; } $db->Free($result); + */ + // }}} return $data; } @@ -160,10 +168,12 @@ function getNews($id = NULL){ function displayNews($data){ date_default_timezone_set("America/New_York"); + + foreach($data as $news) - { + { $numComments = getNumOfComments($news['news_id']); - + //echo "<pre>".print_r($news,true)."</pre>"; OpenContent(); ?> <div class="contentHeading"> @@ -177,12 +187,12 @@ function displayNews($data){ <div class="content"> <img src="modules/news/categories/<?php echo $news['catimage']; ?>" alt="<?php echo $news['catname']; ?>" align="right" /> <?php echo BBCode($news['message']); ?> - </div> + </div> <div class="contentFooter"> <table width="100%"> <tr> <td style="text-align:left;"> - View Comments: <a href="?load=news&id=<?php echo $news['news_id']; ?>"><?php echo $numComments;?> Comments</a> + View Comments: <a href="<?php echo $_SERVER['PHP_SELF']; ?>?load=news&id=<?php echo $news['news_id']; ?>"><?php echo $numComments;?> Comments</a> </td> <td style="text-align:right;">Posted on: <?php echo date('D M j, Y g:i a T', strtotime($news['date'])); ?></td> </tr> @@ -192,7 +202,8 @@ function displayNews($data){ <?php CloseContent(); echo "<br />"; - } + + } } /** 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; } - + */ + // }}} ?> <a name="add"></a> <h2>Add Your Comment</h2> @@ -257,4 +271,4 @@ function commentForm(){ <?php } -?>
\ 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 <?php + global $db; $x=0; - $get_slides = mysql_query("SELECT * FROM `bayonet_newsreel` WHERE `visible`= 1 ORDER BY `weight` ASC LIMIT 0,6"); + $result = $db->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++; } - <?php - echo' if(x=='.$x.'){ - x=0;}'; - ?> + if(x==<?php echo $x; ?>){ + x=0; + } var timerId=setTimeout("playBanner()", timing); } } @@ -95,16 +93,23 @@ window.onload = init_Slides; //starts the reels movement <div class="content1"><div class="content2"> <img src="modules/newsreel/slides/<?php echo $startSRC; ?>" name="myBanner" alt="newsreel" /> - <table border="0" cellspacing="0" cellpadding="0" height="21px" width="100%"> + <table border="0" cellspacing="0" cellpadding="0" style="height:21px;" width="100%"> <tr> <?php -$y=0; +$y=0; /* $get_slidenav = mysql_query("SELECT * FROM `bayonet_newsreel` WHERE `visible`= 1 ORDER BY `weight` ASC LIMIT 0, 6"); while($echo_slidenav = mysql_fetch_array($get_slidenav)){ echo '<td id="'.$y.'" width="'.$width.'%" class="slidenav" onclick="nextSlide(this.id,true)" onmouseover="mouseOverBG(this.id)" onmouseout="mouseOutBG(this.id)">'.$echo_slidenav['title'].'</td>'; $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 "<td id=\"{$y}\" width=\"{$width}%\" class=\"slidenav\" onclick=\"javascript:nextSlide(this.id, true); return false;\" onmouseover=\"javascript:mouseOverBG(this.id); return false;\" onmouseout=\"javascript:mouseOutBG(this.id); return false;\">{$link['title']}</td>\n"; + $y++; + } ?> </tr> </table> 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 "<div class=\"contentHeading\">Page Map</div>"; @@ -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 "<div class=\"content\">"; - $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 '<h2>'.$articleTitle.'</h2>'; + //$aresult = $db->Query("SELECT * FROM `bayonet_page` WHERE `page_id` = $id ORDER BY `weight` ASC"); + //$article = $db->Fetch($aresult); + foreach($pages as $page) + { + echo '<h2>'.$page['title'].'</h2>'; //echo "<h3>".$article['title']."</h3>"; - echo bbcode_format($article['text']); - } - echo "</div>"; + echo bbcode_format($page['text']); + echo "</div>"; + } + CloseContent(); - } + ?> <?php // echo bbcode_format($page['text']) ?> <!-- <tr><th><?php echo $page['author'] ?></th></tr> --> @@ -100,4 +97,4 @@ else ReportError("Page does not exist.<br>\n"); } -?>
\ No newline at end of file +?> |