]> 91.132.146.200 Git - dolphin.git/commitdiff
code cleanup and updated validate input
authorBanana <banana@optimus.de>
Tue, 16 Jul 2019 13:31:36 +0000 (15:31 +0200)
committerBanana <banana@optimus.de>
Tue, 16 Jul 2019 13:31:36 +0000 (15:31 +0200)
simple-framework/lib/function.library.php
single-functions/validate-input.php

index a516eaa774083e1fd9cff99073cef1921cb1d525..dfa3e47a73351462d917e0551813dceeeba782b0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
 * dolphin. Collection of useful PHP skeletons.
-* Copyright (C) 2009 Johannes 'Banana' Keßler
+* Copyright (C) 2009-2019 Johannes 'Banana' Keßler
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
 
        switch ($mode) {
                case 'mail':
-                       return self::check_email_address($input);
+                   if(filter_var($input,FILTER_VALIDATE_EMAIL) === $input) {
+                       return true;
+                   }
+            else {
+                return false;
+                   }
                break;
 
                case 'url':
-                       return filter_var($input,FILTER_VALIDATE_URL);
+                       if(filter_var($input,FILTER_VALIDATE_URL) === $input) {
+                               return true;
+                       }
+                       else {
+                               return false;
+                       }
                break;
 
                case 'nospace':
index 21ddfd95243bc2d7903a681e7ae733e4720698f0..358ff795b56aa9629de9fe6549d3ba513505a6e9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  *  dolphin. Collection of useful PHP skeletons.
- *  Copyright (C) 2009  Johannes 'Banana' Keßler
+ *  Copyright (C) 2009-2019 Johannes 'Banana' Keßler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
 
        switch ($mode) {
                case 'mail':
-                       return self::check_email_address($input);
+                   if(filter_var($input,FILTER_VALIDATE_EMAIL) === $input) {
+                       return true;
+                   }
+            else {
+                return false;
+                   }
                break;
 
                case 'url':
-                       return filter_var($input,FILTER_VALIDATE_URL);
+                       if(filter_var($input,FILTER_VALIDATE_URL) === $input) {
+                               return true;
+                       }
+                       else {
+                               return false;
+                       }
                break;
 
                case 'nospace':
                        $pattern = '/[\p{L}\p{N}\p{Po}\p{Z}\s]/u';
                break;
 
+               # strange. the \p{M} is needed.. don't know why..
+               case 'filename':
+                       $pattern = '/[\p{L}\p{N}\p{M}\-_\.\p{Zs}]/u';
+               break;
+
                case 'text':
                default:
                        $pattern = '/[\p{L}\p{N}\p{P}\p{S}\p{Z}\p{M}\s]/u';