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; + } } ?>