From 2459f4fb212c924c68cfedd82c8aa7756a23b607 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 19 Dec 2004 05:26:44 +0000 Subject: [PATCH] r2: Changed Environment object to be BugTrack ($env --> $bugsys).. hopefully this doesn't conflict with any variables :D. --- admin/global.php | 10 ++++----- admin/options.php | 4 ++-- admin/priority.php | 2 +- admin/product.php | 2 +- admin/resolution.php | 2 +- admin/severity.php | 2 +- admin/status.php | 2 +- admin/usergroup.php | 2 +- includes/adminfunctions.php | 4 ++-- includes/functions.php | 4 ++-- includes/functions_datastore.php | 32 +++++++++++++-------------- includes/functions_mail.php | 14 ++++++------ includes/init.php | 6 ++--- login.php | 4 ++-- newreport.php | 38 +++++++++++++++++++++++--------- register.php | 16 +++++++------- 16 files changed, 80 insertions(+), 64 deletions(-) diff --git a/admin/global.php b/admin/global.php index 038b574..8a338d9 100755 --- a/admin/global.php +++ b/admin/global.php @@ -22,14 +22,14 @@ $admin = new Admin_Print_Class(); function admin_login() { - global $admin, $env; + global $admin, $bugsys; - $admin->page_start('Login', '', 15, '', 'document.cplogin.' . iff($env->userinfo['email'], 'password', 'email') . '.focus();'); + $admin->page_start('Login', '', 15, '', 'document.cplogin.' . iff($bugsys->userinfo['email'], 'password', 'email') . '.focus();'); $admin->form_start('../login.php', 'cplogin', false, 'cplogin'); $admin->table_start(true, '425'); $admin->table_head('[#]app[#] Login'); - $admin->row_input('Email', 'email', $env->userinfo['email'], 2, 35, false, false, 'middle'); + $admin->row_input('Email', 'email', $bugsys->userinfo['email'], 2, 35, false, false, 'middle'); $admin->row_input('Password', 'password', '', 2, 35, false, true, 'middle'); $admin->row_submit('', 'Login'); $admin->table_end(); @@ -42,9 +42,9 @@ function admin_login() if ($_COOKIE[COOKIE_PREFIX . 'adminsession']) { - if ($env->userinfo['permissions'] & CANADMINPANEL) + if ($bugsys->userinfo['permissions'] & CANADMINPANEL) { - if (md5(md5($env->userinfo['authkey']) . md5($env->userinfo['email']) . md5($env->userinfo['userid'])) != $_COOKIE[COOKIE_PREFIX . 'adminsession']) + if (md5(md5($bugsys->userinfo['authkey']) . md5($bugsys->userinfo['email']) . md5($bugsys->userinfo['userid'])) != $_COOKIE[COOKIE_PREFIX . 'adminsession']) { mysetcookie(COOKIE_PREFIX . 'adminsession', ''); $admin->error('Invalid admin session has been terminated.'); diff --git a/admin/options.php b/admin/options.php index 178d8eb..c432916 100755 --- a/admin/options.php +++ b/admin/options.php @@ -14,7 +14,7 @@ require_once('./global.php'); require_once('./includes/settings.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINTOOLS)) +if (!($bugsys->userinfo['permissions'] & CANADMINTOOLS)) { admin_login(); } @@ -79,7 +79,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_head(phrase('settinggroup_' . $group)); foreach ($settings["$group"] AS $opt) { - $admin->row_span('" . phrase('setting_' . $opt[1] . '_title') . "", 'thead'); + $admin->row_span('" . phrase('setting_' . $opt[1] . '_title') . "", 'thead'); switch ($opt[2]) { case 'textbox': diff --git a/admin/priority.php b/admin/priority.php index 84dc69f..6b5cf98 100755 --- a/admin/priority.php +++ b/admin/priority.php @@ -13,7 +13,7 @@ require_once('./global.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINFIELDS)) +if (!($bugsys->userinfo['permissions'] & CANADMINFIELDS)) { admin_login(); } diff --git a/admin/product.php b/admin/product.php index b456ee2..09b7ceb 100755 --- a/admin/product.php +++ b/admin/product.php @@ -12,7 +12,7 @@ require_once('./global.php'); -if (!($env->userinfo['permissions'] & CANADMINVERSIONS)) +if (!($bugsys->userinfo['permissions'] & CANADMINVERSIONS)) { admin_login(); } diff --git a/admin/resolution.php b/admin/resolution.php index b3d44de..c3e7680 100755 --- a/admin/resolution.php +++ b/admin/resolution.php @@ -13,7 +13,7 @@ require_once('./global.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINFIELDS)) +if (!($bugsys->userinfo['permissions'] & CANADMINFIELDS)) { admin_login(); } diff --git a/admin/severity.php b/admin/severity.php index 936f586..212eac0 100755 --- a/admin/severity.php +++ b/admin/severity.php @@ -13,7 +13,7 @@ require_once('./global.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINFIELDS)) +if (!($bugsys->userinfo['permissions'] & CANADMINFIELDS)) { admin_login(); } diff --git a/admin/status.php b/admin/status.php index 4ffcc06..6de2c14 100755 --- a/admin/status.php +++ b/admin/status.php @@ -13,7 +13,7 @@ require_once('./global.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINFIELDS)) +if (!($bugsys->userinfo['permissions'] & CANADMINFIELDS)) { admin_login(); } diff --git a/admin/usergroup.php b/admin/usergroup.php index f114b7b..20e4d26 100755 --- a/admin/usergroup.php +++ b/admin/usergroup.php @@ -13,7 +13,7 @@ require_once('./global.php'); require_once('./includes/functions_datastore.php'); -if (!($env->userinfo['permissions'] & CANADMINGROUPS)) +if (!($bugsys->userinfo['permissions'] & CANADMINGROUPS)) { admin_login(); } diff --git a/includes/adminfunctions.php b/includes/adminfunctions.php index 0a49772..1e47b6d 100755 --- a/includes/adminfunctions.php +++ b/includes/adminfunctions.php @@ -100,9 +100,9 @@ EOD; function page_end() { - global $env; + global $bugsys; - $copyright = "\r
\r

\r\t[#]app[#] " . $env->options['trackerversion'] . ", © 2003 - " . date('Y') . " Iris Studios, Inc.\r

"; + $copyright = "\r
\r

\r\t[#]app[#] " . $bugsys->options['trackerversion'] . ", © 2003 - " . date('Y') . " Iris Studios, Inc.\r

"; if (!defined('HIDE_SETUP')) { diff --git a/includes/functions.php b/includes/functions.php index 722060e..e80e677 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -13,7 +13,7 @@ // ########################### Start phrase ########################## function phrase() { - global $env; + global $bugsys; $args = func_get_args(); $numargs = count($args); @@ -23,7 +23,7 @@ function phrase() return false; } - if ($phrasetext = $env->language["$args[0]"]) + if ($phrasetext = $bugsys->language["$args[0]"]) { if ($numargs < 2) { diff --git a/includes/functions_datastore.php b/includes/functions_datastore.php index 1370f6c..493b3c2 100755 --- a/includes/functions_datastore.php +++ b/includes/functions_datastore.php @@ -13,7 +13,7 @@ // ###################### Start build_languages ###################### function build_languages() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $languages = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "language"); while ($language = $DB_sql->fetch_array($languages)) @@ -27,13 +27,13 @@ function build_languages() VALUES ('language', '" . addslasheslike(serialize($tempstore)) . "')" ); - $env->datastore['language'] = $tempstore; + $bugsys->datastore['language'] = $tempstore; } // ####################### Start build_settings ###################### function build_settings() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $settings = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "setting"); while ($setting = $DB_sql->fetch_array($settings)) @@ -47,13 +47,13 @@ function build_settings() VALUES ('setting', '" . addslasheslike(serialize($options)) . "')" ); - $env->datastore['setting'] = $options; + $bugsys->datastore['setting'] = $options; } // ###################### Start build_usergroups ##################### function build_usergroups() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $usergroups = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "usergroup"); while ($usergroup = $DB_sql->fetch_array($usergroups)) @@ -67,13 +67,13 @@ function build_usergroups() VALUES ('usergroup', '" . addslasheslike(serialize($groups)) . "')" ); - $env->datastore['usergroup'] = $groups; + $bugsys->datastore['usergroup'] = $groups; } // ####################### Start build_statuses ###################### function build_statuses() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $statuses = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "status ORDER BY displayorder ASC"); while ($status = $DB_sql->fetch_array($statuses)) @@ -87,13 +87,13 @@ function build_statuses() VALUES ('status', '" . addslasheslike(serialize($tempstore)) . "')" ); - $env->datastore['status'] = $tempstore; + $bugsys->datastore['status'] = $tempstore; } // ###################### Start build_severities ##################### function build_severities() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $severities = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder ASC"); while ($severity = $DB_sql->fetch_array($severities)) @@ -107,13 +107,13 @@ function build_severities() VALUES ('severity', '" . addslasheslike(serialize($tempstore)) . "')" ); - $env->datastore['severity'] = $tempstore; + $bugsys->datastore['severity'] = $tempstore; } // ###################### Start build_priorities ##################### function build_priorities() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $priorities = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder ASC"); while ($priority = $DB_sql->fetch_array($priorities)) @@ -127,13 +127,13 @@ function build_priorities() VALUES ('priority', '" . addslasheslike(serialize($tempstore)) . "')" ); - $env->datastore['priority'] = $tempstore; + $bugsys->datastore['priority'] = $tempstore; } // ###################### Start build_assignedto ##################### function build_assignedto() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $users = $DB_sql->query(" SELECT user.email, user.displayname, user.userid, user.showemail @@ -153,13 +153,13 @@ function build_assignedto() VALUES ('assignto', '" . addslasheslike(serialize($devs)) . "')" ); - $env->datastore['assignto'] = $devs; + $bugsys->datastore['assignto'] = $devs; } // ##################### Start build_resolutions ##################### function build_resolutions() { - global $DB_sql, $env; + global $DB_sql, $bugsys; $resolutions = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC"); while ($resolution = $DB_sql->fetch_array($resolutions)) @@ -173,7 +173,7 @@ function build_resolutions() VALUES ('resolution', '" . addslasheslike(serialize($tempstore)) . "')" ); - $env->datastore['resolution'] = $tempstore; + $bugsys->datastore['resolution'] = $tempstore; } /*=====================================================================*\ diff --git a/includes/functions_mail.php b/includes/functions_mail.php index fb27f85..2b52dd3 100755 --- a/includes/functions_mail.php +++ b/includes/functions_mail.php @@ -13,7 +13,7 @@ // ########################### Start mymail ########################## function mymail($toemail, $subject, $message, $fromemail = '', $headers = '', $fparam = true) { - global $env; + global $bugsys; // Make sure sendmail is at our disposal if (!(@ini_get('sendmail_path'))) @@ -25,9 +25,9 @@ function mymail($toemail, $subject, $message, $fromemail = '', $headers = '', $f $fromemail = fetch_first_line($fromemail); if ($fromemail == -1 OR !$fromemail) { - if ($env->options['webmasteremail']) + if ($bugsys->options['webmasteremail']) { - $fromemail = fetch_first_line($env->options['webmasteremail']); + $fromemail = fetch_first_line($bugsys->options['webmasteremail']); } else { @@ -50,7 +50,7 @@ function mymail($toemail, $subject, $message, $fromemail = '', $headers = '', $f $subject = fetch_first_line($subject); if (!$subject) { - $subject = $env->options['trackertitle'] . ' Notification'; + $subject = $bugsys->options['trackertitle'] . ' Notification'; } // Work out the body @@ -62,10 +62,10 @@ function mymail($toemail, $subject, $message, $fromemail = '', $headers = '', $f // Construct mail headers $headers = convert_standard_line_breaks($headers, "\n"); - $headers .= "From: \"$fromemail\" <" . $env->options['webmasteremail'] . ">\n"; - $headers .= "Return-Path: " . $env->options['webmasteremail'] . "\n"; + $headers .= "From: \"$fromemail\" <" . $bugsys->options['webmasteremail'] . ">\n"; + $headers .= "Return-Path: " . $bugsys->options['webmasteremail'] . "\n"; $headers .= "X-Mailer: [#]app[#] [#]version[#] Mail\n"; - $headers .= "Content-Type: text/plain; charset=\"" . $env->options['lang_charset'] . "\"\n"; + $headers .= "Content-Type: text/plain; charset=\"" . $bugsys->options['lang_charset'] . "\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n"; if ($fparam) diff --git a/includes/init.php b/includes/init.php index 22fd90a..5d1a325 100755 --- a/includes/init.php +++ b/includes/init.php @@ -39,14 +39,14 @@ unset($database, $servername, $username, $password, $usepconnect, $tableprefix, // Initialize our environment require_once('./includes/functions_datastore.php'); require_once('./includes/functions.php'); -class Environment +class BugTracker { var $options = array(); var $userinfo = array(); var $language = array(); var $datastore = array(); - function Environment() + function BugTracker() { global $DB_sql, $vars; @@ -155,7 +155,7 @@ class Environment } } -$env = new Environment(); +$bugsys = new BugTracker(); // ################################################################### // Initialize usergroup system diff --git a/login.php b/login.php index 3cb2b64..9aaf276 100755 --- a/login.php +++ b/login.php @@ -14,7 +14,7 @@ require_once('./global.php'); // ################################################################### -if ($env->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin') +if ($bugsys->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin') { echo 'You are already logged in.'; exit; @@ -89,7 +89,7 @@ if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin') if ($_REQUEST['do'] == 'logout') { - if ($env->userinfo['userid']) + if ($bugsys->userinfo['userid']) { mysetcookie(COOKIE_PREFIX . 'userid'); mysetcookie(COOKIE_PREFIX . 'authkey'); diff --git a/newreport.php b/newreport.php index f0cbd45..1114297 100755 --- a/newreport.php +++ b/newreport.php @@ -12,7 +12,7 @@ require_once('./global.php'); -if (!($env->userinfo['permissions'] & CANSUBMITBUGS)) +if (!($bugsys->userinfo['permissions'] & CANSUBMITBUGS)) { echo 'NO permission'; exit; @@ -43,22 +43,38 @@ if ($_POST['do'] == 'insert') ); // check permissions on various input values - if (!$env->userinfo['permissions'] & CANCHANGESTATUS) + if (!$bugsys->userinfo['permissions'] & CANCHANGESTATUS) { unset($vars['priority'], $vars['status'], $vars['resolution']); } - if (!$env->userinfo['permissions'] & CANASSIGN) + if (!$bugsys->userinfo['permissions'] & CANASSIGN) { unset($vars['assignedto']); } else { // assigned person is not a dev or a valid user - if (!$env->datastore['assignto']["$vars[assignedto]"]['userid']) + if (!$bugsys->datastore['assignto']["$vars[assignedto]"]['userid']) { unset($vars['assignedto']); } } + + if (!$vars['product'] OR !$vars['component'] OR !$vars['version']) + { + echo 'there was a problem selecting the product, component, or version'; + exit; + } + if (!$vars['summary']) + { + echo 'please enter a bug title'; + exit; + } + if (!$vars['comment']) + { + echo 'please enter a bug description'; + exit; + } } // ################################################################### @@ -159,40 +175,40 @@ if ($_REQUEST['do'] == 'add') echo '
Summary/Title:
'; echo '
Severity:
'; - if ($env->userinfo['permissions'] & CANCHANGESTATUS) + if ($bugsys->userinfo['permissions'] & CANCHANGESTATUS) { echo '
Priority:
'; echo '
Status:
'; echo '
Resolution:
'; } - if ($env->userinfo['permissions'] & CANASSIGN) + if ($bugsys->userinfo['permissions'] & CANASSIGN) { echo '
Assigned to: