aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/admin_functions.php7
-rw-r--r--admin/admins/functions.php4
-rw-r--r--admin/announcements/functions.php11
-rw-r--r--admin/blocks/functions.php4
-rw-r--r--admin/newsreel/functions.php37
-rw-r--r--includes/functions.php2
-rw-r--r--includes/sql.class.php4
-rw-r--r--index.php2
8 files changed, 43 insertions, 28 deletions
diff --git a/admin/admin_functions.php b/admin/admin_functions.php
index 83392a1..95c2aa5 100644
--- a/admin/admin_functions.php
+++ b/admin/admin_functions.php
@@ -50,8 +50,8 @@ function login()
$password = crypt(md5($password),'iamnotadirtywhorebitch');
$result = $db->Query("SELECT * FROM bayonet_users WHERE username = '$username' AND password = '$password' LIMIT 1");
$rows = $db->Rows($result);
- $row = $db->Fetch($result);
-
+ $row = $db->FetchRow($result);
+
if($rows > 0)
{
$_SESSION['username'] = stripslashes($username);
@@ -64,7 +64,8 @@ function login()
ReportError("Login incorrect.");
//NOT CORRECT LOGIN, DEFAULT TO LOGIN PAGE
- echo "<meta http-equiv=\"Refresh\" content=\"1;url=index.php\">";
+ //echo "<meta http-equiv=\"Refresh\" content=\"1;url=index.php\">";
+ PageRedirect(1, "index.php");
return false;
}
diff --git a/admin/admins/functions.php b/admin/admins/functions.php
index 563b507..6cda0c4 100644
--- a/admin/admins/functions.php
+++ b/admin/admins/functions.php
@@ -252,8 +252,8 @@
}
$result = $db->Query("SELECT * FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1");
- $admin = $db->fetch($result);
-
+ $admin = $db->FetchRow($result);
+
if($maxLevel < $admin['level']){
ReportError("You do not have permission to access this user.");
return;
diff --git a/admin/announcements/functions.php b/admin/announcements/functions.php
index 917e342..f45a7e3 100644
--- a/admin/announcements/functions.php
+++ b/admin/announcements/functions.php
@@ -26,7 +26,7 @@ function EditAnnouncements()
{
global $db;
- if(isset($_POST['announcementprocessed']))
+ if(isset($_POST['processed']))
{
//Secure our data to prevent injection attacks.
$title = addslashes($_POST['title']);
@@ -43,7 +43,7 @@ function EditAnnouncements()
<a href=\"?op=announcements\">Click here if you don't feel like waiting.</a>";
// 3 second redirect to go back to the edit page
- echo "<meta http-equiv=\"Refresh\" content=\"3;url=?op=announcements\">";
+ PageRedirect(2, "?op=announcements");
//die, because we have completed what we wanted to do.
return;
@@ -52,15 +52,14 @@ 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");
- /** FIXME - this probably broke. */
- $announcement = $db->Fetch($result);
+ $announcement = $db->FetchRow($result);
?>
- <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
+ <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr><td>Announcement Title: <input type="text" name="title" value="<?php echo $announcement['title'] ?>" maxlength="50" size="30" /> </td></tr>
<tr><td> <textarea id="markItUp" rows="30" cols="80" name="text"><?php echo $announcement['text'] ?></textarea> </td></tr>
- <tr><td> <input type="submit" name="announcementprocessed" value="Submit Changes" /> </td></tr>
+ <tr><td> <input type="submit" name="processed" value="Submit Changes" /> </td></tr>
</table>
</form>
<?php
diff --git a/admin/blocks/functions.php b/admin/blocks/functions.php
index aaa7f36..5194357 100644
--- a/admin/blocks/functions.php
+++ b/admin/blocks/functions.php
@@ -119,8 +119,8 @@ 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'");
- $block = $db->FetchRow($result);
-
+ $block = $db->FetchRow($result);
+
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
<table align="center">
diff --git a/admin/newsreel/functions.php b/admin/newsreel/functions.php
index 9dece93..6bde17c 100644
--- a/admin/newsreel/functions.php
+++ b/admin/newsreel/functions.php
@@ -55,6 +55,9 @@ $(document).ready(function(){
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+ define(MAX_SLIDES, 6);
+
function EditOrder(){
global $db;
@@ -87,7 +90,7 @@ $(document).ready(function(){
global $db;
$lastspot = GetLastPosition();
- if($lastspot >= 6){
+ if($lastspot >= MAX_SLIDES){
ReportError("There are already 6 active slides. You must disable one in order to enable another.");
PageRedirect(3,"?op=newsreel");
return;
@@ -100,12 +103,20 @@ $(document).ready(function(){
function DisableSlide($slide_id){
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'];
- }
+ $slide = $db->FetchRow($result);
+
+ $oldWeight = $slide['weight'];
+
+ if($oldWeight < MAX_SLIDES){
+ $total = getNumOfActive();
+ for($i=$oldWeight+1; $i<=$total; $i++){
+ //echo "Change Weight:".$i." to ".($i-1)."<br />";
+ $new = $i-1;
+ $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$new' WHERE `weight` = '$i' LIMIT 1");
+ }
+ }
+
$db->Query("UPDATE `bayonet_newsreel` SET `visible` = 0, `weight` = 0 WHERE `slide_id` = '$slide_id' LIMIT 1");
PageRedirect(0,"?op=newsreel");
}
@@ -134,11 +145,15 @@ $(document).ready(function(){
global $db;
$result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1");
- $row = $db->Fetch($result);
- foreach($row as $slide){
- $weight = $slide['weight'];
- }
- return $weight;
+ $row = $db->FetchRow($result);
+
+ return $row['weight'];
+ }
+
+ function getNumOfActive(){
+ global $db;
+ $result = $db->Query("SELECT `slide_id` FROM `bayonet_newsreel` WHERE `visible` = 1");
+ return $db->Rows($result);
}
diff --git a/includes/functions.php b/includes/functions.php
index bc169ff..4db70c5 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -469,7 +469,7 @@ define('BAYONET_LOG_ERROR','bayonet_log_error');
define('BAYONET_LOG_WARN','bayonet_log_warn');
define('BAYONET_LOG_INFO','bayonet_log_info');
-function WriteLog($message,$flag)
+function WriteLogBayonet($message,$flag)
{
global $config;
$enabled = $config['logs']['enabled'];
diff --git a/includes/sql.class.php b/includes/sql.class.php
index 3b93e2a..2bdb996 100644
--- a/includes/sql.class.php
+++ b/includes/sql.class.php
@@ -116,8 +116,8 @@ class Bayonet_SQL
decho("Fetching single row");
- while ($row = mysqli_fetch_row($p_result)) {
- $result[] = $row;
+ while ($row = mysqli_fetch_assoc($p_result)) {
+ $result = $row;
}
$this->Free($p_result);
diff --git a/index.php b/index.php
index e2d34ed..855fcee 100644
--- a/index.php
+++ b/index.php
@@ -70,4 +70,4 @@ catch(Exception $e)
"<style>td.short{width:100%;}</style><table style=\"width:0;\"><tr><th>Code</th>" . "<td class=\"short\">" . $e->getCode() . "</td>" . "</tr><tr><th>In File</th>" . "<td class=\"short\">" . $e->getFile() . "</td>" . "</tr></table>" . $e->getLine() . " - " . $e->getMessage() . "<br/>"
);
}
-?> \ No newline at end of file
+?>