Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function filterInput($value, $type) {
- if(!isset($type))
- return;
- switch($type)
- {
- case 'email': $pattern = '#^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$#'; break;
- case 'password': $pattern = '#\b(?=.*[a-z]+)(?=.*[0-9]+).{6,20}\b#'; break;
- case 'username': $pattern = '#\b[a-z0-9\.]{8,32}\b#'; break;
- case 'phone': $pattern = '#^(\(\d+\)\s{0,1}){0,1}(\d+((\-|\s){0,1})\d+){0,}$#'; break;
- case 'number': $pattern = '#\b[\d]+\b#'; break;
- case 'only-string': $pattern = '#\b[a-z]+\b#i'; break;
- case 'only-string-lower': $pattern = '#\b[a-z]+\b#'; break;
- case 'only-string-upper': $pattern = '#\b[A-Z]+\b#'; break;
- case 'alnum': $pattern = '#\b[a-z0-9]+\b#i'; break;
- case 'word': $pattern = '#\b[a-z0-9_]+\b#'; break;
- }
- if(preg_match($pattern, $value)){
- #array_push(self::$_temporary, $value, $type, 'success');
- self::$serialized = self::serialize(array($value, $type, 'success'));
- }
- else {
- #array_push(self::$_temporary, $value, $type, 'failed');
- self::$serialized = self::serialize(array($value, $type, 'failed'));
- }
- return self::$that;
- }
- public static function setFilterValue() {
- $unserialized = array();
- $unserialized = self::unserialize(self::$serialized);
- if(!empty($unserialized)) {
- if(in_array('success', $unserialized)){
- array_push(self::$_filtered, array($unserialized[1] => $unserialized[0]));
- }
- else{
- array_push(self::$_unfiltered, array($unserialized[1] => $unserialized[0]));
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement