From c50753e61c5479be8f54bbcdb86bcd1c4fc881f3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 May 2005 16:03:11 +0000 Subject: [PATCH] r172: Removing from our echo; exit; error reporting system to Error::throw() --- attachment.php | 40 +++++++++++++++------------------------- editcomment.php | 9 +++------ editreport.php | 15 +++++---------- index.php | 3 +-- login.php | 9 ++++----- newcomment.php | 6 ++---- newreport.php | 12 ++++-------- register.php | 27 +++++++++++---------------- search.php | 9 +++------ showhistory.php | 3 +-- showreport.php | 6 ++---- viewattachment.php | 6 ++---- 12 files changed, 53 insertions(+), 92 deletions(-) diff --git a/attachment.php b/attachment.php index d4bda84..98b8703 100755 --- a/attachment.php +++ b/attachment.php @@ -22,16 +22,14 @@ if (isset($bugsys->in['attachmentid'])) $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid'])); if (!$attachment) { - echo 'alert: bad attachment'; - exit; + $error->throw('alert: bad attachment'); } } $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . (($attachment['attachmentid']) ? $attachment['bugid'] : intval($bugsys->in['bugid']))); if (!$bug) { - echo 'alert: bad bug'; - exit; + $error->throw('alert: bad bug'); } // setup logging @@ -45,8 +43,7 @@ if ($_REQUEST['do'] == 'kill') { if (!can_perform('caneditattach')) { - echo 'alert: no permission'; - exit; + $error->throw_permission(); } $db->query("DELETE FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = $attachment[attachmentid]"); @@ -65,8 +62,7 @@ if ($_REQUEST['do'] == 'delete') { if (!can_perform('caneditattach')) { - echo 'alert: no permission'; - exit; + $error->throw_permission(); } echo "are you sure you want to delete this attachment? yes"; @@ -78,8 +74,7 @@ if ($_POST['do'] == 'insert') { if (!can_perform('canputattach')) { - echo 'alert: no permission'; - exit; + $error->throw_permission(); } // create alias @@ -89,26 +84,24 @@ if ($_POST['do'] == 'insert') switch ($FILE['error']) { case 0: break; - case 1: echo 'PHP said the file you uploaded was too big.'; exit; break; - case 2: echo 'The file exceeds the allowed upload size.'; exit; break; - case 3: echo 'The file was only partially uploaded.'; exit; break; - case 4: echo 'The file was not uploaded at all.'; exit; break; - case 6: echo 'PHP could not find the /tmp directory.'; exit; 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; } // did it upload? if (!is_uploaded_file($FILE['tmp_name'])) { - echo 'The file you specified did not upload.'; - exit; + $error->throw('The file you specified did not upload.'); } // #*# put some MIME-type validation here if (!$bugsys->in['description']) { - echo 'you need a file description!'; - exit; + $error->throw('you need a file description!'); } $filedata = $bugsys->escape(file_get_contents($FILE['tmp_name']), true, true); @@ -185,8 +178,7 @@ if ($_REQUEST['do'] == 'add') { if (!can_perform('canputattach')) { - echo 'alert: no permission'; - exit; + $error->throw_permission(); } $MAXFILESIZE = $funct->fetch_max_attachment_size(); @@ -211,8 +203,7 @@ if ($_POST['do'] == 'update') { if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach')))) { - echo 'alert: no permssion'; - exit; + $error->throw_permission(); } $db->query(" @@ -241,8 +232,7 @@ if ($_REQUEST['do'] == 'edit') { if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach')))) { - echo 'alert: no permssion'; - exit; + $error->throw_permission(); } $show['delete'] = ((can_perform('caneditattach')) ? true : false); diff --git a/editcomment.php b/editcomment.php index 01138b3..7beaf7a 100644 --- a/editcomment.php +++ b/editcomment.php @@ -26,16 +26,14 @@ $comment = $db->query_first(" if (!$comment) { - echo 'alert: bad comment'; - exit; + $error->throw('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'))) { - echo 'no permission'; - exit; + $error->throw_permission(); } // ################################################################### @@ -66,8 +64,7 @@ if ($_POST['do'] == 'update') { if (!$bugsys->in['comment']) { - echo 'you need to enter some text'; - exit; + $error->throw('you need to enter some text'); } $bugsys->in['comment_parsed'] = $bugsys->in['comment']; diff --git a/editreport.php b/editreport.php index bb6bcea..0240c0a 100644 --- a/editreport.php +++ b/editreport.php @@ -27,14 +27,12 @@ $bug = $db->query_first(" if (!$bug) { - echo 'alert: bad bug'; - exit; + $error->throw('alert: bad bug'); } if (!(((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo'))) { - echo 'no permission'; - exit; + $error->throw_permission(); } // setup logging @@ -72,13 +70,11 @@ if ($_POST['do'] == 'update') if (!$bugsys->in['summary']) { - echo 'you need to enter a summary'; - exit; + $error->throw('you need to enter a summary'); } if (!$pcv) { - echo 'invalid product/component/version'; - exit; + $error->throw('invalid product/component/version'); } $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); @@ -151,8 +147,7 @@ if ($_POST['do'] == 'update') if (!$bugsys->in['firstcomment']) { - echo 'you need to enter some text in the first comment'; - exit; + $error->throw('you need to enter some text in the first comment'); } $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment']; diff --git a/index.php b/index.php index b882b96..9329918 100644 --- a/index.php +++ b/index.php @@ -19,8 +19,7 @@ require_once('./global.php'); if (!can_perform('canviewbugs')) { - echo 'no permission'; - exit; + $error->throw_permission(); } // ################################################################### diff --git a/login.php b/login.php index 90387fb..1430e48 100755 --- a/login.php +++ b/login.php @@ -20,8 +20,7 @@ require_once('./global.php'); if ($bugsys->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout') { - echo 'You are already logged in.'; - exit; + $error->throw('You are already logged in.'); } // ################################################################### @@ -71,8 +70,8 @@ if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin') $funct->cookie(COOKIE_PREFIX . 'userid'); $funct->cookie(COOKIE_PREFIX . 'authkey'); } - echo 'Invalid email or password.'; - exit; + + $error->throw('Invalid email or password.'); } @@ -93,7 +92,7 @@ if ($_REQUEST['do'] == 'logout') } else { - echo 'You need to be logged in!'; + $error->throw('You need to be logged in!'); } } diff --git a/newcomment.php b/newcomment.php index e69a9de..c4393e7 100644 --- a/newcomment.php +++ b/newcomment.php @@ -18,8 +18,7 @@ require_once('./global.php'); if (!can_perform('canpostcomments')) { - echo 'no permission'; - exit; + $error->throw_permission(); } // ################################################################### @@ -74,8 +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) { - echo 'alert: bad bug'; - exit; + $error->throw('alert: bad bug'); } eval('$template->flush("' . $template->fetch('newcomment') . '");'); diff --git a/newreport.php b/newreport.php index 0041d9f..9dd5eec 100755 --- a/newreport.php +++ b/newreport.php @@ -19,8 +19,7 @@ require_once('./global.php'); if (!can_perform('cansubmitbugs')) { - echo 'NO permission'; - exit; + $erorr->throw_permission(); } // ################################################################### @@ -80,18 +79,15 @@ if ($_POST['do'] == 'insert') // sanity checks if (!$pcv) { - echo 'there was a problem selecting the product, component, or version'; - exit; + $error->throw('there was a problem selecting the product, component, or version'); } if (!$bugsys->in['summary']) { - echo 'please enter a bug title'; - exit; + $error->throw('please enter a bug title'); } if (!$bugsys->in['comment']) { - echo 'please enter a bug description'; - exit; + $error->throw('please enter a bug description'); } // ------------------------------------------------------------------- diff --git a/register.php b/register.php index 110a048..6df6ed4 100755 --- a/register.php +++ b/register.php @@ -20,14 +20,12 @@ require_once('./global.php'); if ($bugsys->userinfo['userid']) { - echo 'Sorry, you are already registered!'; - exit; + $error->throw('Sorry, you are already registered!'); } if (!$bugsys->options['allownewreg']) { - echo 'Sorry, we don\'t allow new registrations!'; - exit; + $error->throw('Sorry, we don\'t allow new registrations!'); } // ################################################################### @@ -49,39 +47,36 @@ if ($_POST['do'] == 'insert') { if ($bugsys->in['email'] != $bugsys->in['confirmemail']) { - $errors[] = 'The emails you entered do not match.'; + $error->phrase[] = 'The emails you entered do not match.'; } if (!$bugsys->in['email']) { - $errors[] = 'The password you specified was blank.'; + $error->phrase[] = 'The password you specified was blank.'; } if ($bugsys->in['password'] != $bugsys->in['confirmpassword']) { - $errors[] = 'The passwords you entered did not match.'; + $error->phrase[] = 'The passwords you entered did not match.'; } if (!$bugsys->in['password']) { - $errors[] = 'The password you specified was blank.'; + $error->phrase[] = 'The password you specified was blank.'; } if (!$funct->is_valid_email($bugsys->in['email'])) { - $errors[] = 'The specified email is invalid.'; + $error->phrase[] = 'The specified email is invalid.'; } if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $bugsys->in['email'] . "'"))) { - $errors[] = 'The specified email is already in use.'; + $error->phrase[] = 'The specified email is already in use.'; } - if (is_array($errors)) - { - echo implode('
', $errors); - exit; - } + $error->construct(); + $error->throw(); $salt = $funct->rand(15); @@ -165,7 +160,7 @@ if ($_REQUEST['do'] == 'activate') } else { - echo 'we could not match your registration string. please make sure you entered the correct url'; + $error->throw('we could not match your registration string. please make sure you entered the correct url'); } } diff --git a/search.php b/search.php index 7f2db59..64b9148 100644 --- a/search.php +++ b/search.php @@ -20,8 +20,7 @@ require_once('./global.php'); if (!can_perform('cansearch')) { - echo 'no permission'; - exit; + $error->throw_permission(); } define('MODE', intval($bugsys->in['mode'])); @@ -167,8 +166,7 @@ if ($_REQUEST['do'] == 'results') } else { - echo 'bad sort'; - exit; + $error->throw('bad sort'); } // ------------------------------------------------------------------- @@ -193,8 +191,7 @@ if ($_REQUEST['do'] == 'results') if ($numrows < 1) { - echo 'no results found'; - exit; + $error->throw('no results found'); } while ($bug = $db->fetch_array($search)) diff --git a/showhistory.php b/showhistory.php index 432021e..1ac1a3e 100644 --- a/showhistory.php +++ b/showhistory.php @@ -21,8 +21,7 @@ require_once('./global.php'); $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid'])); if (!$bug) { - echo 'alert: bad bug'; - exit; + $error->throw('alert: bad bug'); } // ################################################################### diff --git a/showreport.php b/showreport.php index c0bcf1b..8e9e13f 100644 --- a/showreport.php +++ b/showreport.php @@ -20,8 +20,7 @@ require_once('./global.php'); if (!can_perform('canviewbugs')) { - echo 'no permission'; - exit; + $error->throw_permission(); } // ################################################################### @@ -38,8 +37,7 @@ $bug = $db->query_first(" if (!is_array($bug)) { - echo 'alert: bad bug'; - exit; + $error->throw('alert: bad bug'); } // ------------------------------------------------------------------- diff --git a/viewattachment.php b/viewattachment.php index 0a6d1d6..2ccaf78 100755 --- a/viewattachment.php +++ b/viewattachment.php @@ -17,14 +17,12 @@ require_once('./global.php'); $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid'])); if (!$attachment) { - echo 'alert: bad attachment'; - exit; + $error->throw('alert: bad attachment'); } if (!can_perform('cangetattach') OR !can_perform('caneditattach')) { - echo 'alert: no permission'; - exit; + $error->throw_permission(); } ob_clean(); -- 2.43.5