2000000) { $content = file_get_contents($filePath, false, null, -2000000); $fileSizeMb = filesize($filePath) / 1000000; } else { $content = file_get_contents($filePath); $fileSizeMb = filesize($filePath) / 1000000; } // Prepare the download button HTML if filePath resides under the active log base path $downloadButtonHtml = ''; $logPrefix = $logBasePath . '/'; if ($logPrefix !== '/' && strpos($filePath, $logPrefix) === 0) { $downloadName = basename($filePath); $downloadButtonHtml = ' '; } // Prepare buttons HTML $buttonsHtml = ''; $totalButtons = count($buttons); $colClass = $totalButtons > 0 ? (12 / $totalButtons) : 12; foreach ($buttons as $button) { $labelStringCode = isset($button['labelStringCode']) ? $button['labelStringCode'] : ''; $event = isset($button['event']) ? $button['event'] : ''; $buttonsHtml .= '
'; } // Render HTML $html = '
' . htmlspecialchars($filePath) . '
' . number_format($fileSizeMb, 2, ",", ".") . ' MB' . $downloadButtonHtml . '
' . $buttonsHtml . '
'; return $html; } // Load default data from JSON file $defaultDataFile = 'logs_defaults.json'; $defaultData = file_exists($defaultDataFile) ? json_decode(file_get_contents($defaultDataFile), true) : []; // Check if JSON data is submitted via POST if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['items'])) { $items = json_decode($_POST['items'], true); } else { $items = $defaultData; } // Render the log areas with the retrieved or default data $html = ''; foreach ($items as $item) { $html .= renderLogArea($item); } echo $html; exit(); ?>