From fa8180ea3a41584943dd7464eb8c3cad769d8211 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 17 Apr 2011 16:49:09 +0000 Subject: Jessus christ git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2.1@491 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/images/bayonet_logo.jpg | Bin 36192 -> 38851 bytes admin/rudi/index.php | 1 + admin/rudi/views/view.awards.edit.php | 15 +- admin/rudi/views/view.awards.php | 6 + admin/rudi/views/view.members.php | 4 +- admin/rudi/views/view.members.profile.php | 2 + admin/rudi/views/view.units.php | 22 ++ include/classes.php | 347 +++++++++++++++++++----------- include/debug.php | 4 +- include/functions.php | 54 +---- index.php | 108 +--------- modules/index/index.php | 2 + modules/news/functions.php | 19 +- modules/news/index.php | 42 +++- modules/rudi/includes/common.class.php | 4 +- modules/rudi/views/view.roster.php | 2 +- themes/default/include/primary.css | 4 + themes/default/index.php | 2 +- 18 files changed, 348 insertions(+), 290 deletions(-) diff --git a/admin/images/bayonet_logo.jpg b/admin/images/bayonet_logo.jpg index d957c7d..5127ad2 100644 Binary files a/admin/images/bayonet_logo.jpg and b/admin/images/bayonet_logo.jpg differ diff --git a/admin/rudi/index.php b/admin/rudi/index.php index 3d93bf0..2e4a42a 100644 --- a/admin/rudi/index.php +++ b/admin/rudi/index.php @@ -49,6 +49,7 @@ $th = array('Rudi Options',''); $td = array( LinkInternal('Roster','?op=rudi&show=members'), + LinkInternal('Units','?op=rudi&show=units'), LinkInternal('Awards', '?op=rudi&show=awards') ); diff --git a/admin/rudi/views/view.awards.edit.php b/admin/rudi/views/view.awards.edit.php index 09f041c..21ec156 100644 --- a/admin/rudi/views/view.awards.edit.php +++ b/admin/rudi/views/view.awards.edit.php @@ -3,19 +3,22 @@ $form = new BayonetForm("", "POST"); if($form->verifySubmit('processed')) { - echo "Key states
\n"; - $keydump = print_r($form->getKeyStates($form->request), true); - echo "
{$keydump}
\n"; - - echo "

Transaction processed

\n"; - + 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'); ?> Award Classes"; $classes = getAwardClasses(); @@ -18,6 +23,7 @@ $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']." diff --git a/admin/rudi/views/view.members.php b/admin/rudi/views/view.members.php index 659ef2b..38929df 100644 --- a/admin/rudi/views/view.members.php +++ b/admin/rudi/views/view.members.php @@ -16,7 +16,7 @@ echo "

Current Members

"; echo ""; echo ""; - $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 <= 3 ORDER BY rudi_ranks.weight DESC , rudi_unit_members.date_promotion ASC , rudi_unit_members.date_enlisted ASC"); $row = $db->Fetch($result); foreach($row as $member){ @@ -32,7 +32,7 @@ echo "

Previous Members

"; echo "
RankSoldierMain InfoService RecordMedal Record
"; echo ""; - $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 OR 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 > 3 ORDER BY rudi_ranks.weight DESC, rudi_unit_members.date_promotion ASC, rudi_unit_members.date_enlisted ASC"); $row = $db->Fetch($result); foreach($row as $member){ diff --git a/admin/rudi/views/view.members.profile.php b/admin/rudi/views/view.members.profile.php index fedabdd..bd776d7 100644 --- a/admin/rudi/views/view.members.profile.php +++ b/admin/rudi/views/view.members.profile.php @@ -51,6 +51,8 @@ decho($query); $db->Query($query); + $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}"); return; diff --git a/admin/rudi/views/view.units.php b/admin/rudi/views/view.units.php index e69de29..2ccf35a 100644 --- a/admin/rudi/views/view.units.php +++ b/admin/rudi/views/view.units.php @@ -0,0 +1,22 @@ + +
+ Kilo Company
+ 1st Platoon
+ 1st Squad
+ Fireteam Alpha
+ Fireteam Bravo
+ 2nd Squad
+ Fireteam Alpha
+ Fireteam Bravo
+
\ No newline at end of file diff --git a/include/classes.php b/include/classes.php index 0042c95..5f51e99 100644 --- a/include/classes.php +++ b/include/classes.php @@ -1,131 +1,238 @@ "; + echo "
"; + } + + function CloseContent() + { + echo "
"; + echo ""; + } +} + +class Bayonet_Theme extends Bayonet_Layout +{ + static public $index; + static public $header; + static public $footer; + + static public $name; + static public $root_path; + static public $include_path; + static public $image_path; + static public $config_path; + static public $config; + static public $primary_css; + + static function init() + { + if (!isset($_GET['theme'])) + { + self::$name = Bayonet_Config::$ini['site']['theme']; + } + else + { + self::$name = $_GET['theme']; + } + + decho('Initializing theme variables for \'' . self::$name . '\''); + self::$root_path = dirname(BAYONET_ROOT) . '/themes/' . self::$name; + self::$include_path = self::$root_path . '/include'; + self::$image_path = self::$root_path . '/images'; + self::$primary_css = self::$include_path . '/primary.css'; + self::$config_path = self::$include_path . '/theme.ini'; + + if (!self::is_valid()) + { + die('Theme failed during initialization.'); + } + self::$config = parse_ini_file(self::$config_path, true); + + self::$index = self::$root_path . '/index.php'; + self::$header = self::$root_path . '/header.php'; + self::$footer = self::$root_path . '/footer.php'; + + //decho(get_class_vars(Bayonet_Theme)); //do not re-enable this + self::load(); + } + + static private function is_valid() + { + if (file_exists(self::$root_path) && file_exists(self::$include_path) && + file_exists(self::$config_path)) return true; + else return false; + } + + static function load() + { + global $db, $config; + decho("Loading theme: '" . self::$name . "'"); + require self::$index; + } +} + +class Bayonet_Config +{ + static $ini; + static function init() + { + decho('Parsing configuration data'); + if (file_exists(BAYONET_CONFIG)) + { + self::$ini = parse_ini_file(BAYONET_CONFIG, true); + decho(self::$ini); + } + else die(BAYONET_CONFIG . ' not found'); + } +} + +class Bayonet +{ + static function init() + { + global $db, $config; + Bayonet_Config::init(); + + // Set globally referenced configuration and database variables + $config = Bayonet_Config::$ini; + $db = new Bayonet_SQL(); + + //Connect to the MySQL server + $db->Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']); + $db->Select_db($config['sql']['database']); + + decho('Initializing Bayonet'); + Bayonet_Theme::init(); + } +} + + define('PASSWORD', true); define('NO_PASSWORD', false); define('CHECKED', true); class BayonetForm { - static public $request; - - public function __construct($action, $method) - { - $this->request = $_POST; - echo "\n"; - } - - public function __destruct() - { - echo "\n"; - } - - function getKeyStates($keys) - { - $good = array(); - $bad = array(); - - if(!is_array($keys)) - return array(); - - foreach($keys as $key => $value) - { - if(!empty($value)) - $good[$key] = $value; - else - $bad[$key] = $value; - } - - $data = array( - 'set' => $good, - 'unset' => $bad - ); - - return $data; - } - - function verify($submit_key) - { - return $this->verifySubmit($submit_key); - } - - function verifySubmit($submit_key) - { - return isset($this->request[$submit_key]) ? true : false; - } - - function button($extern_name, $value, $text = "Button") - { - echo "\n"; - } - - function submitButton($extern_name, $value = "Submit") - { - echo "\n"; - } - - function reset($value = "Reset") - { - echo "\n"; - } - - function textField($extern_name, $value = NULL, $isPassword = false, $size = NULL, $max = NULL) - { - $type = 'text'; - if($isPassword) $type = 'password'; - - $value = filter_var($value, FILTER_SANITIZE_STRING); - echo "\n"; - } - - function radioButton($extern_name, $value, $isChecked = false) - { - if($isChecked) - { - echo "\n"; - } - else - { - echo "\n"; - } - } - - function checkBox($extern_name, $value, $isChecked = false) - { - if($isChecked) - { - echo "\n"; - } - else - { - echo "\n"; - } - } - - function dropDown($extern_name, $values = array('None'), $select = NULL) - { - $selectIterator = 1; - - echo "\n"; - } - - function textArea($extern_name, $rows = 10, $cols = 30, $value = NULL) - { - $value = filter_var($value, FILTER_SANITIZE_STRING); - echo "\n"; - } + static public $request; + + public function __construct($action, $method) + { + $this->request = $_POST; + echo "\n"; + } + + public function __destruct() + { + echo "\n"; + } + + function getKeyStates($keys) + { + $good = array(); + $bad = array(); + + if (!is_array($keys)) return array(); + + foreach ($keys as $key => $value) + { + if (!empty($value)) $good[$key] = $value; + else $bad[$key] = $value; + } + + $data = array('set' => $good, 'unset' => $bad); + + return $data; + } + + function verify($submit_key) + { + return $this->verifySubmit($submit_key); + } + + function verifySubmit($submit_key) + { + return isset($this->request[$submit_key]) ? true : false; + } + + function button($extern_name, $value, $text = "Button") + { + echo "\n"; + } + + function submitButton($extern_name, $value = "Submit") + { + echo "\n"; + } + + function reset($value = "Reset") + { + echo "\n"; + } + + function textField($extern_name, $value = null, $isPassword = false, $size = null, + $max = null) + { + $type = 'text'; + if ($isPassword) $type = 'password'; + + $value = filter_var($value, FILTER_SANITIZE_STRING); + echo "\n"; + } + + function radioButton($extern_name, $value, $isChecked = false) + { + if ($isChecked) + { + echo "\n"; + } + else + { + echo "\n"; + } + } + + function checkBox($extern_name, $value, $isChecked = false) + { + if ($isChecked) + { + echo "\n"; + } + else + { + echo "\n"; + } + } + + function dropDown($extern_name, $values = array('None'), $select = null) + { + $selectIterator = 1; + + echo "\n"; + } + + function textArea($extern_name, $rows = 10, $cols = 30, $value = null) + { + $value = filter_var($value, FILTER_SANITIZE_STRING); + echo "\n"; + } } ?> \ No newline at end of file diff --git a/include/debug.php b/include/debug.php index 29f4195..a0c2236 100644 --- a/include/debug.php +++ b/include/debug.php @@ -115,7 +115,7 @@ function logQueueFlush($force = false) static $log_message_last_count = 0; static $next = false; - OpenContent(); + //OpenContent(); echo "
Bayonet Debug Messages
"; echo "
"; @@ -168,7 +168,7 @@ function logQueueFlush($force = false) } echo "
"; - CloseContent(); + //CloseContent(); error_reporting(1); } diff --git a/include/functions.php b/include/functions.php index 3f1c3d2..109f11c 100644 --- a/include/functions.php +++ b/include/functions.php @@ -330,26 +330,27 @@ if(!defined("CALLED_FROM_ADMIN")) /** * OpenContent() * Begins a Bayonet site table. + * MOVE FOR CUSTOMIZED USE FOR THEMES * @return */ - function OpenContent() +/* function OpenContent() { echo "
"; echo "
"; - } + } */ /** * CloseContent() * Closes a Bayonet site table. * @return */ - function CloseContent() + /* function CloseContent() { echo "
"; echo "
"; - } + } */ } - +/* MOVED TO THEMES function OpenBlock($title = 'New Block') { OpenContent(); @@ -361,7 +362,7 @@ function CloseBlock() { echo ""; CloseContent(); -} +} */ static $error_stack_messages = array(); //global stack of errors accumulated throughout execution function push_error_stack($message) @@ -404,9 +405,9 @@ function handle_error ($errno, $errstr, $errfile, $errline) function ReportError($message) { //WriteLog($message,BAYONET_LOG_ERROR); - OpenContent(); + //OpenContent(); echo "
Error Message
{$message}
"; - CloseContent(); + //CloseContent(); } /** @@ -421,9 +422,9 @@ function ReportError($message) function ReportHack($message) { //WriteLog($message,BAYONET_LOG_HACK); - OpenContent(); + //OpenContent(); echo "
Hacking Attempt
{$message}
"; - CloseContent(); + //CloseContent(); } /** @@ -552,39 +553,6 @@ function WriteLogBayonet($message,$flag) } } -/** - * 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 ""; - break; - case BAYONET_SECTION: - echo ""; - } - - if(!is_null($message)) - { - echo ""; - } - - CloseTable(); - echo "
"; -} - /** * valid_result() * diff --git a/index.php b/index.php index 01fe58b..d6280da 100644 --- a/index.php +++ b/index.php @@ -10,114 +10,10 @@ define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini'); require BAYONET_INCLUDE . '/debug.php'; require BAYONET_INCLUDE . '/sql.class.php'; require BAYONET_INCLUDE . '/functions.php'; +require_once BAYONET_INCLUDE . '/classes.php'; - -class Bayonet_Theme -{ - static public $index; - static public $header; - static public $footer; - - static public $name; - static public $root_path; - static public $include_path; - static public $image_path; - static public $config_path; - static public $config; - static public $primary_css; - - static function init() - { - if(!isset($_GET['theme'])) - { - self::$name = Bayonet_Config::$ini['site']['theme']; - } - else - { - self::$name = $_GET['theme']; - } - - decho('Initializing theme variables for \'' . self::$name . '\''); - self::$root_path = dirname(BAYONET_ROOT) . '/themes/' . self::$name; - self::$include_path = self::$root_path . '/include'; - self::$image_path = self::$root_path . '/images'; - self::$primary_css = self::$include_path . '/primary.css'; - self::$config_path = self::$include_path . '/theme.ini'; - - if(!self::is_valid()) - { - die('Theme failed during initialization.'); - } - self::$config = parse_ini_file(self::$config_path, true); - - self::$index = self::$root_path . '/index.php'; - self::$header = self::$root_path . '/header.php'; - self::$footer = self::$root_path . '/footer.php'; - - //decho(get_class_vars(Bayonet_Theme)); //do not re-enable this - self::load(); - } - - static private function is_valid() - { - if( - file_exists(self::$root_path) && - file_exists(self::$include_path) && - file_exists(self::$config_path) - ) - return true; - else - return false; - } - - static function load() - { - global $db, $config; - - // Globally referenced configuration and database variables - $config = Bayonet_Config::$ini; - $db = new Bayonet_SQL(); - - $db->Connect( - $config['sql']['hostname'], - $config['sql']['username'], - $config['sql']['password'] - ); - $db->Select_db($config['sql']['database']); - - decho("Loading theme: '" . self::$name . "'"); - require self::$index; - } -} - -class Bayonet_Config -{ - static $ini; - static function init() - { - decho('Parsing configuration data'); - if(file_exists(BAYONET_CONFIG)) - { - self::$ini = parse_ini_file(BAYONET_CONFIG, true); - decho(self::$ini); - } - else - die(BAYONET_CONFIG . ' not found'); - } -} - -class Bayonet -{ - static function init() - { - decho('Initializing Bayonet'); - Bayonet_Config::init(); - Bayonet_Theme::init(); - } -} - +/* Initialize Bayonet CMS */ Bayonet::init(); - ?> \ No newline at end of file diff --git a/modules/index/index.php b/modules/index/index.php index 9847cb5..54c8dbd 100644 --- a/modules/index/index.php +++ b/modules/index/index.php @@ -8,6 +8,8 @@ * */ +define('INDEX_MODULE', true); + $result = $db->Query("SELECT `dir_name` FROM `bayonet_modules` ORDER BY `weight` ASC"); $modules = $db->Fetch($result); foreach($modules as $module) diff --git a/modules/news/functions.php b/modules/news/functions.php index 22952af..f3505df 100644 --- a/modules/news/functions.php +++ b/modules/news/functions.php @@ -127,7 +127,7 @@ function getNumOfComments($id){ * Function that gets the desired news from the database and returns it as an array * @param id - (optional) news_id cooresponding to `bayonet_news` */ -function getNews($id = NULL){ +function getNews($id = NULL, $limit = NULL, $index = 0){ global $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 ". @@ -138,11 +138,12 @@ function getNews($id = NULL){ $query = $query."WHERE n.news_id = '$id' "; }else{ $query = $query."ORDER BY date DESC"; - if($limit !=NULL){ - $query = $query." LIMIT '$limit'"; - } + if($index > 0) + $query = $query." LIMIT $index, $limit"; + else if($limit !=NULL) + $query = $query." LIMIT $limit"; } - + decho($query); $result = $db->Query($query); $data = $db->Fetch($result); @@ -159,6 +160,12 @@ function displayNews($data){ date_default_timezone_set("America/New_York"); + if(empty($data)){ + ReportError("Sorry, we found no news using these parameters."); + echo "
"; + } + + foreach($data as $news) { $numComments = getNumOfComments($news['news_id']); @@ -235,7 +242,7 @@ function commentForm(){ echo "Guest"; } ?> -

+

diff --git a/modules/news/index.php b/modules/news/index.php index 6aaec2d..1dfd98a 100644 --- a/modules/news/index.php +++ b/modules/news/index.php @@ -27,6 +27,20 @@ include 'modules/news/functions.php'; $logged_id = 2; +if(!defined('INDEX_MODULE')){ + $page_num = 1; + $page_num = $_GET['page']; //get variable for page number + + $page_num --; //so the $index can be calculated easier while keeping [1,n] page numbers + + $limit = 3; //number of items per page + $index = $page_num * $limit; + +}else{ + //only do the limit + $limit = 3; +} + if(isset($_GET['id'])) { $news_id = $_GET['id']; @@ -36,9 +50,35 @@ if(isset($_GET['id'])) } else { - displayNews(getNews()); + $news = getNews(null, $limit, $index); + displayNews($news); + OpenContent(); + if(defined('INDEX_MODULE')){ +?> +
+ Read All  +
+ + 0) + echo " More Recent News"; + + decho("count: ".count($news)); + if(count($news) == $limit){ +?> +
+ Older News  +
+"; + CloseContent(); return; } + + ?> \ No newline at end of file diff --git a/modules/rudi/includes/common.class.php b/modules/rudi/includes/common.class.php index 2e64e48..2112853 100644 --- a/modules/rudi/includes/common.class.php +++ b/modules/rudi/includes/common.class.php @@ -708,10 +708,10 @@ class RUDI_Common * @param int $unit_id */ public function displayUnitsRec($unit_id){ - $result = $this->db->Query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = '$unit_id'"); + $result = $this->db->Query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = '$unit_id' ORDER BY `weight`"); $row = $this->db->FetchObject($result,'UnitInfo'); foreach($row as $unit){ - echo ""; + echo ""; $this->printRoster($unit->unit_id, $unit->leader_id); $this->displayUnitsRec($unit->unit_id); } diff --git a/modules/rudi/views/view.roster.php b/modules/rudi/views/view.roster.php index 01da5ea..c0ee92d 100644 --- a/modules/rudi/views/view.roster.php +++ b/modules/rudi/views/view.roster.php @@ -3,7 +3,7 @@ $result = $this->db->query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = 0"); $row = $this->db->fetch($result); foreach($row as $unit){ - echo ""; + echo ""; ?> diff --git a/themes/default/include/primary.css b/themes/default/include/primary.css index 93aa1ab..7bed7ce 100644 --- a/themes/default/include/primary.css +++ b/themes/default/include/primary.css @@ -100,6 +100,10 @@ font-size: 10px; } + .clear { + clear: both; + } + /********************************* ** Nav Links Styles ** *********************************/ diff --git a/themes/default/index.php b/themes/default/index.php index 1004e0a..3d02ec1 100644 --- a/themes/default/index.php +++ b/themes/default/index.php @@ -15,7 +15,7 @@ try { ob_start("fatal_error_handler"); set_error_handler("handle_error"); - +require_once self::$root_path . '/include/functions.php'; include self::$header; //session_start(); -- cgit
RankSoldierMain InfoService RecordMedal Record
Site is currently under construction : $timestamp
Section currently under construction : $timestamp
$message
{$unit->name}
{$unit->name} : {$unit->callsign}
{$unit['name']}
{$unit['name']} : {$unit['callsign']}