From 2c8bedb55af82d8f17279290b09adcd313cb552f Mon Sep 17 00:00:00 2001 From: Graham Cole <chckens@sucs.org> Date: Thu, 17 Jan 2008 23:15:35 +0000 Subject: [PATCH] nearly eradicate duplicated error reporting strategies --- lib/banana-admin.php | 2 +- lib/session.php | 18 +++++++++--------- templates/banana-award.tpl | 7 ------- templates/index.tpl | 7 ------- templates/pastebin.tpl | 6 +----- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/lib/banana-admin.php b/lib/banana-admin.php index 9c264ae..41278c1 100644 --- a/lib/banana-admin.php +++ b/lib/banana-admin.php @@ -26,7 +26,7 @@ if (isset($session->groups[$permission])) { $DB->Query("INSERT INTO awards (username, score, whn, who, why) VALUES (?,?,NOW(),?,?)", array($who, $number, $session->username, $why)); header("Location: " . $_SERVER['PHP_SELF']); } else { - $smarty->assign("errormsg","No reason entered for the awarding of bananas."); + trigger_error("No reason entered for the awarding of bananas.", E_USER_WARNING); } } } elseif ($session->loggedin) { diff --git a/lib/session.php b/lib/session.php index 61b92fe..631e48f 100644 --- a/lib/session.php +++ b/lib/session.php @@ -117,7 +117,7 @@ private $datahash=''; // hash of data field $oldsess=$DB->GetAll("select * from {$this->table} where hash=?", array($this->token)); if (!$oldsess || count($oldsess) < 1) { - $this->errormsg="Session timed out"; + trigger_error("Session timed out", E_USER_NOTICE); $this->newsession(); return; } @@ -133,7 +133,7 @@ private $datahash=''; // hash of data field if ($detail['username']) { // Are we using HTTPS? if (!isset($_SERVER['HTTPS'])) { - $this->errormsg = "Insecure Connection"; + trigger_error("Insecure Connection", E_USER_NOTICE); $this->loggedin = FALSE; return; } @@ -192,7 +192,7 @@ private $datahash=''; // hash of data field private function fetch_detail( $user ) { if (!($ldap = @ldap_connect("ldap://localhost"))) { - $this->errormsg="LDAP connect failed"; + trigger_error("LDAP connect failed", E_USER_ERROR); return FALSE; } $info = $this->ldap_getuser($ldap, $user); @@ -242,17 +242,17 @@ private $datahash=''; // hash of data field { // publically bind to find user if (!($bind=@ldap_bind($ldap, "", ""))) { - $this->errormsg="LDAP bind failed"; + trigger_error("LDAP bind failed", E_USER_ERROR); return NULL; } // find the user if (!($search=@ldap_search($ldap, "dc=sucs,dc=org", "(&(uid=$user))"))) { - $this->errormsg="LDAP search fail"; + trigger_error("LDAP search fail", E_USER_ERROR); return NULL; } $n = ldap_count_entries($ldap, $search); if ($n < 1) { - $this->errormsg = "Username or Password Incorrect"; + trigger_error("Username or Password Incorrect", E_USER_WARNING); return NULL; } $info = ldap_get_entries($ldap, $search); @@ -274,7 +274,7 @@ private $datahash=''; // hash of data field { // Open connection if (!($ldap = @ldap_connect("ldap://localhost"))) { - $this->errormsg="LDAP connect failed"; + trigger_error("LDAP connect failed", E_USER_ERROR); return FALSE; } $info = $this->ldap_getuser($ldap, $user); @@ -284,7 +284,7 @@ private $datahash=''; // hash of data field ldap_close($ldap); if ($real) return TRUE; - $this->errormsg="Username or Password Incorrect"; + trigger_error("Username or Password Incorrect", E_USER_WARNING); return FALSE; } @@ -297,7 +297,7 @@ private $datahash=''; // hash of data field // This prevents replay attacks $sess = $DB->GetAll("select * from {$this->table} where hash=? and username is NULL", array($this->token)); if (!$sess || count($sess)<1) { - $this->errormsg = "Invalid session, login again."; + trigger_error("Invalid session, login again.", E_USER_WARNING); return; } diff --git a/templates/banana-award.tpl b/templates/banana-award.tpl index 65cb6aa..befb7e3 100644 --- a/templates/banana-award.tpl +++ b/templates/banana-award.tpl @@ -1,12 +1,5 @@ {* Banana awarding widget *} -{if $errormsg} - <div class="errorbar"> - <div><div><div> - Error: {$errormsg} - </div></div></div> - </div> -{/if} <div class="cbb"> {if $awarded == true} <h3>Nomination Received</h3> diff --git a/templates/index.tpl b/templates/index.tpl index 6f41725..cd4ce5a 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,10 +1,3 @@ -{if $session->errormsg} - <div class="errorbar"> - <div><div><div> - Session: {$session->errormsg} - </div></div></div> - </div> -{/if} {if $secondary} <div id="primary"> diff --git a/templates/pastebin.tpl b/templates/pastebin.tpl index 7812c7e..aed75f6 100644 --- a/templates/pastebin.tpl +++ b/templates/pastebin.tpl @@ -1,8 +1,4 @@ -{if !empty($error) } -{foreach name=error from=$error item=errorMessage} - <p>{$errorMessage}</p> -{/foreach} -{elseif isset($userInfo)} +{if isset($userInfo)} <div id="userInfo"> <h3> {$userInfo}</h3> <a href="{$uri}{$id}">{$uri}{$id}</a> -- GitLab