aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/database.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-18 18:47:17 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-18 18:47:17 +0000
commit2408cc5c69209350a350246e260de494720eb773 (patch)
tree50f278b2a70d4c5a850a32a6349083deed760341 /engine/lib/database.php
parente18e17ef647e7faf4563bb8ce77ffe448bc929cb (diff)
downloadelgg-2408cc5c69209350a350246e260de494720eb773.tar.gz
elgg-2408cc5c69209350a350246e260de494720eb773.tar.bz2
Fixes #2046. Applied Franz' patch for sanitize_int().
git-svn-id: http://code.elgg.org/elgg/trunk@9004 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r--engine/lib/database.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index a9c4017a0..6b1b494b9 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -680,22 +680,31 @@ function sanitize_string($string) {
* Sanitises an integer for database use.
*
* @param int $int Integer
- *
+ * @param bool[optional] $signed Whether negative values should be allowed (true)
* @return int Sanitised integer
*/
-function sanitise_int($int) {
+function sanitise_int($int, $signed = true) {
+ $int = (int) $int;
+
+ if ($signed === false) {
+ if ($int < 0) {
+ $int = 0;
+ }
+ }
+
return (int) $int;
}
/**
- * Wrapper function for alternate English spelling
+ * Sanitises an integer for database use.
+ * Wrapper function for alternate English spelling (@see sanitise_int)
*
* @param int $int Integer
- *
+ * @param bool[optional] $signed Whether negative values should be allowed (true)
* @return int Sanitised integer
*/
-function sanitize_int($int) {
- return (int) $int;
+function sanitize_int($int, $signed = true) {
+ return sanitise_int($int, $signed);
}
/**