12require_once
$root . DIRECTORY_SEPARATOR .
'include' . DIRECTORY_SEPARATOR .
'dbxValidator.class.php';
19 new RecursiveDirectoryIterator(
20 $root . DIRECTORY_SEPARATOR .
'modules',
21 FilesystemIterator::SKIP_DOTS
26 '/\$field\s*\[\s*([\'"])rules\1\s*\]\s*=\s*([\'"])(.*?)\2\s*;/s',
27 '/\brules\s*:\s*([\'"])(.*?)\1/s',
31 if (!
$file->isFile() || strtolower(
$file->getExtension()) !==
'php') {
35 $path = str_replace(
'\\',
'/',
$file->getPathname());
36 $relativePath =
'/' . ltrim(str_replace(
39 substr(
$file->getPathname(), strlen(
$root . DIRECTORY_SEPARATOR .
'modules'))
41 if (strpos($relativePath,
'/vendor/') !==
false
42 || strpos($relativePath,
'/add_ons/') !==
false
43 || strpos($relativePath,
'/work/') !==
false) {
47 $source = (string)file_get_contents(
$file->getPathname());
48 foreach (
$patterns as $patternNo => $pattern) {
49 if (!preg_match_all($pattern,
$source, $matches, PREG_SET_ORDER)) {
53 foreach ($matches as $match) {
54 $valueIndex = $patternNo === 0 ? 3 : 2;
55 $rule = stripcslashes((
string)($match[$valueIndex] ??
''));
56 if (
$rule ===
'' || strpbrk(
$rule,
'${}') !==
false) {
62 if ((
$result[
'code'] ??
'') ===
'invalid_rule') {
70 fwrite(STDERR,
"FAIL: Keine literal definierten Validator-Regeln gefunden.\n");
75 fwrite(STDERR,
"FAIL: Unbekannte oder widerspruechliche Validator-Regeln:\n - "
76 . implode(
"\n - ", array_unique(
$errors)) .
"\n");
80echo
'OK: ' . count(
$rules) .
" literal definierte Validator-Regeln sind kompatibel.\n";
Zentrale, strikt pruefende Eingabevalidierung.