Permalink
Browse files

new parameter cleaning PARAM_BOOL and PARAM_ALPHANUM

  • Loading branch information...
1 parent 76b2685 commit 5fa32737f63c3372d35389368e07ccb556717fe5 skodak committed Feb 3, 2005
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/moodlelib.php
View
@@ -57,6 +57,8 @@
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()
/// PARAMETER HANDLING ////////////////////////////////////////////////////
@@ -116,6 +118,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);
}

0 comments on commit 5fa3273

Please sign in to comment.