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'] = [];
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (isset($GLOBALS['layoutContext']['asset_version'])) {
|
||||
|
||||
@@ -20,9 +20,7 @@ $clientIp = trim($clientIp);
|
||||
$version = $GLOBALS['app_version'] ?? '';
|
||||
$versionLabel = $version ? (' | v' . $version) : '';
|
||||
$accessLine = date(DATE_ATOM) . ' | ' . ($clientIp !== '' ? $clientIp : 'unknown') . $versionLabel . "\n";
|
||||
$logFile = $debugDir . '/last_access.log';
|
||||
$existing = is_file($logFile) ? (string)@file_get_contents($logFile) : '';
|
||||
@file_put_contents($logFile, $accessLine . $existing);
|
||||
debug_log_write('last_access', $accessLine, ['append' => true, 'json' => false]);
|
||||
|
||||
$pageTitle = 'Email Template System – Admin';
|
||||
$pageId = 'home';
|
||||
|
||||
@@ -9,6 +9,7 @@ ob_start();
|
||||
|
||||
// Lade den AuthService
|
||||
require_once __DIR__ . '/AuthService.php';
|
||||
require_once __DIR__ . '/../inc/helpers.php';
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ApiKernel.php (OPTIMIERT & KORRIGIERT)
|
||||
@@ -4925,26 +4926,12 @@ SQL;
|
||||
}
|
||||
}
|
||||
$dir = $this->debugDir();
|
||||
if (!is_dir($dir)) {
|
||||
@mkdir($dir, 0777, true);
|
||||
}
|
||||
@chmod($dir, 0777);
|
||||
$safeName = preg_replace('/[^a-zA-Z0-9_\.\-]/', '_', $name) ?: 'debug';
|
||||
$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);
|
||||
debug_log_write($name, $payload, [
|
||||
'dir' => $dir,
|
||||
'append' => false,
|
||||
'json' => true,
|
||||
'newline' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
private function defaultApiBase(): string
|
||||
|
||||
Reference in New Issue
Block a user