From 0077cb99704fe863cf731fc5cab792af2ede96c2 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 17 Apr 2011 20:13:07 -0400 Subject: Backporting retarded amount of changes outside of version control --- admin/adjutant/functions.php | 14 +- admin/adjutant/style.css | 24 +- admin/admins/functions.php | 656 ++++++++--------- admin/admins/index.php | 108 +-- admin/announcements/functions.php | 132 ++-- admin/announcements/index.php | 66 +- admin/calendar/index.php | 180 ++--- admin/calendar/style.css | 96 +++ admin/functions.php | 1124 ++++++++++++++--------------- admin/header.php | 160 ++-- admin/images/tree_blank.gif | Bin 0 -> 62 bytes admin/images/tree_branch.gif | Bin 0 -> 74 bytes admin/images/tree_leaf.gif | Bin 0 -> 72 bytes admin/index.php | 20 +- admin/modules/functions.php | 211 ++---- admin/modules/index.php | 118 +-- admin/navigation/functions.php | 180 ++--- admin/navigation/index.php | 106 +-- admin/news/functions.php | 96 ++- admin/news/index.php | 2 + admin/newsreel/functions.php | 318 ++++---- admin/newsreel/index.php | 92 +-- admin/newsreel/updateDB.php | 87 ++- admin/rudi/functions.php | 140 ++-- admin/rudi/includes/functions.awards.php | 38 +- admin/rudi/includes/functions.battles.php | 70 ++ admin/rudi/includes/functions.members.php | 48 +- admin/rudi/includes/functions.units.php | 33 + admin/rudi/index.php | 120 +-- admin/rudi/views/view.awards.add.php | 27 + admin/rudi/views/view.awards.delete.php | 29 + admin/rudi/views/view.awards.edit.php | 54 +- admin/rudi/views/view.awards.php | 78 +- admin/rudi/views/view.battles.list.php | 18 + admin/rudi/views/view.battles.php | 36 + admin/rudi/views/view.members.award.php | 39 +- admin/rudi/views/view.members.new.php | 179 +++++ admin/rudi/views/view.members.php | 20 +- admin/rudi/views/view.members.profile.php | 50 +- admin/rudi/views/view.units.php | 51 +- admin/scripts/mocha.js | 312 ++++---- admin/settings/functions.php | 152 ++-- admin/settings/index.php | 104 +-- admin/settings/style.css | 126 ++-- admin/style.css | 4 + 45 files changed, 3031 insertions(+), 2487 deletions(-) create mode 100644 admin/calendar/style.css create mode 100644 admin/images/tree_blank.gif create mode 100644 admin/images/tree_branch.gif create mode 100644 admin/images/tree_leaf.gif create mode 100644 admin/rudi/includes/functions.battles.php create mode 100644 admin/rudi/includes/functions.units.php create mode 100644 admin/rudi/views/view.awards.add.php create mode 100644 admin/rudi/views/view.awards.delete.php create mode 100644 admin/rudi/views/view.battles.list.php create mode 100644 admin/rudi/views/view.battles.php create mode 100644 admin/rudi/views/view.members.new.php (limited to 'admin') 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 @@ } ?>
- +
- + {$soldier['first_name']} {$soldier['last_name']} - "; + + "; echo "\n"; @@ -104,7 +106,7 @@ $num = 1; foreach($row as $member){ if($num %2 == 0) - echo ""; + echo ""; else echo ""; echo ""; 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 @@ - - - -. - */ - - 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 ""; - foreach($admins as $admin) - { - if($admin['level'] != $level){ - $level = $admin['level']; - echo ""; - } - echo ""; - $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

- Please wait while you are redirected.

- Click here if you don't feel like waiting."; - - // 3 second redirect to go back to the edit page - PageRedirect(2, "?op=admins"); - return; - } -?> -
Cancel
-
- -
RankSoldierStatusPointsDrills Missed
RankSoldierStatusPointsDrills MissedDrills Attended
".getStatus($soldier['status_id'])." /100/3/3/3
{$member['shortname']}{$member['first_name']} {$member['last_name']}Edit
UsernameLevel

{$num}.{$admin['username']}{$admin['level']}
- - - - - - - - - - - -
Username:*
First Name:
Last Name:
Email Address:*
Level: - -
- -
-
- -
- - -
- - - - - - - - -
Everything elseSquad LeaderAdjutantQuartermaster
- - "; - else - echo ""; - ?> - - - "; - else - echo ""; - ?> - - - "; - else - echo ""; - ?> - - - "; - else - echo ""; - ?> -
-
- -

Show/Hide Permissions

- 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

- Please wait while you are redirected.

- Click here if you don't feel like waiting."; - - // 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; - } -?> -
- Edit the attributes of this administrator.
-
- - - - - - - - - -
Username:
Level: - -
- - -
-
- -
-
-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; - } - ?> -
-
- - - -
Are you SURE you want to delete the administrative user: ''?
   
-
-
- + $(document).ready(function(){ + $(".flip").click(function(){ + $(".slidepanel").slideToggle("slow"); + }); + }); + + + +. + */ + + 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 "UsernameLevel"; + foreach($admins as $admin) + { + if($admin['level'] != $level){ + $level = $admin['level']; + echo "
"; + } + echo "{$num}.{$admin['username']}{$admin['level']}"; + $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

+ Please wait while you are redirected.

+ Click here if you don't feel like waiting."; + + // 3 second redirect to go back to the edit page + PageRedirect(2, "?op=admins"); + return; + } +?> +
Cancel
+
+
+ + + + + + + + + + + + +
Username:*
First Name:
Last Name:
Email Address:*
Level: + +
+ +
+
+ +
+
+ +
+ + + + + + + + +
Everything elseSquad LeaderAdjutantQuartermaster
+ + "; + else + echo ""; + ?> + + + "; + else + echo ""; + ?> + + + "; + else + echo ""; + ?> + + + "; + else + echo ""; + ?> +
+
+ +

Show/Hide Permissions

+ 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

+ Please wait while you are redirected.

+ Click here if you don't feel like waiting."; + + // 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; + } +?> +
+ Edit the attributes of this administrator.
+
+ + + + + + + + + +
Username:
Level: + +
+ + +
+
+ +
+
+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; + } + ?> +
+
+ + + +
Are you SURE you want to delete the administrative user: ''?
   
+
+
+ \ 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 @@ -. - */ -?> -

- Edit Admins

- - - - - - - -
- - -
Add New Admin','?op=admins&create=true'); ?>
- -
- -
+. + */ +?> +

- Edit Admins

+ + + + + + + +
+ + +
Add New Admin','?op=admins&create=true'); ?>
+ +
+ +
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 @@ -. - */ - -/** - * 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

Please wait while you are redirected.

- Click here if you don't feel like waiting."; - - // 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); - - ?> -
- - - - -
Announcement Title:
-
- . + */ + +/** + * 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

Please wait while you are redirected.

+ Click here if you don't feel like waiting."; + + // 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); + + ?> +
+ + + + +
Announcement Title:
+
+ \ 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 @@ -. - */ - ?> - -

- Edit Announcements

- - - - +. + */ + ?> + +

- Edit Announcements

+ + +
+
\ 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 @@ -. - */ - ?> - -

- Manage Calendar & Events

- - - - - - - - - -
- Add New Event

- - Click on a day to add/edit/delete events -
- -
- +. + */ + ?> + +

- Manage Calendar & Events

+ + + + + + + + + +
+ Add New Event

+ + Click on a day to add/edit/delete events +
+ +
+ 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 @@ -. - */ - -/** - * 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( - '$1', - '$1', - '$1', - '
', - '

$1

', - '
$1
', - '

$1

', - '

$1

', - '

$1

', - '
$1
', - '
$1
', - '$1 wrote:
$2
', - '$2', - '$2', - '$2', - '$2' - ); - - $order = array("\r\n", "\n", "\r"); - $replace = "\n
"; - - $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
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\]/", '$1', $Text); - $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text); - //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '$2', $Text); - - // Perform MAIL Search - $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '$1', $Text); - $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '$2', $Text); - - // Check for bold text - $Text = preg_replace("(\[b\](.+?)\[\/b])is",'$1',$Text); - - // Check for Italics text - $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'$1',$Text); - - // Check for Underline text - $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'$1',$Text); - - // Check for strike-through text - $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'$1',$Text); - - // Check for over-line text - $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'$1',$Text); - - // Check for colored text - $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","$2",$Text); - - // Check for sized text - $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","$2",$Text); - - // Check for list text - $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '' ,$Text); - $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '' ,$Text); - $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '' ,$Text); - $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '' ,$Text); - $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '' ,$Text); - $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '' ,$Text); - $Text = str_replace("[*]", "
  • ", $Text); - - // Check for font change text - $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","$2",$Text); - - // Declare the format for [code] layout - $CodeLayout = ' - - - - - - -
    Code:
    $1
    '; - // Check for [code] text - $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text); - // Declare the format for [php] layout - $phpLayout = ' - - - - - - -
    Code:
    $1
    '; - // Check for [php] text - $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text); - - // Declare the format for [quote] layout - $QuoteLayout = ' - - - - - - -
    Quote:
    $1
    '; - - // Check for [quote] text - $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text); - - // Images - // [img]pathtoimage[/img] - $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text); - - //[img=align]image source[/img] - $Text = preg_replace("(\[img align\=(.+?)\](.+?)\[\/img\])is","",$Text); - - // [img=widthxheight]image source[/img] - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); - - // Alignment - // [align=type]text[/align] - $Text = preg_replace("(\[align=(.+?)\](.+?)\[\/align\])is","
    $2
    ",$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 "
      "; - foreach($array as $text => $link) - { - echo "
    • $text
    • "; - } - echo "
    "; -} - -/** - * 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 "{$link_name}"; -} - -/** - * LinkPage() - * - * Helper function to link to Bayonet pages. - * - * @param mixed $page_id - * @param mixed $page_name - * @return - */ -function LinkPage($page_id,$page_name) -{ - return "{$page_name}"; -} - -/** - * 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 "{$name}"; -} - -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 "\n"; - } - - /** - * CloseTable() - * - * Closes a Bayonet site table. - * - * @return - */ - function CloseTable() - { - echo "
    "; - } -} - -function OpenBlock($title = 'New Block') -{ - OpenTable(); - echo "
    {$title}
    "; - echo "
    "; -} - -function CloseBlock() -{ - echo "
    "; - 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 "Error Message{$message}"; - 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 "Hack Attempt{$message}"; - 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("
    ",'',$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.
    '; - return; - } - if(file_exists($fp)){ - fwrite($fp,$full_message); - fclose($fp); - }else{ - //echo "could not write to file because file does not exist.
    "; - } -} - -/** - * 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 "Site is currently under construction : $timestamp"; - break; - case BAYONET_SECTION: - echo "Section currently under construction : $timestamp"; - } - - if(!is_null($message)) - { - echo "$message"; - } - - CloseTable(); - echo "
    "; -} - -/** - * 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 "
    "; - } - } -} - -/** - * PageRedirect() - * - * performs an http redirect - * - * @param $delay - * @param $link - */ -function PageRedirect($delay, $link) -{ - echo ""; -} +. + */ + +/** + * 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( + '$1', + '$1', + '$1', + '
    ', + '

    $1

    ', + '
    $1
    ', + '

    $1

    ', + '

    $1

    ', + '

    $1

    ', + '
    $1
    ', + '
    $1
    ', + '$1 wrote:
    $2
    ', + '$2', + '$2', + '$2', + '$2' + ); + + $order = array("\r\n", "\n", "\r"); + $replace = "\n
    "; + + $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
    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\]/", '$1', $Text); + $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text); + //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '$2', $Text); + + // Perform MAIL Search + $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '$1', $Text); + $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '$2', $Text); + + // Check for bold text + $Text = preg_replace("(\[b\](.+?)\[\/b])is",'$1',$Text); + + // Check for Italics text + $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'$1',$Text); + + // Check for Underline text + $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'$1',$Text); + + // Check for strike-through text + $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'$1',$Text); + + // Check for over-line text + $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'$1',$Text); + + // Check for colored text + $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","$2",$Text); + + // Check for sized text + $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","$2",$Text); + + // Check for list text + $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '
      $1
    ' ,$Text); + $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '
      $1
    ' ,$Text); + $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '
      $1
    ' ,$Text); + $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '
      $1
    ' ,$Text); + $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '
      $1
    ' ,$Text); + $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '
      $1
    ' ,$Text); + $Text = str_replace("[*]", "
  • ", $Text); + + // Check for font change text + $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","$2",$Text); + + // Declare the format for [code] layout + $CodeLayout = ' + + + + + + +
    Code:
    $1
    '; + // Check for [code] text + $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text); + // Declare the format for [php] layout + $phpLayout = ' + + + + + + +
    Code:
    $1
    '; + // Check for [php] text + $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text); + + // Declare the format for [quote] layout + $QuoteLayout = ' + + + + + + +
    Quote:
    $1
    '; + + // Check for [quote] text + $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text); + + // Images + // [img]pathtoimage[/img] + $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text); + + //[img=align]image source[/img] + $Text = preg_replace("(\[img align\=(.+?)\](.+?)\[\/img\])is","",$Text); + + // [img=widthxheight]image source[/img] + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); + + // Alignment + // [align=type]text[/align] + $Text = preg_replace("(\[align=(.+?)\](.+?)\[\/align\])is","
    $2
    ",$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 "
      "; + foreach($array as $text => $link) + { + echo "
    • $text
    • "; + } + echo "
    "; +} + +/** + * 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 "{$link_name}"; +} + +/** + * LinkPage() + * + * Helper function to link to Bayonet pages. + * + * @param mixed $page_id + * @param mixed $page_name + * @return + */ +function LinkPage($page_id,$page_name) +{ + return "{$page_name}"; +} + +/** + * 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 "{$name}"; +} + +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 "\n"; + } + + /** + * CloseTable() + * + * Closes a Bayonet site table. + * + * @return + */ + function CloseTable() + { + echo "
    "; + } +} + +function OpenBlock($title = 'New Block') +{ + OpenTable(); + echo "
    {$title}
    "; + echo "
    "; +} + +function CloseBlock() +{ + echo "
    "; + 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 "Error Message{$message}"; + 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 "Hack Attempt{$message}"; + 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("
    ",'',$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.
    '; + return; + } + if(file_exists($fp)){ + fwrite($fp,$full_message); + fclose($fp); + }else{ + //echo "could not write to file because file does not exist.
    "; + } +} + +/** + * 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 "Site is currently under construction : $timestamp"; + break; + case BAYONET_SECTION: + echo "Section currently under construction : $timestamp"; + } + + if(!is_null($message)) + { + echo "$message"; + } + + CloseTable(); + echo "
    "; +} + +/** + * 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 "
    "; + } + } +} + +/** + * PageRedirect() + * + * performs an http redirect + * + * @param $delay + * @param $link + */ +function PageRedirect($delay, $link) +{ + echo ""; +} ?> \ 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 @@ -. - */ - -ob_start(); -$starttime = explode(' ', microtime()); -$starttime = $starttime[1] + $starttime[0]; -?> - - - - -Bayonet CMS Admin Tools - - - - - - - - - - - - - - - - - - - +. + */ + +ob_start(); +$starttime = explode(' ', microtime()); +$starttime = $starttime[1] + $starttime[0]; +?> + + + + +Bayonet CMS Admin Tools + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/admin/images/tree_blank.gif b/admin/images/tree_blank.gif new file mode 100644 index 0000000..a2a96d6 Binary files /dev/null and b/admin/images/tree_blank.gif differ diff --git a/admin/images/tree_branch.gif b/admin/images/tree_branch.gif new file mode 100644 index 0000000..5e13681 Binary files /dev/null and b/admin/images/tree_branch.gif differ diff --git a/admin/images/tree_leaf.gif b/admin/images/tree_leaf.gif new file mode 100644 index 0000000..94ef67a Binary files /dev/null and b/admin/images/tree_leaf.gif differ 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'])){ + ?> + +
    @@ -65,7 +82,7 @@ include 'header.php'; bayonet online web admin Account Settings  |  - Logout, + Logout, @@ -109,6 +126,7 @@ include 'header.php';
    +
    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 @@ -. - */ - -function ListModules() -{ - global $db; - $result = $db->Query("SELECT * FROM `bayonet_blocks` ORDER BY `active` DESC, `weight` ASC, `position`"); - $blocks = $db->fetch($result); - - echo ""; - foreach($blocks as $block) - { - echo ""; - } - echo "
    Existing Blocks
    {$block['weight']} : {$block['dir_name']}EditDelete
    "; -} - -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; - } - - ?> -
    - - - - - - - -
    Title
    Weight
    Position
    Directory Name
    Active -
    -
    - 'Yes',0 => 'No'); - foreach($options as $option => $value) - { - $selected = NULL; - if($active == $option) - { - $selected = "selected"; - } - echo "\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) - - ?> -
    - - - - - - - - -
    Title
    Weight
    Position
    Directory Name
    Active - -
    -
    - 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; - } - - ?> -
    - - - -
    Are you SURE you want to delete the block titled: ''?
       
    -
    - . + */ + +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 "Directory NameWeightStatus"; + foreach($modules as $module){ + echo "".$module['dir_name']."".$module['weight']."".$module['status'].""; + } + 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 @@ -. - */ - -/** - * 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.
    "; -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 "
    ".LinkInternal('Create a Module','?load=admin&op=modules&create=true')."
    "; - -//ListModules(); - +. + */ + +/** + * This file administers the site modules. + * + * -weight + * -directory name + */ + + ?> +

    - Manage Modules

    + "; +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 "
    ".LinkInternal('Create a Module','?load=admin&op=modules&create=true')."
    "; + +//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 @@ - - - -. - */ - -/** - * 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); - - ?> -
    - - - - - -
    News Reel Order
    -
      - {$nav['title']}"; - } - ?> -
    - Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. -
    - + +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; +} + + + + +. + */ + +/** + * 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); + + ?> +
    + + + + + +
    News Reel Order
    +
      + {$nav['title']}"; + } + ?> +
    + Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. +
    + \ 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 @@ -. - */ - ?> - -

    - Navigation Links

    - -Edit Order, Edit Page, Delete Pages, Add Pages
    - -. + */ + ?> + +

    - Navigation Links

    + -Edit Order, Edit Page, Delete Pages, Add Pages
    + + \ 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 ""; - echo "{$news['title']} | {$news['catname']}  
    "; - if(($len = strlen($newsBody))>150) - echo substr($newsBody, 0, 150)."..."; - else - echo $newsBody; - echo '
    '; - echo "Posted By: {$news['author']} on ".date('D M j, Y g:i a T', strtotime($news['date'])); - echo '

    '; +?> + +  |   
    + Posted By: on +

    +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); - ?> +?> +

    Edit News

    -
    + + Originally posted on +Last edited on ".date('n/j/Y @ g:ia e', strtotime($row['edited'])); + } +?> - -
    Author
    Title
    Date
    Time
    Text
    - 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; + } +?> + +

    Post News

    +
    + + + + +
     
    +
    +"; + 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 @@ - - - -. - */ - - define(MAX_SLIDES, 6); - - function EditOrder(){ - - global $db; - ?> -
    - - - - - -
    News Reel Order
    -
      - 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 "
    • "; - PrintSlide($slide); - echo "
    • "; - } -?> -
    - Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. -
    -= 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)."
    "; - $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 "

    Disabled Slides

    "; - $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 "


    "; - } - } - - function PrintSlide($slide){ - echo "{$slide['title']}"; - if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){ - echo "
    "; - } - } - - 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); - } - - + + + +. + */ + + define(MAX_SLIDES, 6); + + function EditOrder(){ + + global $db; + ?> +
    + + + + + +
    News Reel Order
    +
      + 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 "
    • "; + PrintSlide($slide); + echo "
    • "; + } +?> +
    + Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. +
    += 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)."
    "; + $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 "

    Disabled Slides

    "; + $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 "


    "; + } + } + + function PrintSlide($slide){ + echo "{$slide['title']}"; + if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){ + echo "
    "; + } + } + + 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 @@ -. - */ - -if(!defined("ADMIN_FILE")) -{ - die("Access denied."); -} - -include $basedir.'newsreel/functions.php'; -?> -

    - Manage News Reel

    - -Add/Edit/Delete needs to be completed. - - - - - -
    - -
    +. + */ + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'newsreel/functions.php'; +?> +

    - Manage News Reel

    + -Add/Edit/Delete needs to be completed. + + + + + +
    + +
    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 @@ -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 ""; -/* - echo '
    ';
    -	print_r($updateRecordsArray);
    -	echo '
    '; - echo 'If you refresh the page, you will see that records will stay just as you modified.'; -*/ -} -else{ - echo ""; -} -date_default_timezone_set("America/New_York"); -echo " Updated at ".date("g:i:s a", time()); +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 ""; +/* + echo '
    ';
    +	print_r($updateRecordsArray);
    +	echo '
    '; + echo 'If you refresh the page, you will see that records will stay just as you modified.'; +*/ +} +else{ + echo ""; +} +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 @@ -. - */ - /* - 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(); */ +. + */ + /* + 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 @@ -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); - } +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 @@ +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 @@ Edit - Delete + Delete 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(); +?> + Are you SURE you want to delete the award record: ''? for this member?
    All changes are final. +     +__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 @@ +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 ' '.$unit_name.'
    '; + selectUnits($unit_id, 0, $member['cunit_id']); + } + } + + function selectUnits($previous_unit, $indent, $members_unit){ + global $db; + + $indent++; + //$formatting = str_repeat("     ", $indent); + $formatting = str_repeat('', $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.' '.$unit_name.'
    '; + + 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 @@ -. - */ - - ?> - -

    - RUDI/Quartermaster Control Panel

    - . + */ + + ?> + +

    - RUDI/Quartermaster Control Panel

    + \ 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 @@ +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(); +?> + +Name:textField('name', "", false, "50"); ?> +Image: +Text:textArea('text',10,30); ?> +submitButton('processed', 'Add'); ?> + +__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 @@ +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(); +?> + Are you SURE you want to delete the award titled: ''?
    All users who have recieved this award will lose it off their records (not yet at least). +     +__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 @@ -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(); -?> - -Name:textField('name', $award['name'], false, "50"); ?> -Image: -Text:textArea('text',10,30,$award['description']); ?> -submitButton('processed', 'Update'); ?> - -__destruct(); -?> - +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(); +?> + +Name:textField('name', $award['name'], false, "50"); ?> +Image: +Text:textArea('text',10,30,$award['description']); ?> +submitButton('processed', 'Update'); ?> + +__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 @@ -Award Classes"; - $classes = getAwardClasses(); - OpenTable(); - echo ""; - foreach($classes as $class){ - echo "".LinkInternal($class['name'],'?op=rudi&show=awards&cid='.$class['class_id']).""; - } - echo ""; - CloseTable(); - - if(isset($_GET['cid'])){ - $class_id = $_GET['cid']; - $awards = getAwardsByClass($class_id); - echo "

    Awards

    "; - echo LinkInternal(' Add New Award','?op=rudi&show=awards&cid={$class_id}&add=true'); - OpenTable(); - foreach($awards as $award){ - echo "".$award['name']." - Edit - Delete"; - } - CloseTable(); - //include 'view.members.profile.php'; - }else if(isset($_GET['aid'])){ - $award_id = $_GET['aid']; - //include 'view.members.service.php'; - } - } +Award Classes"; + $classes = getAwardClasses(); + OpenTable(); + echo ""; + foreach($classes as $class){ + echo "".LinkInternal($class['name'],'?op=rudi&show=awards&cid='.$class['class_id']).""; + } + echo ""; + CloseTable(); + + if(isset($_GET['cid'])){ + $class_id = $_GET['cid']; + $awards = getAwardsByClass($class_id); + echo "

    Awards

    "; + echo LinkInternal(' Add New Award','?op=rudi&show=awards&cid={$class_id}&add=true'); + OpenTable(); + foreach($awards as $award){ + echo "".$award['name']." + Edit + Delete"; + } + 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 @@ + Use AJAX oncheck to save the status of that member + + $battle = getBattleInfo($war_id); + + decho($battle); + + $members = getCombatSoldiers($war_id); + + decho($members); + +?> +

    Engagement :

    \ 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 @@ + 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); + +?> +

    Unit Engagement:

    + + +"; + + } + 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 @@ -Query("SELECT `first_name`, `last_name` FROM `rudi_unit_members` WHERE `member_id` = '$member_id' LIMIT 1"); - $member = $db->FetchRow($result); - echo "

    Award Record of {$member['first_name']} {$member['last_name']}

    "; - - if(isset($_GET['edit'])){ - $record_id = $_GET['edit']; - EditAwardRecord($record_id); - }else if(isset($_GET['add'])){ - if($_GET['add']){ - AddAwardRecord($_GET['award']); - } - }else{ - - echo "
    ".LinkInternal('Back to Roster', '?op=rudi&show=members')."
    "; - ListAwardRecord($_GET['award']); - } +Query("SELECT `first_name`, `last_name` FROM `rudi_unit_members` WHERE `member_id` = '$member_id' LIMIT 1"); + $member = $db->FetchRow($result); + echo "

    Award Record of {$member['first_name']} {$member['last_name']}

    "; + + 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 "
    ".LinkInternal('Back to Roster', '?op=rudi&show=members')."
    "; + 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 @@ +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; + } +?> + Cancel
    + +
    TitleOpponentResultDate
    {$battle['title']}vs {$battle['name']}{$battle['status']} {$battle['home_score']}-{$battle['visit_score']}"; + echo date("M j Y", strtotime($battle['date'])); + echo "
    + + + +
    Personnel File of
    Rank: + +
    Country: + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Vital Statistics
    First:
    Last:
    Username:
    City:
    Province:
    Status: + +
    Primary MOS:
    Role: + +
    Unit: + +
    Weapons: + +
    Enlisted Date:
    Promotion Date: + +
    Discharge Date:
    Xfire:
    E-Mail:
    +
    + + + + +
    Personal Bio
    + \ 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 "

    Current Members

    "; - echo ""; - echo ""; + echo LinkInternal('New Soldier','?op=rudi&show=members&create=soldier'); +?> +

    Current Members

    +
    RankSoldierMain InfoService RecordMedal Record
    + +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 ""; } CloseTable(); - - echo "

    Previous Members

    "; - echo "
    RankSoldierMain InfoService RecordMedal Record
    "; - echo ""; +?> +

    Previous Members

    +
    RankSoldierMain InfoService RecordMedal Record
    + +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 @@ ?> + +
    RankSoldierMain InfoService RecordMedal Record
    ArmA2 ID
    ArmA2:OA ID
    @@ -118,15 +127,21 @@ - + 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 @@ - -
    - Kilo Company
    - 1st Platoon
    - 1st Squad
    - Fireteam Alpha
    - Fireteam Bravo
    - 2nd Squad
    - Fireteam Alpha
    - Fireteam Bravo
    -
    \ No newline at end of file +

    Unit Structure

    +
    +'; + DisplayUnits(); + echo ''; + + } + + +?> +
    + \ 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=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 :" + baseScore + "" - + "
    Length Bonus :" + (num.Excess*bonus.Excess) + " ["+num.Excess+"x"+bonus.Excess+"] " - + "
    Upper case bonus :" + (num.Upper*bonus.Upper) + " ["+num.Upper+"x"+bonus.Upper+"] " - + "
    Number Bonus : " + (num.Numbers*bonus.Numbers) + " ["+num.Numbers+"x"+bonus.Numbers+"]" - + "
    Symbol Bonus : " + (num.Symbols*bonus.Symbols) + " ["+num.Symbols+"x"+bonus.Symbols+"]" - + "
    Combination Bonus : " + bonus.Combo + "" - + "
    Lower case only penalty : " + bonus.FlatLower + "" - + "
    Numbers only penalty : " + bonus.FlatNumber + "" - + "
    Total Score: " + score + "" ); */ -} - -} -); +/* + * -------------------------------------------------------------------- + * 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=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 :" + baseScore + "" + + "
    Length Bonus :" + (num.Excess*bonus.Excess) + " ["+num.Excess+"x"+bonus.Excess+"] " + + "
    Upper case bonus :" + (num.Upper*bonus.Upper) + " ["+num.Upper+"x"+bonus.Upper+"] " + + "
    Number Bonus : " + (num.Numbers*bonus.Numbers) + " ["+num.Numbers+"x"+bonus.Numbers+"]" + + "
    Symbol Bonus : " + (num.Symbols*bonus.Symbols) + " ["+num.Symbols+"x"+bonus.Symbols+"]" + + "
    Combination Bonus : " + bonus.Combo + "" + + "
    Lower case only penalty : " + bonus.FlatLower + "" + + "
    Numbers only penalty : " + bonus.FlatNumber + "" + + "
    Total Score: " + score + "" ); */ +} + +} +); 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 @@ -. - */ - -/** - * 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 ""; - 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; - } -?> -
    -
    -

    Change Your Password

    -
    Vital Statistics
    Role: @@ -153,7 +168,7 @@
    Weapons: +
    Primary Weapon: +
    Secondary Weapon: +
    - - - - - - - - - - - -
    Password: - - - -
    Password Strength:
    -
    Minimum of 6 Characters
    Confirm Password:
    - - -. + */ + +/** + * 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 ""; + 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; + } +?> +
    +
    +

    Change Your Password

    + + + + + + + + + + + + +
    Password: + + + +
    Password Strength:
    +
    Minimum of 6 Characters
    Confirm Password:
    +
    +
    +. - */ - ?> - -

    - Account Settings

    - -Change password, email, name
    -
    - - - - - - - - +. + */ + ?> + +

    - Account Settings

    + -Change password, email, name
    +
    + + + + + + + + \ 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 -- cgit