Added a check to disallow awarding zero bananas

parent 2bf9eb8a
...@@ -28,12 +28,18 @@ if (isset($session->groups[$permission])) { ...@@ -28,12 +28,18 @@ if (isset($session->groups[$permission])) {
$why = $_POST['why']; $why = $_POST['why'];
if ( abs($number) <= $maxbanana ){ if ( (abs($number) <= $maxbanana ) && $number <> 0 ){
$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 { }
// Checks for a nonzero banana and denies awarding if it's zero
elseif ( $number == 0 ){
trigger_error("Come on ".$session->username.", enter a nonzero value please");
}
else {
trigger_error("Nice try ".$session->username."! You've submitted a request with too many bananas"); trigger_error("Nice try ".$session->username."! You've submitted a request with too many bananas");
} }
...@@ -56,7 +62,7 @@ if (isset($session->groups[$permission])) { ...@@ -56,7 +62,7 @@ if (isset($session->groups[$permission])) {
} }
$secondary = $smarty->getTemplateVars("secondary"); $secondary = $smarty->get_template_vars("secondary");
$secondary .= $smarty->fetch('banana-award.tpl'); $secondary .= $smarty->fetch('banana-award.tpl');
$smarty->assign('secondary', $secondary); $smarty->assign('secondary', $secondary);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment