$raw], 'panel'); } catch (\Throwable $e) { /* Hide unsafe URL. */ } } if (($config['graphs_authorization_confirmed'] ?? false) === true && Graphite::validUuid($fields['uuid'] ?? null) && is_string($fields['vtype'] ?? null) && preg_match('/\A[a-z0-9_-]{1,24}\z/', $fields['vtype'])) { try { $graphs = Config::url($config, 'graphs_url') . '/collect/servidor/' . rawurlencode($fields['vtype']) . '/' . rawurlencode($fields['uuid']) . '/-1h/now'; } catch (\Throwable $e) { /* Configuration is optional. */ } } ob_start(); require __DIR__ . '/../templates/links.php'; return ob_get_clean(); } public static function render(array $params, $requestedRange = '24h', ?Graphite $graphite = null): string { $range = Graphite::range($requestedRange); $config = []; try { $config = Config::load(); } catch (\Throwable $e) { /* Metrics fail independently. */ } $links = self::links($params, $config); if (($params['customfields']['vtype'] ?? null) !== 'lx') { return $links; } $metrics = null; try { $graphite = $graphite ?? new Graphite($config); $metrics = $graphite->getForService($params, $range); } catch (\Throwable $e) { // Do not log exceptions, configuration, raw responses or WHMCS parameters. } $serviceId = filter_var($params['serviceid'] ?? null, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $ranges = Graphite::RANGES; $cards = ['load' => 'Carga del sistema', 'memory' => 'Uso de memoria', 'network' => 'Tráfico de red']; $json = $metrics === null ? '' : json_encode($metrics, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_THROW_ON_ERROR); ob_start(); require __DIR__ . '/../templates/metrics.php'; return ob_get_clean(); } }