[SUCS Devel] site r702 - trunk/lib
elbows at sucs.org
elbows at sucs.org
Sun Apr 26 21:39:39 BST 2015
Author: elbows
Date: 2015-04-26 21:39:32 +0100 (Sun, 26 Apr 2015)
New Revision: 702
Modified:
trunk/lib/banana-admin.php
Log:
Added a check to disallow awarding zero bananas
Modified: trunk/lib/banana-admin.php
===================================================================
--- trunk/lib/banana-admin.php 2015-04-26 20:23:02 UTC (rev 701)
+++ trunk/lib/banana-admin.php 2015-04-26 20:39:32 UTC (rev 702)
@@ -26,27 +26,33 @@
if (trim ($_POST['why']) !== "") {
$number = intval($_POST['number']);
- $why = $_POST['why'];
+ $why = $_POST['why'];
+
+ if ( (abs($number) <= $maxbanana ) && $number <> 0 ){
- if ( abs($number) <= $maxbanana ){
-
$DB->Query("INSERT INTO awards (username, score, whn, who, why) VALUES (?,?,NOW(),?,?)", array($who, $number, $session->username, $why));
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");
}
} else {
trigger_error("No reason entered for the awarding of bananas.", E_USER_WARNING);
- }
+ }
}
} elseif ($session->loggedin) {
if ($_REQUEST['action'] == "award") {
$number = intval($_POST['number']);
- $why = $_POST['why'];
+ $why = $_POST['why'];
- // Send a mail to someone about them bananas
+ // Send a mail to someone about them bananas
$msgbody = $session->username." thinks $who deserves $number bananas:\r\n";
$msgbody .= "\"$why\"\r\n\r\nVisit https://sucs.org/Community/Members/$who if you want to make an award.";
mail($contact, "Banana Award Nomination", $msgbody, $msgheaders);
@@ -56,7 +62,7 @@
}
-$secondary = $smarty->getTemplateVars("secondary");
+$secondary = $smarty->get_template_vars("secondary");
$secondary .= $smarty->fetch('banana-award.tpl');
$smarty->assign('secondary', $secondary);
More information about the Devel
mailing list