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 # 3. Domain-Einstieg
RewriteRule ^$ home/public/index.php [L] 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} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L] RewriteRule ^ - [L]
# 5. Globales Routing ans Portfolio # 6. Globales Routing ans Portfolio
RewriteRule ^(.*)$ home/public/index.php?url=$1 [L,QSA] RewriteRule ^(.*)$ home/public/index.php?url=$1 [L,QSA]

View file

@ -69,15 +69,24 @@ class ModuleService {
// Ignorierte Systemverzeichnisse // Ignorierte Systemverzeichnisse
$ignoredDirs = ['.git', '.vscode', 'home', 'philcore', 'node_modules', 'vendor', '_template']; $ignoredDirs = ['.git', '.vscode', 'home', 'philcore', 'node_modules', 'vendor', '_template'];
if (is_dir($rootPath)) { // 1. Primär: modules/ Verzeichnis scannen
$entries = scandir($rootPath); $scanLocations = [
if ($entries !== false) { $rootPath . '/modules',
$rootPath
];
foreach ($scanLocations as $basePath) {
if (!is_dir($basePath)) continue;
$entries = scandir($basePath);
if ($entries === false) continue;
foreach ($entries as $entry) { foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..' || in_array($entry, $ignoredDirs, true)) { if ($entry === '.' || $entry === '..' || in_array($entry, $ignoredDirs, true) || isset($modules[$entry])) {
continue; continue;
} }
$moduleDir = $rootPath . '/' . $entry; $moduleDir = $basePath . '/' . $entry;
if (!is_dir($moduleDir)) { if (!is_dir($moduleDir)) {
continue; continue;
} }
@ -88,7 +97,6 @@ class ModuleService {
$data = $jsonContent ? json_decode($jsonContent, true) : null; $data = $jsonContent ? json_decode($jsonContent, true) : null;
if (is_array($data)) { if (is_array($data)) {
// Ignorieren, falls explizit deaktiviert
if (isset($data['enabled']) && $data['enabled'] === false) { if (isset($data['enabled']) && $data['enabled'] === false) {
continue; continue;
} }
@ -106,7 +114,6 @@ class ModuleService {
} }
} }
} }
}
// Falls keine Module gefunden wurden, Fallback nutzen // Falls keine Module gefunden wurden, Fallback nutzen
if (empty($modules)) { if (empty($modules)) {

View file

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

View file

@ -1,8 +1,8 @@
<?php <?php
// DATEI: dinos/api_proxy.php // DATEI: dinos/api_proxy.php
$authFile = __DIR__ . '/../auth.php'; $authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile)) { if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__); $current_project = basename(__DIR__);
require_once $authFile; require_once $authFile;
} }
@ -17,7 +17,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
// 1. API-Schlüssel sicher aus .env laden // 1. API-Schlüssel sicher aus .env laden
$apiKey = ''; $apiKey = '';
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../home/.env']; $envFiles = [__DIR__ . '/.env', __DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envFiles as $envFile) { foreach ($envFiles as $envFile) {
if (file_exists($envFile)) { if (file_exists($envFile)) {
foreach (file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) { 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) // 1. Projekt identifizieren und schützen (Graceful Auth)
$authFile = __DIR__ . '/../auth.php'; $authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
if (file_exists($authFile)) { if (file_exists($authFile) && php_sapi_name() !== 'cli') {
$current_project = basename(__DIR__); $current_project = basename(__DIR__);
require_once $authFile; require_once $authFile;
} }
@ -14,13 +14,9 @@ if (file_exists($authFile)) {
// 2. Nutzerdaten abrufen // 2. Nutzerdaten abrufen
$loggedInUser = isset($_SESSION['user_email']) ? $_SESSION['user_email'] : 'Gast'; $loggedInUser = isset($_SESSION['user_email']) ? $_SESSION['user_email'] : 'Gast';
// Dein API-Key sicher aus .env laden // Dein API-Key sicher aus .env laden
$apiKey = ''; $apiKey = '';
$envFiles = [__DIR__ . '/.env', __DIR__ . '/../home/.env']; $envFiles = [__DIR__ . '/.env', __DIR__ . '/../../home/.env', __DIR__ . '/../home/.env'];
foreach ($envFiles as $envFile) { foreach ($envFiles as $envFile) {
if (file_exists($envFile)) { if (file_exists($envFile)) {
foreach (file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) { 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. * Führt den Google Login durch und speichert den Token.
*/ */
$current_project = 'dinos'; $authFile = file_exists(__DIR__ . '/../../auth.php') ? __DIR__ . '/../../auth.php' : __DIR__ . '/../auth.php';
require_once __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 // Nur Administratoren dürfen Google OAuth Konten verknüpfen
if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) { if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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