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])) {
$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) {
......
......@@ -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;
}
......
{* 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>
......
{if $session->errormsg}
<div class="errorbar">
<div><div><div>
Session: {$session->errormsg}
</div></div></div>
</div>
{/if}
{if $secondary}
<div id="primary">
......
{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>
......
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