feat: add system information drawer (#44)

This commit is contained in:
2026-01-05 13:32:42 +03:00
committed by Nikita Kiselev
parent 966ed4baab
commit 9da605b9ea
3 changed files with 136 additions and 1 deletions

View File

@@ -182,4 +182,61 @@ class SettingsHandler
return null;
}
}
public function getSystemInfo(): JsonResponse
{
$info = [];
$info['PHP Version'] = PHP_VERSION;
$info['PHP SAPI'] = PHP_SAPI;
$info['PHP Memory Limit'] = ini_get('memory_limit');
$info['PHP Memory Usage'] = $this->formatBytes(memory_get_usage(true));
$info['PHP Peak Memory Usage'] = $this->formatBytes(memory_get_peak_usage(true));
$info['PHP Max Execution Time'] = ini_get('max_execution_time') . 's';
$info['PHP Upload Max Filesize'] = ini_get('upload_max_filesize');
$info['PHP Post Max Size'] = ini_get('post_max_size');
try {
$mysqlVersion = $this->connection->select('SELECT VERSION() as version');
$info['MySQL Version'] = $mysqlVersion[0]['version'] ?? 'Unknown';
} catch (Exception $e) {
$info['MySQL Version'] = 'Error: ' . $e->getMessage();
}
$cacheDriver = env('TELECART_CACHE_DRIVER', 'mysql');
$cacheClass = get_class($this->cache);
$info['Cache Driver'] = $cacheDriver . ' (' . basename(str_replace('\\', '/', $cacheClass)) . ')';
$info['Module Version'] = module_version();
$info['OpenCart Version'] = defined('VERSION') ? VERSION : 'Unknown';
$info['OpenCart Core Version'] = defined('VERSION_CORE') ? VERSION_CORE : 'Unknown';
$info['Operating System'] = PHP_OS;
$info['Server Software'] = $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown';
$info['Document Root'] = $_SERVER['DOCUMENT_ROOT'] ?? 'Unknown';
$info['PHP Timezone'] = date_default_timezone_get();
$info['Server Time'] = date('Y-m-d H:i:s');
$info['UTC Time'] = gmdate('Y-m-d H:i:s');
$info['Loaded PHP Extensions'] = implode(', ', get_loaded_extensions());
$infoText = '';
foreach ($info as $key => $value) {
$infoText .= $key . ': ' . $value . "\n";
}
return new JsonResponse(['data' => $infoText]);
}
private function formatBytes(int $bytes, int $precision = 2): string
{
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
for ($i = 0; $bytes > 1024 && $i < count($units) - 1; $i++) {
$bytes /= 1024;
}
return round($bytes, $precision) . ' ' . $units[$i];
}
}

View File

@@ -28,6 +28,7 @@ return [
'getTelegramCustomers' => [TelegramCustomersHandler::class, 'getCustomers'],
'resetCache' => [SettingsHandler::class, 'resetCache'],
'saveSettingsForm' => [SettingsHandler::class, 'saveSettingsForm'],
'getSystemInfo' => [SettingsHandler::class, 'getSystemInfo'],
'sendMessageToCustomer' => [SendMessageHandler::class, 'sendMessage'],
'testTgMessage' => [TelegramHandler::class, 'testTgMessage'],
'tgGetMe' => [TelegramHandler::class, 'tgGetMe'],