diff --git a/homepage/mams/index.php b/homepage/mams/index.php
index bc45acd..63bfa03 100644
--- a/homepage/mams/index.php
+++ b/homepage/mams/index.php
@@ -1,74 +1,48 @@
-
-
-
-
-
-
-
-
-
-
-
- Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV
-
-
-
- ☰ mams
+
+
+
+
+
+
+
+
+ Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV
+
+
+
+
Anwesenheiten hinzufügen
diff --git a/homepage/mams/lib/api.php b/homepage/mams/lib/api.php
index 04910fa..6cd3bdf 100644
--- a/homepage/mams/lib/api.php
+++ b/homepage/mams/lib/api.php
@@ -10,12 +10,16 @@ function processPostData($db, $post, $redirectLocation = "."){
}
if($post['action'] == "addCoronaUser"){
if(
- isValid($post['corona_PLZ'], "plz")
+ array_keys_exist(
+ $post,
+ ['name', 'vorname', 'corona_PLZ', 'corona_telephon', 'corona_eMail']
+ )
+ && isValid($post['corona_PLZ'], "plz")
+ && isValid($post['corona_telephon'], "phonenumber")
+ && isValid($post['corona_eMail'], "email")
// && isValid($post['name'], "name")
// && isValid($post['vorname'], "name")
- // && isValid($post['corona_telephon'], "phonenumber")
- // && isValid($post['corona_eMail'], "email")
- ){
+ ){
addCoronaUser(
$db,
$post['name'],
@@ -114,15 +118,37 @@ function isValid($toValidate, $type){
// for now we disable the name validation: what do i know how people can be called!
// $regexName="/^[A-Z][a-zA-Z]*$/";
$regexPlz ="/^[0-9]{5}$/";
- if($type == "plz" )
- return preg_match($regexPlz, $toValidate) > 0;
- if($type == "name")
- return preg_match($regexName, $toValidate) > 0;
- if($type == "phonenumber" )
- return validate_phone_number($toValidate);
- if($type == "email")
- return filter_var($toValidate, FILTER_VALIDATE_EMAIL);
-
+ switch( $type ){
+ case "plz":
+ return preg_match($regexPlz, $toValidate) > 0;
+ case "phonenumber":
+ return validate_phone_number($toValidate);
+ case "email":
+ return filter_var($toValidate, FILTER_VALIDATE_EMAIL);
+ default:
+ return false;
+ }
return false;
}
+
+//! Checks if multiple keys exist in an array
+//!
+//! @param array $array array to check for key
+//! @param array|string $keys keys to check for
+//!
+//! @return bool true, if *all* keys are set in the array
+function array_keys_exist( array $array, $keys ) {
+ if ( ! is_array( $keys ) ) {
+ $keys = func_get_args();
+ array_shift( $keys );
+ }
+ $count = 0;
+ foreach ( $keys as $key ) {
+ if ( isset( $array[$key] ) || array_key_exists( $key, $array ) ) {
+ $count++;
+ }
+ }
+
+ return count( $keys ) === $count;
+}
?>
diff --git a/homepage/mams/lib/mams/materializeInit.php b/homepage/mams/lib/mams/materializeInit.php
new file mode 100644
index 0000000..62f5524
--- /dev/null
+++ b/homepage/mams/lib/mams/materializeInit.php
@@ -0,0 +1,11 @@
+
diff --git a/homepage/mams/lib/mams/sidenav.php b/homepage/mams/lib/mams/sidenav.php
new file mode 100644
index 0000000..6ca1209
--- /dev/null
+++ b/homepage/mams/lib/mams/sidenav.php
@@ -0,0 +1,6 @@
+
+☰ mams