Browse Source

Add support for regex matching on API vars

master
Skylar Ittner 7 months ago
parent
commit
6ceeeaa087
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      api/functions.php

+ 6
- 4
api/functions.php View File

@@ -109,11 +109,13 @@ function checkVars($vars, $or = false) {
109 109
                 continue;
110 110
             }
111 111
         }
112
-        $checkmethod = "is_$val";
113
-        if ($checkmethod($VARS[$key]) !== true) {
114
-            $ok[$key] = false;
112
+
113
+        if (strpos($val, "/") === 0) {
114
+            // regex
115
+            $ok[$key] = preg_match($val, $VARS[$key]) === 1;
115 116
         } else {
116
-            $ok[$key] = true;
117
+            $checkmethod = "is_$val";
118
+            $ok[$key] = !($checkmethod($VARS[$key]) !== true);
117 119
         }
118 120
     }
119 121
     if ($or) {

Loading…
Cancel
Save