diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2011-04-17 20:13:07 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2011-04-17 20:13:07 -0400 |
commit | 0077cb99704fe863cf731fc5cab792af2ede96c2 (patch) | |
tree | dd68f44971aa2aee821f588d33b250dcd2fe57e3 /admin | |
parent | e8b28c5e910d92cbec3d4baa6e98f025e8418d28 (diff) | |
download | bayonetcms-0077cb99704fe863cf731fc5cab792af2ede96c2.tar.gz |
Backporting retarded amount of changes outside of version control
Diffstat (limited to 'admin')
45 files changed, 3031 insertions, 2487 deletions
diff --git a/admin/adjutant/functions.php b/admin/adjutant/functions.php index 57e9fe8..87bc4b4 100644 --- a/admin/adjutant/functions.php +++ b/admin/adjutant/functions.php @@ -21,7 +21,7 @@ global $db; - $result = $db->Query("SELECT * FROM `rudi_unit_members` JOIN `rudi_ranks` ON rudi_unit_members.rank_id=rudi_ranks.rank_id WHERE rudi_unit_members.status_id != 4 AND rudi_unit_members.status_id != 5 ORDER BY rudi_ranks.weight DESC , rudi_unit_members.date_promotion ASC , rudi_unit_members.date_enlisted ASC"); + $result = $db->Query("SELECT * FROM `rudi_unit_members` JOIN `rudi_ranks` ON rudi_unit_members.rank_id=rudi_ranks.rank_id WHERE rudi_unit_members.status_id < 4 ORDER BY rudi_ranks.weight DESC , rudi_unit_members.date_promotion ASC , rudi_unit_members.date_enlisted ASC"); $row = $db->Fetch($result); if(isset($_POST['processed'])){ @@ -29,10 +29,11 @@ foreach($row as $soldier){ $mID = $soldier['member_id']; $missed = $_POST[$mID.'missed']; + $attended = $_POST[$mID.'attended']; $points = $_POST[$mID.'points']; if($missed !="" && $points != ""){ - $db->Query("UPDATE `rudi_unit_members` SET `points` = $points, `drillcount` = $missed WHERE `member_id` = $mID LIMIT 1"); + $db->Query("UPDATE `rudi_unit_members` SET `points` = $points, `drillcount` = $missed, `attendcount` = $attended WHERE `member_id` = $mID LIMIT 1"); }else{ ReportError("Error updating points for soldier id# '$mID'. Please contact administrator."); } @@ -42,9 +43,9 @@ } ?> <form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> - <table style="text-align:center;" width="100%"> + <table style="text-align:center;" width="100%" cellspacing="0"> <?php //OpenTable(); ?> - <tr><th>Rank</th><th>Soldier</th><th>Status</th><th>Points</th><th>Drills Missed</th></tr> + <tr><th>Rank</th><th>Soldier</th><th>Status</th><th>Points</th><th>Drills Missed</th><th>Drills Attended</th></tr> <?php foreach($row as $soldier){ $memberID = $soldier['member_id']; @@ -56,7 +57,8 @@ <td>{$soldier['first_name']} {$soldier['last_name']}</td> <td>".getStatus($soldier['status_id'])."</td> <td><input type=\"text\" class=\"lrg\" value=\"{$soldier['points']}\" name=\"{$memberID}points\" size=\"1\" maxlength=\"3\" />/100</td> - <td><input type=\"text\" class=\"lrg\" value=\"{$soldier['drillcount']}\" name=\"{$memberID}missed\" size=\"1\" maxlength=\"1\" />/3</td>"; + <td><input type=\"text\" class=\"lrg\" value=\"{$soldier['drillcount']}\" name=\"{$memberID}missed\" size=\"1\" maxlength=\"1\" />/3</td> + <td><input type=\"text\" class=\"lrg\" value=\"{$soldier['attendcount']}\" name=\"{$memberID}attended\" size=\"1\" maxlength=\"1\" />/3</td>"; echo "<input type=\"hidden\" value=\"{$memberID}\" name=\"{$memberID}id\" />\n"; @@ -104,7 +106,7 @@ $num = 1; foreach($row as $member){ if($num %2 == 0) - echo "<tr style=\"background-color:#c6c6c6;\">"; + echo "<tr style=\"background-color:#dfdfdf;\">"; else echo "<tr>"; echo "<td>{$member['shortname']}</td><td>{$member['first_name']} {$member['last_name']}</td><td><a href=\"?op=adjutant&edit=loas&member={$member['member_id']}\">Edit</a></td></tr>"; diff --git a/admin/adjutant/style.css b/admin/adjutant/style.css index 24a3eb8..823873b 100644 --- a/admin/adjutant/style.css +++ b/admin/adjutant/style.css @@ -1,13 +1,13 @@ - input.lrg {
- font-size:14px;
- font-weight:bold;
- text-align:center;
- font-family: Arial, Sans-Serif;
- }
-
- tr.inactive {
- background-color:#dfdfdf;
- }
- tr.inactive td {
- color:#a2a2a2;
+ input.lrg { + font-size:14px; + font-weight:bold; + text-align:center; + font-family: Arial, Sans-Serif; + } + + tr.inactive { + background-color:#dfdfdf; + } + tr.inactive td { + color:#a2a2a2; }
\ No newline at end of file diff --git a/admin/admins/functions.php b/admin/admins/functions.php index d28ff7d..f3da1be 100644 --- a/admin/admins/functions.php +++ b/admin/admins/functions.php @@ -1,329 +1,329 @@ -<script type="text/javascript">
- $(document).ready(function(){
- $(".flip").click(function(){
- $(".slidepanel").slideToggle("slow");
- });
- });
-</script>
-
-<style type="text/css">
- p.flip
- {
- margin:0px;
- padding:5px;
- text-align:center;
- background: #5b8dda;
- border:solid 1px #848484;
- color:white;
- }
- div.slidepanel
- {
- height:75px;
- display:none;
- }
-</style>
-<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- function ListAdmins()
- {
- global $db;
- $result = $db->Query("SELECT `user_id`, `username`, `level` FROM `bayonet_users` ORDER BY `level` DESC, `username` ASC");
- $admins = $db->fetch($result);
-
- $num = 1;
- OpenTable("300px");
- echo "<tr><th></th><th style=\"text-align:left;\">Username</th><th style=\"text-align:left;\">Level</th></tr>";
- foreach($admins as $admin)
- {
- if($admin['level'] != $level){
- $level = $admin['level'];
- echo "<tr><td colspan=\"3\"><hr /></td></tr>";
- }
- echo "<tr><td>{$num}.</td><td><a href=\"?op=admins&edit={$admin['user_id']}\">{$admin['username']}</a></td><td>{$admin['level']}</td></tr>";
- $num++;
- }
- CloseTable();
- }
-
- function NewAdmin()
- {
-
- global $db;
- $maxLevel = $_SESSION['level'];
-
- if(isset($_POST['processed'])){
-
- $username = addslashes($_POST['username']);
- $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');
-
- if(empty($username))
- {
- ReportError("This user must have a username to continue.");
- 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);
- if(!$sent){
- ReportError("Error validating email. This user was not saved.");
- 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', 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");
- return;
- }
-?>
-<div style="text-align:right"><img src="images/cancel.png" />Cancel</div>
-<center>
- <form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
- <table>
- <tr><th>Username:</th><td><input type="text" value="" name="username" />*</td></tr>
- <tr><th>First Name:</th><td><input type="text" value="" name="first" /></td></tr>
- <tr><th>Last Name:</th><td><input type="text" value="" name="last" /></td></tr>
- <tr><th>Email Address:</th><td><input type="text" value="" name="email" />*</td></tr>
- <tr>
- <th>Level:</th>
- <td>
- <select name="level">
- <?php
- for($x=$maxLevel; $x>0;$x--){
- echo "<option value=\"{$x}\">{$x}</option>";
- }
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2" style="text-align:center;">
- <input type="submit" name="processed" value="Submit" />
- </td>
- </tr>
- </table>
- <br />
- <?php GetPermissions(); ?>
- </form>
-</center>
-<?php
- }
-
- function GetPermissions($user = NULL)
- {
- ?>
- <div class="slidepanel">
- <table width="100%" style="text-align:center;">
- <tr><th>Everything else</th><th>Squad Leader</th><th>Adjutant</th><th>Quartermaster</th></tr>
- <tr>
- <td width="25%">
- <input type="hidden" name="all" value="0" />
- <?php
- if(isset($user['all']) && $user['all'] == 1)
- echo "<input type=\"checkbox\" name=\"all\" value=\"1\" checked/>";
- else
- echo "<input type=\"checkbox\" name=\"all\" value=\"1\" />";
- ?>
- </td>
- <td width="25%">
- <input type="hidden" name="squadleader" value="0" />
- <?php
- if(isset($user['squadleader']) && $user['squadleader'] == 1)
- echo "<input type=\"checkbox\" name=\"squadleader\" value=\"1\" checked/>";
- else
- echo "<input type=\"checkbox\" name=\"squadleader\" value=\"1\" />";
- ?>
- </td>
- <td width="25%">
- <input type="hidden" name="adjutant" value="0" />
- <?php
- if(isset($user['adjutant']) && $user['adjutant'] == 1)
- echo "<input type=\"checkbox\" name=\"adjutant\" value=\"1\" checked/>";
- else
- echo "<input type=\"checkbox\" name=\"adjutant\" value=\"1\" />";
- ?>
- </td>
- <td width="25%">
- <input type="hidden" name="quartermaster" value="0" />
- <?php
- if(isset($user['quartermaster']) && $user['quartermaster'] == 1)
- echo "<input type=\"checkbox\" name=\"quartermaster\" value=\"1\" checked/>";
- else
- echo "<input type=\"checkbox\" name=\"quartermaster\" value=\"1\" />";
- ?>
- </td>
- </tr>
- </table>
- </div>
-
- <p class="flip">Show/Hide Permissions</p>
- <?php
- }
-
- function GeneratePassword($length)
- {
- srand(date("s"));
- $possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $string = "";
- while(strlen($string)<$length) {
- $string .= substr($possible_charactors, rand()%(strlen($possible_charactors)),1);
- }
- return($string);
- }
-
- function EditAdmin($user_id)
- {
- global $db;
- $maxLevel = $_SESSION['level'];
-
- if(isset($_POST['processed']))
- {
- $username = addslashes($_POST['username']);
- $level = addslashes($_POST['level']);
-
- $all = $_POST['all'];
- $squadleader = $_POST['squadleader'];
- $adjutant = $_POST['adjutant'];
- $quartermaster = $_POST['quartermaster'];
-
- if(empty($username))
- {
- echo "You must fill everything out before proceeding.";
- return;
- }
-
- $db->Query("UPDATE `bayonet_users` SET `username` = '$username', `level` = '$level', `all` = '$all', `squadleader` = '$squadleader', `adjutant` = '$adjutant', `quartermaster` = '$quartermaster' WHERE `user_id` = '$user_id' LIMIT 1");
-
- echo "Admin, '$username' level '$level' has been edited.\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&edit={$user_id}");
- return;
- }
-
- $result = $db->Query("SELECT * FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1");
- $admin = $db->FetchRow($result);
-
- if($maxLevel < $admin['level']){
- ReportError("You do not have permission to access this user.");
- return;
- }
-?>
-<center>
- Edit the attributes of this administrator.<br />
- <form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
- <table>
- <tr><th>Username:</th><td><input type="text" value="<?php echo $admin['username']; ?>" name="username" /></td></tr>
- <tr>
- <th>Level:</th>
- <td>
- <select name="level">
- <?php
- for($x=$maxLevel; $x>0;$x--){
- if($admin['level'] == $x)
- echo "<option value=\"{$x}\" selected>{$x}</option>";
- else
- echo "<option value=\"{$x}\">{$x}</option>";
- }
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2" style="text-align:center;">
- <input type="submit" name="processed" value="Submit" />
- <a href="?op=admins&delete=<?php echo $user_id; ?>"><input type="button" value="Delete Admin" /></a>
- </td>
- </tr>
- </table>
- <br />
- <?php GetPermissions($admin); ?>
- </form>
-</center>
-<?php
- }
-
- function DeleteAdmin($user_id)
- {
- global $db;
- $maxLevel = $_SESSION['level'];
-
- $result = $db->Query("SELECT `username` FROM `bayonet_users` WHERE `user_id` = '$user_id'");
- $admin = $db->Fetch($result);
-
- if(isset($_POST['proceed']))
- {
- echo "Admin '{$admin['username']}', was deleted.";
- $db->Query("DELETE FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1");
- PageRedirect(3,"?op=admins");
- return;
- }
- if(isset($_POST['cancel']))
- {
- echo "User cancelled deletion of admin: '{$admin['username']}'";
- PageRedirect(1,"?op=admins");
- return;
- }
- ?>
- <center>
- <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
- <table>
- <th>Are you SURE you want to delete the administrative user: '<?php echo $admin['username']?>'?</th>
- <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr>
- </table>
- </form>
- </center>
- <?php
- }
+<script type="text/javascript"> + $(document).ready(function(){ + $(".flip").click(function(){ + $(".slidepanel").slideToggle("slow"); + }); + }); +</script> + +<style type="text/css"> + p.flip + { + margin:0px; + padding:5px; + text-align:center; + background: #5b8dda; + border:solid 1px #848484; + color:white; + } + div.slidepanel + { + height:75px; + display:none; + } +</style> +<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + function ListAdmins() + { + global $db; + $result = $db->Query("SELECT `user_id`, `username`, `level` FROM `bayonet_users` ORDER BY `level` DESC, `username` ASC"); + $admins = $db->fetch($result); + + $num = 1; + OpenTable("300px"); + echo "<tr><th></th><th style=\"text-align:left;\">Username</th><th style=\"text-align:left;\">Level</th></tr>"; + foreach($admins as $admin) + { + if($admin['level'] != $level){ + $level = $admin['level']; + echo "<tr><td colspan=\"3\"><hr /></td></tr>"; + } + echo "<tr><td>{$num}.</td><td><a href=\"?op=admins&edit={$admin['user_id']}\">{$admin['username']}</a></td><td>{$admin['level']}</td></tr>"; + $num++; + } + CloseTable(); + } + + function NewAdmin() + { + + global $db; + $maxLevel = $_SESSION['level']; + + if(isset($_POST['processed'])){ + + $username = addslashes($_POST['username']); + $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'); + + if(empty($username)) + { + ReportError("This user must have a username to continue."); + 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); + if(!$sent){ + ReportError("Error validating email. This user was not saved."); + 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', 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"); + return; + } +?> +<div style="text-align:right"><img src="images/cancel.png" />Cancel</div> +<center> + <form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> + <table> + <tr><th>Username:</th><td><input type="text" value="" name="username" />*</td></tr> + <tr><th>First Name:</th><td><input type="text" value="" name="first" /></td></tr> + <tr><th>Last Name:</th><td><input type="text" value="" name="last" /></td></tr> + <tr><th>Email Address:</th><td><input type="text" value="" name="email" />*</td></tr> + <tr> + <th>Level:</th> + <td> + <select name="level"> + <?php + for($x=$maxLevel; $x>0;$x--){ + echo "<option value=\"{$x}\">{$x}</option>"; + } + ?> + </select> + </td> + </tr> + <tr> + <td colspan="2" style="text-align:center;"> + <input type="submit" name="processed" value="Submit" /> + </td> + </tr> + </table> + <br /> + <?php GetPermissions(); ?> + </form> +</center> +<?php + } + + function GetPermissions($user = NULL) + { + ?> + <div class="slidepanel"> + <table width="100%" style="text-align:center;"> + <tr><th>Everything else</th><th>Squad Leader</th><th>Adjutant</th><th>Quartermaster</th></tr> + <tr> + <td width="25%"> + <input type="hidden" name="all" value="0" /> + <?php + if(isset($user['all']) && $user['all'] == 1) + echo "<input type=\"checkbox\" name=\"all\" value=\"1\" checked/>"; + else + echo "<input type=\"checkbox\" name=\"all\" value=\"1\" />"; + ?> + </td> + <td width="25%"> + <input type="hidden" name="squadleader" value="0" /> + <?php + if(isset($user['squadleader']) && $user['squadleader'] == 1) + echo "<input type=\"checkbox\" name=\"squadleader\" value=\"1\" checked/>"; + else + echo "<input type=\"checkbox\" name=\"squadleader\" value=\"1\" />"; + ?> + </td> + <td width="25%"> + <input type="hidden" name="adjutant" value="0" /> + <?php + if(isset($user['adjutant']) && $user['adjutant'] == 1) + echo "<input type=\"checkbox\" name=\"adjutant\" value=\"1\" checked/>"; + else + echo "<input type=\"checkbox\" name=\"adjutant\" value=\"1\" />"; + ?> + </td> + <td width="25%"> + <input type="hidden" name="quartermaster" value="0" /> + <?php + if(isset($user['quartermaster']) && $user['quartermaster'] == 1) + echo "<input type=\"checkbox\" name=\"quartermaster\" value=\"1\" checked/>"; + else + echo "<input type=\"checkbox\" name=\"quartermaster\" value=\"1\" />"; + ?> + </td> + </tr> + </table> + </div> + + <p class="flip">Show/Hide Permissions</p> + <?php + } + + function GeneratePassword($length) + { + srand(date("s")); + $possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + $string = ""; + while(strlen($string)<$length) { + $string .= substr($possible_charactors, rand()%(strlen($possible_charactors)),1); + } + return($string); + } + + function EditAdmin($user_id) + { + global $db; + $maxLevel = $_SESSION['level']; + + if(isset($_POST['processed'])) + { + $username = addslashes($_POST['username']); + $level = addslashes($_POST['level']); + + $all = $_POST['all']; + $squadleader = $_POST['squadleader']; + $adjutant = $_POST['adjutant']; + $quartermaster = $_POST['quartermaster']; + + if(empty($username)) + { + echo "You must fill everything out before proceeding."; + return; + } + + $db->Query("UPDATE `bayonet_users` SET `username` = '$username', `level` = '$level', `all` = '$all', `squadleader` = '$squadleader', `adjutant` = '$adjutant', `quartermaster` = '$quartermaster' WHERE `user_id` = '$user_id' LIMIT 1"); + + echo "Admin, '$username' level '$level' has been edited.\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&edit={$user_id}"); + return; + } + + $result = $db->Query("SELECT * FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1"); + $admin = $db->FetchRow($result); + + if($maxLevel < $admin['level']){ + ReportError("You do not have permission to access this user."); + return; + } +?> +<center> + Edit the attributes of this administrator.<br /> + <form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> + <table> + <tr><th>Username:</th><td><input type="text" value="<?php echo $admin['username']; ?>" name="username" /></td></tr> + <tr> + <th>Level:</th> + <td> + <select name="level"> + <?php + for($x=$maxLevel; $x>0;$x--){ + if($admin['level'] == $x) + echo "<option value=\"{$x}\" selected>{$x}</option>"; + else + echo "<option value=\"{$x}\">{$x}</option>"; + } + ?> + </select> + </td> + </tr> + <tr> + <td colspan="2" style="text-align:center;"> + <input type="submit" name="processed" value="Submit" /> + <a href="?op=admins&delete=<?php echo $user_id; ?>"><input type="button" value="Delete Admin" /></a> + </td> + </tr> + </table> + <br /> + <?php GetPermissions($admin); ?> + </form> +</center> +<?php + } + + function DeleteAdmin($user_id) + { + global $db; + $maxLevel = $_SESSION['level']; + + $result = $db->Query("SELECT `username` FROM `bayonet_users` WHERE `user_id` = '$user_id'"); + $admin = $db->Fetch($result); + + if(isset($_POST['proceed'])) + { + echo "Admin '{$admin['username']}', was deleted."; + $db->Query("DELETE FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1"); + PageRedirect(3,"?op=admins"); + return; + } + if(isset($_POST['cancel'])) + { + echo "User cancelled deletion of admin: '{$admin['username']}'"; + PageRedirect(1,"?op=admins"); + return; + } + ?> + <center> + <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> + <table> + <th>Are you SURE you want to delete the administrative user: '<?php echo $admin['username']?>'?</th> + <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr> + </table> + </form> + </center> + <?php + } ?>
\ No newline at end of file diff --git a/admin/admins/index.php b/admin/admins/index.php index 1223d3a..a2e71e9 100644 --- a/admin/admins/index.php +++ b/admin/admins/index.php @@ -1,54 +1,54 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-?>
- <div style="text-align:left;"><h2>- Edit Admins</h2></div>
-<?php
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-include $basedir.'admins/functions.php';
-?>
-
-<table class="panel" width="100%" cellspacing="0">
- <tr>
- <td class="panel-none">
- <table align="center" width="200px">
- <tr><th><?php echo LinkInternal('<img src="images/add.png" />Add New Admin','?op=admins&create=true'); ?></th></tr>
- </table>
- <?php ListAdmins(); ?>
- </td>
- <td class="panel-box">
-<?php
-if(isset($_GET['edit'])){
- $user_id = $_GET['edit'];
- EditAdmin($user_id);
-}
-else if(isset($_GET['delete'])){
- $user_id = $_GET['delete'];
- DeleteAdmin($user_id);
-}
-else if(isset($_GET['create'])){
- NewAdmin();
-}
-?>
- </td>
- </tr>
-</table>
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +?> + <div style="text-align:left;"><h2>- Edit Admins</h2></div> +<?php +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'admins/functions.php'; +?> + +<table class="panel" width="100%" cellspacing="0"> + <tr> + <td class="panel-none"> + <table align="center" width="200px"> + <tr><th><?php echo LinkInternal('<img src="images/add.png" />Add New Admin','?op=admins&create=true'); ?></th></tr> + </table> + <?php ListAdmins(); ?> + </td> + <td class="panel-box"> +<?php +if(isset($_GET['edit'])){ + $user_id = $_GET['edit']; + EditAdmin($user_id); +} +else if(isset($_GET['delete'])){ + $user_id = $_GET['delete']; + DeleteAdmin($user_id); +} +else if(isset($_GET['create'])){ + NewAdmin(); +} +?> + </td> + </tr> +</table> diff --git a/admin/announcements/functions.php b/admin/announcements/functions.php index f45a7e3..b089cf3 100644 --- a/admin/announcements/functions.php +++ b/admin/announcements/functions.php @@ -1,67 +1,67 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * Note to anyone feeling the need to edit this file...
- * You MUST declare $db as global inside your functions in order access MySQL from here.
- */
-
-function EditAnnouncements()
-{
- global $db;
-
- if(isset($_POST['processed']))
- {
- //Secure our data to prevent injection attacks.
- $title = addslashes($_POST['title']);
- $text = addslashes($_POST['text']);
- if(empty($title) || empty($text))
- {
- echo "You must fill everything out before proceeding.";
- return;
- }
-
- //Update the database with the new data.
- $db->Query("UPDATE bayonet_announcements SET title = '$title', text = '$text' WHERE announcement_id = 0");
- echo "Announcement, '$title', has been edited.\n <br /><br /> Please wait while you are redirected. <br /><br />
- <a href=\"?op=announcements\">Click here if you don't feel like waiting.</a>";
-
- // 3 second redirect to go back to the edit page
- PageRedirect(2, "?op=announcements");
-
- //die, because we have completed what we wanted to do.
- return;
- }
-
-
- //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");
- $announcement = $db->FetchRow($result);
-
- ?>
- <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="processed" value="Submit Changes" /> </td></tr>
- </table>
- </form>
- <?php
-}
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Note to anyone feeling the need to edit this file... + * You MUST declare $db as global inside your functions in order access MySQL from here. + */ + +function EditAnnouncements() +{ + global $db; + + if(isset($_POST['processed'])) + { + //Secure our data to prevent injection attacks. + $title = addslashes($_POST['title']); + $text = addslashes($_POST['text']); + if(empty($title) || empty($text)) + { + echo "You must fill everything out before proceeding."; + return; + } + + //Update the database with the new data. + $db->Query("UPDATE bayonet_announcements SET title = '$title', text = '$text' WHERE announcement_id = 0"); + echo "Announcement, '$title', has been edited.\n <br /><br /> Please wait while you are redirected. <br /><br /> + <a href=\"?op=announcements\">Click here if you don't feel like waiting.</a>"; + + // 3 second redirect to go back to the edit page + PageRedirect(2, "?op=announcements"); + + //die, because we have completed what we wanted to do. + return; + } + + + //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"); + $announcement = $db->FetchRow($result); + + ?> + <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="processed" value="Submit Changes" /> </td></tr> + </table> + </form> + <?php +} ?>
\ No newline at end of file diff --git a/admin/announcements/index.php b/admin/announcements/index.php index 6b0874e..14d7710 100644 --- a/admin/announcements/index.php +++ b/admin/announcements/index.php @@ -1,34 +1,34 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ?>
-
- <div style="text-align:left;"><h2>- Edit Announcements</h2></div>
-
- <?php
-
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-include $basedir.'announcements/functions.php';
-?>
-<table class="panel" width="100%">
- <tr><td><?php EditAnnouncements(); ?></td></tr>
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + ?> + + <div style="text-align:left;"><h2>- Edit Announcements</h2></div> + + <?php + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'announcements/functions.php'; +?> +<table class="panel" width="100%"> + <tr><td><?php EditAnnouncements(); ?></td></tr> </table>
\ No newline at end of file diff --git a/admin/calendar/index.php b/admin/calendar/index.php index 2b631d8..097622f 100644 --- a/admin/calendar/index.php +++ b/admin/calendar/index.php @@ -1,90 +1,90 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ?>
- <link rel="stylesheet" type="text/css" href="calendar/style.css" media="screen"/>
- <div style="text-align:left;"><h2>- Manage Calendar & Events</h2></div>
-<?php
-
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-include $basedir.'calendar/functions.php';
-
-
-?>
-
-<!--
-<hr />
- <table width="100%" style="text-align:center;">
- <tr>
- <td>
- <?php echo LinkInternal('Add Events','?op=calendar&create=true'); ?>
- </td>
- <td>
- <?php echo LinkInternal('Edit Events','?op=calendar&edit='); ?>
- </td>
- <td>
- <?php echo LinkInternal('Delete Events','?op=calendar&delete='); ?>
- </td>
- </tr>
- </table> -->
-
- <table class="panel" width="100%">
- <tr>
- <td style="width:325px; vertical-align:top; text-align:center;">
- <a href="?op=calendar&create=true"><img src="images/add.png" /> Add New Event</a><br /><br />
- <?php PrintCalendar(); ?>
- Click on a day to add/edit/delete events
- </td>
- <td class="panel-box">
- <?php
- if(isset($_GET['list']))
- {
- $eventDate = $_GET['list'];
- ListEvents($eventDate);
- //return;
- }
- else if(isset($_GET['edit']))
- {
- $event_id = $_GET['edit'];
- EditEvent($event_id);
- //return;
- }
- else if(isset($_GET['delete']))
- {
- $event_id = $_GET['delete'];
- DeleteEvent($event_id);
- //return;
- }
- else if(isset($_GET['create']))
- {
- $create = $_GET['create'];
- if($create)
- {
- NewEvent();
- //return;
- }
- }
- ?>
- </td>
- </tr>
- </table>
-
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + ?> + <link rel="stylesheet" type="text/css" href="calendar/style.css" media="screen"/> + <div style="text-align:left;"><h2>- Manage Calendar & Events</h2></div> +<?php + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'calendar/functions.php'; + + +?> + +<!-- +<hr /> + <table width="100%" style="text-align:center;"> + <tr> + <td> + <?php echo LinkInternal('Add Events','?op=calendar&create=true'); ?> + </td> + <td> + <?php echo LinkInternal('Edit Events','?op=calendar&edit='); ?> + </td> + <td> + <?php echo LinkInternal('Delete Events','?op=calendar&delete='); ?> + </td> + </tr> + </table> --> + + <table class="panel" width="100%"> + <tr> + <td style="width:325px; vertical-align:top; text-align:center;"> + <a href="?op=calendar&create=true"><img src="images/add.png" /> Add New Event</a><br /><br /> + <?php PrintCalendar(); ?> + Click on a day to add/edit/delete events + </td> + <td class="panel-box"> + <?php + if(isset($_GET['list'])) + { + $eventDate = $_GET['list']; + ListEvents($eventDate); + //return; + } + else if(isset($_GET['edit'])) + { + $event_id = $_GET['edit']; + EditEvent($event_id); + //return; + } + else if(isset($_GET['delete'])) + { + $event_id = $_GET['delete']; + DeleteEvent($event_id); + //return; + } + else if(isset($_GET['create'])) + { + $create = $_GET['create']; + if($create) + { + NewEvent(); + //return; + } + } + ?> + </td> + </tr> + </table> + diff --git a/admin/calendar/style.css b/admin/calendar/style.css new file mode 100644 index 0000000..167b75f --- /dev/null +++ b/admin/calendar/style.css @@ -0,0 +1,96 @@ +/* START>> CALENDAR STYLES*/ + .monthTitle{ + color:black; + text-align:center; + font-size:12px; + font-weight:bold; + font-family:arial; + } + td.weekday { + width:40px; + height:20px; + background-color:#cb2121; + color:green; + text-align:center; + font-size:10px; + font-weight:bold; + } + th.weekday { + width:40px; + height:29px; + background-color:white; + color:black; + text-align:center; + font-size:11px; + font-weight:bold; + } + .monthday { + width:40px; + height:20px; + background-color:#aea2a2; + color:white; + text-align:left; + font-size:10pt; + font-weight:bold; + + } + .monthtoday { + width:38px; + height:38px; + /* background-color:#3666ba; */ + color:#225eac; + text-align:center; + font-size:14px; + font-weight:bold; + border:1px solid #333333; + } + .event { + width:38px; + height:38px; + background-color:#225eac; + text-align:center; + border:1px solid #333333; + } + table.calendar a, table.calendar a:visited, table.calendar a:active, table.calendar a:hover { + color:white; + } + .eventtoday{ + width:38px; + height:38px; + background-color:#225eac; + color:#ef8e25; + text-align:center; + font-size:14px; + font-weight:bold; + border:1px solid #333333; + } + td.cal_weekday { + width:40px; + height:40px; + background-color:#a1a1a1; + vertical-align:top; + color:#eeeeee; + font-family:arial; + text-align:center; + font-size:14px; + } + td.cal_weekend { + width:40px; + height:40px; + background-color:#8f8f8f; + vertical-align:top; + color:#eeeeee; + font-family:arial; + text-align:center; + font-size:14px; + } + td.cal_notmonth { + width:40px; + height:40px; + background-color:#6e6e6e; + vertical-align:top; + color:#d4d4d4; + text-align:left; + font-size:11px; + } +/* END>> CALENDAR STYLES */
\ No newline at end of file diff --git a/admin/functions.php b/admin/functions.php index 9b950c4..5c018a0 100644 --- a/admin/functions.php +++ b/admin/functions.php @@ -1,563 +1,563 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * bbcode_format()
- *
- * Modified public domain code from www.phpit.net
- *
- * @param mixed $str
- * @return
- */
-function bbcode_format ($str)
-{
- $str = htmlentities($str);
- $str = strip_tags($str);
- $str = wordwrap($str,100,"\n",true);
-
- $simple_search = array(
- '/\[b\](.*?)\[\/b\]/is',
- '/\[i\](.*?)\[\/i\]/is',
- '/\[u\](.*?)\[\/u\]/is',
- '/\[hr\]/is',
- '/\[pi\](.*?)\[\/pi\]/is',
- '/\[center\](.*?)\[\/center\]/is',
- '/\[title\](.*?)\[\/title\]/is',
- '/\[article\](.*?)\[\/article\]/is',
- '/\[section\](.*?)\[\/section\]/is',
- '/\[code\](.*?)\[\/code\]/is',
- '/\[quote\](.*?)\[\/quote\]/is',
- '/\[quote\=(.*?)\](.*?)\[\/quote\]/is',
- '/\[url\=(.*?)\](.*?)\[\/url\]/is',
- '/\[align\=(.*?)\](.*?)\[\/align\]/is',
- '/\[size\=(.*?)\](.*?)\[\/size\]/is',
- '/\[img\=(.*?)\](.*?)\[\/img\]/is'
- );
-
- $simple_replace = array(
- '<strong>$1</strong>',
- '<em>$1</em>',
- '<u>$1</u>',
- '<hr>',
- '<p style="text-indent:3em;">$1</p>',
- '<center>$1</center>',
- '<h2>$1</h2>',
- '<h3>$1</h3>',
- '<h4>$1</h4>',
- '<blockquote><pre>$1</pre></blockquote>',
- '<blockquote>$1</blockquote>',
- '<i>$1 wrote:</i><br/><blockquote>$2</blockquote>',
- '<a href="$1">$2</a>',
- '<align="$1">$2</align>',
- '<font style="font-size:$1px;">$2</font>',
- '<img src="$1" alt="$2"/>'
- );
-
- $order = array("\r\n", "\n", "\r");
- $replace = "\n<br/>";
-
- $str = preg_replace ($simple_search, $simple_replace, $str);
- $str = str_ireplace($order,$replace,$str);
- return $str;
-}
-
- //BBcode 2 HTML was written by WAY2WEB.net
-
- function BBCode($Text)
- {
- // Replace any html brackets with HTML Entities to prevent executing HTML or script
- // Don't use strip_tags here because it breaks [url] search by replacing & with amp
- $Text = str_replace("<", "<", $Text);
- $Text = str_replace(">", ">", $Text);
-
- // Convert new line chars to html <br /> tags
- $Text = nl2br($Text);
-
- // Set up the parameters for a URL search string
- $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
- // Set up the parameters for a MAIL search string
- $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
-
- // Perform URL Search
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $Text);
- $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
- //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
-
- // Perform MAIL Search
- $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
- $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
-
- // Check for bold text
- $Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text);
-
- // Check for Italics text
- $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="italics">$1</span>',$Text);
-
- // Check for Underline text
- $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span class="underline">$1</span>',$Text);
-
- // Check for strike-through text
- $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span class="strikethrough">$1</span>',$Text);
-
- // Check for over-line text
- $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text);
-
- // Check for colored text
- $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text);
-
- // Check for sized text
- $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text);
-
- // Check for list text
- $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
- $Text = str_replace("[*]", "<li>", $Text);
-
- // Check for font change text
- $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);
-
- // Declare the format for [code] layout
- $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td class="quotecodeheader"> Code:</td>
- </tr>
- <tr>
- <td class="codebody">$1</td>
- </tr>
- </table>';
- // Check for [code] text
- $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text);
- // Declare the format for [php] layout
- $phpLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td class="quotecodeheader"> Code:</td>
- </tr>
- <tr>
- <td class="codebody">$1</td>
- </tr>
- </table>';
- // Check for [php] text
- $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text);
-
- // Declare the format for [quote] layout
- $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td class="quotecodeheader"> Quote:</td>
- </tr>
- <tr>
- <td class="quotebody">$1</td>
- </tr>
- </table>';
-
- // Check for [quote] text
- $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text);
-
- // Images
- // [img]pathtoimage[/img]
- $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text);
-
- //[img=align]image source[/img]
- $Text = preg_replace("(\[img align\=(.+?)\](.+?)\[\/img\])is","<img src=\"$2\" align=\"$1\" />",$Text);
-
- // [img=widthxheight]image source[/img]
- $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" height="$2" width="$1">', $Text);
-
- // Alignment
- // [align=type]text[/align]
- $Text = preg_replace("(\[align=(.+?)\](.+?)\[\/align\])is","<div style=\"text-align: $1\">$2</div>",$Text);
-
- return $Text;
- }
-
-function articleHeading($text){
-
- // Set the content-type
- header('Content-type: image/png');
-
- //$text = $_GET['text'];
-
- $im = imagecreatefrompng('images/news_header.png'); // open image
- imagealphablending($im, true); // setting alpha blending on
- imagesavealpha($im, true); // save alphablending setting (important)
-
- // Create some colors
- $black = imagecolorallocate($im, 0, 0, 0);
-
-
- // Replace path by your own font path
- //$font = 'TrajanPro-Regular.otf';
- //$font = 'TrajanPro-Bold.otf';
- $font = 'BrushScriptStd.otf';
- //$font = 'TRATS__.TTF';
- //$text = strtoupper($text);
-
- // Add the text
- imagettftext($im, 18, 0, 0, 17, $black, $font, $text);
-
- // Using imagepng() results in clearer text compared with imagejpeg()
- imagepng($im);
- imagedestroy($im);
-}
-
-function LinkList($array)
-{
- if(!is_array($array))
- {
- ReportError("List was not an array");
- return;
- }
-
- echo "<ul class=\"block\">";
- foreach($array as $text => $link)
- {
- echo "<li><a href=\"$link\">$text</a></li>";
- }
- echo "</ul>";
-}
-
-/**
- * LinkModule()
- *
- * Helper function to link to Bayonet modules.
- *
- * @param mixed $module_name
- * @param mixed $link_name
- * @return
- */
-function LinkModule($module_name,$args = NULL,$link_name)
-{
- return "<a href=\"?load={$module_name}{$args}\">{$link_name}</a>";
-}
-
-/**
- * LinkPage()
- *
- * Helper function to link to Bayonet pages.
- *
- * @param mixed $page_id
- * @param mixed $page_name
- * @return
- */
-function LinkPage($page_id,$page_name)
-{
- return "<a href=\"?load=page&id={$page_id}\">{$page_name}</a>";
-}
-
-/**
- * LinkInternal()
- *
- * Helper function to link to a relative Bayonet path.
- *
- * @param mixed $name
- * @param string $rel_path
- * @param string $file
- * @return
- */
-function LinkInternal($name,$file,$rel_path = "./")
-{
- return "<a href=\"{$rel_path}{$file}\">{$name}</a>";
-}
-
-if(!defined("CALLED_FROM_ADMIN"))
-{
- /**
- * OpenTable()
- *
- * Begins a Bayonet site table.
- *
- * @return
- */
- function OpenTable($width = "100%")
- {
- //width="100%" is important. Otherwise all of our tables will be text width.
- echo "<table width=\"{$width}\" align=\"center\" class=\"cleartable\">\n";
- }
-
- /**
- * CloseTable()
- *
- * Closes a Bayonet site table.
- *
- * @return
- */
- function CloseTable()
- {
- echo "</table>";
- }
-}
-
-function OpenBlock($title = 'New Block')
-{
- OpenTable();
- echo "<div class=\"contentHeading\">{$title}</div>";
- echo "<div class=\"content\">";
-}
-
-function CloseBlock()
-{
- echo "</div>";
- CloseTable();
-}
-/**
- * ReportError()
- *
- * This function should be called in the event that an error has occured.
- *
- * @param mixed $message - automatically logged
- * @return
- */
-function ReportError($message)
-{
- //WriteLog($message,BAYONET_LOG_ERROR);
- OpenTable();
- echo "<tr><th>Error Message</th></tr><tr><td style=\"text-align:center;\">{$message}</td></tr>";
- CloseTable();
-}
-
-/**
- * ReportHack()
- *
- * This function should be called in the event that we are confirming
- * a hacking attempt.
- *
- * @param mixed $message - automatically logged
- * @return void
- */
-function ReportHack($message)
-{
- //WriteLog($message,BAYONET_LOG_HACK);
- OpenTable();
- echo "<tr><th>Hack Attempt</th></tr><tr><td style=\"text-align:center;\">{$message}</td></tr>";
- CloseTable();
-}
-
-
-/**
- * array_dump()
- *
- * Useful against $_POST and $_GET variables, for dumping data to
- * a log file, or to stdout. The return value is a single string,
- * with each array key => value pair delimited by a character.
- * The default character is a pipe -> '|'. It is assumed that if
- * wanted to have a newline character inserted, just replace $spacer
- * with '\n'.
- *
- * @param mixed $array
- * @param string $spacer
- * @return
- */
-function array_dump($array, $spacer = '|')
-{
- $retval = NULL;
- foreach($array as $challenge => $answer)
- {
- $retval .= " $challenge => $answer " . $spacer;
- }
-
- return $retval;
-}
-
-/**
- * WriteLog()
- *
- * This function can be accessed directly, however, anything that is
- * passed to ReportError() or ReportHack(), or decho() will be logged in their
- * appropriate log file.
- *
- * Change made: added checks to see if the log files exist before opening
- *
- * @param mixed $message
- * @param mixed $flag
- * @return
- */
-define('BAYONET_LOG_HACK','bayonet_log_hack');
-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)
-{
- global $config;
- $enabled = $config['logs']['enabled'];
-
- if(!$enabled)
- {
- return false;
- }
-
- $dir = $config['logs']['dir'];
- date_default_timezone_set($config['logs']['timezone']);
- $varstr = array_dump($_GET);
- $type = NULL;
- $ip = $_SERVER['REMOTE_ADDR'];
- $hostname = gethostbyaddr($ip);
- $executed = $_SERVER['PHP_SELF'];
- $timestamp = date('Y-M-d H:i:s T');
-
-
- $message = str_replace("\n",'',$message);
- $message = str_replace("<br>",'',$message);
-
- switch($flag)
- {
- case BAYONET_LOG_HACK:
- if(!file_exists($dir.'hacks.log')){
- break;
- }
- $fp = fopen($dir.'hacks.log','a');
- $type = 'HACK';
- $full_message = "TIMESTAMP: {$timestamp}\n\t\tIP: {$ip}\n\t\tHOSTNAME: {$hostname}\n\t\tACTION: {$type} of {$executed}\n\t\tDEFERRAL: {$message}\n\t\tVAR: ({$varstr})\n\n";
- break;
- case BAYONET_LOG_ERROR:
- if(!file_exists($dir.'error.log')){
- break;
- }
- $fp = fopen($dir.'error.log','a');
- $type = 'ERROR';
- $full_message = "({$timestamp}) - {$type} - {$message} - ({$varstr})\n";
- break;
- case BAYONET_LOG_WARN:
- if(!file_exists($dir.'warn.log')){
- break;
- }
- $fp = fopen($dir.'warn.log','a');
- $type = 'WARN';
- $full_message = "({$timestamp}) - {$type} - {$message} - ({$varstr})\n";
- break;
- case BAYONET_LOG_INFO:
- if(!file_exists($dir.'info.log')){
- break;
- }
- $fp = fopen($dir.'info.log','a');
- $type = 'INFO';
- $full_message = "({$timestamp}) - {$type} - {$message}\n";
- break;
- default:
- echo 'To log something, you need to define a log to write to.<br>';
- return;
- }
- if(file_exists($fp)){
- fwrite($fp,$full_message);
- fclose($fp);
- }else{
- //echo "could not write to file because file does not exist.<br />";
- }
-}
-
-/**
- * UnderConstruction()
- *
- * Displays a site-wide message across the page header.
- *
- * @param mixed $message
- * @param mixed $flag Acceptable flags are BAYONET_SITE, and BAYONET_SECTION
- * @return
- */
-define('BAYONET_SITE','bayonet_site');
-define('BAYONET_SECTION','bayonet_section');
-function UnderConstruction($message = NULL, $flag = BAYONET_SITE)
-{
- $timestamp = date("Y-M-d h:m:s");
- OpenTable();
- switch($flag)
- {
- case BAYONET_SITE:
- echo "<tr><th>Site is currently under construction : $timestamp</th></tr>";
- break;
- case BAYONET_SECTION:
- echo "<tr><th>Section currently under construction : $timestamp</th></tr>";
- }
-
- if(!is_null($message))
- {
- echo "<tr><td><i>$message</i></td></tr>";
- }
-
- CloseTable();
- echo "<br>";
-}
-
-/**
- * GetBlocks()
- *
- * Includes all directories listed in blocks/ and uses the bayonet_blocks
- * MySQL table to determine the order of the blocks displayed.
- *
- * @return
- */
-
-define('BLOCK_LEFT',false);
-define('BLOCK_RIGHT',false);
-
-function GetBlocks($position = BLOCK_LEFT)
-{
- global $config;
- /**
- * I had to reconnect to the database for some fucking reason at this point.
- * I have no idea why, but I was recieving errors telling me that $db was no longer
- * an object. This is/was bullshit.
- */
- $db = new Bayonet_SQL();
- $db->Connect(
- $config['sql']['hostname'],
- $config['sql']['username'],
- $config['sql']['password']
- );
- $db->Select_db($config['sql']['database']);
-
- $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY weight, position");
- $blocks = $db->Fetch($result);
-
- foreach($blocks as $block)
- {
- if($block['position'] == $position && $block['active'] == true)
- {
- $load = 'blocks/'.$block['dir_name'].'/index.php';
- if(file_exists($load))
- {
- OpenBlock($block['title']);
- include $load;
- CloseBlock();
- }
- else
- {
- ReportError("Failed to load block, '{$block['dir_name']}'. Check block config.");
- }
- if($config['blocks']['spacer']) echo "<br />";
- }
- }
-}
-
-/**
- * PageRedirect()
- *
- * performs an http redirect
- *
- * @param $delay
- * @param $link
- */
-function PageRedirect($delay, $link)
-{
- echo "<meta http-equiv=\"Refresh\" content=\"{$delay};url={$link}\">";
-}
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * bbcode_format() + * + * Modified public domain code from www.phpit.net + * + * @param mixed $str + * @return + */ +function bbcode_format ($str) +{ + $str = htmlentities($str); + $str = strip_tags($str); + $str = wordwrap($str,100,"\n",true); + + $simple_search = array( + '/\[b\](.*?)\[\/b\]/is', + '/\[i\](.*?)\[\/i\]/is', + '/\[u\](.*?)\[\/u\]/is', + '/\[hr\]/is', + '/\[pi\](.*?)\[\/pi\]/is', + '/\[center\](.*?)\[\/center\]/is', + '/\[title\](.*?)\[\/title\]/is', + '/\[article\](.*?)\[\/article\]/is', + '/\[section\](.*?)\[\/section\]/is', + '/\[code\](.*?)\[\/code\]/is', + '/\[quote\](.*?)\[\/quote\]/is', + '/\[quote\=(.*?)\](.*?)\[\/quote\]/is', + '/\[url\=(.*?)\](.*?)\[\/url\]/is', + '/\[align\=(.*?)\](.*?)\[\/align\]/is', + '/\[size\=(.*?)\](.*?)\[\/size\]/is', + '/\[img\=(.*?)\](.*?)\[\/img\]/is' + ); + + $simple_replace = array( + '<strong>$1</strong>', + '<em>$1</em>', + '<u>$1</u>', + '<hr>', + '<p style="text-indent:3em;">$1</p>', + '<center>$1</center>', + '<h2>$1</h2>', + '<h3>$1</h3>', + '<h4>$1</h4>', + '<blockquote><pre>$1</pre></blockquote>', + '<blockquote>$1</blockquote>', + '<i>$1 wrote:</i><br/><blockquote>$2</blockquote>', + '<a href="$1">$2</a>', + '<align="$1">$2</align>', + '<font style="font-size:$1px;">$2</font>', + '<img src="$1" alt="$2"/>' + ); + + $order = array("\r\n", "\n", "\r"); + $replace = "\n<br/>"; + + $str = preg_replace ($simple_search, $simple_replace, $str); + $str = str_ireplace($order,$replace,$str); + return $str; +} + + //BBcode 2 HTML was written by WAY2WEB.net + + function BBCode($Text) + { + // Replace any html brackets with HTML Entities to prevent executing HTML or script + // Don't use strip_tags here because it breaks [url] search by replacing & with amp + $Text = str_replace("<", "<", $Text); + $Text = str_replace(">", ">", $Text); + + // Convert new line chars to html <br /> tags + $Text = nl2br($Text); + + // Set up the parameters for a URL search string + $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'"; + // Set up the parameters for a MAIL search string + $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@"; + + // Perform URL Search + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $Text); + $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text); + //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text); + + // Perform MAIL Search + $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text); + $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text); + + // Check for bold text + $Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text); + + // Check for Italics text + $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="italics">$1</span>',$Text); + + // Check for Underline text + $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span class="underline">$1</span>',$Text); + + // Check for strike-through text + $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span class="strikethrough">$1</span>',$Text); + + // Check for over-line text + $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text); + + // Check for colored text + $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text); + + // Check for sized text + $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text); + + // Check for list text + $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text); + $Text = str_replace("[*]", "<li>", $Text); + + // Check for font change text + $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text); + + // Declare the format for [code] layout + $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> + <tr> + <td class="quotecodeheader"> Code:</td> + </tr> + <tr> + <td class="codebody">$1</td> + </tr> + </table>'; + // Check for [code] text + $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text); + // Declare the format for [php] layout + $phpLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> + <tr> + <td class="quotecodeheader"> Code:</td> + </tr> + <tr> + <td class="codebody">$1</td> + </tr> + </table>'; + // Check for [php] text + $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text); + + // Declare the format for [quote] layout + $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> + <tr> + <td class="quotecodeheader"> Quote:</td> + </tr> + <tr> + <td class="quotebody">$1</td> + </tr> + </table>'; + + // Check for [quote] text + $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text); + + // Images + // [img]pathtoimage[/img] + $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text); + + //[img=align]image source[/img] + $Text = preg_replace("(\[img align\=(.+?)\](.+?)\[\/img\])is","<img src=\"$2\" align=\"$1\" />",$Text); + + // [img=widthxheight]image source[/img] + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" height="$2" width="$1">', $Text); + + // Alignment + // [align=type]text[/align] + $Text = preg_replace("(\[align=(.+?)\](.+?)\[\/align\])is","<div style=\"text-align: $1\">$2</div>",$Text); + + return $Text; + } + +function articleHeading($text){ + + // Set the content-type + header('Content-type: image/png'); + + //$text = $_GET['text']; + + $im = imagecreatefrompng('images/news_header.png'); // open image + imagealphablending($im, true); // setting alpha blending on + imagesavealpha($im, true); // save alphablending setting (important) + + // Create some colors + $black = imagecolorallocate($im, 0, 0, 0); + + + // Replace path by your own font path + //$font = 'TrajanPro-Regular.otf'; + //$font = 'TrajanPro-Bold.otf'; + $font = 'BrushScriptStd.otf'; + //$font = 'TRATS__.TTF'; + //$text = strtoupper($text); + + // Add the text + imagettftext($im, 18, 0, 0, 17, $black, $font, $text); + + // Using imagepng() results in clearer text compared with imagejpeg() + imagepng($im); + imagedestroy($im); +} + +function LinkList($array) +{ + if(!is_array($array)) + { + ReportError("List was not an array"); + return; + } + + echo "<ul class=\"block\">"; + foreach($array as $text => $link) + { + echo "<li><a href=\"$link\">$text</a></li>"; + } + echo "</ul>"; +} + +/** + * LinkModule() + * + * Helper function to link to Bayonet modules. + * + * @param mixed $module_name + * @param mixed $link_name + * @return + */ +function LinkModule($module_name,$args = NULL,$link_name) +{ + return "<a href=\"?load={$module_name}{$args}\">{$link_name}</a>"; +} + +/** + * LinkPage() + * + * Helper function to link to Bayonet pages. + * + * @param mixed $page_id + * @param mixed $page_name + * @return + */ +function LinkPage($page_id,$page_name) +{ + return "<a href=\"?load=page&id={$page_id}\">{$page_name}</a>"; +} + +/** + * LinkInternal() + * + * Helper function to link to a relative Bayonet path. + * + * @param mixed $name + * @param string $rel_path + * @param string $file + * @return + */ +function LinkInternal($name,$file,$rel_path = "./") +{ + return "<a href=\"{$rel_path}{$file}\">{$name}</a>"; +} + +if(!defined("CALLED_FROM_ADMIN")) +{ + /** + * OpenTable() + * + * Begins a Bayonet site table. + * + * @return + */ + function OpenTable($width = "100%") + { + //width="100%" is important. Otherwise all of our tables will be text width. + echo "<table width=\"{$width}\" align=\"center\" class=\"cleartable\">\n"; + } + + /** + * CloseTable() + * + * Closes a Bayonet site table. + * + * @return + */ + function CloseTable() + { + echo "</table>"; + } +} + +function OpenBlock($title = 'New Block') +{ + OpenTable(); + echo "<div class=\"contentHeading\">{$title}</div>"; + echo "<div class=\"content\">"; +} + +function CloseBlock() +{ + echo "</div>"; + CloseTable(); +} +/** + * ReportError() + * + * This function should be called in the event that an error has occured. + * + * @param mixed $message - automatically logged + * @return + */ +function ReportError($message) +{ + //WriteLog($message,BAYONET_LOG_ERROR); + OpenTable(); + echo "<tr><th>Error Message</th></tr><tr><td style=\"text-align:center;\">{$message}</td></tr>"; + CloseTable(); +} + +/** + * ReportHack() + * + * This function should be called in the event that we are confirming + * a hacking attempt. + * + * @param mixed $message - automatically logged + * @return void + */ +function ReportHack($message) +{ + //WriteLog($message,BAYONET_LOG_HACK); + OpenTable(); + echo "<tr><th>Hack Attempt</th></tr><tr><td style=\"text-align:center;\">{$message}</td></tr>"; + CloseTable(); +} + + +/** + * array_dump() + * + * Useful against $_POST and $_GET variables, for dumping data to + * a log file, or to stdout. The return value is a single string, + * with each array key => value pair delimited by a character. + * The default character is a pipe -> '|'. It is assumed that if + * wanted to have a newline character inserted, just replace $spacer + * with '\n'. + * + * @param mixed $array + * @param string $spacer + * @return + */ +function array_dump($array, $spacer = '|') +{ + $retval = NULL; + foreach($array as $challenge => $answer) + { + $retval .= " $challenge => $answer " . $spacer; + } + + return $retval; +} + +/** + * WriteLog() + * + * This function can be accessed directly, however, anything that is + * passed to ReportError() or ReportHack(), or decho() will be logged in their + * appropriate log file. + * + * Change made: added checks to see if the log files exist before opening + * + * @param mixed $message + * @param mixed $flag + * @return + */ +define('BAYONET_LOG_HACK','bayonet_log_hack'); +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) +{ + global $config; + $enabled = $config['logs']['enabled']; + + if(!$enabled) + { + return false; + } + + $dir = $config['logs']['dir']; + date_default_timezone_set($config['logs']['timezone']); + $varstr = array_dump($_GET); + $type = NULL; + $ip = $_SERVER['REMOTE_ADDR']; + $hostname = gethostbyaddr($ip); + $executed = $_SERVER['PHP_SELF']; + $timestamp = date('Y-M-d H:i:s T'); + + + $message = str_replace("\n",'',$message); + $message = str_replace("<br>",'',$message); + + switch($flag) + { + case BAYONET_LOG_HACK: + if(!file_exists($dir.'hacks.log')){ + break; + } + $fp = fopen($dir.'hacks.log','a'); + $type = 'HACK'; + $full_message = "TIMESTAMP: {$timestamp}\n\t\tIP: {$ip}\n\t\tHOSTNAME: {$hostname}\n\t\tACTION: {$type} of {$executed}\n\t\tDEFERRAL: {$message}\n\t\tVAR: ({$varstr})\n\n"; + break; + case BAYONET_LOG_ERROR: + if(!file_exists($dir.'error.log')){ + break; + } + $fp = fopen($dir.'error.log','a'); + $type = 'ERROR'; + $full_message = "({$timestamp}) - {$type} - {$message} - ({$varstr})\n"; + break; + case BAYONET_LOG_WARN: + if(!file_exists($dir.'warn.log')){ + break; + } + $fp = fopen($dir.'warn.log','a'); + $type = 'WARN'; + $full_message = "({$timestamp}) - {$type} - {$message} - ({$varstr})\n"; + break; + case BAYONET_LOG_INFO: + if(!file_exists($dir.'info.log')){ + break; + } + $fp = fopen($dir.'info.log','a'); + $type = 'INFO'; + $full_message = "({$timestamp}) - {$type} - {$message}\n"; + break; + default: + echo 'To log something, you need to define a log to write to.<br>'; + return; + } + if(file_exists($fp)){ + fwrite($fp,$full_message); + fclose($fp); + }else{ + //echo "could not write to file because file does not exist.<br />"; + } +} + +/** + * UnderConstruction() + * + * Displays a site-wide message across the page header. + * + * @param mixed $message + * @param mixed $flag Acceptable flags are BAYONET_SITE, and BAYONET_SECTION + * @return + */ +define('BAYONET_SITE','bayonet_site'); +define('BAYONET_SECTION','bayonet_section'); +function UnderConstruction($message = NULL, $flag = BAYONET_SITE) +{ + $timestamp = date("Y-M-d h:m:s"); + OpenTable(); + switch($flag) + { + case BAYONET_SITE: + echo "<tr><th>Site is currently under construction : $timestamp</th></tr>"; + break; + case BAYONET_SECTION: + echo "<tr><th>Section currently under construction : $timestamp</th></tr>"; + } + + if(!is_null($message)) + { + echo "<tr><td><i>$message</i></td></tr>"; + } + + CloseTable(); + echo "<br>"; +} + +/** + * GetBlocks() + * + * Includes all directories listed in blocks/ and uses the bayonet_blocks + * MySQL table to determine the order of the blocks displayed. + * + * @return + */ + +define('BLOCK_LEFT',false); +define('BLOCK_RIGHT',false); + +function GetBlocks($position = BLOCK_LEFT) +{ + global $config; + /** + * I had to reconnect to the database for some fucking reason at this point. + * I have no idea why, but I was recieving errors telling me that $db was no longer + * an object. This is/was bullshit. + */ + $db = new Bayonet_SQL(); + $db->Connect( + $config['sql']['hostname'], + $config['sql']['username'], + $config['sql']['password'] + ); + $db->Select_db($config['sql']['database']); + + $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY weight, position"); + $blocks = $db->Fetch($result); + + foreach($blocks as $block) + { + if($block['position'] == $position && $block['active'] == true) + { + $load = 'blocks/'.$block['dir_name'].'/index.php'; + if(file_exists($load)) + { + OpenBlock($block['title']); + include $load; + CloseBlock(); + } + else + { + ReportError("Failed to load block, '{$block['dir_name']}'. Check block config."); + } + if($config['blocks']['spacer']) echo "<br />"; + } + } +} + +/** + * PageRedirect() + * + * performs an http redirect + * + * @param $delay + * @param $link + */ +function PageRedirect($delay, $link) +{ + echo "<meta http-equiv=\"Refresh\" content=\"{$delay};url={$link}\">"; +} ?>
\ No newline at end of file diff --git a/admin/header.php b/admin/header.php index 61c19fa..7ecc702 100644 --- a/admin/header.php +++ b/admin/header.php @@ -1,81 +1,81 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-ob_start();
-$starttime = explode(' ', microtime());
-$starttime = $starttime[1] + $starttime[0];
-?>
-
-<html>
-
-<head>
-<title>Bayonet CMS Admin Tools</title>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-<link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
-<link rel="stylesheet" type="text/css" href="../style_bbcode.css" media="screen"/>
-
-<!-- jQuery 1.3.2 -->
-<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
-<!-- PASSWORD CHECK
-<script type="text/javascript" src="../functions.js"></script> -->
-
-<!-- markItUp! -->
-<script type="text/javascript" src="scripts/markitup/markitup/jquery.markitup.pack.js"></script>
-<!-- markItUp! toolbar settings -->
-<script type="text/javascript" src="scripts/markitup/markitup/sets/bbcode/set.js"></script>
-<!-- markItUp! skin -->
-<link rel="stylesheet" type="text/css" href="scripts/markitup/markitup/skins/markitup/style.css" />
-<!-- markItUp! toolbar skin -->
-<link rel="stylesheet" type="text/css" href="scripts/markitup/markitup/sets/bbcode/style.css" />
-<script type="text/javascript">
-<!--
-$(document).ready(function() {
- // Add markItUp! to your textarea in one line
- // $('textarea').markItUp( { Settings }, { OptionalExtraSettings } );
- $('#markItUp').markItUp(mySettings);
-
- // You can add content from anywhere in your page
- // $.markItUp( { Settings } );
- $('.add').click(function() {
- $.markItUp( { openWith:'<opening tag>',
- closeWith:'<\/closing tag>',
- placeHolder:"New content"
- }
- );
- return false;
- });
-
- // And you can add/remove markItUp! whenever you want
- // $(textarea).markItUpRemove();
- $('.toggle').click(function() {
- if ($("#markItUp.markItUpEditor").length === 1) {
- $("#markItUp").markItUpRemove();
- $("span", this).text("get markItUp! back");
- } else {
- $('#markItUp').markItUp(mySettings);
- $("span", this).text("remove markItUp!");
- }
- return false;
- });
-});
--->
-</script>
-</head>
-
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +ob_start(); +$starttime = explode(' ', microtime()); +$starttime = $starttime[1] + $starttime[0]; +?> + +<html> + +<head> +<title>Bayonet CMS Admin Tools</title> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> +<link rel="stylesheet" type="text/css" href="style.css" media="screen"/> +<link rel="stylesheet" type="text/css" href="../style_bbcode.css" media="screen"/> + +<!-- jQuery 1.3.2 --> +<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script> +<!-- PASSWORD CHECK +<script type="text/javascript" src="../functions.js"></script> --> + +<!-- markItUp! --> +<script type="text/javascript" src="scripts/markitup/markitup/jquery.markitup.pack.js"></script> +<!-- markItUp! toolbar settings --> +<script type="text/javascript" src="scripts/markitup/markitup/sets/bbcode/set.js"></script> +<!-- markItUp! skin --> +<link rel="stylesheet" type="text/css" href="scripts/markitup/markitup/skins/markitup/style.css" /> +<!-- markItUp! toolbar skin --> +<link rel="stylesheet" type="text/css" href="scripts/markitup/markitup/sets/bbcode/style.css" /> +<script type="text/javascript"> +<!-- +$(document).ready(function() { + // Add markItUp! to your textarea in one line + // $('textarea').markItUp( { Settings }, { OptionalExtraSettings } ); + $('#markItUp').markItUp(mySettings); + + // You can add content from anywhere in your page + // $.markItUp( { Settings } ); + $('.add').click(function() { + $.markItUp( { openWith:'<opening tag>', + closeWith:'<\/closing tag>', + placeHolder:"New content" + } + ); + return false; + }); + + // And you can add/remove markItUp! whenever you want + // $(textarea).markItUpRemove(); + $('.toggle').click(function() { + if ($("#markItUp.markItUpEditor").length === 1) { + $("#markItUp").markItUpRemove(); + $("span", this).text("get markItUp! back"); + } else { + $('#markItUp').markItUp(mySettings); + $("span", this).text("remove markItUp!"); + } + return false; + }); +}); +--> +</script> +</head> + <body>
\ No newline at end of file diff --git a/admin/images/tree_blank.gif b/admin/images/tree_blank.gif Binary files differnew file mode 100644 index 0000000..a2a96d6 --- /dev/null +++ b/admin/images/tree_blank.gif diff --git a/admin/images/tree_branch.gif b/admin/images/tree_branch.gif Binary files differnew file mode 100644 index 0000000..5e13681 --- /dev/null +++ b/admin/images/tree_branch.gif diff --git a/admin/images/tree_leaf.gif b/admin/images/tree_leaf.gif Binary files differnew file mode 100644 index 0000000..94ef67a --- /dev/null +++ b/admin/images/tree_leaf.gif diff --git a/admin/index.php b/admin/index.php index da8e92d..c1209e5 100644 --- a/admin/index.php +++ b/admin/index.php @@ -55,6 +55,23 @@ include 'header.php'; //this is so dirty... sigh. if(is_loggedin()) { + + //GET ADMIN USER INFO - DEFINE IMPORTANT INFO + $username = $_SESSION['username']; + $result = $db->Query("SELECT user_id, level FROM bayonet_users WHERE username = '$username' LIMIT 1"); + $row = $db->FetchRow($result); + define("ADMIN_USERNAME", $username); + define("ADMIN_ID", $row['user_id']); + define("ADMIN_LEVEL", $row['level']); + + + if(isset($_GET['op'])){ + ?> + <script type="text/javascript"> + window.location = window.location+"#operation"; + </script> + <?php + } ?> <center> @@ -65,7 +82,7 @@ include 'header.php'; <td><a href="index.php"><img src="images/bayonet_logo.jpg" alt="bayonet online web admin" /></a></td> <td style="text-align:right"> <a href="?op=settings">Account Settings</a> | - <a href="?op=logout">Logout, <?php echo $_SESSION['username']; ?></a> + <a href="?op=logout">Logout, <?php echo ADMIN_USERNAME; ?></a> </td> </tr> </table> @@ -109,6 +126,7 @@ include 'header.php'; </fieldset> <br /> +<a name="operation"></a> <div style="text-align:center"><?php include 'operation.php' ?></div> </div> diff --git a/admin/modules/functions.php b/admin/modules/functions.php index 3c44b5a..1d8d917 100644 --- a/admin/modules/functions.php +++ b/admin/modules/functions.php @@ -1,171 +1,42 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-function ListModules()
-{
- global $db;
- $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY `active` DESC, `weight` ASC, `position`");
- $blocks = $db->fetch($result);
-
- echo "<table align=\"center\"><tr><th colspan=\"3\">Existing Blocks</th></tr>";
- foreach($blocks as $block)
- {
- echo "<tr><td>{$block['weight']} : {$block['dir_name']}</td><td><a href=\"?load=admin&op=blocks&edit={$block['block_id']}\">Edit</a></td><td><a href=\"?load=admin&op=blocks&delete={$block['block_id']}\">Delete</a></td></tr>";
- }
- echo "</table>";
-}
-
-function NewModule()
-{
- global $db;
- if(isset($_POST['processed']))
- {
- //Secure our data to prevent injection attacks.
- $weight = addslashes($_POST['weight']);
- $dir_name = addslashes($_POST['dir_name']);
- $position = addslashes($_POST['position']);
- $active = addslashes($_POST['active']);
- $title = addslashes($_POST['title']);
-
- if(!is_int($weight) || empty($dir_name) || empty($title) || !is_int($position))
- {
- echo "You must fill everything out before proceeding.";
- return;
- }
- //Update the database with the new data.
- $db->Query("INSERT INTO `bayonet_blocks` SET `weight` = '$weight', `dir_name` = '$dir_name', `title` = '$title', `position` = '$position', `active` = '$active'");
- //die, because we have completed what we wanted to do.
- echo "New block, '$dir_name', at position '$weight' added.\n";
- return;
- }
-
- ?>
- <form action="<?php $_SERVER['PHP_SELF']?>" method="post">
- <table align="center">
- <tr><th>Title</th><td><input type="text" name="title" value="<?php echo $block['title'] ?>"></td></tr>
- <tr><th>Weight</th><td><input type="text" name="weight" value="<?php echo $block['weight'] ?>"></td></tr>
- <tr><th>Position</th><td><input type="text" name="position" value="<?php echo $block['position'] ?>"></td></tr>
- <tr><th>Directory Name</th><td><input type="text" name="dir_name" value="<?php echo $block['dir_name'] ?>"></td>
- <tr><th>Active</th><td>
- <select name="active">
- <option value="1">Yes</option>
- <option value="0">No</option>
- </select></td>
- <tr><th colspan="2"><input type="submit" name="processed" value="Submit"></th></tr>
- </table>
- </form>
- <?php
-}
-
-function GetActive($module_id, &$active)
-{
- $options = array(1 => 'Yes',0 => 'No');
- foreach($options as $option => $value)
- {
- $selected = NULL;
- if($active == $option)
- {
- $selected = "selected";
- }
- echo "<option " . $selected . " value=\"". $option ."\">" . $value . "</option>\n";
- }
-
-
-}
-
-function EditModule($module_id)
-{
- global $db;
- if(isset($_POST['processed']))
- {
- //Secure our data to prevent injection attacks.
- $weight = (int) addslashes($_POST['weight']);
- $dir_name = addslashes($_POST['dir_name']);
- $position = (int) addslashes($_POST['position']);
- $active = addslashes($_POST['active']);
- $title = addslashes($_POST['title']);
-
- if(!is_int($weight) || empty($dir_name) || empty($title) || !is_int($position))
- {
- echo "You must fill everything out before proceeding.";
- return;
- }
-
- //Update the database with the new data.
- $db->Query("UPDATE bayonet_blocks SET weight = '$weight', dir_name = '$dir_name', position = '$position', active = '$active' WHERE block_id = '$block_id'");
- //$isActive = $active ? "IS" : "IS NOT";
- echo "Block, '$dir_name', at position '$weight' has been edited.\n";
- PageRedirect(3, "?op=blocks");
- //die, because we have completed what we wanted to do.
- return;
- }
-
- //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->Fetch($result)
-
- ?>
- <form action="<?php $_SERVER['PHP_SELF']?>" method="post">
- <table align="center">
- <tr><th>Title</th><td><input type="text" name="title" value="<?php echo $block['title'] ?>" /></td></tr>
- <tr><th>Weight</th><td><input type="text" name="weight" value="<?php echo $block['weight'] ?>" /></td></tr>
- <tr><th>Position</th><td><input type="text" name="position" value="<?php echo $block['position'] ?>" /></td></tr>
- <tr><th>Directory Name</th><td><input type="text" name="dir_name" value="<?php echo $block['dir_name'] ?>" /></td>
- <tr><th>Active</th><td>
- <select name="active">
- <?php GetActive($block_id, $block['active']) ?>
- </select>
- </td>
-
- <tr><th colspan="2"><input type="submit" name="processed" value="Submit"></th></tr>
- </table>
- </form>
- <?php
-}
-
-function DeleteModule($module_id)
-{
- global $db;
-
- $result = $db->Query("SELECT dir_name FROM bayonet_blocks WHERE block_id = '$block_id'");
- $block = $db->Fetch($result);
-
- if(isset($_POST['proceed']))
- {
- echo "Block '{$block['dir_name']}', was deleted.";
- $db->Query("DELETE FROM bayonet_blocks WHERE block_id = '$block_id' LIMIT 1");
- return;
- }
- if(isset($_POST['cancel']))
- {
- echo "User cancelled deletion of page: '{$block['dir_name']}'";
- return;
- }
-
- ?>
- <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
- <table align="center">
- <th>Are you SURE you want to delete the block titled: '<?php echo $block['dir_name']?>'?</th>
- <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr>
- </table>
- </form>
- <?php
-}
-
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +function ListModules(){ + + global $db; + $result = $db->Query("SELECT dir_name, weight, status FROM bayonet_modules ORDER BY status DESC, weight ASC"); + $modules = $db->Fetch($result); + + OpenTable("50%"); + echo "<tr><th>Directory Name</th><th>Weight</th><th>Status</th></tr>"; + foreach($modules as $module){ + echo "<tr><td>".$module['dir_name']."</td><td>".$module['weight']."</td><td>".$module['status']."</td></tr>"; + } + CloseTable(); +} + +function EditModule($module_id){ + +} + +function DeleteModule($module_id){ + +} + ?>
\ No newline at end of file diff --git a/admin/modules/index.php b/admin/modules/index.php index 94e2814..28382eb 100644 --- a/admin/modules/index.php +++ b/admin/modules/index.php @@ -1,59 +1,61 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * This file administers the site modules.
- *
- * -weight
- * -directory name
- */
-
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-echo "Do a database for the index modules, thats all this really is anyway.<br />";
-include $basedir.'modules/functions.php';
-
-if(isset($_GET['edit']))
-{
- $module_id = $_GET['edit'];
- EditModule($module_id);
- return;
-}
-
-if(isset($_GET['delete']))
-{
- $module_id = $_GET['delete'];
- DeleteModule($module_id);
- return;
-}
-
-if(isset($_GET['create']))
-{
- NewModule();
- return;
-}
-
-//echo "<table align=\"center\" width=\"200px\"><tr><th>".LinkInternal('Create a Module','?load=admin&op=modules&create=true')."</th></tr></table>";
-
-//ListModules();
-
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * This file administers the site modules. + * + * -weight + * -directory name + */ + + ?> + <div style="text-align:left;"><h2>- Manage Modules</h2></div> + <?php + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +echo "Do a database for the index modules, thats all this really is anyway.<br />"; +include $basedir.'modules/functions.php'; + +if(isset($_GET['edit'])){ + $module_id = $_GET['edit']; + EditModule($module_id); + return; + +}else if(isset($_GET['delete'])){ + $module_id = $_GET['delete']; + DeleteModule($module_id); + return; + +}else if(isset($_GET['create'])){ + NewModule(); + return; + +}else{ + ListModules(); +} + +//echo "<table align=\"center\" width=\"200px\"><tr><th>".LinkInternal('Create a Module','?load=admin&op=modules&create=true')."</th></tr></table>"; + +//ListModules(); + ?>
\ No newline at end of file diff --git a/admin/navigation/functions.php b/admin/navigation/functions.php index 68ab7c3..da8a8e4 100644 --- a/admin/navigation/functions.php +++ b/admin/navigation/functions.php @@ -1,91 +1,91 @@ -<style>
-
-ul {
- margin: 0;
-}
-
-#contentLeft {
- width: 400px;
-}
-
-#contentLeft li {
- list-style: none;
- margin: 0 0 4px 0;
- padding: 10px;
- background-color:#a1a1a1;
- border: #CCCCCC solid 1px;
- color:#fff;
- text-align:center;
- cursor:move;
-}
-
-</style>
-<script type="text/javascript" src="scripts/jquery-ui-1.7.1.custom.min.js"></script>
-<script type="text/javascript">
-$(document).ready(function(){
-
- $(function() {
- $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
- var order = $(this).sortable("serialize") + '&action=updateOrder';
- $.post("navigation/updateDB.php", order, function(theResponse){
- $("#updateStatus").html(theResponse);
- });
- }
- });
- });
-
-});
-</script>
-<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * Note to anyone feeling the need to edit this file...
- * You MUST declare $db as global inside your functions in order access MySQL from here.
- */
-
-function ListNavigation(){
-
- global $db;
- $result = $db->Query("SELECT `nav_id`, `title`, `weight` FROM `bayonet_navigation` ORDER BY `weight`");
- $data = $db->Fetch($result);
-
- ?>
- <div id="contentLeft">
- <table>
- <tr>
- <th>News Reel Order</th>
- <td id="updateStatus"></td>
- </tr>
- </table>
- <ul>
- <?php
-
- foreach($data as $nav){
-
- echo "<li id=\"recordsArray_{$nav['nav_id']}\">{$nav['title']}</li>";
- }
- ?>
- </ul>
- Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved.
- </div>
- <?php
-
-}
+<style> + +ul { + margin: 0; +} + +#contentLeft { + width: 400px; +} + +#contentLeft li { + list-style: none; + margin: 0 0 4px 0; + padding: 10px; + background-color:#a1a1a1; + border: #CCCCCC solid 1px; + color:#fff; + text-align:center; + cursor:move; +} + +</style> +<script type="text/javascript" src="scripts/jquery-ui-1.7.1.custom.min.js"></script> +<script type="text/javascript"> +$(document).ready(function(){ + + $(function() { + $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() { + var order = $(this).sortable("serialize") + '&action=updateOrder'; + $.post("navigation/updateDB.php", order, function(theResponse){ + $("#updateStatus").html(theResponse); + }); + } + }); + }); + +}); +</script> +<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Note to anyone feeling the need to edit this file... + * You MUST declare $db as global inside your functions in order access MySQL from here. + */ + +function ListNavigation(){ + + global $db; + $result = $db->Query("SELECT `nav_id`, `title`, `weight` FROM `bayonet_navigation` ORDER BY `weight`"); + $data = $db->Fetch($result); + + ?> + <div id="contentLeft"> + <table> + <tr> + <th>News Reel Order</th> + <td id="updateStatus"></td> + </tr> + </table> + <ul> + <?php + + foreach($data as $nav){ + + echo "<li id=\"recordsArray_{$nav['nav_id']}\">{$nav['title']}</li>"; + } + ?> + </ul> + Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. + </div> + <?php + +} ?>
\ No newline at end of file diff --git a/admin/navigation/index.php b/admin/navigation/index.php index e2179a1..fff3196 100644 --- a/admin/navigation/index.php +++ b/admin/navigation/index.php @@ -1,54 +1,54 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ?>
-
- <div style="text-align:left;"><h2>- Navigation Links</h2></div>
- -Edit Order, Edit Page, Delete Pages, Add Pages<br />
-
-<?php
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-
-include $basedir.'navigation/functions.php';
-
-if(isset($_GET['edit']))
-{
- $block_id = $_GET['edit'];
- EditBlock($block_id);
- return;
-}
-
-if(isset($_GET['delete']))
-{
- $block_id = $_GET['delete'];
- DeleteBlock($block_id);
- return;
-}
-
-if(isset($_GET['create']))
-{
- NewBlock();
- return;
-}
-
- ListNavigation();
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + ?> + + <div style="text-align:left;"><h2>- Navigation Links</h2></div> + -Edit Order, Edit Page, Delete Pages, Add Pages<br /> + +<?php +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + + +include $basedir.'navigation/functions.php'; + +if(isset($_GET['edit'])) +{ + $block_id = $_GET['edit']; + EditBlock($block_id); + return; +} + +if(isset($_GET['delete'])) +{ + $block_id = $_GET['delete']; + DeleteBlock($block_id); + return; +} + +if(isset($_GET['create'])) +{ + NewBlock(); + return; +} + + ListNavigation(); ?>
\ No newline at end of file diff --git a/admin/news/functions.php b/admin/news/functions.php index 6feabcf..9645311 100644 --- a/admin/news/functions.php +++ b/admin/news/functions.php @@ -21,24 +21,20 @@ 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 ". + $result = $db->Query("SELECT n.news_id, n.title, 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"); + "LEFT OUTER JOIN `bayonet_users` AS u ON u.user_id = n.author_id ORDER BY `date` DESC"); $row = $db->Fetch($result); foreach($row as $news) { - $newsBody = $news['message']; - echo "<a href=\"?op=news&edit={$news['news_id']}\">"; - echo "<span class=\"bold\">{$news['title']}</span> | <span class=\"blue\">{$news['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: {$news['author']} on ".date('D M j, Y g:i a T', strtotime($news['date'])); - echo '<br /><br />'; +?> + <a href="?op=news&edit=<?php echo $news['news_id']; ?>"> + <span class="bold"><?php echo $news['title']; ?></span> | <span class="blue"><?php echo $news['catname']; ?></span> <img src="images/page.png" /></a><br /> + Posted By: <?php echo $news['author']; ?> on <?php echo date('n/j/Y @ g:ia T', strtotime($news['date'])); ?> + <br /><br /> +<?php } } @@ -49,26 +45,90 @@ function EditNews($news_id){ if(isset($_POST['processed'])){ + $title = $_POST['title']; + //$datetime = $_POST['year']."-".$_POST['month']."-".$_POST['day']." ".$_POST['time']; + date_default_timezone_set('America/New_York'); + $datetime = date('Y-m-d H:i:s'); + $text = $_POST['text']; + $author_id = $_POST['author']; + $edited_id = ADMIN_ID; + //$category_id = 1; + $text = addslashes($text); + + $db->Query("UPDATE `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `edited` = '$datetime', `edited_id` = '$edited_id' WHERE `news_id` = '$news_id'"); + decho("UPDATE `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `edited` = '$datetime', `edited_id` = '$edited_id' WHERE `news_id` = '$news_id'"); + PageRedirect(1, "?op=news"); return; } - $result = $db->Query("SELECT `author_id`, `title`, `message`, `date`, `category_id` FROM `bayonet_news` WHERE `news_id` = '$news_id' LIMIT 1"); + $result = $db->Query("SELECT `author_id`, `title`, `message`, `date`, `category_id`, `edited`, `edited_id` FROM `bayonet_news` WHERE `news_id` = '$news_id' LIMIT 1"); $row = $db->FetchRow($result); - ?> +?> +<style type="text/css"> +input { + height: 35px; + width: 300px; + font-size: 18px; + } +</style> <h3>Edit News</h3> - <form action="<?php $_SERVER['PHP_SELF']?>" method="post"> + <form action="" method="post"> + Originally posted on <?php echo date('n/j/Y @ g:ia e', strtotime($row['date'])); ?> +<?php + if($row['edited'] != NULL){ + echo "<br />Last edited on ".date('n/j/Y @ g:ia e', strtotime($row['edited'])); + } +?> <table> <tr><th>Author</th><td><?php SelectAuthor($row['author_id']); ?></td></tr> <tr><th>Title</th><td><input type="text" name="title" value="<?php echo $row['title']; ?>" /></td></tr> - <tr><th>Date</th><td><?php SelectDate($row['date']); ?></td></tr> - <tr><th>Time</th><td><input type="text" name="time" value="<?php echo date('G:i', strtotime($row['date'])); ?>" maxlength="5" size="5" /></td></tr> <tr><th>Text</th><td><textarea id="markItUp" rows="30" cols="80" name="text"><?php echo $row['message']; ?></textarea></td> <tr><th colspan="2"><input type="submit" name="processed" value="Submit" /></th></tr> </table> </form> - <?php +<?php +} + +function CreateNews(){ + + global $db; + + if(isset($_POST['processed'])){ + + $title = $_POST['title']; + //$datetime = $_POST['year']."-".$_POST['month']."-".$_POST['day']." ".$_POST['time']; + date_default_timezone_set('America/New_York'); + $datetime = date('Y-m-d H:i:s'); + $text = $_POST['text']; + $author_id = ADMIN_ID; + $category_id = 1; + $text = addslashes($text); + + $db->Query("INSERT INTO `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `date` = '$datetime', `category_id` = '$category_id'"); + + decho("INSERT INTO `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `date` = '$datetime', `category_id` = '$category_id'"); + PageRedirect(1, "?op=news"); + return; + } +?> +<style type="text/css"> +input { + height: 35px; + width: 300px; + font-size: 18px; + } +</style> + <h3>Post News</h3> + <form action="" method="post"> + <table> + <tr><td> <input type="text" name="title" value="" /></td></tr> + <tr><td><textarea id="markItUp" rows="30" cols="80" name="text"></textarea></td> + <tr><th colspan="2"><input type="submit" name="processed" value="Post" /></th></tr> + </table> + </form> +<?php } /** diff --git a/admin/news/index.php b/admin/news/index.php index ec78089..6cd8d30 100644 --- a/admin/news/index.php +++ b/admin/news/index.php @@ -39,6 +39,8 @@ if(isset($_GET['edit'])){ } else{ ListNews(); + echo "</td><td class=\"panel-shadow\">"; + CreateNews(); } diff --git a/admin/newsreel/functions.php b/admin/newsreel/functions.php index 6bde17c..f8cb759 100644 --- a/admin/newsreel/functions.php +++ b/admin/newsreel/functions.php @@ -1,160 +1,160 @@ -<style>
-
-ul {
- margin: 0;
-}
-
-#contentLeft {
- width: 400px;
-}
-
-#contentLeft li {
- list-style: none;
- margin: 0 0 4px 0;
- padding: 10px;
- background-color:#a1a1a1;
- border: #CCCCCC solid 1px;
- color:#fff;
- text-align:center;
- cursor:move;
-}
-
-</style>
-<script type="text/javascript" src="scripts/jquery-ui-1.7.1.custom.min.js"></script>
-<script type="text/javascript">
-$(document).ready(function(){
-
- $(function() {
-
- $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
- var order = $(this).sortable("serialize") + '&action=updateReelOrder';
- $.post("newsreel/updateDB.php", order, function(theResponse){
- $("#updateStatus").html(theResponse);
- });
- }
- });
- });
-
-});
-</script>
-<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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;
- ?>
- <div id="contentLeft">
- <table>
- <tr>
- <th>News Reel Order</th>
- <td id="updateStatus"></td>
- </tr>
- </table>
- <ul>
- <?php
- $result = $db->Query("SELECT `title`, `slide_id`, `src` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` ASC");
- $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.
- </div>
-<?php
- }
-
- function EnableSlide($slide_id){
-
- global $db;
- $lastspot = GetLastPosition();
- 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;
- }
- $weight = $lastspot+1;
- $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 1, `weight` = '$weight' WHERE `slide_id` = '$slide_id' LIMIT 1");
- PageRedirect(0,"?op=newsreel");
- }
-
- function DisableSlide($slide_id){
-
- global $db;
- $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `slide_id` = '$slide_id' LIMIT 1");
- $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");
- }
-
- function ListInactive(){
-
- 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");
- $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){
- echo "{$slide['title']}";
- if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){
- echo "<br /><img src=\"../modules/newsreel/slides/{$slide['src']}\" width=\"100px\" />";
- }
- }
-
- function GetLastPosition(){
-
- global $db;
- $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1");
- $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);
- }
-
-
+<style> + +ul { + margin: 0; +} + +#contentLeft { + width: 400px; +} + +#contentLeft li { + list-style: none; + margin: 0 0 4px 0; + padding: 10px; + background-color:#a1a1a1; + border: #CCCCCC solid 1px; + color:#fff; + text-align:center; + cursor:move; +} + +</style> +<script type="text/javascript" src="scripts/jquery-ui-1.7.1.custom.min.js"></script> +<script type="text/javascript"> +$(document).ready(function(){ + + $(function() { + + $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() { + var order = $(this).sortable("serialize") + '&action=updateReelOrder'; + $.post("newsreel/updateDB.php", order, function(theResponse){ + $("#updateStatus").html(theResponse); + }); + } + }); + }); + +}); +</script> +<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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; + ?> + <div id="contentLeft"> + <table> + <tr> + <th>News Reel Order</th> + <td id="updateStatus"></td> + </tr> + </table> + <ul> + <?php + $result = $db->Query("SELECT `title`, `slide_id`, `src` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` ASC"); + $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. + </div> +<?php + } + + function EnableSlide($slide_id){ + + global $db; + $lastspot = GetLastPosition(); + 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; + } + $weight = $lastspot+1; + $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 1, `weight` = '$weight' WHERE `slide_id` = '$slide_id' LIMIT 1"); + PageRedirect(0,"?op=newsreel"); + } + + function DisableSlide($slide_id){ + + global $db; + $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `slide_id` = '$slide_id' LIMIT 1"); + $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"); + } + + function ListInactive(){ + + 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"); + $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){ + echo "{$slide['title']}"; + if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){ + echo "<br /><img src=\"../modules/newsreel/slides/{$slide['src']}\" width=\"100px\" />"; + } + } + + function GetLastPosition(){ + + global $db; + $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1"); + $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); + } + + ?>
\ No newline at end of file diff --git a/admin/newsreel/index.php b/admin/newsreel/index.php index 0b97deb..18a239d 100644 --- a/admin/newsreel/index.php +++ b/admin/newsreel/index.php @@ -1,46 +1,46 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-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>
- <td class="panel-box" width="50%">
- <?php
- if(isset($_GET['enable'])){
- $slide_id = $_GET['enable'];
- EnableSlide($slide_id);
- }else if(isset($_GET['disable'])){
- $slide_id = $_GET['disable'];
- DisableSlide($slide_id);
- }else{
- ListInactive();
- }
- ?>
- </td>
- </tr>
- </table>
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +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> + <td class="panel-box" width="50%"> + <?php + if(isset($_GET['enable'])){ + $slide_id = $_GET['enable']; + EnableSlide($slide_id); + }else if(isset($_GET['disable'])){ + $slide_id = $_GET['disable']; + DisableSlide($slide_id); + }else{ + ListInactive(); + } + ?> + </td> + </tr> + </table> diff --git a/admin/newsreel/updateDB.php b/admin/newsreel/updateDB.php index f4031a2..cd1a311 100644 --- a/admin/newsreel/updateDB.php +++ b/admin/newsreel/updateDB.php @@ -1,40 +1,49 @@ -<?php
-
-include '../../includes/debug.php';
-include '../../includes/config.php';
-include '../../includes/sql.class.php';
-include '../../includes/functions.php';
-
-$action = $_POST['action'];
-$updateRecordsArray = $_POST['recordsArray'];
-
-$db = new Bayonet_SQL();
-$db->Connect(
- $config['sql']['hostname'],
- $config['sql']['username'],
- $config['sql']['password']
- );
-$db->Select_db($config['sql']['database']);
-
-if ($action == "updateReelOrder"){
-
- $listingCounter = 1;
- foreach ($updateRecordsArray as $recordIDValue) {
-
- $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'");
- $listingCounter = $listingCounter + 1;
- }
- echo "<img src=\"images/accepted.png\" />";
-/*
- echo '<pre>';
- print_r($updateRecordsArray);
- echo '</pre>';
- echo 'If you refresh the page, you will see that records will stay just as you modified.';
-*/
-}
-else{
- echo "<img src=\"images/rejected.png\" />";
-}
-date_default_timezone_set("America/New_York");
-echo " Updated at ".date("g:i:s a", time());
+<?php + +//basename(dirname('.')) +$dirname = "/home/thirdid/3rd-infantry-division.org"; + +define('BAYONET_ROOT', $dirname); +define('BAYONET_INCLUDE', BAYONET_ROOT . '/include'); +define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini'); + +require BAYONET_INCLUDE . '/debug.php'; +require BAYONET_INCLUDE . '/sql.class.php'; +require BAYONET_INCLUDE . '/functions.php'; + +Bayonet_Config::init(); +$config = Bayonet_Config::$ini; +$db = new Bayonet_SQL(); + + +//Connect to the MySQL server +$db->Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']); +$db->Select_db($config['sql']['database']); + +/*----------------------------- */ + +$action = $_POST['action']; +$updateRecordsArray = $_POST['recordsArray']; + +if ($action == "updateReelOrder"){ + + $listingCounter = 1; + foreach ($updateRecordsArray as $recordIDValue) { + + $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'"); + $listingCounter = $listingCounter + 1; + } + echo "<img src=\"images/accepted.png\" />"; +/* + echo '<pre>'; + print_r($updateRecordsArray); + echo '</pre>'; + echo 'If you refresh the page, you will see that records will stay just as you modified.'; +*/ +} +else{ + echo "<img src=\"images/rejected.png\" />"; +} +date_default_timezone_set("America/New_York"); +echo " Updated at ".date("g:i:s a", time()); ?>
\ No newline at end of file diff --git a/admin/rudi/functions.php b/admin/rudi/functions.php index b22468b..dc6faea 100644 --- a/admin/rudi/functions.php +++ b/admin/rudi/functions.php @@ -1,71 +1,71 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /*
- include $basedir.'rudi/functions.php';
-
- //chek to see if the person is indeed an quartermaster
-
- if(isset($_GET['edit'])){
-
- if($_GET['edit'] == "profile"){
- $member_id = $_GET['id'];
- EditProfile($member_id);
- return;
- }
- if($_GET['edit'] == "service"){
- if(isset($_GET['var'])){
- if($_GET['var'] == "add"){
- $member_id = $_GET['id'];
- AddServiceRecord($member_id);
- }
- if($_GET['var'] == "edit"){
- $record_id = $_GET['id'];
- EditServiceRecord($record_id);
- }
- if($_GET['var'] == "delete"){
- $record_id = $_GET['id'];
- }
- }else{
- $member_id = $_GET['id'];
- ListServiceRecord($member_id);
- }
- return;
- }
- if($_GET['edit'] == "medals"){
- if(isset($_GET['var'])){
- if($_GET['var'] == "add"){
-
- }
- if($_GET['var'] == "edit"){
-
- }
- if($_GET['var'] == "delete"){
-
- }
- }else{
- $member_id = $_GET['id'];
- ListMedalRecord($member_id);
- }
-
- return;
- }
- }
-
- ListMembers(); */
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + /* + include $basedir.'rudi/functions.php'; + + //chek to see if the person is indeed an quartermaster + + if(isset($_GET['edit'])){ + + if($_GET['edit'] == "profile"){ + $member_id = $_GET['id']; + EditProfile($member_id); + return; + } + if($_GET['edit'] == "service"){ + if(isset($_GET['var'])){ + if($_GET['var'] == "add"){ + $member_id = $_GET['id']; + AddServiceRecord($member_id); + } + if($_GET['var'] == "edit"){ + $record_id = $_GET['id']; + EditServiceRecord($record_id); + } + if($_GET['var'] == "delete"){ + $record_id = $_GET['id']; + } + }else{ + $member_id = $_GET['id']; + ListServiceRecord($member_id); + } + return; + } + if($_GET['edit'] == "medals"){ + if(isset($_GET['var'])){ + if($_GET['var'] == "add"){ + + } + if($_GET['var'] == "edit"){ + + } + if($_GET['var'] == "delete"){ + + } + }else{ + $member_id = $_GET['id']; + ListMedalRecord($member_id); + } + + return; + } + } + + ListMembers(); */ ?>
\ No newline at end of file diff --git a/admin/rudi/includes/functions.awards.php b/admin/rudi/includes/functions.awards.php index 439f0e1..0b4b1e2 100644 --- a/admin/rudi/includes/functions.awards.php +++ b/admin/rudi/includes/functions.awards.php @@ -1,20 +1,20 @@ -<?php
-
- function getAwardClasses(){
- global $db;
- $result = $db->Query("SELECT `name`, `class_id` FROM `rudi_award_classes`");
- return $db->Fetch($result);
- }
-
- function getAwardsByClass($class_id){
- global $db;
- $result = $db->Query("SELECT `award_id`, `name`, `image`, `description` FROM `rudi_awards` WHERE `class_id` = '$class_id' ORDER BY `name`");
- return $db->Fetch($result);
- }
-
- function getAward($award_id){
- global $db;
- $result = $db->Query("SELECT `award_id`, `name`, `image`, `description`, `class_id` FROM `rudi_awards` WHERE `award_id` = '$award_id' LIMIT 1");
- return $db->FetchRow($result);
- }
+<?php + + function getAwardClasses(){ + global $db; + $result = $db->Query("SELECT `name`, `class_id` FROM `rudi_award_classes`"); + return $db->Fetch($result); + } + + function getAwardsByClass($class_id){ + global $db; + $result = $db->Query("SELECT `award_id`, `name`, `image`, `description` FROM `rudi_awards` WHERE `class_id` = '$class_id' ORDER BY `name`"); + return $db->Fetch($result); + } + + function getAward($award_id){ + global $db; + $result = $db->Query("SELECT `award_id`, `name`, `image`, `description`, `class_id` FROM `rudi_awards` WHERE `award_id` = '$award_id' LIMIT 1"); + return $db->FetchRow($result); + } ?>
\ No newline at end of file diff --git a/admin/rudi/includes/functions.battles.php b/admin/rudi/includes/functions.battles.php new file mode 100644 index 0000000..2b878da --- /dev/null +++ b/admin/rudi/includes/functions.battles.php @@ -0,0 +1,70 @@ +<?php + + function getAllBattles(){ + global $db; + + $result = $db->Query("SELECT w.war_id, + w.title, + w.visit_unit_id, + w.home_score, + w.visit_score, + w.date, + w.status, + v.name + FROM rudi_war_stats AS w + LEFT OUTER JOIN rudi_war_units AS v + ON v.visitor_id = w.visit_unit_id + ORDER BY w.date"); + $data = $db->Fetch($result); + + return $data; + } + + function getBattleInfo($war_id){ + global $db; + + $result = $db->Query("SELECT w.war_id, + w.title, + w.visit_unit_id, + w.home_score, + w.visit_score, + w.date, + w.status, + v.name + FROM rudi_war_stats AS w + LEFT OUTER JOIN rudi_war_units AS v + ON v.visitor_id = w.visit_unit_id + WHERE w.war_id = {$war_id}"); + $data = $db->FetchRow($result); + + return $data; + } + + function getCombatSoldiers($war_id){ + global $db; + + $query = "SELECT m.member_id, + m.first_name, + m.last_name, + r.shortname, + r.longname, + w.record_id, + + FROM rudi_combat_record AS w + JOIN rudi_unit_members AS m + ON m.member_id = w.member_id + JOIN rudi_ranks AS r + ON m.rank_id = r.rank_id + WHERE m.status_id < 4, w.war_id = {$war_id} OR w.war_id IS NULL + ORDER BY r.weight DESC , m.date_promotion ASC , m.date_enlisted ASC"; + + decho($query); + $result = $db->Query($query); + $data = $db->Fetch($result); + + + + return $data; + } + +?>
\ No newline at end of file diff --git a/admin/rudi/includes/functions.members.php b/admin/rudi/includes/functions.members.php index 6a4970e..86848dc 100644 --- a/admin/rudi/includes/functions.members.php +++ b/admin/rudi/includes/functions.members.php @@ -48,9 +48,17 @@ function GetRoles(){ global $db; - $result = $db->Query("SELECT * FROM `rudi_roles`"); - $row = $db->Fetch($result); - return $row; + $data = array(); + $result = $db->Query("SELECT * FROM `rudi_role_classes` ORDER BY `weight` ASC"); + $classes = $db->Fetch($result); + + foreach($classes as $class){ + $rclass_id = $class['rclass_id']; + $result2 = $db->Query("SELECT * FROM rudi_roles WHERE rclass_id = '$rclass_id' ORDER BY `weight` ASC"); + $data[] = array("name" => $class['name'], "roles" => $db->Fetch($result2)); + } + + return $data; } function GetCountry(){ @@ -177,7 +185,7 @@ <td><?php echo date("M j Y", strtotime($record['date_added'])); ?></td> <td><?php echo $record['record_note']; ?></td> <td><a href="?op=rudi&show=members&award=<?php echo $member_id; ?>&edit=<?php echo $record['record_id']; ?>">Edit</a></td> - <td><a href="?op=rudi&show=members&award=<?php echo $row['member_id']; ?>&delete=<?php echo $record['record_id']; ?>">Delete</a></td> + <td><a href="?op=rudi&show=members&award=<?php echo $member_id; ?>&delete=<?php echo $record['record_id']; ?>">Delete</a></td> </tr> <?php } @@ -224,6 +232,38 @@ } + function DeleteAwardRecord($record_id){ + global $db; + + $result = $db->Query("SELECT r.date_added, r.record_note, r.member_id, a.name FROM rudi_award_record AS r LEFT OUTER JOIN rudi_awards AS a ON a.award_id = r.award_id WHERE r.record_id = '$record_id' LIMIT 1"); + $record = $db->FetchRow($result); + decho($record_id); + decho($record); + $form = new BayonetForm("", "POST"); + + if(isset($_POST['proceed'])) + { + echo "Award '{$record['name']}', was deleted from that soldiers record."; + $db->Query("DELETE FROM `rudi_award_record` WHERE `record_id` = '$record_id' LIMIT 1"); + PageRedirect(2, "?op=rudi&show=members&award={$record['member_id']}"); + return; + } + if(isset($_POST['cancel'])) + { + echo "User cancelled deletion of award: '{$record['name']}'"; + PageRedirect(2, "?op=rudi&show=members&award={$award['member_id']}"); + return; + } + + OpenTable(); +?> + <th>Are you <u>SURE</u> you want to delete the award record: '<?php echo $record['name'];?>'? for this member?<br />All changes are final.</th> + <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr> +<?php + CloseTable(); + $form->__destruct(); + } + function AddAwardRecord($member_id){ global $db; diff --git a/admin/rudi/includes/functions.units.php b/admin/rudi/includes/functions.units.php new file mode 100644 index 0000000..5005fa0 --- /dev/null +++ b/admin/rudi/includes/functions.units.php @@ -0,0 +1,33 @@ +<?php + + function DisplayUnits(){ + global $db; + $result = $db->Query("SELECT `unit_id`, `name` FROM `rudi_combat_units` WHERE `detachment` = 0 "); + $row = $db->Fetch($result); + foreach($row as $unit){ + $unit_name = $unit['name']; + $unit_id = $unit['unit_id']; + echo '<img src="images/tree_branch.gif" /> '.$unit_name.'<br />'; + selectUnits($unit_id, 0, $member['cunit_id']); + } + } + + function selectUnits($previous_unit, $indent, $members_unit){ + global $db; + + $indent++; + //$formatting = str_repeat(" ", $indent); + $formatting = str_repeat('<img src="images/tree_leaf.gif" />', $indent); + + $result = $db->Query("SELECT `unit_id`, `name` FROM `rudi_combat_units` WHERE `detachment` = '$previous_unit'"); + $row = $db->Fetch($result); + foreach($row as $unit){ + $unit_id = $unit['unit_id']; + $unit_name = $unit['name']; + echo $formatting.'<img src="images/tree_branch.gif" /> '.$unit_name.'<br />'; + + selectUnits($unit_id, $indent, $members_unit); + } + } + +?>
\ No newline at end of file diff --git a/admin/rudi/index.php b/admin/rudi/index.php index 2e4a42a..62eaacf 100644 --- a/admin/rudi/index.php +++ b/admin/rudi/index.php @@ -1,59 +1,63 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- ?>
- <link rel="stylesheet" type="text/css" href="rudi/style.css" media="screen"/>
- <div style="text-align:left;"><h2>- RUDI/Quartermaster Control Panel</h2></div>
- <?php
- if(!defined("ADMIN_FILE"))
- {
- die("Access denied.");
- }
-
- if(isset($_GET['show'])){
-
- switch($_GET['show']){
- case 'members':
- include $basedir.'rudi/views/view.members.php';
- break;
- case 'units':
- include $basedir.'rudi/views/view.units.php';
- break;
- case 'awards':
- include $basedir.'rudi/views/view.awards.php';
- break;
- case 'ranks':
- include $basedir.'rudi/views/view.ranks.php';
- break;
- case 'drills':
- include $basedir.'rudi/views/view.drills.php';
- break;
- }
- }else{
- $th = array('Rudi Options','');
- $td = array(
- LinkInternal('Roster','?op=rudi&show=members'),
- LinkInternal('Units','?op=rudi&show=units'),
- LinkInternal('Awards', '?op=rudi&show=awards')
- );
-
- //render administration table
- CompileAdmin($th,$td);
- }
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + ?> + <link rel="stylesheet" type="text/css" href="rudi/style.css" media="screen"/> + <div style="text-align:left;"><h2>- RUDI/Quartermaster Control Panel</h2></div> + <?php + if(!defined("ADMIN_FILE")) + { + die("Access denied."); + } + + if(isset($_GET['show'])){ + + switch($_GET['show']){ + case 'members': + include $basedir.'rudi/views/view.members.php'; + break; + case 'units': + include $basedir.'rudi/views/view.units.php'; + break; + case 'awards': + include $basedir.'rudi/views/view.awards.php'; + break; + case 'ranks': + include $basedir.'rudi/views/view.ranks.php'; + break; + case 'drills': + include $basedir.'rudi/views/view.drills.php'; + break; + case 'battles': + include $basedir.'rudi/views/view.battles.php'; + break; + } + }else{ + $th = array('Rudi Options',''); + $td = array( + LinkInternal('Roster','?op=rudi&show=members'), + LinkInternal('Units','?op=rudi&show=units'), + LinkInternal('Awards', '?op=rudi&show=awards'), + LinkInternal('Battles', '?op=rudi&show=battles') + ); + + //render administration table + CompileAdmin($th,$td); + } ?>
\ No newline at end of file diff --git a/admin/rudi/views/view.awards.add.php b/admin/rudi/views/view.awards.add.php new file mode 100644 index 0000000..9c97c54 --- /dev/null +++ b/admin/rudi/views/view.awards.add.php @@ -0,0 +1,27 @@ +<?php + $class_id = $_GET['cid']; + $form = new BayonetForm("", "POST"); + if($form->verifySubmit('processed')) + { + global $db; + $name = $form->request['name']; + $text = $form->request['text']; + $db->Query("INSERT INTO `rudi_awards` SET `class_id` = '$class_id', `name` = '$name', `image` = '', `description` = '$text'"); + + PageRedirect(1, "?op=rudi&show=awards&cid={$class_id}"); + return; + } + echo LinkInternal("Cancel","?op=rudi&show=awards&cid={$class_id}"); + OpenTable(); +?> + +<tr><th>Name:</th><td><?php $form->textField('name', "", false, "50"); ?></td><tr> +<tr><th>Image:</th><td><?php ?></td></tr> +<tr><th>Text:</th><td><?php $form->textArea('text',10,30); ?></td></tr> +<tr><td><?php $form->submitButton('processed', 'Add'); ?></td></tr> + +<?php + CloseTable(); + $form->__destruct(); +?> + diff --git a/admin/rudi/views/view.awards.delete.php b/admin/rudi/views/view.awards.delete.php new file mode 100644 index 0000000..6fde068 --- /dev/null +++ b/admin/rudi/views/view.awards.delete.php @@ -0,0 +1,29 @@ +<?php + global $db; + + $result = $db->Query("SELECT `name`, `class_id` FROM `rudi_awards` WHERE `award_id` = '$award_id' LIMIT 1"); + $award = $db->FetchRow($result); + $form = new BayonetForm("", "POST"); + + if(isset($_POST['proceed'])) + { + echo "Award '{$award['name']}', was deleted."; + $db->Query("DELETE FROM `rudi_awards` WHERE `award_id` = '$award_id' LIMIT 1"); + PageRedirect(2, "?op=rudi&show=awards&cid={$award['class_id']}"); + return; + } + if(isset($_POST['cancel'])) + { + echo "User cancelled deletion of award: '{$award['name']}'"; + PageRedirect(2, "?op=rudi&show=awards&cid={$award['class_id']}"); + return; + } + + OpenTable(); +?> + <th>Are you <u>SURE</u> you want to delete the award titled: '<?php echo $award['name'];?>'?<br />All users who have recieved this award will lose it off their records (not yet at least).</th> + <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr> +<?php + CloseTable(); + $form->__destruct(); +?>
\ No newline at end of file diff --git a/admin/rudi/views/view.awards.edit.php b/admin/rudi/views/view.awards.edit.php index 21ec156..0b82ef6 100644 --- a/admin/rudi/views/view.awards.edit.php +++ b/admin/rudi/views/view.awards.edit.php @@ -1,27 +1,27 @@ -<?php
- $award = getAward($award_id);
- $form = new BayonetForm("", "POST");
- if($form->verifySubmit('processed'))
- {
- global $db;
- $name = $form->request['name'];
- $text = $form->request['text'];
- $db->Query("UPDATE `rudi_awards` SET `name` = '$name', `description` = '$text' WHERE `award_id` = '$award_id' LIMIT 1");
-
- PageRedirect(1, "?op=rudi&show=awards&award={$award_id}");
- return;
- }
- echo LinkInternal("Cancel","?op=rudi&show=awards&cid={$award['class_id']}");
- OpenTable();
-?>
-
-<tr><th>Name:</th><td><?php $form->textField('name', $award['name'], false, "50"); ?></td><tr>
-<tr><th>Image:</th><td><?php ?></td></tr>
-<tr><th>Text:</th><td><?php $form->textArea('text',10,30,$award['description']); ?></td></tr>
-<tr><td><?php $form->submitButton('processed', 'Update'); ?></td></tr>
-
-<?php
- CloseTable();
- $form->__destruct();
-?>
-
+<?php + $award = getAward($award_id); + $form = new BayonetForm("", "POST"); + if($form->verifySubmit('processed')) + { + global $db; + $name = $form->request['name']; + $text = $form->request['text']; + $db->Query("UPDATE `rudi_awards` SET `name` = '$name', `description` = '$text' WHERE `award_id` = '$award_id' LIMIT 1"); + + PageRedirect(1, "?op=rudi&show=awards&award={$award_id}"); + return; + } + echo LinkInternal("Cancel","?op=rudi&show=awards&cid={$award['class_id']}"); + OpenTable(); +?> + +<tr><th>Name:</th><td><?php $form->textField('name', $award['name'], false, "50"); ?></td><tr> +<tr><th>Image:</th><td><?php ?></td></tr> +<tr><th>Text:</th><td><?php $form->textArea('text',10,30,$award['description']); ?></td></tr> +<tr><td><?php $form->submitButton('processed', 'Update'); ?></td></tr> + +<?php + CloseTable(); + $form->__destruct(); +?> + diff --git a/admin/rudi/views/view.awards.php b/admin/rudi/views/view.awards.php index b4c912f..3a5729f 100644 --- a/admin/rudi/views/view.awards.php +++ b/admin/rudi/views/view.awards.php @@ -1,40 +1,40 @@ -<?php
- include $basedir.'rudi/includes/functions.awards.php';
- if(isset($_GET['award'])){
- $award_id = $_GET['award'];
- include 'view.awards.edit.php';
- }else if(isset($_GET['add'])){
- include 'view.awards.add.php';
- }else if(isset($_GET['delete'])){
- $award_id = $_GET['delete'];
- include 'view.awards.delete.php';
- }else{
- echo "<h3>Award Classes</h3>";
- $classes = getAwardClasses();
- OpenTable();
- echo "<tr style=\"text-align:center\">";
- foreach($classes as $class){
- echo "<td>".LinkInternal($class['name'],'?op=rudi&show=awards&cid='.$class['class_id'])."</td>";
- }
- echo "</tr>";
- CloseTable();
-
- if(isset($_GET['cid'])){
- $class_id = $_GET['cid'];
- $awards = getAwardsByClass($class_id);
- echo "<h3>Awards</h3>";
- echo LinkInternal('<img src="images/add.png" /> Add New Award','?op=rudi&show=awards&cid={$class_id}&add=true');
- OpenTable();
- foreach($awards as $award){
- echo "<tr><td>".$award['name']."</td>
- <td><a href=\"?op=rudi&show=awards&award={$award['award_id']}\">Edit</a></td>
- <td><a href=\"?op=rudi&show=awards&delete={$award['award_id']}\">Delete</a></td></tr>";
- }
- CloseTable();
- //include 'view.members.profile.php';
- }else if(isset($_GET['aid'])){
- $award_id = $_GET['aid'];
- //include 'view.members.service.php';
- }
- }
+<?php + include $basedir.'rudi/includes/functions.awards.php'; + if(isset($_GET['award'])){ + $award_id = $_GET['award']; + include 'view.awards.edit.php'; + }else if(isset($_GET['add'])){ + include 'view.awards.add.php'; + }else if(isset($_GET['delete'])){ + $award_id = $_GET['delete']; + include 'view.awards.delete.php'; + }else{ + echo "<h3>Award Classes</h3>"; + $classes = getAwardClasses(); + OpenTable(); + echo "<tr style=\"text-align:center\">"; + foreach($classes as $class){ + echo "<td>".LinkInternal($class['name'],'?op=rudi&show=awards&cid='.$class['class_id'])."</td>"; + } + echo "</tr>"; + CloseTable(); + + if(isset($_GET['cid'])){ + $class_id = $_GET['cid']; + $awards = getAwardsByClass($class_id); + echo "<h3>Awards</h3>"; + echo LinkInternal('<img src="images/add.png" /> Add New Award','?op=rudi&show=awards&cid={$class_id}&add=true'); + OpenTable(); + foreach($awards as $award){ + echo "<tr><td>".$award['name']."</td> + <td><a href=\"?op=rudi&show=awards&award={$award['award_id']}\">Edit</a></td> + <td><a href=\"?op=rudi&show=awards&delete={$award['award_id']}\">Delete</a></td></tr>"; + } + CloseTable(); + //include 'view.members.profile.php'; + }else if(isset($_GET['aid'])){ + $award_id = $_GET['aid']; + //include 'view.members.service.php'; + } + } ?>
\ No newline at end of file diff --git a/admin/rudi/views/view.battles.list.php b/admin/rudi/views/view.battles.list.php new file mode 100644 index 0000000..573d422 --- /dev/null +++ b/admin/rudi/views/view.battles.list.php @@ -0,0 +1,18 @@ +<?php + + global $db; + + // get all active members and members that attended the match + // each member has a checkbox + // -> Use AJAX oncheck to save the status of that member + + $battle = getBattleInfo($war_id); + + decho($battle); + + $members = getCombatSoldiers($war_id); + + decho($members); + +?> +<h3>Engagement : <?php echo $battle['title']; ?></h3>
\ No newline at end of file diff --git a/admin/rudi/views/view.battles.php b/admin/rudi/views/view.battles.php new file mode 100644 index 0000000..d00452e --- /dev/null +++ b/admin/rudi/views/view.battles.php @@ -0,0 +1,36 @@ +<?php + + // list all battles + // -> click one to view who was attending (lists everyone in the unit and those attending) + // buttons to add/edit/delete battles + + // definitely gonna use ajax for this... + + include $basedir.'rudi/includes/functions.battles.php'; + + if(isset($_GET['id'])){ + $war_id = $_GET['id']; + include 'view.battles.list.php'; + }else if(isset($_GET['service'])){ + $member_id = $_GET['service']; + include 'view.members.service.php'; + }else{ + + // list all battles + $battles = getAllBattles(); + decho($battles); + +?> + <h3>Unit Engagement:</h3> + <table width="100%" style="text-align:center;"> + <tr><th>Title</th><th>Opponent</th><th>Result</th><th>Date</th></tr> +<?php + foreach($battles as $battle){ + echo "<tr><td><a href=\"?op=rudi&show=battles&id={$battle['war_id']}\">{$battle['title']}</a></td><td>vs {$battle['name']}</td><td>{$battle['status']} {$battle['home_score']}-{$battle['visit_score']}</td><td>"; + echo date("M j Y", strtotime($battle['date'])); + echo "</td><tr>"; + + } + CloseTable(); + } +?>
\ No newline at end of file diff --git a/admin/rudi/views/view.members.award.php b/admin/rudi/views/view.members.award.php index cda8595..db6f88e 100644 --- a/admin/rudi/views/view.members.award.php +++ b/admin/rudi/views/view.members.award.php @@ -1,19 +1,22 @@ -<?php
- global $db;
- $result = $db->Query("SELECT `first_name`, `last_name` FROM `rudi_unit_members` WHERE `member_id` = '$member_id' LIMIT 1");
- $member = $db->FetchRow($result);
- echo "<h3>Award Record of {$member['first_name']} {$member['last_name']}</h3>";
-
- if(isset($_GET['edit'])){
- $record_id = $_GET['edit'];
- EditAwardRecord($record_id);
- }else if(isset($_GET['add'])){
- if($_GET['add']){
- AddAwardRecord($_GET['award']);
- }
- }else{
-
- echo "<div style=\"text-align:left;\">".LinkInternal('Back to Roster', '?op=rudi&show=members')."</div>";
- ListAwardRecord($_GET['award']);
- }
+<?php + global $db; + $result = $db->Query("SELECT `first_name`, `last_name` FROM `rudi_unit_members` WHERE `member_id` = '$member_id' LIMIT 1"); + $member = $db->FetchRow($result); + echo "<h3>Award Record of {$member['first_name']} {$member['last_name']}</h3>"; + + if(isset($_GET['edit'])){ + $record_id = $_GET['edit']; + EditAwardRecord($record_id); + }else if(isset($_GET['add'])){ + if($_GET['add']){ + AddAwardRecord($_GET['award']); + } + }else if(isset($_GET['delete'])){ + $record_id = $_GET['delete']; + DeleteAwardRecord($record_id); + }else{ + + echo "<div style=\"text-align:left;\">".LinkInternal('Back to Roster', '?op=rudi&show=members')."</div>"; + ListAwardRecord($_GET['award']); + } ?>
\ No newline at end of file diff --git a/admin/rudi/views/view.members.new.php b/admin/rudi/views/view.members.new.php new file mode 100644 index 0000000..cbc086f --- /dev/null +++ b/admin/rudi/views/view.members.new.php @@ -0,0 +1,179 @@ +<?php
+ global $db;
+
+ if(isset($_POST['processed'])){
+
+ echo "Please wait while the information is processed...";
+
+ $rank_id = $_POST['rank'];
+ $country_id = $_POST['country'];
+ $status_id = $_POST['status'];
+ $role_id = $_POST['role'];
+ $unit_id = $_POST['unit'];
+ $weapon_id = $_POST['weapon'];
+ $first_name = addslashes($_POST['first']);
+ $last_name = addslashes($_POST['last']);
+ $username = addslashes($_POST['username']);
+ $city = addslashes($_POST['city']);
+ $province = addslashes($_POST['province']);
+ $primary_mos = addslashes($_POST['primmos']);
+ $enlisted = addslashes($_POST['enlist']);
+ $promoted = addslashes($_POST['promote']);
+ $discharged = addslashes($_POST['discharge']);
+ $xfire = addslashes($_POST['xfire']);
+ $email = addslashes($_POST['email']);
+ $bio = addslashes($_POST['bio']);
+
+ //$discharged = empty($discharged) ? NULL : "'{$discharged}'";
+
+ $query = "INSERT INTO `rudi_unit_members` SET"
+ ." `rank_id` = '$rank_id',"
+ ." `country_id` = '$country_id',"
+ ." `status_id` = '$status_id',"
+ ." `cunit_id` = '$unit_id',"
+ ." `weapon_id` = '$weapon_id',"
+ ." `username` = '$username',"
+ ." `email` = '$email',"
+ ." `xfire` = '$xfire',"
+ ." `first_name` = '$first_name',"
+ ." `last_name` = '$last_name',"
+ ." `location_city` = '$city',"
+ ." `location_province` = '$province',"
+ ." `bio` = '$bio',"
+ ." `date_enlisted` = '$enlisted',"
+ ." `date_promotion` = '$promoted',"
+ ." `primary_mos` = '$primary_mos',";
+ if(empty($discharged))
+ $query = $query." `date_discharged` = null";
+ else
+ $query = $query." `date_discharged` = '$discharged'";
+ decho($query);
+ $db->Query($query);
+
+ $member_id = $db->InsertID();
+ decho($member_id);
+ $db->Query("INSERT INTO `rudi_roles_container` SET `role_id` = '$role_id', `member_id` = '$member_id'");
+
+ PageRedirect(1, "?op=rudi&show=members");
+ return;
+ }
+?>
+ <a href="?op=rudi&show=members">Cancel</a><br />
+ <form method="POST" action="">
+ <table width="100%" style="text-align:center;">
+ <tr><th colspan="2" style="background-color:#c4c4c4;">Personnel File of <?php echo $member['first_name']." ".$member['last_name']; ?></th></tr>
+ <tr><td class="right" width="50%">Rank:</td><td class="left">
+ <select name="rank">
+<?php $ranks = GetRanks();
+ foreach($ranks as $rank){
+ echo "<option value=\"{$rank['rank_id']}\">{$rank['longname']}</option>";
+ }
+?>
+ </select>
+ </td></tr>
+ <tr><td class="right">Country:</td><td class="left">
+ <select name="country">
+<?php $countries = GetCountry();
+ foreach($countries as $country){
+ echo "<option value=\"{$country['country_id']}\">{$country['name']}</option>";
+ }
+?>
+ </select>
+ </td></tr>
+ </table>
+ <table width="100%" style="text-align:center;">
+ <tr><th colspan="2" style="background-color:#c4c4c4;">Vital Statistics</th></tr>
+ <tr>
+ <td class="right" width="50%">First:</td>
+ <td class="left"><input type="text" name="first" value="" /></td>
+ </tr>
+ <tr>
+ <td class="right">Last:</td>
+ <td class="left"><input type="text" name="last" value="" /></td>
+ </tr>
+ <tr><td class="right">Username:</td><td class="left"><input type="text" name="username" value="" /></td></tr>
+ <tr><td class="right">City:</td><td class="left"><input type="text" name="city" value=""/></td></tr>
+ <tr><td class="right">Province:</td><td class="left"><input type="text" name="province" value="" /></td></tr>
+ <tr><td class="right">Status:</td><td class="left">
+ <select name="status">
+<?php $statuses = GetStatuses();
+ foreach($statuses as $status){
+ echo "<option value=\"{$status['status_id']}\">{$status['name']}</option>";
+ }
+?>
+ </select>
+ </td></tr>
+ <tr><td class="right">Primary MOS:</td><td class="left"><input type="text" name="primmos" value="" /></td></tr>
+ <tr>
+ <td class="right">Role:</td>
+ <td class="left">
+ <select name="role">
+<?php
+ $roles = GetRoles();
+ foreach($roles as $role){
+ echo "<option value=\"{$role['role_id']}\">{$role['name']}</option>";
+ }
+?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td class="right" style="font-weight:bold;">Unit:</td>
+ <td class="left">
+ <select name="unit">
+ <option value="0">N/A</option>
+<?php
+ $result = $db->Query("SELECT `unit_id`, `name` FROM `rudi_combat_units` WHERE `detachment` = 0 ");
+ $row = $db->Fetch($result);
+ foreach($row as $unit){
+ $unit_name = $unit['name'];
+ $unit_id = $unit['unit_id'];
+ if($member['cunit_id']==$unit_id)
+ echo '<option value="'.$unit_id.'" selected>'.$unit_name.'</option>';
+ else
+ echo '<option value="'.$unit_id.'">'.$unit_name.'</option>';
+ selectUnits($unit_id, 0, $member['cunit_id']);
+ }
+?>
+ </select>
+ </td>
+ </tr>
+ <tr><td class="right">Weapons:</td><td class="left">
+ <select name="weapon">
+<?php $weapons = GetWeapons();
+ foreach($weapons as $weapon){
+ echo "<option value=\"{$weapon['weapon_id']}\">{$weapon['model']}</option>";
+ }
+?>
+ </select>
+ </td></tr>
+ <tr>
+ <td class="right">Enlisted Date:</td>
+ <td class="left"><input type="text" name="enlist" value="" /></td>
+ </tr>
+ <tr>
+ <td class="right">Promotion Date:</td>
+ <td class="left">
+ <input type="text" name="promote" value="" />
+ </td>
+ </tr>
+ <tr>
+ <td class="right">Discharge Date:</td>
+ <td class="left"><input type="text" name="discharge" value="" /></td>
+ </tr>
+ <tr>
+ <td class="right">Xfire:</td>
+ <td class="left"><input type="text" name="xfire" value=""/></td>
+ </tr>
+ <tr>
+ <td class="right">E-Mail:</td>
+ <td class="left"><input type="text" name="email" value=""/></td>
+ </tr>
+ </table>
+ <br />
+ <table width="100%" style="text-align:center;">
+ <tr><th colspan="2" style="background-color:#c4c4c4;">Personal Bio</th></tr>
+ <tr><td><textarea rows="7" name="bio" cols="60"></textarea></td></tr>
+ <tr><td colspan="2"><input type="submit" value="Submit" name="processed" /></td>
+ </table>
+ </form>
\ No newline at end of file diff --git a/admin/rudi/views/view.members.php b/admin/rudi/views/view.members.php index 38929df..9013b8e 100644 --- a/admin/rudi/views/view.members.php +++ b/admin/rudi/views/view.members.php @@ -9,13 +9,18 @@ }else if(isset($_GET['award'])){ $member_id = $_GET['award']; include 'view.members.award.php'; + }else if(isset($_GET['create']) && $_GET['create'] == "soldier"){ + include 'view.members.new.php'; }else{ global $db; - echo "<h3>Current Members</h3>"; - echo "<table width=\"100%\" style=\"text-align:center;\">"; - echo "<tr><th>Rank</th><th>Soldier</th><th>Main Info</th><th>Service Record</th><th>Medal Record</th></tr>"; + echo LinkInternal('New Soldier','?op=rudi&show=members&create=soldier'); +?> + <h3>Current Members</h3> + <table width="100%" style="text-align:center;"> + <tr><th>Rank</th><th>Soldier</th><th>Main Info</th><th>Service Record</th><th>Medal Record</th></tr> +<?php $result = $db->Query("SELECT * FROM `rudi_unit_members` JOIN `rudi_ranks` ON rudi_unit_members.rank_id=rudi_ranks.rank_id WHERE rudi_unit_members.status_id <= 3 ORDER BY rudi_ranks.weight DESC , rudi_unit_members.date_promotion ASC , rudi_unit_members.date_enlisted ASC"); $row = $db->Fetch($result); @@ -28,10 +33,11 @@ echo "<tr>"; } CloseTable(); - - echo "<h3>Previous Members</h3>"; - echo "<table width=\"100%\" style=\"text-align:center;\">"; - echo "<tr><th>Rank</th><th>Soldier</th><th>Main Info</th><th>Service Record</th><th>Medal Record</th></tr>"; +?> + <h3>Previous Members</h3> + <table width="100%" style="text-align:center;"> + <tr><th>Rank</th><th>Soldier</th><th>Main Info</th><th>Service Record</th><th>Medal Record</th></tr> +<?php $result = $db->Query("SELECT * FROM `rudi_unit_members` JOIN `rudi_ranks` ON rudi_unit_members.rank_id=rudi_ranks.rank_id WHERE rudi_unit_members.status_id > 3 ORDER BY rudi_ranks.weight DESC, rudi_unit_members.date_promotion ASC, rudi_unit_members.date_enlisted ASC"); $row = $db->Fetch($result); diff --git a/admin/rudi/views/view.members.profile.php b/admin/rudi/views/view.members.profile.php index bd776d7..6355d2e 100644 --- a/admin/rudi/views/view.members.profile.php +++ b/admin/rudi/views/view.members.profile.php @@ -10,7 +10,10 @@ $status_id = $_POST['status']; $role_id = $_POST['role']; $unit_id = $_POST['unit']; + $a2_id = $_POST['a2_id']; + $oa_id = $_POST['oa_id']; $weapon_id = $_POST['weapon']; + $weapon2_id = $_POST['weapon2']; $first_name = addslashes($_POST['first']); $last_name = addslashes($_POST['last']); $username = addslashes($_POST['username']); @@ -29,9 +32,13 @@ $query = "UPDATE `rudi_unit_members` SET" ." `rank_id` = '$rank_id'," ." `country_id` = '$country_id'," + ." `role_id` = '$role_id', " ." `status_id` = '$status_id'," ." `cunit_id` = '$unit_id'," ." `weapon_id` = '$weapon_id'," + ." `weapon2_id` = '$weapon2_id'," + ." `a2_id` = '$a2_id'," + ." `oa_id` = '$oa_id'," ." `username` = '$username'," ." `email` = '$email'," ." `xfire` = '$xfire'," @@ -51,10 +58,10 @@ decho($query); $db->Query($query); - $db->Query("UPDATE `rudi_roles_container` SET `role_id` = '$role_id' WHERE `member_id` = '$member_id' LIMIT 1"); + //$db->Query("UPDATE `rudi_roles_container` SET `role_id` = '$role_id' WHERE `member_id` = '$member_id' LIMIT 1"); /* do the role query as well */ - PageRedirect(1, "?op=rudi&show=members&profile={$member_id}"); + PageRedirect(1, "?op=rudi&show=members"); return; } $member = GetMember($member_id); @@ -87,6 +94,8 @@ ?> </select> </td></tr> + <tr><td class="right" width="50%">ArmA2 ID</td><td class="left"><input type="text" name="a2_id" value="<?php echo $member['a2_id']; ?>"/></td></tr> + <tr><td class="right" width="50%">ArmA2:OA ID</td><td class="left"><input type="text" name="oa_id" value="<?php echo $member['oa_id']; ?>"/></td></tr> </table> <table width="100%" style="text-align:center;"> <tr><th colspan="2" style="background-color:#c4c4c4;">Vital Statistics</th></tr> @@ -118,15 +127,21 @@ <td class="right">Role:</td> <td class="left"> <select name="role"> + <option value="0">---SELECT-POSITION---</option> <?php - $member_roles = GetMembersRoles($member['member_id']); - $roles = GetRoles(); - foreach($member_roles as $member_role){} - foreach($roles as $role){ - if($role['role_id']==$member_role['role_id']) - echo "<option value=\"{$role['role_id']}\" selected>{$role['name']}</option>"; - else - echo "<option value=\"{$role['role_id']}\">{$role['name']}</option>"; + //$member_roles = GetMembersRoles($member['member_id']); + $groups = GetRoles(); + decho($groups); + //foreach($member_roles as $member_role){} + foreach($groups as $group){ + echo "<optgroup label=\"{$group['name']}\">"; + foreach($group['roles'] as $role){ + if($role['role_id']==$member['role_id']) + echo "<option value=\"{$role['role_id']}\" selected>{$role['name']}</option>"; + else + echo "<option value=\"{$role['role_id']}\">{$role['name']}</option>"; + } + echo "</optgroup>"; } ?> </select> @@ -153,7 +168,7 @@ </select> </td> </tr> - <tr><td class="right">Weapons:</td><td class="left"> + <tr><td class="right">Primary Weapon:</td><td class="left"> <select name="weapon"> <?php $weapons = GetWeapons(); foreach($weapons as $weapon){ @@ -165,6 +180,19 @@ ?> </select> </td></tr> + <tr><td class="right">Secondary Weapon:</td><td class="left"> + <select name="weapon2"> + <option value="0">None</option> +<?php + foreach($weapons as $weapon){ + if($weapon['weapon_id'] == $member['weapon2_id']) + echo "<option value=\"{$weapon['weapon_id']}\" selected>{$weapon['model']}</option>"; + else + echo "<option value=\"{$weapon['weapon_id']}\">{$weapon['model']}</option>"; + } +?> + </select> + </td></tr> <tr> <td class="right">Enlisted Date:</td> <td class="left"><input type="text" name="enlist" value="<?php echo !empty($member['date_enlisted']) ? date('Y-m-d', strtotime($member['date_enlisted'])) : ""; ?>" /></td> diff --git a/admin/rudi/views/view.units.php b/admin/rudi/views/view.units.php index 2ccf35a..ab3dedd 100644 --- a/admin/rudi/views/view.units.php +++ b/admin/rudi/views/view.units.php @@ -1,22 +1,29 @@ -<?php
- include $basedir.'rudi/includes/functions.units.php';
- if(isset($_GET['unit'])){
-
- }else{
- //list units
- DisplayUnits();
-
- }
-
-
-?>
-<div style="text-align:left;">
-<img src="images/tree_branch.gif" /> Kilo Company<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 1st Platoon<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 1st Squad<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_leaf.gif" /><img src="images/tree_branch.gif" /> Fireteam Alpha<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_leaf.gif" /><img src="images/tree_branch.gif" /> Fireteam Bravo<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 2nd Squad<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> Fireteam Alpha<br />
-<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> Fireteam Bravo<br />
-</div>
\ No newline at end of file +<h3>Unit Structure</h3> +<center> +<?php + include $basedir.'rudi/includes/functions.units.php'; + if(isset($_GET['unit'])){ + + }else{ + //list units + echo '<div style="text-align:left; width:300px;">'; + DisplayUnits(); + echo '</div>'; + + } + + +?> +</center> +<!-- +<div style="text-align:left;"> +<img src="images/tree_branch.gif" /> Kilo Company<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 1st Platoon<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 1st Squad<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_leaf.gif" /><img src="images/tree_branch.gif" /> Fireteam Alpha<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_leaf.gif" /><img src="images/tree_branch.gif" /> Fireteam Bravo<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> 2nd Squad<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> Fireteam Alpha<br /> +<img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_blank.gif" /><img src="images/tree_branch.gif" /> Fireteam Bravo<br /> +</div> +-->
\ No newline at end of file diff --git a/admin/scripts/mocha.js b/admin/scripts/mocha.js index a220424..2e250c2 100644 --- a/admin/scripts/mocha.js +++ b/admin/scripts/mocha.js @@ -1,156 +1,156 @@ -/*
- * --------------------------------------------------------------------
- * Simple Password Strength Checker
- * by Siddharth S, www.ssiddharth.com, hello@ssiddharth.com
- * for Net Tuts, www.net.tutsplus.com
- * Version: 1.0, 05.10.2009
- * --------------------------------------------------------------------
- */
-
-
-$(document).ready(function()
-{
- var strPassword;
- var charPassword;
- var complexity = $("#complexity");
- var rating = $("#rating")
- var minPasswordLength = 6;
- var baseScore = 0, score = 0;
-
- var num = {};
- num.Excess = 0;
- num.Upper = 0;
- num.Numbers = 0;
- num.Symbols = 0;
-
- var bonus = {};
- bonus.Excess = 3;
- bonus.Upper = 4;
- bonus.Numbers = 5;
- bonus.Symbols = 5;
- bonus.Combo = 0;
- bonus.FlatLower = 0;
- bonus.FlatNumber = 0;
-
- outputResult();
- $("#inputPassword").bind("keyup", checkVal);
-
-function checkVal()
-{
- init();
-
- if (charPassword.length >= minPasswordLength)
- {
- baseScore = 50;
- analyzeString();
- calcComplexity();
- }
- else
- {
- baseScore = 0;
- }
-
- outputResult();
-}
-
-function init()
-{
- strPassword= $("#inputPassword").val();
- charPassword = strPassword.split("");
-
- num.Excess = 0;
- num.Upper = 0;
- num.Numbers = 0;
- num.Symbols = 0;
- bonus.Combo = 0;
- bonus.FlatLower = 0;
- bonus.FlatNumber = 0;
- baseScore = 0;
- score =0;
-}
-
-function analyzeString ()
-{
- for (i=0; i<charPassword.length;i++)
- {
- if (charPassword[i].match(/[A-Z]/g)) {num.Upper++;}
- if (charPassword[i].match(/[0-9]/g)) {num.Numbers++;}
- if (charPassword[i].match(/(.*[!,@,#,$,%,^,&,*,?,_,~])/)) {num.Symbols++;}
- }
-
- num.Excess = charPassword.length - minPasswordLength;
-
- if (num.Upper && num.Numbers && num.Symbols)
- {
- bonus.Combo = 25;
- }
-
- else if ((num.Upper && num.Numbers) || (num.Upper && num.Symbols) || (num.Numbers && num.Symbols))
- {
- bonus.Combo = 15;
- }
-
- if (strPassword.match(/^[\sa-z]+$/))
- {
- bonus.FlatLower = -15;
- }
-
- if (strPassword.match(/^[\s0-9]+$/))
- {
- bonus.FlatNumber = -35;
- }
-}
-
-function calcComplexity()
-{
- score = baseScore + (num.Excess*bonus.Excess) + (num.Upper*bonus.Upper) + (num.Numbers*bonus.Numbers) + (num.Symbols*bonus.Symbols) + bonus.Combo + bonus.FlatLower + bonus.FlatNumber;
-
-}
-
-function outputResult()
-{
- if ($("#inputPassword").val()== "")
- {
- complexity.html(" ");
- rating.removeClass("short weak good strong secure").addClass("default");
- }
- else if (charPassword.length < minPasswordLength)
- {
- complexity.html("Too Short");
- rating.removeClass("weak good strong secure").addClass("short");
- }
- else if (score<50)
- {
- complexity.html("Weak");
- rating.removeClass("good strong secure").addClass("weak");
- }
- else if (score>=50 && score<75)
- {
- complexity.html("Good");
- rating.removeClass("strong secure").addClass("good");
- }
- else if (score>=75 && score<100)
- {
- complexity.html("Strong");
- rating.removeClass("secure").addClass("strong");
- }
- else if (score>=100)
- {
- complexity.html("Secure");
- rating.addClass("secure");
- }
-
- /*
- $("#details").html("Base Score :<span class=\"value\">" + baseScore + "</span>"
- + "<br />Length Bonus :<span class=\"value\">" + (num.Excess*bonus.Excess) + " ["+num.Excess+"x"+bonus.Excess+"]</span> "
- + "<br />Upper case bonus :<span class=\"value\">" + (num.Upper*bonus.Upper) + " ["+num.Upper+"x"+bonus.Upper+"]</span> "
- + "<br />Number Bonus :<span class=\"value\"> " + (num.Numbers*bonus.Numbers) + " ["+num.Numbers+"x"+bonus.Numbers+"]</span>"
- + "<br />Symbol Bonus :<span class=\"value\"> " + (num.Symbols*bonus.Symbols) + " ["+num.Symbols+"x"+bonus.Symbols+"]</span>"
- + "<br />Combination Bonus :<span class=\"value\"> " + bonus.Combo + "</span>"
- + "<br />Lower case only penalty :<span class=\"value\"> " + bonus.FlatLower + "</span>"
- + "<br />Numbers only penalty :<span class=\"value\"> " + bonus.FlatNumber + "</span>"
- + "<br />Total Score:<span class=\"value\"> " + score + "</span>" ); */
-}
-
-}
-);
+/* + * -------------------------------------------------------------------- + * Simple Password Strength Checker + * by Siddharth S, www.ssiddharth.com, hello@ssiddharth.com + * for Net Tuts, www.net.tutsplus.com + * Version: 1.0, 05.10.2009 + * -------------------------------------------------------------------- + */ + + +$(document).ready(function() +{ + var strPassword; + var charPassword; + var complexity = $("#complexity"); + var rating = $("#rating") + var minPasswordLength = 6; + var baseScore = 0, score = 0; + + var num = {}; + num.Excess = 0; + num.Upper = 0; + num.Numbers = 0; + num.Symbols = 0; + + var bonus = {}; + bonus.Excess = 3; + bonus.Upper = 4; + bonus.Numbers = 5; + bonus.Symbols = 5; + bonus.Combo = 0; + bonus.FlatLower = 0; + bonus.FlatNumber = 0; + + outputResult(); + $("#inputPassword").bind("keyup", checkVal); + +function checkVal() +{ + init(); + + if (charPassword.length >= minPasswordLength) + { + baseScore = 50; + analyzeString(); + calcComplexity(); + } + else + { + baseScore = 0; + } + + outputResult(); +} + +function init() +{ + strPassword= $("#inputPassword").val(); + charPassword = strPassword.split(""); + + num.Excess = 0; + num.Upper = 0; + num.Numbers = 0; + num.Symbols = 0; + bonus.Combo = 0; + bonus.FlatLower = 0; + bonus.FlatNumber = 0; + baseScore = 0; + score =0; +} + +function analyzeString () +{ + for (i=0; i<charPassword.length;i++) + { + if (charPassword[i].match(/[A-Z]/g)) {num.Upper++;} + if (charPassword[i].match(/[0-9]/g)) {num.Numbers++;} + if (charPassword[i].match(/(.*[!,@,#,$,%,^,&,*,?,_,~])/)) {num.Symbols++;} + } + + num.Excess = charPassword.length - minPasswordLength; + + if (num.Upper && num.Numbers && num.Symbols) + { + bonus.Combo = 25; + } + + else if ((num.Upper && num.Numbers) || (num.Upper && num.Symbols) || (num.Numbers && num.Symbols)) + { + bonus.Combo = 15; + } + + if (strPassword.match(/^[\sa-z]+$/)) + { + bonus.FlatLower = -15; + } + + if (strPassword.match(/^[\s0-9]+$/)) + { + bonus.FlatNumber = -35; + } +} + +function calcComplexity() +{ + score = baseScore + (num.Excess*bonus.Excess) + (num.Upper*bonus.Upper) + (num.Numbers*bonus.Numbers) + (num.Symbols*bonus.Symbols) + bonus.Combo + bonus.FlatLower + bonus.FlatNumber; + +} + +function outputResult() +{ + if ($("#inputPassword").val()== "") + { + complexity.html(" "); + rating.removeClass("short weak good strong secure").addClass("default"); + } + else if (charPassword.length < minPasswordLength) + { + complexity.html("Too Short"); + rating.removeClass("weak good strong secure").addClass("short"); + } + else if (score<50) + { + complexity.html("Weak"); + rating.removeClass("good strong secure").addClass("weak"); + } + else if (score>=50 && score<75) + { + complexity.html("Good"); + rating.removeClass("strong secure").addClass("good"); + } + else if (score>=75 && score<100) + { + complexity.html("Strong"); + rating.removeClass("secure").addClass("strong"); + } + else if (score>=100) + { + complexity.html("Secure"); + rating.addClass("secure"); + } + + /* + $("#details").html("Base Score :<span class=\"value\">" + baseScore + "</span>" + + "<br />Length Bonus :<span class=\"value\">" + (num.Excess*bonus.Excess) + " ["+num.Excess+"x"+bonus.Excess+"]</span> " + + "<br />Upper case bonus :<span class=\"value\">" + (num.Upper*bonus.Upper) + " ["+num.Upper+"x"+bonus.Upper+"]</span> " + + "<br />Number Bonus :<span class=\"value\"> " + (num.Numbers*bonus.Numbers) + " ["+num.Numbers+"x"+bonus.Numbers+"]</span>" + + "<br />Symbol Bonus :<span class=\"value\"> " + (num.Symbols*bonus.Symbols) + " ["+num.Symbols+"x"+bonus.Symbols+"]</span>" + + "<br />Combination Bonus :<span class=\"value\"> " + bonus.Combo + "</span>" + + "<br />Lower case only penalty :<span class=\"value\"> " + bonus.FlatLower + "</span>" + + "<br />Numbers only penalty :<span class=\"value\"> " + bonus.FlatNumber + "</span>" + + "<br />Total Score:<span class=\"value\"> " + score + "</span>" ); */ +} + +} +); diff --git a/admin/settings/functions.php b/admin/settings/functions.php index 1e3ada4..74155fa 100644 --- a/admin/settings/functions.php +++ b/admin/settings/functions.php @@ -1,77 +1,77 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * Note to anyone feeling the need to edit this file...
- * You MUST declare $db as global inside your functions in order access MySQL from here.
- */
-
-
-function changePassword(){
-echo "<script type=\"text/javascript\" src=\"scripts/mocha.js\"></script>";
- global $db;
-
- if(isset($_POST['processed']))
- {
- $password = $_POST['password'];
- $confirm = $_POST['confirm'];
-
- if($password != $confirm){
- ReportError("The passwords you entered did not match.");
- PageRedirect(3, "?op=settings&change=password");
- return;
- }else if(strlen($password)<6){
- ReportError("The password you entered is less than 6 characters.");
- PageRedirect(3, "?op=settings&change=password");
- return;
- }
- $newpassword = crypt(md5($password),'iamnotadirtywhorebitch');
- $username = $_SESSION['username'];
- $db->Query("UPDATE `bayonet_users` SET `password` = '$newpassword' WHERE `username` = '$username' LIMIT 1");
-
- echo "Your password has successfully been changed.";
- PageRedirect(3,"?op=settings");
- return;
- }
-?>
-<div id="pwordCont">
-<form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
-<h1>Change Your Password</h1>
- <table>
- <tr>
- <td class="right">Password: </td>
- <td><input type="password" id="inputPassword" name="password" style="width:200px;" /></td>
- <td>
- <table cellspacing="0">
- <tr><td>Password Strength:</td><td id="complexity"></td></tr>
- <tr><td colspan="2"><div class="outer"><div id="rating"></div></div></td></tr>
- </table>
- </td>
- </tr>
- <tr><td></td><td style="text-align:center; color:#626262;">Minimum of 6 Characters</td><td></td></tr>
- <tr>
- <td>Confirm Password: </td>
- <td><input type="password" name="confirm" style="width:200px;" /></td>
- </tr>
- <tr><td colspan="2"><input type="submit" value="Change Password" name="processed" /></td>
- </table>
-</form>
-</div>
-<?php
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Note to anyone feeling the need to edit this file... + * You MUST declare $db as global inside your functions in order access MySQL from here. + */ + + +function changePassword(){ +echo "<script type=\"text/javascript\" src=\"scripts/mocha.js\"></script>"; + global $db; + + if(isset($_POST['processed'])) + { + $password = $_POST['password']; + $confirm = $_POST['confirm']; + + if($password != $confirm){ + ReportError("The passwords you entered did not match."); + PageRedirect(3, "?op=settings&change=password"); + return; + }else if(strlen($password)<6){ + ReportError("The password you entered is less than 6 characters."); + PageRedirect(3, "?op=settings&change=password"); + return; + } + $newpassword = crypt(md5($password),'iamnotadirtywhorebitch'); + $username = $_SESSION['username']; + $db->Query("UPDATE `bayonet_users` SET `password` = '$newpassword' WHERE `username` = '$username' LIMIT 1"); + + echo "Your password has successfully been changed."; + PageRedirect(3,"?op=settings"); + return; + } +?> +<div id="pwordCont"> +<form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> +<h1>Change Your Password</h1> + <table> + <tr> + <td class="right">Password: </td> + <td><input type="password" id="inputPassword" name="password" style="width:200px;" /></td> + <td> + <table cellspacing="0"> + <tr><td>Password Strength:</td><td id="complexity"></td></tr> + <tr><td colspan="2"><div class="outer"><div id="rating"></div></div></td></tr> + </table> + </td> + </tr> + <tr><td></td><td style="text-align:center; color:#626262;">Minimum of 6 Characters</td><td></td></tr> + <tr> + <td>Confirm Password: </td> + <td><input type="password" name="confirm" style="width:200px;" /></td> + </tr> + <tr><td colspan="2"><input type="submit" value="Change Password" name="processed" /></td> + </table> +</form> +</div> +<?php }
\ No newline at end of file diff --git a/admin/settings/index.php b/admin/settings/index.php index e3c8946..49ad784 100644 --- a/admin/settings/index.php +++ b/admin/settings/index.php @@ -1,53 +1,53 @@ -<?php
-/**
- * Bayonet Content Management System
- * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ?>
- <link rel="stylesheet" type="text/css" href="settings/style.css" media="screen"/>
- <div style="text-align:left;"><h2>- Account Settings</h2>
- -<a href="?op=settings&change=password" >Change password</a>, email, name<br />
- </div>
-
- <?php
-
-if(!defined("ADMIN_FILE"))
-{
- die("Access denied.");
-}
-
-include $basedir.'settings/functions.php';
-
- if(isset($_GET['change']))
- {
- $change = $_GET['change'];
- if($change == "password"){
- changePassword();
- }else if($change == "email"){
- changeEmail();
- }
- //return;
- }
-
-
-?>
-
- </tr>
- </table>
-
-
-
+<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + ?> + <link rel="stylesheet" type="text/css" href="settings/style.css" media="screen"/> + <div style="text-align:left;"><h2>- Account Settings</h2> + -<a href="?op=settings&change=password" >Change password</a>, email, name<br /> + </div> + + <?php + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'settings/functions.php'; + + if(isset($_GET['change'])) + { + $change = $_GET['change']; + if($change == "password"){ + changePassword(); + }else if($change == "email"){ + changeEmail(); + } + //return; + } + + +?> + + </tr> + </table> + + +
\ No newline at end of file diff --git a/admin/settings/style.css b/admin/settings/style.css index 9969542..ff45ec6 100644 --- a/admin/settings/style.css +++ b/admin/settings/style.css @@ -1,64 +1,64 @@ -/* START>> PASSWORD STYLES */
-
-input{
- font-family: "Lucida Grande", "Verdana", sans-serif;
-}
-
-#pwordCont{
- font-family: "Lucida Grande", "Verdana", sans-serif;
- width: 820px;
- font-size:12px;
- margin-left: auto;
- margin-right: auto;
- padding: 50px 0 0 0;
-}
-
-#complexity{
- color: #000;
- font-size: 10px;
- text-align: center;
-}
-
-.outer {
- width:180px;
- height:5px;
- background-color: #CCC;
-}
-
-.default {
- height:5px;
- background-color: #CCC;
- width:0px;
-}
-.short {
- height:5px;
- background-color: #aa0033;
- width:15px;
-}
-.weak {
- height:5px;
- background-color: #aa0033;
- width:45px;
-}
-.good {
- height:5px;
- background-color: #6699cc;
- width:90px;
-}
-.strong {
- height:5px;
- background-color: #008000;
- width:135px;
-}
-.secure {
- height:5px;
- background-color: #008000;
- width:180px;
-}
-
-span.value{
- font-weight:bold;
- float: right;
-}
-
+/* START>> PASSWORD STYLES */ + +input{ + font-family: "Lucida Grande", "Verdana", sans-serif; +} + +#pwordCont{ + font-family: "Lucida Grande", "Verdana", sans-serif; + width: 820px; + font-size:12px; + margin-left: auto; + margin-right: auto; + padding: 50px 0 0 0; +} + +#complexity{ + color: #000; + font-size: 10px; + text-align: center; +} + +.outer { + width:180px; + height:5px; + background-color: #CCC; +} + +.default { + height:5px; + background-color: #CCC; + width:0px; +} +.short { + height:5px; + background-color: #aa0033; + width:15px; +} +.weak { + height:5px; + background-color: #aa0033; + width:45px; +} +.good { + height:5px; + background-color: #6699cc; + width:90px; +} +.strong { + height:5px; + background-color: #008000; + width:135px; +} +.secure { + height:5px; + background-color: #008000; + width:180px; +} + +span.value{ + font-weight:bold; + float: right; +} + /* END>> PASSWORD STYLES */
\ No newline at end of file diff --git a/admin/style.css b/admin/style.css index 686276b..48ab804 100644 --- a/admin/style.css +++ b/admin/style.css @@ -140,4 +140,8 @@ fieldset { .right{ text-align:right; } + +.bold { + font-size:18px; +}
\ No newline at end of file |