From 6c42f30a0424cbf1c1af63f21d7f5074a4653c7a Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Wed, 23 Dec 2009 01:58:08 +0000 Subject: (OC) tried fixing the insert in NewAdmin(), no luck git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@394 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/admins/functions.php | 69 +++++++++++++++++++++++++++++++++----- admin/calendar/index.php | 1 - admin/news/functions.php | 2 +- admin/news/index.php | 6 +++- blocks/mini_calendar/functions.php | 5 +-- footer.php | 2 +- includes/debug.php | 42 ++++++++++++++++------- includes/sql.class.php | 5 +++ index.php | 2 +- 9 files changed, 106 insertions(+), 28 deletions(-) diff --git a/admin/admins/functions.php b/admin/admins/functions.php index c44d05a..413c0fe 100644 --- a/admin/admins/functions.php +++ b/admin/admins/functions.php @@ -62,12 +62,55 @@ function NewAdmin() { + + global $db; $maxLevel = $_SESSION['level']; if(isset($_POST['processed'])){ - echo GeneratePassword(8); - return; + $username = addslashes($_POST['username']); + $level = addslashes($_POST['level']); + $email = addslashes($_POST['email']); + $first = addslashes($_POST['first']); + $last = addslashes($_POST['last']); + + $all = $_POST['all']; + $squadleader = $_POST['squadleader']; + $adjutant = $_POST['adjutant']; + $quartermaster = $_POST['quartermaster']; + + $password = GeneratePassword(8); + $cryptpassword = crypt(md5($password),'iamnotadirtywhorebitch'); + + if(empty($username)) + { + ReportError("This user must have a username to continue."); + 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', '', $level, $all, $squadleader, $adjutant, $quartermaster)"); + + $db->Query("INSERT INTO `bayonet_users` SET `username` = '$username'"); + + + 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
@@ -103,14 +146,14 @@
- + - - + -
Everything elseAdjutantQuartermaster
Everything elseSquad LeaderAdjutantQuartermaster
+ "; ?> + + + "; + else + echo ""; + ?> + "; ?> + Query("UPDATE `bayonet_users` SET `username` = '$username', `level` = '$level', `all` = '$all', `adjutant` = '$adjutant', `quartermaster` = '$quartermaster' WHERE `user_id` = '$user_id' LIMIT 1"); + $db->Query("UPDATE `bayonet_users` SET `username` = '$username', `level` = '$level', `all` = '$all', `squadleader` = '$squadleader', `adjutant` = '$adjutant', `quartermaster` = '$quartermaster' WHERE `user_id` = '$user_id' LIMIT 1"); echo "Admin, '$username' level '$level' has been edited.\n

Please wait while you are redirected.

diff --git a/admin/calendar/index.php b/admin/calendar/index.php index a61424f..1197990 100644 --- a/admin/calendar/index.php +++ b/admin/calendar/index.php @@ -19,7 +19,6 @@ ?>

- Manage Calendar & Events

- -Edit events needs to be completed. "; - $result = $db->Query("SELECT `user_id`, `lastname` FROM `bayonet_users` WHERE `active` = 1 ORDER BY `username` ASC"); + $result = $db->Query("SELECT `user_id`, `lastname` FROM `bayonet_users` ORDER BY `username` ASC"); while(($row = $db->Fetch($result))!= false){ if($author_id == $row['user_id']) echo ""; diff --git a/admin/news/index.php b/admin/news/index.php index 2b7dca1..43baf81 100644 --- a/admin/news/index.php +++ b/admin/news/index.php @@ -16,7 +16,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + ?> +

- Manage News

+ -Everything needs to be completed. + if(isset($_GET['edit'])){ $news_id = $_GET['edit']; EditNews($news_id); - return; } diff --git a/blocks/mini_calendar/functions.php b/blocks/mini_calendar/functions.php index 3291e6b..0dee840 100644 --- a/blocks/mini_calendar/functions.php +++ b/blocks/mini_calendar/functions.php @@ -252,7 +252,7 @@ $isEvent=false; global $db; - $result = $db->Query("SELECT title,color FROM `bayonet_events` WHERE `date` = '$sqlDate' ORDER BY `date` DESC"); + $result = $db->Query("SELECT title,color,date,time FROM `bayonet_events` WHERE `date` = '$sqlDate' ORDER BY `date` DESC"); while(($row = $db->Fetch($result))!=false) { $isEvent = true; @@ -301,7 +301,8 @@ if(count($todaysEvents)>0){ echo "

Today's Events

"; foreach($todaysEvents as $event){ - echo "   {$event['title']}
"; + $time = date("g:i a", strtotime($event['date']." ".$event['time'])); + echo "   {$event['title']} @ {$time}
"; } } } diff --git a/footer.php b/footer.php index df7d61a..8437681 100644 --- a/footer.php +++ b/footer.php @@ -35,7 +35,7 @@ $debug_output = sprintf("Page generated in %.3f seconds | Memory: real(%.3fmb) p Administrative Control Panel


-
+


diff --git a/includes/debug.php b/includes/debug.php index 875ba8d..75e0d0f 100644 --- a/includes/debug.php +++ b/includes/debug.php @@ -16,11 +16,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +global $config; define("RUDI_DEBUG",true); define("RUDI_DEBUG_LEVEL",true); -define('NO_REPEAT','norepeat'); -define('REPEAT','repeat'); +define('NO_REPEAT',false); +define('REPEAT',true); static $last_message = NULL; static $last_message_count = 0; @@ -28,18 +30,23 @@ static $last_message_count = 0; static $log_message_last = NULL; static $log_message_queue = array(); static $log_message_pos = 0; + function decho2($message) { - global $log_message_last, $log_message_queue, $log_message_pos; + global $log_message_last, $log_message_queue, $log_message_pos, $config; + date_default_timezone_set($config['logs']['timezone']); + $timestamp = date('Y-M-d H:i:s T'); + $message = "[$timestamp]: $message"; array_push($log_message_queue, $message); $log_message_pos++; } function logQueueFlush() { - global $log_message_queue; + global $log_message_queue, $config; $messageCount = 0; static $log_message_last_count = 0; + static $next = false; echo "
Bayonet Debug Messages
"; echo "
"; @@ -49,20 +56,29 @@ function logQueueFlush() { echo "{$messageCount}: $message
\n"; } - else + elseif($message == $log_message_queue[$messageCount - 1]) { - if($message == $log_message_queue[$messageCount - 1]) - { - echo "incrementing
\n"; - $log_message_last_count++; - } - else + $log_message_last_count++; + if($config['debug']['repeat_messages'] == false) { - echo "Previous message received $log_message_last_count times
\n"; - $log_message_last_count = 0; + echo "{$messageCount}: $message
\n"; + if($config['debug']['repeat_messages'] == true) + { + if($log_message_queue[$messageCount + 1] != $message) + { + $next = true; + } + } } } + if($next == true) + { + echo "$messageCount: Last message recieved $log_message_last_count times
\n"; + $log_message_last_count = 0; + $next = false; + } + $messageCount++; } echo "
"; diff --git a/includes/sql.class.php b/includes/sql.class.php index 141a7ae..57fdd5d 100644 --- a/includes/sql.class.php +++ b/includes/sql.class.php @@ -42,6 +42,11 @@ class Bayonet_SQL //return mysql_close($link); } + public function Stat() + { + return mysql_stat(); + } + public function Select_db($db) { decho("Selecting database ('$db')"); diff --git a/index.php b/index.php index 3687f0d..4f6d84b 100644 --- a/index.php +++ b/index.php @@ -11,8 +11,8 @@ /* Begin try/catch block */ try { -include './includes/debug.php'; include './includes/config.php'; +include './includes/debug.php'; include './includes/sql.class.php'; include './includes/functions.php'; -- cgit