= 10) { return true; }else{ return false; } } /** * Prüft, ob die Kategorie eine erlaubt Kategorie ist. * @param $category * @return bool */ function articleCategoryValidator($category) { $allowedCategories = [ 'deutsch', 'englisch', 'franzoesisch', 'latein', 'literatur', 'mathe', 'biologie', 'chemie', 'physik', 'informatik', 'astronomie', 'geschichte', 'erdkunde', 'sozialkunde', 'wirtschaft', 'religion', 'ethik', 'philosophie', 'psychologie', 'kunst', 'musik', 'theater', 'technik', 'werken', 'hauswirtschaft', 'sport' ]; if (in_array($category, $allowedCategories, true)) { return true; } else { return false; } } /** * Prüft, ob die Tags die folgenden Bedingungen erfüllen: * Buchstaben von a-z; A-Z * Zahlen von 0-9 * Umlaute äöüÄÖÜß * Satzeichen - * 2-50 Zeichen * @param $tags * @return bool */ function articleTagValidator($tags) { if (!isset($tags)) { $tags = ''; } $rawTags = explode(',', $tags); foreach ($rawTags as $rawTag) { // Leerzeichen am Anfang/Ende des einzelnen Tags entfernen: $tag = trim($rawTag); // leere Elemente überspringen: if ($tag === '') { continue; } // Tag mit Regex prüfen: $tagPattern = '/^[a-zA-Z0-9äöüÄÖÜß\s-]{2,50}$/u'; if (!preg_match($tagPattern, $tag)) { return false; } } return true; } ?>