From f52d3a455cbea650e9be050eca1f0a7a52c6bc3a Mon Sep 17 00:00:00 2001 From: OliiverHacker Date: Tue, 25 May 2021 16:35:41 +0200 Subject: [PATCH 1/2] add date validation --- content/student/studentDBDML.php | 10 ++++++++-- include/datum.class.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/content/student/studentDBDML.php b/content/student/studentDBDML.php index becb31e88..5a32563c3 100644 --- a/content/student/studentDBDML.php +++ b/content/student/studentDBDML.php @@ -365,7 +365,6 @@ if(!$error) $error = true; $errormsg = 'Sie haben keine Schreibrechte fuer diesen Studiengang'; } - //Studentendaten speichern if(!$error) { @@ -377,7 +376,14 @@ if(!$error) $errormsg = 'Fehler beim Laden:'.$student->errormsg; $error = true; } - + $datum = new datum(); + $geb = $_POST['geburtsdatum']; + if(!$datum->verifyDate($geb)) + { + $return = false; + $errormsg = 'Datum ist nicht korrekt: '.$geb; + $error = true; + } if(!$error) { $student->uid = $_POST['uid']; diff --git a/include/datum.class.php b/include/datum.class.php index 9b7ebcc5e..e7aedd305 100644 --- a/include/datum.class.php +++ b/include/datum.class.php @@ -416,5 +416,21 @@ class datum return intval(substr($timestring, 0, 2)) + intval(substr($timestring, 3, 2)) / 60; } + /** + * Prueft das Datum + * @param $date = string + * @return true wenn ok, sonst false + */ + static public function verifyDate($date, $strict = true) + { + $dateTime = DateTime::createFromFormat('Y-m-d', $date); + if ($strict) { + $errors = DateTime::getLastErrors(); + if (!empty($errors['warning_count'])) { + return false; + } + } + return $dateTime !== false; + } } ?> From 5aacf9f9b287cfb77dcf63ebadd33571f00b3579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 14 Jun 2021 13:13:03 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Datumspr=C3=BCfung=20bei=20Geburtsdatum=20k?= =?UTF-8?q?orrigiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/student/studentDBDML.php | 7 ++++--- include/datum.class.php | 17 ----------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/content/student/studentDBDML.php b/content/student/studentDBDML.php index 5a32563c3..79e330c7f 100644 --- a/content/student/studentDBDML.php +++ b/content/student/studentDBDML.php @@ -377,11 +377,12 @@ if(!$error) $error = true; } $datum = new datum(); - $geb = $_POST['geburtsdatum']; - if(!$datum->verifyDate($geb)) + + $gebdatum = $_POST['geburtsdatum']; + if($gebdatum!='' && !$datum->checkDatum($gebdatum)) { $return = false; - $errormsg = 'Datum ist nicht korrekt: '.$geb; + $errormsg = 'Geburtsdatum ist nicht korrekt.'; $error = true; } if(!$error) diff --git a/include/datum.class.php b/include/datum.class.php index e7aedd305..f09066009 100644 --- a/include/datum.class.php +++ b/include/datum.class.php @@ -415,22 +415,5 @@ class datum { return intval(substr($timestring, 0, 2)) + intval(substr($timestring, 3, 2)) / 60; } - - /** - * Prueft das Datum - * @param $date = string - * @return true wenn ok, sonst false - */ - static public function verifyDate($date, $strict = true) - { - $dateTime = DateTime::createFromFormat('Y-m-d', $date); - if ($strict) { - $errors = DateTime::getLastErrors(); - if (!empty($errors['warning_count'])) { - return false; - } - } - return $dateTime !== false; - } } ?>