From f24148ef0ff37b1b5db63ad60062e0710f31e319 Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 3 Feb 2005 18:14:45 +0000 Subject: [PATCH] new parameter cleaning PARAM_BOOL and PARAM_ALPHANUM, merged from MOODLE_14_STABLE --- lib/moodlelib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f65d248732..3c8df90eb0 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -105,6 +105,8 @@ define('PARAM_HOST', 0x0040); // FQDN or IPv4 dotted quad define('PARAM_URL', 0x0080); define('PARAM_LOCALURL',0x0180); // NOT orthogonal to the others! Implies PARAM_URL! define('PARAM_CLEANFILE',0x0200); +define('PARAM_ALPHANUM',0x0400); //numbers or letters only +define('PARAM_BOOL', 0x0800); //convert to value 1 or 0 using empty() /** * Definition of page types @@ -201,6 +203,14 @@ function clean_param($param, $options) { $param = eregi_replace('[^a-z]', '', $param); } + if ($options & PARAM_ALPHANUM) { // Remove everything not a-zA-Z0-9 + $param = eregi_replace('[^A-Za-z0-9]', '', $param); + } + + if ($options & PARAM_BOOL) { // Convert to 1 or 0 + $param = empty($param) ? 0 : 1; + } + if ($options & PARAM_NOTAGS) { // Strip all tags completely $param = strip_tags($param); } -- 2.39.5