dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
template_hygiene_test.php
Go to the documentation of this file.
1<?php
2
3$root = dirname(__DIR__, 3);
4$failures = array();
5$iterator = new RecursiveIteratorIterator(
6 new RecursiveDirectoryIterator($root . '/dbx', FilesystemIterator::SKIP_DOTS)
7);
8
9foreach ($iterator as $file) {
10 if (!$file->isFile() || strtolower($file->getExtension()) !== 'htm') {
11 continue;
12 }
13 $path = $file->getRealPath();
14 $normalized = str_replace('\\', '/', $path ?: '');
15 if (strpos($normalized, '/vendor/') !== false) {
16 continue;
17 }
18 $source = file_get_contents($path);
19 if (!is_string($source)) {
20 continue;
21 }
22 $issues = array();
23 if (strncmp($source, "\xEF\xBB\xBF", 3) === 0) {
24 $issues[] = 'UTF-8-BOM';
25 }
26 if (preg_match('/\son[a-z]+\s*=/i', $source) === 1) {
27 $issues[] = 'Inline-Eventhandler';
28 }
29 if ($issues) {
30 $failures[] = str_replace('\\', '/', substr($path, strlen($root) + 1)) . ' (' . implode(', ', $issues) . ')';
31 }
32}
33
35 fwrite(STDERR, "FAIL: Template-Hygiene: " . implode(', ', $failures) . "\n");
36 exit(1);
37}
38
39echo "OK template hygiene\n";
exit
Definition index.php:146