Permalink
Browse files

new parameter cleaning PARAM_BOOL and PARAM_ALPHANUM, merged from MOO…

…DLE_14_STABLE
  • Loading branch information...
1 parent adf3c01 commit f24148ef0ff37b1b5db63ad60062e0710f31e319 skodak committed Feb 3, 2005
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/moodlelib.php
View
@@ -105,6 +105,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()
/**
* 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);
}

0 comments on commit f24148e

Please sign in to comment.