refactor: subprojekte nach /modules/ verschoben und test-sound wiederhergestellt

- Alle Module nach /modules/ verschoben (dinos, plants, storymachine, test, _template)
- .htaccess transparentes Routing fuer /modules/ eingerichtet
- ModuleService Auto-Discovery auf /modules/ Verzeichnis angepasst
- Original Web Audio Synthese (playOrganicFart) und Furzkissen-UI in modules/test/index.php wiederhergestellt
- AGENTS.md Dokumentation aktualisiert
This commit is contained in:
Philipp Urbschat 2026-09-13 00:33:01 +02:00
parent f393beb7ff
commit 3de05f542c
Signed by: Phili
SSH key fingerprint: SHA256:ZSQWnldzrYiABzOV6vTICPe0h19pTpus7sCbm2S0po0
140 changed files with 451 additions and 282 deletions

View file

@ -102,10 +102,19 @@ RewriteRule ^robots\.txt$ home/public/index.php?url=seo/robots [L,QSA]
# 3. Domain-Einstieg
RewriteRule ^$ home/public/index.php [L]
# 4. Echte Verzeichnisse/Dateien im Root (dinos, plants, etc.) direkt bedienen
# 4. Module aus /modules/ Verzeichnis bedienen (z.B. /dinos, /plants, /test -> /modules/...)
RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(modules/.*)$ $1 [L]
RewriteCond %{DOCUMENT_ROOT}/modules/$1 -d [OR]
RewriteCond %{DOCUMENT_ROOT}/modules/$1 -f
RewriteRule ^([^/]+)(/.*)?$ modules/$1$2 [L]
# 5. Echte Verzeichnisse/Dateien im Root direkt bedienen
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# 5. Globales Routing ans Portfolio
# 6. Globales Routing ans Portfolio
RewriteRule ^(.*)$ home/public/index.php?url=$1 [L,QSA]

View file

