aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/admins/functions.php5
-rw-r--r--admin/announcements/functions.php8
-rw-r--r--admin/blocks/functions.php12
-rw-r--r--admin/calendar/functions.php25
-rw-r--r--admin/functions.php7
-rw-r--r--admin/index.php2
-rw-r--r--admin/modules/functions.php11
-rw-r--r--admin/navigation/functions.php5
-rw-r--r--admin/news/functions.php39
-rw-r--r--admin/newsreel/functions.php47
-rw-r--r--admin/newsreel/updateDB.php3
-rw-r--r--admin/pages/functions.php116
-rw-r--r--blocks/donations/index.php5
-rw-r--r--blocks/rss_agw/index.php175
-rw-r--r--blocks/rss_agw/rssreader.php161
-rw-r--r--includes/debug.php4
-rw-r--r--includes/functions.php26
-rw-r--r--includes/sql.class.php86
-rw-r--r--modules/admin/blocks/functions.php12
-rw-r--r--modules/admin/pages/functions.php19
-rw-r--r--modules/download/index.php8
-rw-r--r--modules/index/index.php43
-rw-r--r--modules/news/functions.php32
-rw-r--r--modules/newsreel/index.php41
-rw-r--r--modules/page/index.php37
-rw-r--r--navigation.php13
26 files changed, 411 insertions, 531 deletions
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);
+
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table>
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 "<table align=\"center\"><tr><th colspan=\"3\">Existing Blocks</th></tr>";
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);
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
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 "<table width=\"100%\">";
$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
?>
<tr>
- <td><strong><?php echo $time." - ".$row['title']; ?></strong></td>
- <td><span style="border:1px solid black;background-color:<?php echo $row['color'];?>;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
+ <td><strong><?php echo $time." - ".$event['title']; ?></strong></td>
+ <td><span style="border:1px solid black;background-color:<?php echo $event['color'];?>;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
<td>
- <a href="?op=calendar&month=<?php echo $_GET['month']; ?>&year=<?php echo $_GET['year']; ?>&edit=<?php echo $row['event_id'];?>">Edit</a>
+ <a href="?op=calendar&month=<?php echo $_GET['month']; ?>&year=<?php echo $_GET['year']; ?>&edit=<?php echo $event['event_id'];?>">Edit</a>
&nbsp;|&nbsp;
- <a href="?op=calendar&delete=<?php echo $row['event_id']; ?>">Delete</a>
+ <a href="?op=calendar&delete=<?php echo $event['event_id']; ?>">Delete</a>
</td>
</tr>
<tr>
- <td><?php echo BBCode($row['text']); ?><br /><br /></td>
+ <td><?php echo BBCode($event['text']); ?><br /><br /></td>
</tr>
<tr>
@@ -116,7 +117,6 @@
</tr>
<?php
}
-
if(!isset($tmp))
echo "<tr><td>There are no events posted for this day.</td></tr>";
@@ -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 "<a href=\"?op=calendar&list={$year}-{$monthNum}-{$day_num}\">";
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 "<table align=\"center\"><tr><th colspan=\"3\">Existing Blocks</th></tr>";
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)
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
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|<br />";
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 "<a href=\"?op=news&edit={$row['news_id']}\">";
- echo "<span class=\"bold\">{$row['title']}</span>&nbsp;|&nbsp;<span class=\"blue\">{$row['catname']}</span>&nbsp;&nbsp;<img src=\"images/page.png\" /></a><br />";
- if(($len = strlen($newsBody))>150)
- echo substr($newsBody, 0, 150)."...";
- else
- echo $newsBody;
- echo '<br />';
- echo "Posted By: {$row['author']} on ".date('D M j, Y g:i a T', strtotime($row['date']));
- echo '<br /><br />';
+ $row = $db->Fetch($result);
+ foreach($row as $news)
+ {
+ $newsBody = $news['message'];
+ echo "<a href=\"?op=news&edit={$row['news_id']}\">";
+ echo "<span class=\"bold\">{$row['title']}</span>&nbsp;|&nbsp;<span class=\"blue\">{$row['catname']}</span>&nbsp;&nbsp;<img src=\"images/page.png\" /></a><br />";
+ if(($len = strlen($newsBody))>150)
+ echo substr($newsBody, 0, 150)."...";
+ else
+ echo $newsBody;
+ echo '<br />';
+ echo "Posted By: {$row['author']} on ".date('D M j, Y g:i a T', strtotime($news['date']));
+ echo '<br /><br />';
}
+
}
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);
?>
<h3>Edit News</h3>
@@ -118,12 +121,22 @@ function EditNews($news_id){
echo "<select name=\"author\">";
$result = $db->Query("SELECT `user_id`, `lastname` FROM `bayonet_users` ORDER BY `username` ASC");
- while(($row = $db->Fetch($result))!= false){
+ $row = $db->Fetch($result);
+ foreach($row as $author)
+ {
+ if($author_id == $author['user_id'])
+ echo "<option value=\"{$author['user_id']}\" selected>{$author['lastname']}</option>";
+ else
+ echo "<option value=\"{$author['user_id']}\">{$author['lastname']}</option>";
+ }
+ /** FIXME
+ while(($row = $db->Fetch($result))!= false){
if($author_id == $row['user_id'])
echo "<option value=\"{$row['user_id']}\" selected>{$row['lastname']}</option>";
else
echo "<option value=\"{$row['user_id']}\">{$row['lastname']}</option>";
}
+ */
echo "</select>";
}
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 "<div id=\"contentLeft\">
+ ?>
+ <div id="contentLeft">
<table>
<tr>
<th>News Reel Order</th>
- <td id=\"updateStatus\"></td>
+ <td id="updateStatus"></td>
</tr>
</table>
- <ul>";
-
+ <ul>
+ <?php
$result = $db->Query("SELECT `title`, `slide_id`, `src` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` ASC");
- while(($row = $db->fetch($result))!= false){
- echo "<li id=\"recordsArray_{$row['slide_id']}\">";
- PrintSlide($row);
- echo "<br /><a href=\"?op=newsreel&disable={$row['slide_id']}\"><input type=\"button\" value=\"Disable\" /></a></li>";
- }
+ $row = $db->Fetch($result);
+
+ foreach($row as $slide){
+ echo "<li id=\"recordsArray_{$slide['slide_id']}\">";
+ PrintSlide($slide);
+ echo "<br /><a href=\"?op=newsreel&disable={$slide['slide_id']}\"><input type=\"button\" value=\"Disable\" /></a></li>";
+ }
?>
</ul>
Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved.
@@ -99,6 +101,11 @@ $(document).ready(function(){
global $db;
echo "Disable: ".$slide_id;
+ $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `slide_id` = '$slide_id' LIMIT 1");
+ $row = $db->Fetch($result);
+ foreach($row as $slide){
+ $oldWeight = $slide['weight'];
+ }
$db->Query("UPDATE `bayonet_newsreel` SET `visible` = 0, `weight` = 0 WHERE `slide_id` = '$slide_id' LIMIT 1");
PageRedirect(0,"?op=newsreel");
}
@@ -107,12 +114,13 @@ $(document).ready(function(){
global $db;
echo "<h3>Disabled Slides</h3>";
- $result = $db->query("SELECT `slide_id`, `title`, `src` FROM `bayonet_newsreel` WHERE `visible` = 0 ORDER BY `slide_id` DESC");
- while(($row = $db->fetch($result))!= false){
-
- echo PrintSlide($row);
- echo "<br /><a href=\"?op=newsreel&enable={$row['slide_id']}\"><input type=\"button\" value=\"Enable\" /></a><br /><br />";
- }
+ $result = $db->Query("SELECT `slide_id`, `title`, `src` FROM `bayonet_newsreel` WHERE `visible` = 0 ORDER BY `slide_id` DESC");
+ $row = $db->Fetch($result);
+
+ foreach($row as $slide){
+ echo PrintSlide($slide);
+ echo "<br /><a href=\"?op=newsreel&enable={$slide['slide_id']}\"><input type=\"button\" value=\"Enable\" /></a><br /><br />";
+ }
}
function PrintSlide($slide){
@@ -125,9 +133,12 @@ $(document).ready(function(){
function GetLastPosition(){
global $db;
- $result = $db->query("SELECT `weight` FROM `bayonet_newsreel` ORDER BY `weight` DESC LIMIT 1");
+ $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1");
$row = $db->Fetch($result);
- return $row['weight'];
+ foreach($row as $slide){
+ $weight = $slide['weight'];
+ }
+ return $weight;
}
diff --git a/admin/newsreel/updateDB.php b/admin/newsreel/updateDB.php
index 904e578..f4031a2 100644
--- a/admin/newsreel/updateDB.php
+++ b/admin/newsreel/updateDB.php
@@ -3,7 +3,7 @@
include '../../includes/debug.php';
include '../../includes/config.php';
include '../../includes/sql.class.php';
-include '../functions.php';
+include '../../includes/functions.php';
$action = $_POST['action'];
$updateRecordsArray = $_POST['recordsArray'];
@@ -22,7 +22,6 @@ if ($action == "updateReelOrder"){
foreach ($updateRecordsArray as $recordIDValue) {
$db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'");
- //mysql_query($query) or die('Error, insert query failed');
$listingCounter = $listingCounter + 1;
}
echo "<img src=\"images/accepted.png\" />";
diff --git a/admin/pages/functions.php b/admin/pages/functions.php
index 15b1f0c..7152546 100644
--- a/admin/pages/functions.php
+++ b/admin/pages/functions.php
@@ -22,52 +22,48 @@
* You MUST declare $db as global inside your functions in order access MySQL from here.
*/
-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;
- }
-
- echo "<table class=\"panelitems\" width=\"100%\" cellspacing=\"0\">";
-
- ?>
+function ListArticles($pageid)
+{
+ global $db;
+ $result = $db->Query("SELECT article_id,title FROM bayonet_articles WHERE `page_id` = $pageid ORDER BY `weight`");
+ $articles = $row = $db->Fetch($result);
+
+ echo "<table class=\"panelitems\" width=\"100%\" cellspacing=\"0\">";
+
+ ?>
<tr>
- <td colspan="3" style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df; border-bottom: 1px solid #848484;">
+ <td colspan="3" style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df; border-bottom: 1px solid #848484;">
<?php echo LinkInternal('<img src="images/add.png" />&nbsp;Add New Article','?op=pages&edit='.$pageid.'&newarticle=true'); ?>
- </td>
+ </td>
</tr>
-
- <?php
+
+ <?php
- if(count($articles)==0){
- echo "<tr><td>No Articles Found.<br /></td></tr></table>";
- return;
- }
- foreach($articles as $article)
- {
- if($_GET['aid'] == $article['article_id'])
- echo '<tr class="highlight">';
- else
- echo '<tr>';
- ?>
-
- <td>^</td>
- <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;">
+ if(count($articles)==0)
+ {
+ echo "<tr><td>No Articles Found.<br /></td></tr></table>";
+ return;
+ }
+
+ foreach($articles as $article)
+ {
+ if($_GET['aid'] == $article['article_id'])
+ echo '<tr class="highlight">';
+ else
+ echo '<tr>';
+ ?>
+
+ <td>^</td>
+ <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;">
<a href="?op=pages&edit=<?php echo $pageid; ?>&aid=<?php echo $article['article_id']?>"><?php echo $article['title']; ?></a>
- </td>
- <td>v</td>
- </tr>
+ </td>
+ <td>v</td>
+ </tr>
- <?php
- }
+ <?php
+ }
echo "</table>";
-
-
-
}
function NewArticle($page_id)
@@ -83,13 +79,13 @@ function NewArticle($page_id)
echo "You must fill everything out before proceeding.";
return;
}
- $weight = 0;
- $result = $db->Query("SELECT * FROM `bayonet_articles` WHERE `page_id` = $page_id ORDER BY `weight` DESC LIMIT 1");
- while(($row = $db->Fetch($result))!=false)
- {
- $weight = $row['weight'];
- }
- $weight++;
+
+ $weight = 0;
+ $result = $db->Query("SELECT * FROM `bayonet_articles` WHERE `page_id` = $page_id ORDER BY `weight` DESC LIMIT 1");
+ $row = $db->Fetch($result);
+
+ $weight = $row['weight'];
+ $weight++;
//Update the database with the new data.
$db->Query("INSERT INTO `bayonet_articles` (`article_id` ,`page_id` ,`title` ,`text`, `weight`)VALUES (NULL , $page_id, '$title', '$text', '$weight')");
@@ -146,12 +142,8 @@ function EditArticle($article_id){
//Grab the page from the database according to the $article_id passed to the function.
$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;
- }
-
+ $article = $db->Fetch($result);
+ $article = $row;
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
@@ -201,23 +193,21 @@ 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->Fetch($result);
- echo "<table class=\"panelitems\" width=\"100%\" cellspacing=\"0\">";
+ echo "<table class=\"panelitems\" width=\"100%\" cellspacing=\"0\">";
- ?>
- <tr>
- <td style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df; border-bottom: 1px solid #848484;">
+ ?>
+ <tr>
+ <td style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df; border-bottom: 1px solid #848484;">
<?php echo LinkInternal('<img src="images/add.png" />&nbsp;Create New Page','?op=pages&create=true'); ?>
- </td>
- </tr>
+ </td>
+ </tr>
- <?php
+ <?php
- if(count($pages)==0){
+ if(count($pages)==0)
+ {
echo "<tr><td>No Pages Found.<br /></td></tr></table>";
return;
}
diff --git a/blocks/donations/index.php b/blocks/donations/index.php
index 4deb5dc..ff77657 100644
--- a/blocks/donations/index.php
+++ b/blocks/donations/index.php
@@ -3,9 +3,8 @@
<center>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
-<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHPwYJKoZIhvcNAQcEoIIHMDCCBywCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYB02pTNLjJ9viE69oKIjYRn9waGeUXDObQnS4UMXyr791TDGSY0ekY9VialPYYHO62fCXnza4lbYuiywVBO7rtmANED7FFTL2MO5pSLpHvhY2RC/gXxId24P8EDg/+oxtlVkW3QxYN9bwGoN+YI7qHyDzBPFOcYg/eWVNuKhSCeazELMAkGBSsOAwIaBQAwgbwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI27H2lXKV0t6AgZhtt2zkaDfgIG2AaAOITZYGnG1+bVRxgjLMPWsFSsKSQbZDCNF4AvE7deOiW96NMHVIJoW6Bd8eBiANNb3C/uMZ4VG+OOMoL5ZUiXrdxDNxdXj39r1V3AvIZQGiXRKXgzohwXsLCSNJTjoYGAf9XKfKjF/O7KHCBkaRM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EAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA5MTIyNjA1MzYxN1owIwYJKoZIhvcNAQkEMRYEFJph1XKiDvpvkS9qivFVa0yEu+5GMA0GCSqGSIb3DQEBAQUABIGAvd2V0F6+dYpeLUS5ygxOYUmgxuo8ORUYcRUp+J/ICWDkOrkJwFI1QfcH1hx9vdQUg1TNdREeovbEZx47T9G7HHVpZTcNCQeQNsz0IpFZTfmQAD71ad3qXQvJyh/ghsE/s9guMO6x5AQ1iQdA5ls928WvpqYx8EFs7fGvKYhrPzI=-----END PKCS7-----
-">
-<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
+<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHPwYJKoZIhvcNAQcEoIIHMDCCBywCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxH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kJwFI1QfcH1hx9vdQUg1TNdREeovbEZx47T9G7HHVpZTcNCQeQNsz0IpFZTfmQAD71ad3qXQvJyh/ghsE/s9guMO6x5AQ1iQdA5ls928WvpqYx8EFs7fGvKYhrPzI=-----END PKCS7-----" />
+<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</center>
diff --git a/blocks/rss_agw/index.php b/blocks/rss_agw/index.php
index 1ecad83..8649582 100644
--- a/blocks/rss_agw/index.php
+++ b/blocks/rss_agw/index.php
@@ -1,80 +1,107 @@
<link rel="stylesheet" type="text/css" href="blocks/rss_agw/style.css" media="screen"/>
-<?php
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-function stripBBCode($text_to_search) {
- $pattern = '|[[\/\!]*?[^\[\]]*?]|si';
- $replace = '';
- return preg_replace($pattern, $replace, $text_to_search);
+// {{{ prerequesists
+
+/**
+ * Check to make sure the cURL extension is available to us
+ */
+if (!extension_loaded('curl')) {
+ $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
+ if (!@dl($prefix . 'curl.' . PHP_SHLIB_SUFFIX)) {
+ trigger_error('Unable to load the PHP cURL extension.', E_USER_ERROR);
+ exit;
+ }
}
- include 'rssreader.php';
-
- $rss = new rss_php;
- $cacheReadLength = 2048;
- $cacheFile = dirname(__FILE__) . "/rss.cache";
- $url = 'http://www.armedglobalwarfare.com/index.php?type=rss;action=.xml;limit=150';
-
- if(!file_exists($cacheFile))
- {
- decho("Creating RSS cache");
- $fp = fopen($cacheRead, "x+");
- fclose($fp);
- }
-
- decho("Reading internal RSS cache state");
- $internal = fopen($cacheFile, "r");
- $cacheRead = fread($internal, $cacheReadLength);
- decho(strlen($cacheRead) . " bytes read");
- fclose($internal);
-
- decho("Reading inbound RSS cache data");
- $inbound = fopen($url, "r");
- $cacheTempRead = fread($inbound, $cacheReadLength);
- decho(strlen($cacheTempRead) . " bytes downloaded");
- fclose($inbound);
-
- decho("Comparing RSS caches");
- if((strncmp($cacheTempRead, $cacheRead, $cacheReadLength)) != 0)
- {
- decho("Downloading updated RSS feed");
- $cacheTemp = implode('', file($url));
- decho("Length of updated RSS is " . strlen($cacheTemp));
- decho("Writing cached RSS data to file");
- $cachefp = fopen($cacheFile, "w+");
- $cacheWritten = fwrite($cachefp, $cacheTemp, strlen($cacheTemp));
- fclose($cachefp);
- decho("$cacheWritten bytes written to RSS cache");
- }
- else
- {
- decho("RSS cache matches external source, using internal");
- }
- decho("Loading RSS cache into aggregator");
- $rss->load($cacheFile);
-
- $items = $rss->getItems(); #returns all rss items
-
- $numFeeds = 0;
- echo "<div class=\"rss\" >";
- foreach($items as $story){
- if($story['category']=="Tournament Announcements"){
- $numFeeds++;
- //$text = $story['description'];
- //$text = strip_tags($text);
- //$text = preg_replace("(\[font(.+?)...)","", $text);
- //$text = stripBBCode($text);
-
- echo "<a href=\"{$story['link']}\" target=\"_blank\"><span class=\"title\">{$story['title']}</span></a><br />
- <span class=\"date\">{$story['pubDate']}</span><br />";
- //echo "{$text}<br /><br />";
- echo "<br /><hr />";
- }
+// {{{ constants
+
+/**
+ * Armed Global Warfare Feed
+ */
+define('AGW_FEED', 'http://www.armedglobalwarfare.com/index.php?type=rss;action=.xml;limit=150');
+
+/**
+ * Cache File
+ */
+define('AGW_CACHE', dirname(__FILE__) . '/rss_cache.xml');
+define('AGW_AGE_CACHE', time() - 3600);
+
+/**
+ * Feed Variables
+ */
+$agwFeed = array();
+$agwXml = null;
+$agwProcess = true;
+
+// }}}
+
+// {{{ main
+
+/**
+ * Check existance of cache
+ */
+if (file_exists(AGW_CACHE) && (filectime(AGW_CACHE) > AGW_AGE_CACHE)) {
+ $agwFeed = simplexml_load_file(AGW_CACHE);
+ $agwProcess = false;
+}
+
+/**
+ * If we don't have a cache then we'll need to build one
+ */
+if ($agwProcess === true) {
+ /**
+ * Set up global options for cURL to utilize for the transfer.
+ */
+ $options = array(CURLOPT_FORBID_REUSE => true,
+ CURLOPT_POST => false,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_TIMEOUT => 15,
+ CURLOPT_USERAGENT => 'Mozilla/5.0 (Compatible; libCURL)',
+ CURLOPT_VERBOSE => false);
+
+ /**
+ * Initialize cURL
+ */
+ $agwFeedSource = curl_init(AGW_FEED);
+ curl_setopt_array($agwFeedSource, $options);
+
+ /**
+ * Execute cURL container and store the output
+ */
+ $agwFeedOutput = curl_exec($agwFeedSource);
+
+ /**
+ * Parse the received data
+ */
+
+ if (!curl_errno($agwFeedSource)) {
+ $agwFeed = simplexml_load_string($agwFeedOutput);
+ $agwXml = new SimpleXMLElement($agwFeedOutput);
+
+ file_put_contents(AGW_CACHE, $agwXml->asXML(), LOCK_EX);
+ curl_close($agwFeedSource);
}
- if(!$numFeeds){
- echo "No new updates for this news feed.";
+ else {
+ curl_close($agwFeedSource);
}
- echo "</div>";
- // echo "<pre>";
- //print_r($items);
- // echo "</pre>";
-?>
+
+ /**
+ * Check to make sure the results are not empty before proceeding.
+ */
+ if (empty($agwFeed) || !is_object($agwFeed)) $agwFeed = array();
+}
+
+/**
+ * Process output
+ */
+foreach ($agwFeed->channel->item as $item) {
+ if ($item->category != 'Tournament Announcements') continue;
+
+ echo '<a href="' . $item->link . '" onclick="javascript:window.open(this.href, \'_blank\'); return false;">' .
+ '<span class="title">' . $item->title . '</span></a><br />' .
+ '<span class="date">' . $item->pubDate . '</span><br /><br /><hr />' . PHP_EOL;
+}
+// }}}
+?>
diff --git a/blocks/rss_agw/rssreader.php b/blocks/rss_agw/rssreader.php
deleted file mode 100644
index 41fa238..0000000
--- a/blocks/rss_agw/rssreader.php
+++ /dev/null
@@ -1,161 +0,0 @@
-<?php
-/*
- RSS_PHP - the PHP DOM based RSS Parser
- Author: <rssphp.net>
- Published: 200801 :: blacknet :: via rssphp.net
-
- RSS_PHP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
-
- Usage:
- See the documentation at http://rssphp.net/documentation
- Examples:
- Can be found online at http://rssphp.net/examples
-*/
-
-class rss_php {
-
- public $document;
- public $channel;
- public $items;
-
-/****************************
- public load methods
-***/
- # load RSS by URL
- public function load($url=false, $unblock=true) {
- if($url) {
- if($unblock) {
- $this->loadParser(file_get_contents($url, false, $this->randomContext()));
- } else {
- $this->loadParser(file_get_contents($url));
- }
- }
- }
- # load raw RSS data
- public function loadRSS($rawxml=false) {
- if($rawxml) {
- $this->loadParser($rawxml);
- }
- }
-
-/****************************
- public load methods
- @param $includeAttributes BOOLEAN
- return array;
-***/
- # return full rss array
- public function getRSS($includeAttributes=false) {
- if($includeAttributes) {
- return $this->document;
- }
- return $this->valueReturner();
- }
- # return channel data
- public function getChannel($includeAttributes=false) {
- if($includeAttributes) {
- return $this->channel;
- }
- return $this->valueReturner($this->channel);
- }
- # return rss items
- public function getItems($includeAttributes=false) {
- if($includeAttributes) {
- return $this->items;
- }
- return $this->valueReturner($this->items);
- }
-
-/****************************
- internal methods
-***/
- private function loadParser($rss=false) {
- if($rss) {
- $this->document = array();
- $this->channel = array();
- $this->items = array();
- $DOMDocument = new DOMDocument;
- $DOMDocument->strictErrorChecking = false;
- $DOMDocument->loadXML($rss);
- $this->document = $this->extractDOM($DOMDocument->childNodes);
- }
- }
-
- private function valueReturner($valueBlock=false) {
- if(!$valueBlock) {
- $valueBlock = $this->document;
- }
- foreach($valueBlock as $valueName => $values) {
- if(isset($values['value'])) {
- $values = $values['value'];
- }
- if(is_array($values)) {
- $valueBlock[$valueName] = $this->valueReturner($values);
- } else {
- $valueBlock[$valueName] = $values;
- }
- }
- return $valueBlock;
- }
-
- private function extractDOM($nodeList,$parentNodeName=false) {
- $itemCounter = 0;
- foreach($nodeList as $values) {
- if(substr($values->nodeName,0,1) != '#') {
- if($values->nodeName == 'item') {
- $nodeName = $values->nodeName.':'.$itemCounter;
- $itemCounter++;
- } else {
- $nodeName = $values->nodeName;
- }
- $tempNode[$nodeName] = array();
- if($values->attributes) {
- for($i=0;$values->attributes->item($i);$i++) {
- $tempNode[$nodeName]['properties'][$values->attributes->item($i)->nodeName] = $values->attributes->item($i)->nodeValue;
- }
- }
- if(!$values->firstChild) {
- $tempNode[$nodeName]['value'] = $values->textContent;
- } else {
- $tempNode[$nodeName]['value'] = $this->extractDOM($values->childNodes, $values->nodeName);
- }
- if(in_array($parentNodeName, array('channel','rdf:RDF'))) {
- if($values->nodeName == 'item') {
- $this->items[] = $tempNode[$nodeName]['value'];
- } elseif(!in_array($values->nodeName, array('rss','channel'))) {
- $this->channel[$values->nodeName] = $tempNode[$nodeName];
- }
- }
- } elseif(substr($values->nodeName,1) == 'text') {
-
- $tempValue = trim(preg_replace('/\s\s+/',' ',str_replace("\n",' ', $values->textContent)));
- if($tempValue) {
- $tempNode = $tempValue;
- }
- } elseif(substr($values->nodeName,1) == 'cdata-section'){
- $tempNode = $values->textContent;
- }
- }
- return $tempNode;
- }
-
- private function randomContext() {
- $headerstrings = array();
- $headerstrings['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.'.rand(0,2).'; en-US; rv:1.'.rand(2,9).'.'.rand(0,4).'.'.rand(1,9).') Gecko/2007'.rand(10,12).rand(10,30).' Firefox/2.0.'.rand(0,1).'.'.rand(1,9);
- $headerstrings['Accept-Charset'] = rand(0,1) ? 'en-gb,en;q=0.'.rand(3,8) : 'en-us,en;q=0.'.rand(3,8);
- $headerstrings['Accept-Language'] = 'en-us,en;q=0.'.rand(4,6);
- $setHeaders = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'."\r\n".
- 'Accept-Charset: '.$headerstrings['Accept-Charset']."\r\n".
- 'Accept-Language: '.$headerstrings['Accept-Language']."\r\n".
- 'User-Agent: '.$headerstrings['User-Agent']."\r\n";
- $contextOptions = array(
- 'http'=>array(
- 'method'=>"GET",
- 'header'=>$setHeaders
- )
- );
- return stream_context_create($contextOptions);
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/includes/debug.php b/includes/debug.php
index c67ee9c..2f6e40a 100644
--- a/includes/debug.php
+++ b/includes/debug.php
@@ -33,13 +33,13 @@ static $log_message_pos = 0;
function decho($message, $force = false)
{
global $log_message_last, $log_message_queue, $log_message_pos, $config;
- /*
+
if($force == false)
{
if($config['debug']['enabled'] == false ||
$config['debug']['show_messages'] == false) return;
}
- */
+
date_default_timezone_set($config['logs']['timezone']);
$timestamp = date('H:i:s T');
diff --git a/includes/functions.php b/includes/functions.php
index f0fe60e..bc169ff 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -301,10 +301,10 @@ if(!defined("CALLED_FROM_ADMIN"))
* Begins a Bayonet site table.
* @return
*/
- function OpenTable()
+ function OpenTable($width = "100%")
{
//width="100%" is important. Otherwise all of our tables will be text width.
- echo "<table width=\"100%\" align=\"center\" class=\"cleartable\">\n";
+ echo "<table width=\"{$width}\" align=\"center\" class=\"cleartable\">\n";
}
/**
@@ -314,7 +314,7 @@ if(!defined("CALLED_FROM_ADMIN"))
*/
function CloseTable()
{
- //echo "</table>";
+ echo "</table>";
}
/**
@@ -412,6 +412,19 @@ function ReportHack($message)
CloseTable();
}
+/**
+ * PageRedirect()
+ *
+ * performs an http redirect
+ *
+ * @param $delay
+ * @param $link
+ */
+function PageRedirect($delay, $link)
+{
+ echo "<meta http-equiv=\"Refresh\" content=\"{$delay};url={$link}\">";
+}
+
/**
* array_dump()
@@ -588,11 +601,8 @@ function GetBlocks($position = BLOCK_LEFT)
$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);
+ $blocks[] = $row;
foreach($blocks as $block)
{
diff --git a/includes/sql.class.php b/includes/sql.class.php
index 0dcd0d5..3b93e2a 100644
--- a/includes/sql.class.php
+++ b/includes/sql.class.php
@@ -33,51 +33,38 @@ class Bayonet_SQL
$this->hostname = $hostname;
decho("Connecting ('$hostname')");
- return mysql_connect($hostname, $username, $passwd);
+ return ($GLOBALS['___mysqli_ston'] = mysqli_connect($hostname, $username, $passwd));
}
public function Disconnect($link)
{
decho("Disconnecting ('$link' from '$this->hostname')");
- //return mysql_close($link);
+ return mysqli_close($GLOBALS['___mysqli_ston']);
}
public function Stat()
{
- return mysql_stat();
+ return mysqli_stat($GLOBALS['___mysqli_ston']);
}
public function Select_db($db)
{
decho("Selecting database ('$db')");
- return mysql_select_db($db);
+ return mysqli_select_db($GLOBALS['___mysqli_ston'], $db);
}
public function Query($str)
{
global $db_queries;
++$db_queries;
- //FIGURE OUT HOW TO CHECK EXCEPTION, TRY CATCH ???
- // if(!mysql_query($str))
- // {
- // throw new Exception(mysql_error());
- // }
- /*
- try{
-
- }catch(Exception $e){
-
- } */
-
- return mysql_query($str);
+ return mysqli_query($GLOBALS['___mysqli_ston'], $str);
}
public function Free($result)
{
global $db_frees;
++$db_frees;
- decho("Freeing result");
- return mysql_free_result($result);
+ @((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false);
}
public function Fetch($result)
@@ -85,42 +72,65 @@ class Bayonet_SQL
return $this->FetchArray($result);
}
- public function FetchArray($result)
- {
- global $db_fetches;
- ++$db_fetches;
- /* Alias Fetch() prefered, so no decho information */
- decho("Fetching result");
- return mysql_fetch_array($result,MYSQL_ASSOC);
- }
+ public function FetchArray($p_result)
+ {
+ global $db_fetches;
+ ++$db_fetches;
+
+ decho('Fetching result');
+
+ while ($row = mysqli_fetch_array($p_result, MYSQLI_ASSOC)) {
+ $result[] = $row;
+ }
+
+ $this->Free($p_result);
+
+ return is_array($result) ? $result : array();
+ }
- public function FetchObject($result,$class)
+ public function FetchObject($p_result, $class)
{
global $db_fetches;
++$db_fetches;
+
decho("Fetching object result");
- return mysql_fetch_object($result,$class);
+
+ while ($row = mysqli_fetch_object($p_result, $class)) {
+ (object)$result[] = $row;
+ }
+
+ $this->Free($p_result);
+
+ return is_object($result) ? $result : (object)array();
}
public function FetchAssoc($result)
- {
- global $db_fetches;
- ++$db_fetches;
- decho("Fetching assoc result");
- return mysql_fetch_assoc($result);
+ {
+ return $this->FetchArray($result);
}
- public function FetchRow($result)
+ public function FetchRow($p_result)
{
+ global $db_fetches;
+ ++$db_fetches;
+
decho("Fetching single row");
- return mysql_fetch_row($result);
+
+ while ($row = mysqli_fetch_row($p_result)) {
+ $result[] = $row;
+ }
+
+ $this->Free($p_result);
+
+ return is_array($result) ? $result : array();
}
public function Rows($result)
{
decho("Fetching number of rows");
- return mysql_num_rows($result);
+
+ return mysqli_num_rows($result);
}
}
-?> \ No newline at end of file
+?>
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">-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-&nbsp;-</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&amp;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
+?>
diff --git a/navigation.php b/navigation.php
index ecf1236..5765712 100644
--- a/navigation.php
+++ b/navigation.php
@@ -14,10 +14,11 @@
<?php
$result = $db->Query("SELECT * FROM `bayonet_navigation` ORDER BY `weight`");
- while(($row = $db->Fetch($result))!==false)
- {
- echo '<td>&nbsp;&nbsp;<a href="'.$row['link'].'">'.strtoUpper($row['title']).'</a>&nbsp;&nbsp;</td>';
- }
-?>
+ $nav = $db->Fetch($result);
+
+ foreach ($nav as $link) {
+ echo '<td>&nbsp;&nbsp;<a href="' . str_replace('&', '&amp;', $link['link']) . '">' . strtoupper($link['title']) . '</a>&nbsp;&nbsp;</td>';
+ }
+ ?>
</tr>
-</table> \ No newline at end of file
+</table>