]> git.mjollnir.org Git - moodle.git/commitdiff
new parameter cleaning PARAM_BOOL and PARAM_ALPHANUM, merged from MOODLE_14_STABLE
authorskodak <skodak>
Thu, 3 Feb 2005 18:14:45 +0000 (18:14 +0000)
committerskodak <skodak>
Thu, 3 Feb 2005 18:14:45 +0000 (18:14 +0000)
lib/moodlelib.php

index f65d248732cacf3907b47e6dfaf50de0eff13829..3c8df90eb0ca73bb42ef9781c37c38d7da89cdef 100644 (file)
@@ -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);
     }