diff options
-rw-r--r-- | admin/admins/functions.php | 34 | ||||
-rw-r--r-- | admin/index.php | 4 | ||||
-rw-r--r-- | admin/news/functions.php | 25 | ||||
-rw-r--r-- | admin/news/index.php | 7 | ||||
-rw-r--r-- | admin/newsreel/index.php | 1 | ||||
-rw-r--r-- | admin/pages/functions.php | 53 | ||||
-rw-r--r-- | footer.php | 14 | ||||
-rw-r--r-- | includes/debug.php | 4 | ||||
-rw-r--r-- | modules/index/index.php | 7 | ||||
-rw-r--r-- | modules/news/functions.php | 2 |
10 files changed, 93 insertions, 58 deletions
diff --git a/admin/admins/functions.php b/admin/admins/functions.php index 413c0fe..68b9bc7 100644 --- a/admin/admins/functions.php +++ b/admin/admins/functions.php @@ -69,16 +69,22 @@ if(isset($_POST['processed'])){
$username = addslashes($_POST['username']);
- $level = addslashes($_POST['level']);
$email = addslashes($_POST['email']);
$first = addslashes($_POST['first']);
$last = addslashes($_POST['last']);
-
+
+ $level = $_POST['level'];
$all = $_POST['all'];
$squadleader = $_POST['squadleader'];
$adjutant = $_POST['adjutant'];
$quartermaster = $_POST['quartermaster'];
+ $level = (int)$level;
+ $all = (int)$all;
+ $squadleader = (int)$squadleader;
+ $adjutant = (int)$adjutant;
+ $quartermaster = (int)$quartermaster;
+
$password = GeneratePassword(8);
$cryptpassword = crypt(md5($password),'iamnotadirtywhorebitch');
@@ -88,28 +94,32 @@ return;
}
+ $result = $db->Query("SELECT `level` FROM `bayonet_users` WHERE `username` = '$username' OR `email` = '$email'");
+ if($db->Rows($result) > 0){
+ ReportError("The email and or username you entered is already in use.");
+ return;
+ }
+
+
$Name = "Rocky the Marne Dog";
$subject = "3rd ID Admin Password";
$header = "From: ". $Name . " < DO NOT RESPOND >\r\n"; //optional headerfields
$mail_body = "Do not respond to this email.\n\n------------------------------\nUsername: ".$username."\nPassword: ".$password."\n------------------------------\n\nTo login click on this link. http://testbed.3rd-infantry-division.org/cms/admin/ \n\nIt is recommended that you change your password once you login. To do so, click on Account Settings>Change Password.";
- //$sent = mail($email, $subject, $mail_body, $header);
+ $sent = mail($email, $subject, $mail_body, $header);
if(!$sent){
ReportError("Error validating email. This user was not saved.");
- //return;
- }
+ return;
+ }
- // $db->Query("INSERT INTO `bayonet_users` (`user_id` ,`username` ,`password` ,`lastname` ,`firstname` ,`email` ,`joined` ,`level` ,`all` ,`squadleader` ,`adjutant` ,`quartermaster`) VALUES (NULL, '$username', '$cryptpassword', '$last', '$first', '$email', '', $level, $all, $squadleader, $adjutant, $quartermaster)");
-
- $db->Query("INSERT INTO `bayonet_users` SET `username` = '$username'");
-
-
+ $db->Query("INSERT INTO `bayonet_users` (`user_id` ,`username` ,`password` ,`lastname` ,`firstname` ,`email` ,`joined` ,`level` ,`all` ,`squadleader` ,`adjutant` ,`quartermaster`) VALUES (NULL, '$username', '$cryptpassword', '$last', '$first', '$email', CURRENT_TIMESTAMP, $level, $all, $squadleader, $adjutant, $quartermaster)");
+
echo "Admin, '$username' level '$level' has been added. An email has been sent to him with his username and password.\n <br /><br />
Please wait while you are redirected. <br /><br />
<a href=\"?op=admins\">Click here if you don't feel like waiting.</a>";
// 3 second redirect to go back to the edit page
- //PageRedirect(2, "?op=admins");
+ PageRedirect(2, "?op=admins");
return;
}
?>
@@ -300,7 +310,7 @@ if(isset($_POST['cancel']))
{
echo "User cancelled deletion of admin: '{$admin['username']}'";
- PageRedirect(3,"?op=admins");
+ PageRedirect(1,"?op=admins");
return;
}
?>
diff --git a/admin/index.php b/admin/index.php index feed2ca..fea8112 100644 --- a/admin/index.php +++ b/admin/index.php @@ -57,8 +57,8 @@ include 'header.php'; ?> <center> - <div class="content"> - + <div class="content"> + <table width="100%"> <tr> <td><a href="index.php"><img src="images/bayonet_logo.jpg" alt="bayonet online web admin" /></a></td> diff --git a/admin/news/functions.php b/admin/news/functions.php index f98c4e2..1f9e34a 100644 --- a/admin/news/functions.php +++ b/admin/news/functions.php @@ -16,6 +16,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +date_default_timezone_set("America/New_York"); +function ListNews(){ + + global $db; + + $result = $db->Query("SELECT n.news_id, n.title, n.message, n.date, n.category_id, u.username AS author, c.name AS catname, c.image AS catimage ". + "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> | <span class=\"blue\">{$row['catname']}</span> <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 />'; + } +} function EditNews($news_id){ @@ -31,7 +54,7 @@ function EditNews($news_id){ $row = $db->Fetch($result); ?> - <h3>Edit Event</h3> + <h3>Edit News</h3> <form action="<?php $_SERVER['PHP_SELF']?>" method="post"> <table> <tr><th>Author</th><td><?php SelectAuthor($row['author_id']); ?></td></tr> diff --git a/admin/news/index.php b/admin/news/index.php index 43baf81..ec78089 100644 --- a/admin/news/index.php +++ b/admin/news/index.php @@ -19,7 +19,8 @@ ?> <div style="text-align:left;"><h2>- Manage News</h2></div> - -Everything needs to be completed. + -Add/Edit(-)/Delete news + -Add/Edit/Delete categories <?php if(!defined("ADMIN_FILE")) @@ -36,6 +37,10 @@ if(isset($_GET['edit'])){ $news_id = $_GET['edit']; EditNews($news_id); } +else{ + ListNews(); +} + ?> diff --git a/admin/newsreel/index.php b/admin/newsreel/index.php index 35bed28..0b97deb 100644 --- a/admin/newsreel/index.php +++ b/admin/newsreel/index.php @@ -25,6 +25,7 @@ if(!defined("ADMIN_FILE")) include $basedir.'newsreel/functions.php';
?>
<div style="text-align:left;"><h2>- Manage News Reel</h2></div>
+ -Add/Edit/Delete needs to be completed.
<table class="panel" width="100%">
<tr>
<td class="panel"><?php EditOrder(); ?></td>
diff --git a/admin/pages/functions.php b/admin/pages/functions.php index 3f8f59f..c4d4369 100644 --- a/admin/pages/functions.php +++ b/admin/pages/functions.php @@ -111,6 +111,11 @@ function NewArticle($page_id) <?php } + /** + * EditArticle($article_id) + * Edits an article for a page + * @param id - article_id cooresponding to `bayonet_articles` + */ function EditArticle($article_id){ global $db; @@ -166,14 +171,14 @@ function DeleteArticle($article_id) { global $db; - $result = $db->Query("SELECT title FROM bayonet_articles WHERE article_id = '$article_id'"); + $result = $db->Query("SELECT `title` FROM `bayonet_articles` WHERE `article_id` = '$article_id'"); $article = $db->Fetch($result); if(isset($_POST['proceed'])) { echo "Article '{$article['title']}', was deleted."; $db->Query("DELETE FROM bayonet_articles WHERE article_id = '$article_id' LIMIT 1"); - PageRedirect(2, "?op=pages"); + PageRedirect(2, "?op=pages&edit={$_GET['edit']}"); return; } if(isset($_POST['cancel'])) @@ -219,48 +224,42 @@ function ListPages($pid = NULL) foreach($pages as $page) { - if($pid == $page['page_id']) + $edit = false; + if($pid == $page['page_id']){ + $edit = true; echo '<tr class="highlight">'; - else + }else echo '<tr>'; ?> <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;"> - <a href="?op=pages&edit=<?php echo $page['page_id']?>"><?php echo $page['title']; ?></a> + <a href="?op=pages&edit=<?php echo $page['page_id']?>"> + <img src="images/page.png" /> + <?php echo $page['title']; ?> + </a> </td> </tr> - - <?php - } - ?> -<!-- - <tr style="vertical-align:bottom; background-color:green; text-overflow:ellipsis; overflow:hidden;"> - <td> - <table class="panelitems"> - <tr><td> - <?php echo LinkInternal('<img src="images/add.png" /> Create New Page','?op=pages&create=true'); ?> <br /> - <?php echo LinkInternal('<img src="images/view.png" /> View this Page','../index.php?load=page&id='.$page_id); ?> <br /> - <?php echo LinkInternal('<img src="images/cancel.png" /> Delete this Page','?op=pages&delete='.$page_id); ?> <br /> - </td></tr> - </table> - <td> - </tr> --> -<?php - if(isset($_GET['edit'])){ - ?> - +<?php + if($edit){ +?> <tr> - <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;"> + <td style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df;"> <?php echo LinkInternal('<img src="images/view.png" /> View this Page','../index.php?load=page&id='.$pid.'" target=\"blank'); ?> </td> </tr> <tr> - <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;"> + <td style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df;"> + <?php echo LinkInternal('<img src="images/pencil.png" /> Edit this Page','?op=pages&edit=true&pid='.$pid); ?> + </td> + </tr> + <tr> + <td style="text-align:center; text-overflow:ellipsis; overflow:hidden; background-color:#dfe4df;"> <?php echo LinkInternal('<img src="images/cancel.png" /> Delete this Page','?op=pages&delete='.$pid); ?> </td> </tr> <?php } + } echo "</table>"; } @@ -24,15 +24,11 @@ $debug_output = sprintf("Page generated in %.3f seconds | Memory: real(%.3fmb) p $totaltime, ((float)memory_get_usage()/1024/1024), ((float)memory_get_peak_usage()/1024/1024), $phpversion, $db_queries, $db_fetches); ?> -<? if($config['debug']['enabled']): ?> - -<div class="content"> - - <div style="background:white;"> - <?php logQueueFlush(); ?> - </div> -</div> -<? endif ?> +<?php + if($config['debug']['enabled']){ + logQueueFlush(); + } +?> <div class="footer"> diff --git a/includes/debug.php b/includes/debug.php index 516573d..c50e016 100644 --- a/includes/debug.php +++ b/includes/debug.php @@ -85,6 +85,7 @@ function logQueueFlush() static $log_message_last_count = 0; static $next = false; + OpenTable(); echo "<div class=\"contentHeading\">Bayonet Debug Messages</div>"; echo "<div class=\"content\">"; foreach($log_message_queue as $message) @@ -120,7 +121,8 @@ function logQueueFlush() ++$messageCount; } - echo "</div>"; + echo "</div></div>"; + CloseTable(); } /* diff --git a/modules/index/index.php b/modules/index/index.php index fd1eef1..b7554b7 100644 --- a/modules/index/index.php +++ b/modules/index/index.php @@ -11,14 +11,13 @@ <?php - $result = $db->Query("SELECT `index_modules` FROM `bayonet_settings` WHERE `title` = 'Default'"); + + $result = $db->Query("SELECT `dir_name` FROM `bayonet_modules` ORDER BY `weight` ASC"); while(($row = $db->Fetch($result))!==false) { - $indexModules = $row['index_modules']; + $indexModules[] = $row['dir_name']; } - $indexModules = explode(',',$indexModules); - foreach($indexModules as $module) { if(file_exists("modules/" . $module)) diff --git a/modules/news/functions.php b/modules/news/functions.php index 66c8b68..ee4345d 100644 --- a/modules/news/functions.php +++ b/modules/news/functions.php @@ -184,7 +184,7 @@ function displayNews($data){ <td style="text-align:left;"> View Comments: <a href="?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 H:i a T', strtotime($news['date'])); ?></td> + <td style="text-align:right;">Posted on: <?php echo date('D M j, Y g:i a T', strtotime($news['date'])); ?></td> </tr> </table> </div> |