dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxContentMarketingDeMigration_test.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4$_SERVER['REQUEST_URI'] = '/dbxapp/';
5$_SERVER['HTTP_HOST'] = 'localhost';
6$_SERVER['HTTPS'] = 'on';
7$_SERVER['SCRIPT_NAME'] = '/dbxapp/index.php';
8
9define('dbxSystem', 'dbxWebApp');
10define('dbxRunAsAdmin', 1);
11
12$root = dirname(__DIR__, 4);
13require $root . '/dbx/vendor/autoload.php';
14require_once $root . '/dbx/include/dbxKernel.php';
15require_once $root . '/dbx/modules/dbxContent/include/dbxContent_bootstrap_sync.php';
16
17function marketingDeFail(string $message, int $code): void {
18 fwrite(STDERR, "FAIL: {$message}\n");
19 exit($code);
20}
21
22$migrationFile = $root . '/dbx/modules/dbxContent/tools/restructure_marketing_de.php';
23$source = (string)file_get_contents($migrationFile);
24if (strpos($source, "PHP_SAPI !== 'cli'") === false
25 || strpos($source, "in_array('--apply'") === false
26 || strpos($source, '$db->begin($contentDd)') === false
27 || strpos($source, '$db->rollback($contentDd)') === false
28 || strpos($source, '/backup') === false) {
29 marketingDeFail('Trockenlauf, Backup oder dbxDB-Transaktion fehlen.', 1);
30}
31if (preg_match('/new\s+(?:PDO|SQLite3)\b|(?:PDO|SQLite3)::|->delete\s*\‍(/', $source)) {
32 marketingDeFail('Migration enthaelt direkten Datenbankzugriff oder eine Loeschoperation.', 2);
33}
34
35$contentDatabase = $root . '/dbx/modules/dbx/db/dbxContent.db3';
36if (!is_file($contentDatabase) || filesize($contentDatabase) === 0) {
37 echo "OK: Statischer Marketing-Migrationsvertrag; lokale Inhaltsdaten sind nicht Teil des öffentlichen Checkouts.\n";
38 exit(0);
39}
40
41$db = dbx()->get_system_obj('dbxDB');
44$rows = $db->select(
46 '1=1',
47 'id,permalink,title,description,content,template,folder,activ,addmenu,group_read,meta_robots',
48 'id',
49 'ASC',
50 '',
51 0,
52 0,
53 0
54);
55if (!is_array($rows)) {
56 marketingDeFail('Deutsche Inhalte konnten nicht ueber dbxDB gelesen werden.', 3);
57}
58
59$byId = array();
60$byPermalink = array();
61foreach ($rows as $row) {
62 $byId[(int)($row['id'] ?? 0)] = $row;
63 $byPermalink[(string)($row['permalink'] ?? '')] = $row;
64}
65
66$targets = array(
67 'home', 'loesungen', 'cms-website', 'shop-multichannel',
68 'individuelle-anwendungen', 'intranet-portale', 'dbxki', 'plattform',
69 'pakete', 'referenzen', 'demo', 'entwickler', 'dokumentation', 'kontakt',
70);
71foreach ($targets as $permalink) {
72 $row = $byPermalink[$permalink] ?? array();
73 $allowedTemplates = $permalink === 'home'
74 ? array('c-marketing-body1-footer', 'c-title-hero_header-body1-footer')
75 : array('c-marketing-body1-footer');
76 if ((int)($row['id'] ?? 0) <= 0
77 || (int)($row['activ'] ?? 0) !== 1
78 || !in_array((string)($row['template'] ?? ''), $allowedTemplates, true)
79 || (string)($row['meta_robots'] ?? '') !== 'index,follow') {
80 marketingDeFail("Aktive deutsche Zielseite fehlt oder ist ungueltig: {$permalink}", 4);
81 }
82 $text = (string)($row['title'] ?? '') . ' '
83 . (string)($row['description'] ?? '') . ' '
84 . strip_tags((string)($row['content'] ?? ''));
85 if (preg_match('/dbXapp|dbXApp|DBXapp/', $text)
86 || preg_match('/\b(?:fuer|ueber|aender|oeffent|geschaeft|moeglich|koennen|muessen|waehlen|loeschen)\b/iu', $text)) {
87 marketingDeFail("Schreibweise oder Umlaute sind auf {$permalink} inkonsistent.", 5);
88 }
89}
90
92 2, 4, 5, 6, 8, 45, 47, 48, 51, 53, 56, 57, 58, 59, 60, 62,
93 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
94 115, 116, 117, 118, 119, 120, 121, 122,
95);
96foreach ($archiveIds as $id) {
97 $row = $byId[$id] ?? array();
98 if ((int)($row['folder'] ?? 0) !== 19
99 || (int)($row['activ'] ?? 1) !== 0
100 || (int)($row['addmenu'] ?? 1) !== 0
101 || (string)($row['group_read'] ?? '') !== 'admin'
102 || (string)($row['meta_robots'] ?? '') !== 'noindex,nofollow') {
103 marketingDeFail("Archivseite wurde nicht vollstaendig nach /trash verschoben: {$id}", 6);
104 }
105}
106
107$trash = $db->select1($folderDd, 19, 'id,name,parent_id,group_read', 0);
108if (!is_array($trash)
109 || (string)($trash['name'] ?? '') !== 'trash'
110 || (string)($trash['group_read'] ?? '') !== 'admin') {
111 marketingDeFail('Der deutsche /trash-Ordner ist nicht admin-geschuetzt.', 7);
112}
113
114echo "OK: Deutsche Marketingstruktur ist aktiv; Altseiten liegen unveraendert als Datensaetze in /trash.\n";
static ddFolder(string $lng='')
static ddContent(string $lng='')
$_SERVER['REQUEST_METHOD']
if(!is_file($exportFile)) $contentDatabase
foreach($targets as $permalink) $archiveIds
foreach($rows as $row) $targets
foreach($archiveIds as $id) $trash
if(!is_array($rows)) $byId
marketingDeFail(string $message, int $code)
exit
Definition index.php:146
DBX schema administration.