From 52b90dca0988c9c3415435f822af53c9a4bc6f7a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 May 2005 16:11:20 +0000 Subject: [PATCH] r173: Renaming the error reporting stuff so it can also handle non-error messages and redirects --- attachment.php | 30 +++++++++++++++--------------- editcomment.php | 6 +++--- editreport.php | 10 +++++----- global.php | 4 ++-- includes/class_error.php | 10 +++++----- index.php | 2 +- login.php | 6 +++--- newcomment.php | 4 ++-- newreport.php | 6 +++--- register.php | 10 +++++----- search.php | 6 +++--- showhistory.php | 2 +- showreport.php | 4 ++-- viewattachment.php | 4 ++-- 14 files changed, 52 insertions(+), 52 deletions(-) diff --git a/attachment.php b/attachment.php index 98b8703..7a0f7a2 100755 --- a/attachment.php +++ b/attachment.php @@ -22,14 +22,14 @@ if (isset($bugsys->in['attachmentid'])) $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid'])); if (!$attachment) { - $error->throw('alert: bad attachment'); + $message->error('alert: bad attachment'); } } $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . (($attachment['attachmentid']) ? $attachment['bugid'] : intval($bugsys->in['bugid']))); if (!$bug) { - $error->throw('alert: bad bug'); + $message->error('alert: bad bug'); } // setup logging @@ -43,7 +43,7 @@ if ($_REQUEST['do'] == 'kill') { if (!can_perform('caneditattach')) { - $error->throw_permission(); + $message->error_permission(); } $db->query("DELETE FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = $attachment[attachmentid]"); @@ -62,7 +62,7 @@ if ($_REQUEST['do'] == 'delete') { if (!can_perform('caneditattach')) { - $error->throw_permission(); + $message->error_permission(); } echo "are you sure you want to delete this attachment? yes"; @@ -74,7 +74,7 @@ if ($_POST['do'] == 'insert') { if (!can_perform('canputattach')) { - $error->throw_permission(); + $message->error_permission(); } // create alias @@ -84,24 +84,24 @@ if ($_POST['do'] == 'insert') switch ($FILE['error']) { case 0: break; - case 1: $error->throw('PHP said the file you uploaded was too big.'); break; - case 2: $error->throw('The file exceeds the allowed upload size.'); break; - case 3: $error->throw('The file was only partially uploaded.'); break; - case 4: $error->throw('The file was not uploaded at all.'); break; - case 6: $error->throw('PHP could not find the /tmp directory.'); break; + case 1: $message->error('PHP said the file you uploaded was too big.'); break; + case 2: $message->error('The file exceeds the allowed upload size.'); break; + case 3: $message->error('The file was only partially uploaded.'); break; + case 4: $message->error('The file was not uploaded at all.'); break; + case 6: $message->error('PHP could not find the /tmp directory.'); break; } // did it upload? if (!is_uploaded_file($FILE['tmp_name'])) { - $error->throw('The file you specified did not upload.'); + $message->error('The file you specified did not upload.'); } // #*# put some MIME-type validation here if (!$bugsys->in['description']) { - $error->throw('you need a file description!'); + $message->error('you need a file description!'); } $filedata = $bugsys->escape(file_get_contents($FILE['tmp_name']), true, true); @@ -178,7 +178,7 @@ if ($_REQUEST['do'] == 'add') { if (!can_perform('canputattach')) { - $error->throw_permission(); + $message->error_permission(); } $MAXFILESIZE = $funct->fetch_max_attachment_size(); @@ -203,7 +203,7 @@ if ($_POST['do'] == 'update') { if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach')))) { - $error->throw_permission(); + $message->error_permission(); } $db->query(" @@ -232,7 +232,7 @@ if ($_REQUEST['do'] == 'edit') { if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach')))) { - $error->throw_permission(); + $message->error_permission(); } $show['delete'] = ((can_perform('caneditattach')) ? true : false); diff --git a/editcomment.php b/editcomment.php index 7beaf7a..5795081 100644 --- a/editcomment.php +++ b/editcomment.php @@ -26,14 +26,14 @@ $comment = $db->query_first(" if (!$comment) { - $error->throw('alert: bad comment'); + $message->error('alert: bad comment'); } $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]"); if (!((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers'))) { - $error->throw_permission(); + $message->error_permission(); } // ################################################################### @@ -64,7 +64,7 @@ if ($_POST['do'] == 'update') { if (!$bugsys->in['comment']) { - $error->throw('you need to enter some text'); + $message->error('you need to enter some text'); } $bugsys->in['comment_parsed'] = $bugsys->in['comment']; diff --git a/editreport.php b/editreport.php index 0240c0a..3f60216 100644 --- a/editreport.php +++ b/editreport.php @@ -27,12 +27,12 @@ $bug = $db->query_first(" if (!$bug) { - $error->throw('alert: bad bug'); + $message->error('alert: bad bug'); } if (!(((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo'))) { - $error->throw_permission(); + $message->error_permission(); } // setup logging @@ -70,11 +70,11 @@ if ($_POST['do'] == 'update') if (!$bugsys->in['summary']) { - $error->throw('you need to enter a summary'); + $message->error('you need to enter a summary'); } if (!$pcv) { - $error->throw('invalid product/component/version'); + $message->error('invalid product/component/version'); } $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); @@ -147,7 +147,7 @@ if ($_POST['do'] == 'update') if (!$bugsys->in['firstcomment']) { - $error->throw('you need to enter some text in the first comment'); + $message->error('you need to enter some text in the first comment'); } $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment']; diff --git a/global.php b/global.php index 3669d34..1c5f9f9 100755 --- a/global.php +++ b/global.php @@ -74,8 +74,8 @@ $show = array(); // ################################################################### // create error reporter require_once('./includes/class_error.php'); -$error = new Error(); -$bugsys->error =& $error; +$message = new Message_Reporter(); +$bugsys->message =& $message; /*=====================================================================*\ || ################################################################### diff --git a/includes/class_error.php b/includes/class_error.php index 703fb20..e88d926 100755 --- a/includes/class_error.php +++ b/includes/class_error.php @@ -10,18 +10,18 @@ || ################################################################### || \*=====================================================================*/ -class Error +class Message_Reporter { var $phrase = null; var $process = ''; - function throw($text = '') + function error($text = '') { global $bugsys; if (is_array($this->phrase) AND empty($this->process)) { - trigger_error('Error::phrase is an array so please use Error::construct() to prepare it', E_USER_ERROR); + trigger_error('Message_Reporter::phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR); } if (empty($this->process)) @@ -37,7 +37,7 @@ class Error exit; } - function construct() + function error_list_process() { if (!is_array($this->phrase) OR count($this->phrase) < 1) { @@ -52,7 +52,7 @@ class Error $this->process .= "\n"; } - function throw_permission() + function error_permission() { $this->phrase = 'error_no_permission'; $this->throw(); diff --git a/index.php b/index.php index 9329918..de6c012 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ require_once('./global.php'); if (!can_perform('canviewbugs')) { - $error->throw_permission(); + $message->error_permission(); } // ################################################################### diff --git a/login.php b/login.php index 1430e48..9d688c3 100755 --- a/login.php +++ b/login.php @@ -20,7 +20,7 @@ require_once('./global.php'); if ($bugsys->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout') { - $error->throw('You are already logged in.'); + $message->error('You are already logged in.'); } // ################################################################### @@ -71,7 +71,7 @@ if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin') $funct->cookie(COOKIE_PREFIX . 'authkey'); } - $error->throw('Invalid email or password.'); + $message->error('Invalid email or password.'); } @@ -92,7 +92,7 @@ if ($_REQUEST['do'] == 'logout') } else { - $error->throw('You need to be logged in!'); + $message->error('You need to be logged in!'); } } diff --git a/newcomment.php b/newcomment.php index c4393e7..7421572 100644 --- a/newcomment.php +++ b/newcomment.php @@ -18,7 +18,7 @@ require_once('./global.php'); if (!can_perform('canpostcomments')) { - $error->throw_permission(); + $message->error_permission(); } // ################################################################### @@ -73,7 +73,7 @@ if ($_REQUEST['do'] == 'add') $bug = $db->query_first("SELECT bug.*, comment.comment FROM " . TABLE_PREFIX . "bug LEFT JOIN " . TABLE_PREFIX . "comment AS comment ON (bug.bugid = comment.bugid) WHERE bug.bugid = " . intval($bugsys->in['bugid'])); if (!$bug) { - $error->throw('alert: bad bug'); + $message->error('alert: bad bug'); } eval('$template->flush("' . $template->fetch('newcomment') . '");'); diff --git a/newreport.php b/newreport.php index 9dd5eec..f404b7e 100755 --- a/newreport.php +++ b/newreport.php @@ -79,15 +79,15 @@ if ($_POST['do'] == 'insert') // sanity checks if (!$pcv) { - $error->throw('there was a problem selecting the product, component, or version'); + $message->error('there was a problem selecting the product, component, or version'); } if (!$bugsys->in['summary']) { - $error->throw('please enter a bug title'); + $message->error('please enter a bug title'); } if (!$bugsys->in['comment']) { - $error->throw('please enter a bug description'); + $message->error('please enter a bug description'); } // ------------------------------------------------------------------- diff --git a/register.php b/register.php index 6df6ed4..dde6930 100755 --- a/register.php +++ b/register.php @@ -20,12 +20,12 @@ require_once('./global.php'); if ($bugsys->userinfo['userid']) { - $error->throw('Sorry, you are already registered!'); + $message->error('Sorry, you are already registered!'); } if (!$bugsys->options['allownewreg']) { - $error->throw('Sorry, we don\'t allow new registrations!'); + $message->error('Sorry, we don\'t allow new registrations!'); } // ################################################################### @@ -75,8 +75,8 @@ if ($_POST['do'] == 'insert') $error->phrase[] = 'The specified email is already in use.'; } - $error->construct(); - $error->throw(); + $message->error_list_process(); + $message->error(); $salt = $funct->rand(15); @@ -160,7 +160,7 @@ if ($_REQUEST['do'] == 'activate') } else { - $error->throw('we could not match your registration string. please make sure you entered the correct url'); + $message->error('we could not match your registration string. please make sure you entered the correct url'); } } diff --git a/search.php b/search.php index 64b9148..699b57c 100644 --- a/search.php +++ b/search.php @@ -20,7 +20,7 @@ require_once('./global.php'); if (!can_perform('cansearch')) { - $error->throw_permission(); + $message->error_permission(); } define('MODE', intval($bugsys->in['mode'])); @@ -166,7 +166,7 @@ if ($_REQUEST['do'] == 'results') } else { - $error->throw('bad sort'); + $message->error('bad sort'); } // ------------------------------------------------------------------- @@ -191,7 +191,7 @@ if ($_REQUEST['do'] == 'results') if ($numrows < 1) { - $error->throw('no results found'); + $message->error('no results found'); } while ($bug = $db->fetch_array($search)) diff --git a/showhistory.php b/showhistory.php index 1ac1a3e..f3f8ec4 100644 --- a/showhistory.php +++ b/showhistory.php @@ -21,7 +21,7 @@ require_once('./global.php'); $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid'])); if (!$bug) { - $error->throw('alert: bad bug'); + $message->error('alert: bad bug'); } // ################################################################### diff --git a/showreport.php b/showreport.php index 8e9e13f..eb4e936 100644 --- a/showreport.php +++ b/showreport.php @@ -20,7 +20,7 @@ require_once('./global.php'); if (!can_perform('canviewbugs')) { - $error->throw_permission(); + $message->error_permission(); } // ################################################################### @@ -37,7 +37,7 @@ $bug = $db->query_first(" if (!is_array($bug)) { - $error->throw('alert: bad bug'); + $message->error('alert: bad bug'); } // ------------------------------------------------------------------- diff --git a/viewattachment.php b/viewattachment.php index 2ccaf78..8543af6 100755 --- a/viewattachment.php +++ b/viewattachment.php @@ -17,12 +17,12 @@ require_once('./global.php'); $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid'])); if (!$attachment) { - $error->throw('alert: bad attachment'); + $message->error('alert: bad attachment'); } if (!can_perform('cangetattach') OR !can_perform('caneditattach')) { - $error->throw_permission(); + $message->error_permission(); } ob_clean(); -- 2.43.5