Skip to content
Snippets Groups Projects
Commit 2c8bedb5 authored by Graham Cole's avatar Graham Cole
Browse files

nearly eradicate duplicated error reporting strategies

parent 454817b0
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ if (isset($session->groups[$permission])) { ...@@ -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)); $DB->Query("INSERT INTO awards (username, score, whn, who, why) VALUES (?,?,NOW(),?,?)", array($who, $number, $session->username, $why));
header("Location: " . $_SERVER['PHP_SELF']); header("Location: " . $_SERVER['PHP_SELF']);
} else { } 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) { } elseif ($session->loggedin) {
......
...@@ -117,7 +117,7 @@ private $datahash=''; // hash of data field ...@@ -117,7 +117,7 @@ private $datahash=''; // hash of data field
$oldsess=$DB->GetAll("select * from {$this->table} where hash=?", array($this->token)); $oldsess=$DB->GetAll("select * from {$this->table} where hash=?", array($this->token));
if (!$oldsess || count($oldsess) < 1) { if (!$oldsess || count($oldsess) < 1) {
$this->errormsg="Session timed out"; trigger_error("Session timed out", E_USER_NOTICE);
$this->newsession(); $this->newsession();
return; return;
} }
...@@ -133,7 +133,7 @@ private $datahash=''; // hash of data field ...@@ -133,7 +133,7 @@ private $datahash=''; // hash of data field
if ($detail['username']) { if ($detail['username']) {
// Are we using HTTPS? // Are we using HTTPS?
if (!isset($_SERVER['HTTPS'])) { if (!isset($_SERVER['HTTPS'])) {
$this->errormsg = "Insecure Connection"; trigger_error("Insecure Connection", E_USER_NOTICE);
$this->loggedin = FALSE; $this->loggedin = FALSE;
return; return;
} }
...@@ -192,7 +192,7 @@ private $datahash=''; // hash of data field ...@@ -192,7 +192,7 @@ private $datahash=''; // hash of data field
private function fetch_detail( $user ) private function fetch_detail( $user )
{ {
if (!($ldap = @ldap_connect("ldap://localhost"))) { if (!($ldap = @ldap_connect("ldap://localhost"))) {
$this->errormsg="LDAP connect failed"; trigger_error("LDAP connect failed", E_USER_ERROR);
return FALSE; return FALSE;
} }
$info = $this->ldap_getuser($ldap, $user); $info = $this->ldap_getuser($ldap, $user);
...@@ -242,17 +242,17 @@ private $datahash=''; // hash of data field ...@@ -242,17 +242,17 @@ private $datahash=''; // hash of data field
{ {
// publically bind to find user // publically bind to find user
if (!($bind=@ldap_bind($ldap, "", ""))) { if (!($bind=@ldap_bind($ldap, "", ""))) {
$this->errormsg="LDAP bind failed"; trigger_error("LDAP bind failed", E_USER_ERROR);
return NULL; return NULL;
} }
// find the user // find the user
if (!($search=@ldap_search($ldap, "dc=sucs,dc=org", "(&(uid=$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; return NULL;
} }
$n = ldap_count_entries($ldap, $search); $n = ldap_count_entries($ldap, $search);
if ($n < 1) { if ($n < 1) {
$this->errormsg = "Username or Password Incorrect"; trigger_error("Username or Password Incorrect", E_USER_WARNING);
return NULL; return NULL;
} }
$info = ldap_get_entries($ldap, $search); $info = ldap_get_entries($ldap, $search);
...@@ -274,7 +274,7 @@ private $datahash=''; // hash of data field ...@@ -274,7 +274,7 @@ private $datahash=''; // hash of data field
{ {
// Open connection // Open connection
if (!($ldap = @ldap_connect("ldap://localhost"))) { if (!($ldap = @ldap_connect("ldap://localhost"))) {
$this->errormsg="LDAP connect failed"; trigger_error("LDAP connect failed", E_USER_ERROR);
return FALSE; return FALSE;
} }
$info = $this->ldap_getuser($ldap, $user); $info = $this->ldap_getuser($ldap, $user);
...@@ -284,7 +284,7 @@ private $datahash=''; // hash of data field ...@@ -284,7 +284,7 @@ private $datahash=''; // hash of data field
ldap_close($ldap); ldap_close($ldap);
if ($real) return TRUE; if ($real) return TRUE;
$this->errormsg="Username or Password Incorrect"; trigger_error("Username or Password Incorrect", E_USER_WARNING);
return FALSE; return FALSE;
} }
...@@ -297,7 +297,7 @@ private $datahash=''; // hash of data field ...@@ -297,7 +297,7 @@ private $datahash=''; // hash of data field
// This prevents replay attacks // This prevents replay attacks
$sess = $DB->GetAll("select * from {$this->table} where hash=? and username is NULL", array($this->token)); $sess = $DB->GetAll("select * from {$this->table} where hash=? and username is NULL", array($this->token));
if (!$sess || count($sess)<1) { if (!$sess || count($sess)<1) {
$this->errormsg = "Invalid session, login again."; trigger_error("Invalid session, login again.", E_USER_WARNING);
return; return;
} }
......
{* Banana awarding widget *} {* Banana awarding widget *}
{if $errormsg}
<div class="errorbar">
<div><div><div>
Error: {$errormsg}
</div></div></div>
</div>
{/if}
<div class="cbb"> <div class="cbb">
{if $awarded == true} {if $awarded == true}
<h3>Nomination Received</h3> <h3>Nomination Received</h3>
......
{if $session->errormsg}
<div class="errorbar">
<div><div><div>
Session: {$session->errormsg}
</div></div></div>
</div>
{/if}
{if $secondary} {if $secondary}
<div id="primary"> <div id="primary">
......
{if !empty($error) } {if isset($userInfo)}
{foreach name=error from=$error item=errorMessage}
<p>{$errorMessage}</p>
{/foreach}
{elseif isset($userInfo)}
<div id="userInfo"> <div id="userInfo">
<h3> {$userInfo}</h3> <h3> {$userInfo}</h3>
<a href="{$uri}{$id}">{$uri}{$id}</a> <a href="{$uri}{$id}">{$uri}{$id}</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment