modernize look
This commit is contained in:
@@ -9,14 +9,27 @@ function processPostData($db, $post, $redirectLocation = "."){
|
||||
updateCoronaData($db, $post['userId'], $post['columnName'], $post['columnValue']);
|
||||
}
|
||||
if($post['action'] == "addCoronaUser"){
|
||||
addCoronaUser(
|
||||
$db,
|
||||
$post['name'],
|
||||
$post['vorname'],
|
||||
$post['corona_PLZ'],
|
||||
$post['corona_telephon'],
|
||||
$post['corona_eMail']
|
||||
);
|
||||
if(
|
||||
isValid($post['corona_PLZ'], "plz")
|
||||
// && isValid($post['name'], "name")
|
||||
// && isValid($post['vorname'], "name")
|
||||
// && isValid($post['corona_telephon'], "phonenumber")
|
||||
// && isValid($post['corona_eMail'], "email")
|
||||
){
|
||||
addCoronaUser(
|
||||
$db,
|
||||
$post['name'],
|
||||
$post['vorname'],
|
||||
$post['corona_PLZ'],
|
||||
$post['corona_telephon'],
|
||||
$post['corona_eMail']
|
||||
);
|
||||
$redirectLocation .= "?addCoronaUserSuccess=true";
|
||||
}
|
||||
else{
|
||||
$redirectLocation .= "?addCoronaUserSuccess=false";
|
||||
}
|
||||
$redirectLocation .= "#addCoronaUser";
|
||||
}
|
||||
if($post['action'] == "sendAttandeesPerEmail"){
|
||||
sendEmail(
|
||||
@@ -78,4 +91,38 @@ function attendancesAssocArray2mdList($attendancesAssocArray, $date=null){
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/// Validaing a phone number
|
||||
/// true if it validates, false if not
|
||||
function validate_phone_number($phone)
|
||||
{
|
||||
// Allow +, - and . in phone number
|
||||
$filtered_phone_number = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);
|
||||
// Remove "-" from number
|
||||
$phone_to_check = str_replace("-", "", $filtered_phone_number);
|
||||
// Check the lenght of number
|
||||
// This can be customized if you want phone number from a specific country
|
||||
if (strlen($phone_to_check) < 10 || strlen($phone_to_check) > 14) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// validate different types of input
|
||||
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);
|
||||
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user