@ -69,40 +69,47 @@ class ModuleService {
// Ignorierte Systemverzeichnisse
$ignoredDirs = ['.git', '.vscode', 'home', 'philcore', 'node_modules', 'vendor', '_template'];
if (is_dir($rootPath)) {
$entries = scandir($rootPath);
if ($entries !== false) {
foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..' || in_array($entry, $ignoredDirs, true)) {
continue;
}
// 1. Primär: modules/ Verzeichnis scannen
$scanLocations = [
$rootPath . '/modules',
$rootPath
];
$moduleDir = $rootPath . '/' . $entry;
if (!is_dir($moduleDir)) {
continue;
}
foreach ($scanLocations as $basePath) {
if (!is_dir($basePath)) continue;
$descriptorFile = $moduleDir . '/module.json';
if (file_exists($descriptorFile)) {
$jsonContent = @file_get_contents($descriptorFile);
$data = $jsonContent ? json_decode($jsonContent, true) : null;
$entries = scandir($basePath);
if ($entries === false) continue;
if (is_array($data)) {
// Ignorieren, falls explizit deaktiviert
if (isset($data['enabled']) && $data['enabled'] === false) {
continue;
}
foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..' || in_array($entry, $ignoredDirs, true) || isset($modules[$entry])) {
continue;
}
$modules[$entry] = [
'slug' => $entry,
'name' => $data['name'] ?? ucfirst($entry),
'badge' => $data['badge'] ?? 'Tool',
'description' => $data['description'] ?? '',
'path' => '/' . $entry,
'adminOnly' => !empty($data['adminOnly']),
'order' => isset($data['order']) ? (int)$data['order'] : 999
];
$moduleDir = $basePath . '/' . $entry;
if (!is_dir($moduleDir)) {
continue;
}
$descriptorFile = $moduleDir . '/module.json';
if (file_exists($descriptorFile)) {
$jsonContent = @file_get_contents($descriptorFile);
$data = $jsonContent ? json_decode($jsonContent, true) : null;
if (is_array($data)) {
if (isset($data['enabled']) && $data['enabled'] === false) {
continue;
}
$modules[$entry] = [
'slug' => $entry,
'name' => $data['name'] ?? ucfirst($entry),
'badge' => $data['badge'] ?? 'Tool',
'description' => $data['description'] ?? '',
'path' => '/' . $entry,
'adminOnly' => !empty($data['adminOnly']),
'order' => isset($data['order']) ? (int)$data['order'] : 999
];
}
}
}

View file

@ -12,12 +12,16 @@ if (session_status() === PHP_SESSION_NONE) {
}
// 1. Graceful Auth (im Webbetrieb)
$authPath = __DIR__ . '/../auth.php';
$isHostedOnMainSite = file_exists($authPath);
if ($isHostedOnMainSite && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authPath;
$authCandidates = [
__DIR__ . '/../../auth.php',
__DIR__ . '/../auth.php'
];
foreach ($authCandidates as $authPath) {
if (file_exists($authPath) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authPath;
break;
}
}
// 2. Nutzer-Kontext
@ -32,9 +36,11 @@ if (!function_exists('module_env')) {
if ($envCache === null) {
$envCache = [];
$candidates = [
__DIR__ . '/.env', // 1. Lokale Modul-Konfiguration
__DIR__ . '/../home/.env', // 2. Zentrale philippurbschat.de Konfiguration
__DIR__ . '/../.env' // 3. Root-Konfiguration
__DIR__ . '/.env', // 1. Lokale Modul-Konfiguration
__DIR__ . '/../../home/.env', // 2. Wenn in /modules/<name>
__DIR__ . '/../home/.env', // 3. Wenn im Root
__DIR__ . '/../../.env',
__DIR__ . '/../.env'
];
foreach ($candidates as $file) {

View file

@ -1,8 +1,8 @@
<?php
// DATEI: dinos/api_proxy.php
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}
@ -17,7 +17,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
// 1. API-Schlüssel sicher aus .env laden
$apiKey = '';
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../home/.env'];
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envFiles as $envFile) {
if (file_exists($envFile)) {
foreach (file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {

View file

@ -5,8 +5,8 @@
*/
// 1. Projekt identifizieren und schützen (Graceful Auth)
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}
@ -14,13 +14,9 @@ if (file_exists($authFile)) {
// 2. Nutzerdaten abrufen
$loggedInUser = isset($_SESSION['user_email']) ? $_SESSION['user_email'] : 'Gast';
// Dein API-Key sicher aus .env laden
$apiKey = '';
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../home/.env'];
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envFiles as $envFile) {
if (file_exists($envFile)) {
foreach (file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {

View file

@ -5,8 +5,11 @@
* Führt den Google Login durch und speichert den Token.
*/
$current_project = 'dinos';
require_once __DIR__ . '/../auth.php';
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}
// Nur Administratoren dürfen Google OAuth Konten verknüpfen
if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {

View file

@ -5,8 +5,8 @@
*/
// 1. Projekt identifizieren und schützen (Graceful Auth)
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}

View file

@ -5,8 +5,8 @@
* Nimmt AJAX Request entgegen und sendet an Google Photos.
*/
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}

View file

@ -1,6 +1,6 @@
<?php
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}
@ -117,15 +117,20 @@ try {
$stmt = $pdo->prepare("UPDATE users SET ai_credits = ai_credits - 1 WHERE id = ? AND ai_credits >= 1");
$stmt->execute([$currentUserId]);
$geminiKey = $_ENV['GEMINI_API_KEY'] ?? getenv('GEMINI_API_KEY') ?: '';
if (empty($geminiKey) && file_exists(__DIR__ . '/../home/.env')) {
foreach (file(__DIR__ . '/../home/.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
$line = trim($line);
if ($line === '' || $line[0] === '#') continue;
if (strpos($line, '=') !== false) {
list($k, $v) = explode('=', $line, 2);
if (trim($k) === 'GEMINI_API_KEY') {
$geminiKey = trim(trim($v), '"\'');
break;
if (empty($geminiKey)) {
$envCandidates = [__DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envCandidates as $cand) {
if (file_exists($cand)) {
foreach (file($cand, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
$line = trim($line);
if ($line === '' || $line[0] === '#') continue;
if (strpos($line, '=') !== false) {
list($k, $v) = explode('=', $line, 2);
if (trim($k) === 'GEMINI_API_KEY') {
$geminiKey = trim(trim($v), '"\'');
break 2;
}
}
}
}
}

View file

@ -1,6 +1,6 @@
<?php
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}
@ -23,17 +23,22 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
exit;
}
// API-Schlüssel: Erst lokal prüfen, Fallback auf ../home/.env
// API-Schlüssel: Erst lokal prüfen, Fallback auf ../../home/.env
$apiKey = $_ENV['GEMINI_API_KEY'] ?? getenv('GEMINI_API_KEY') ?: '';
if (empty($apiKey) && file_exists(__DIR__ . '/../home/.env')) {
foreach (file(__DIR__ . '/../home/.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
$line = trim($line);
if ($line === '' || $line[0] === '#') continue;
if (strpos($line, '=') !== false) {
list($k, $v) = explode('=', $line, 2);
if (trim($k) === 'GEMINI_API_KEY') {
$apiKey = trim(trim($v), '"\'');
break;
if (empty($apiKey)) {
$envCandidates = [__DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envCandidates as $cand) {
if (file_exists($cand)) {
foreach (file($cand, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
$line = trim($line);
if ($line === '' || $line[0] === '#') continue;
if (strpos($line, '=') !== false) {
list($k, $v) = explode('=', $line, 2);
if (trim($k) === 'GEMINI_API_KEY') {
$apiKey = trim(trim($v), '"\'');
break 2;
}
}
}
}
}

View file

@ -1,6 +1,6 @@
<?php
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1,7 +1,7 @@
<?php
// Version: 01.10.2025 16:15 (FINAL & COMPLETE)
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}

View file

@ -1,7 +1,7 @@
<?php
// Version: 01.10.2025 12:15 (Layout restored)
$authFile = __DIR__ . '/../auth.php';
if (file_exists($authFile)) {
$authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__);
require_once $authFile;
}

Some files were not shown because too many files have changed in this diff Show more