debug
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.2.23
|
1.2.24
|
||||||
@@ -10,6 +10,46 @@ if (!isset($GLOBALS['page_styles'])) {
|
|||||||
$GLOBALS['page_styles'] = [];
|
$GLOBALS['page_styles'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function debug_log_write(string $name, $payload, array $options = []): bool
|
||||||
|
{
|
||||||
|
$dir = (string)($options['dir'] ?? (dirname(__DIR__) . '/debug'));
|
||||||
|
if ($dir === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
@mkdir($dir, 0777, true);
|
||||||
|
@chmod($dir, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = (string)($options['filename'] ?? '');
|
||||||
|
if ($fileName === '') {
|
||||||
|
$safeName = preg_replace('/[^a-zA-Z0-9_\.\-]/', '_', $name) ?: 'debug';
|
||||||
|
$fileName = $safeName . '.log';
|
||||||
|
} else {
|
||||||
|
$fileName = basename($fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$asJson = $options['json'] ?? (is_array($payload) || is_object($payload));
|
||||||
|
if ($asJson) {
|
||||||
|
$line = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
} else {
|
||||||
|
$line = is_string($payload) ? $payload : (string)$payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($options['newline'] ?? true) && $line !== '' && substr($line, -1) !== "\n") {
|
||||||
|
$line .= "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = rtrim($dir, '/\\') . '/' . $fileName;
|
||||||
|
$flags = ($options['append'] ?? false) ? FILE_APPEND : 0;
|
||||||
|
$result = @file_put_contents($path, $line, $flags | LOCK_EX);
|
||||||
|
if ($result === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@chmod($path, 0666);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function helper_asset_version(): ?string
|
function helper_asset_version(): ?string
|
||||||
{
|
{
|
||||||
if (isset($GLOBALS['layoutContext']['asset_version'])) {
|
if (isset($GLOBALS['layoutContext']['asset_version'])) {
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ $clientIp = trim($clientIp);
|
|||||||
$version = $GLOBALS['app_version'] ?? '';
|
$version = $GLOBALS['app_version'] ?? '';
|
||||||
$versionLabel = $version ? (' | v' . $version) : '';
|
$versionLabel = $version ? (' | v' . $version) : '';
|
||||||
$accessLine = date(DATE_ATOM) . ' | ' . ($clientIp !== '' ? $clientIp : 'unknown') . $versionLabel . "\n";
|
$accessLine = date(DATE_ATOM) . ' | ' . ($clientIp !== '' ? $clientIp : 'unknown') . $versionLabel . "\n";
|
||||||
$logFile = $debugDir . '/last_access.log';
|
debug_log_write('last_access', $accessLine, ['append' => true, 'json' => false]);
|
||||||
$existing = is_file($logFile) ? (string)@file_get_contents($logFile) : '';
|
|
||||||
@file_put_contents($logFile, $accessLine . $existing);
|
|
||||||
|
|
||||||
$pageTitle = 'Email Template System – Admin';
|
$pageTitle = 'Email Template System – Admin';
|
||||||
$pageId = 'home';
|
$pageId = 'home';
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ ob_start();
|
|||||||
|
|
||||||
// Lade den AuthService
|
// Lade den AuthService
|
||||||
require_once __DIR__ . '/AuthService.php';
|
require_once __DIR__ . '/AuthService.php';
|
||||||
|
require_once __DIR__ . '/../inc/helpers.php';
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// ApiKernel.php (OPTIMIERT & KORRIGIERT)
|
// ApiKernel.php (OPTIMIERT & KORRIGIERT)
|
||||||
@@ -4925,26 +4926,12 @@ SQL;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dir = $this->debugDir();
|
$dir = $this->debugDir();
|
||||||
if (!is_dir($dir)) {
|
debug_log_write($name, $payload, [
|
||||||
@mkdir($dir, 0777, true);
|
'dir' => $dir,
|
||||||
}
|
'append' => false,
|
||||||
@chmod($dir, 0777);
|
'json' => true,
|
||||||
$safeName = preg_replace('/[^a-zA-Z0-9_\.\-]/', '_', $name) ?: 'debug';
|
'newline' => true,
|
||||||
$file = rtrim($dir, '/') . '/' . $safeName . '.log';
|
]);
|
||||||
$data = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
|
||||||
@file_put_contents($file, $data ?: '');
|
|
||||||
@chmod($file, 0666);
|
|
||||||
|
|
||||||
$fallback = sys_get_temp_dir() . '/emailtemplate_debug.log';
|
|
||||||
$line = json_encode([
|
|
||||||
'time' => date(DATE_ATOM),
|
|
||||||
'name' => $safeName,
|
|
||||||
'file' => $file,
|
|
||||||
'wrote_bytes' => is_string($data) ? strlen($data) : 0,
|
|
||||||
'dir_exists' => is_dir($dir),
|
|
||||||
'dir_writable' => is_writable($dir),
|
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
||||||
@file_put_contents($fallback, ($line ?: '') . "\n", FILE_APPEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function defaultApiBase(): string
|
private function defaultApiBase(): string
|
||||||
|
|||||||
Reference in New Issue
Block a user