mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 07:48:43 +00:00
chore(release): obfuscate and hash production assets [skip ci]
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* HexaDNS - Ping/Verfügbarkeitstest API
|
||||
*
|
||||
* Prüft die Erreichbarkeit einer Domain
|
||||
*
|
||||
* Verwendung: GET /api/ping-check.php?domain=example.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require_once __DIR__ . '/../includes/api-helpers.php';
|
||||
|
||||
@@ -43,9 +43,9 @@ echo json_encode([
|
||||
'results' => $results
|
||||
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
|
||||
/**
|
||||
* Führt verschiedene Erreichbarkeitstests durch
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function performConnectivityCheck(string $domain): array {
|
||||
$results = [
|
||||
'dns_resolution' => checkDnsResolution($domain),
|
||||
@@ -55,7 +55,7 @@ function performConnectivityCheck(string $domain): array {
|
||||
'overall_status' => 'offline'
|
||||
];
|
||||
|
||||
// Overall-Status bestimmen
|
||||
|
||||
if ($results['https']['reachable'] || $results['http']['reachable']) {
|
||||
$results['overall_status'] = 'online';
|
||||
} elseif ($results['icmp_ping']['reachable']) {
|
||||
@@ -67,9 +67,9 @@ function performConnectivityCheck(string $domain): array {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* DNS-Auflösung prüfen
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function checkDnsResolution(string $domain): array {
|
||||
$start = microtime(true);
|
||||
$ip = gethostbyname($domain);
|
||||
@@ -84,9 +84,9 @@ function checkDnsResolution(string $domain): array {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* ICMP Ping (falls verfügbar)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function checkIcmpPing(string $domain): array {
|
||||
$result = [
|
||||
'reachable' => false,
|
||||
@@ -94,18 +94,18 @@ function checkIcmpPing(string $domain): array {
|
||||
'packet_loss' => null
|
||||
];
|
||||
|
||||
// Versuche ping-Kommando
|
||||
|
||||
$safeDomain = escapeshellarg($domain);
|
||||
$pingResult = @shell_exec("ping -c 3 -W 2 {$safeDomain} 2>/dev/null");
|
||||
|
||||
if ($pingResult) {
|
||||
// Prüfe auf erfolgreiche Antworten
|
||||
|
||||
if (preg_match('/(\d+)% packet loss/', $pingResult, $lossMatch)) {
|
||||
$result['packet_loss'] = (int)$lossMatch[1];
|
||||
$result['reachable'] = $result['packet_loss'] < 100;
|
||||
}
|
||||
|
||||
// Durchschnittliche Zeit extrahieren
|
||||
|
||||
if (preg_match('/avg.*?=.*?[\d.]+\/([\d.]+)\//', $pingResult, $timeMatch)) {
|
||||
$result['response_time_ms'] = (float)$timeMatch[1];
|
||||
} elseif (preg_match('/time[=<]([\d.]+)\s*ms/', $pingResult, $timeMatch)) {
|
||||
@@ -116,9 +116,9 @@ function checkIcmpPing(string $domain): array {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP(S)-Verbindung prüfen
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function checkHttpConnection(string $domain, bool $https = false): array {
|
||||
$protocol = $https ? 'https' : 'http';
|
||||
$port = $https ? 443 : 80;
|
||||
@@ -134,7 +134,7 @@ function checkHttpConnection(string $domain, bool $https = false): array {
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
// cURL verwenden
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => $url,
|
||||
@@ -156,13 +156,13 @@ function checkHttpConnection(string $domain, bool $https = false): array {
|
||||
$result['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$result['reachable'] = $result['status_code'] > 0;
|
||||
|
||||
// Redirect-URL
|
||||
|
||||
$redirectUrl = curl_getinfo($ch, CURLINFO_REDIRECT_URL);
|
||||
if (!empty($redirectUrl)) {
|
||||
$result['redirect_url'] = $redirectUrl;
|
||||
}
|
||||
|
||||
// Server-Header
|
||||
|
||||
if (preg_match('/Server:\s*([^\r\n]+)/i', $response, $serverMatch)) {
|
||||
$result['server'] = trim($serverMatch[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user