Update file inclusion paths in multiple PHP files: Adjusted paths to use the new backend directory structure, ensuring consistent access to functions and configuration files across the application.

This commit is contained in:
𝓜𝓪𝓬𝓮™
2026-04-02 13:46:08 +02:00
parent b4ab365314
commit c8386a8f4b
34 changed files with 2879 additions and 25 deletions

161
backend/api/dns-lookup.php Normal file
View File

@@ -0,0 +1,161 @@
<?php
/**
* HexaDNS - DNS Lookup API
*
* Führt echte DNS-Abfragen durch und gibt die Ergebnisse als JSON zurück.
*
* Verwendung: GET /api/dns-lookup.php?domain=example.com
*/
// CORS Headers für Frontend-Zugriff
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
// Preflight request handling
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
// Nur GET-Anfragen erlauben
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
http_response_code(405);
echo json_encode(['error' => 'Nur GET-Anfragen erlaubt']);
exit;
}
// Domain-Parameter prüfen
$domain = isset($_GET['domain']) ? trim($_GET['domain']) : '';
if (empty($domain)) {
http_response_code(400);
echo json_encode(['error' => 'Domain-Parameter fehlt']);
exit;
}
// Domain validieren (einfache Prüfung)
if (!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\-\.]*\.[a-zA-Z]{2,}$/', $domain)) {
http_response_code(400);
echo json_encode(['error' => 'Ungültiges Domain-Format']);
exit;
}
// DNS-Abfrage durchführen
$startTime = microtime(true);
$result = performDnsLookup($domain);
$queryTime = round((microtime(true) - $startTime) * 1000, 2);
// Ergebnis zurückgeben
echo json_encode([
'success' => true,
'domain' => $domain,
'query_time_ms' => $queryTime,
'timestamp' => date('Y-m-d H:i:s'),
'records' => $result
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
/**
* Führt DNS-Lookup für verschiedene Record-Typen durch
*/
function performDnsLookup(string $domain): array {
$records = [
'A' => [],
'AAAA' => [],
'MX' => [],
'NS' => [],
'TXT' => [],
'CNAME' => [],
'SOA' => []
];
// A-Records (IPv4)
$aRecords = @dns_get_record($domain, DNS_A);
if ($aRecords) {
foreach ($aRecords as $record) {
$records['A'][] = [
'ip' => $record['ip'],
'ttl' => $record['ttl']
];
}
}
// AAAA-Records (IPv6)
$aaaaRecords = @dns_get_record($domain, DNS_AAAA);
if ($aaaaRecords) {
foreach ($aaaaRecords as $record) {
$records['AAAA'][] = [
'ipv6' => $record['ipv6'],
'ttl' => $record['ttl']
];
}
}
// MX-Records (Mail)
$mxRecords = @dns_get_record($domain, DNS_MX);
if ($mxRecords) {
foreach ($mxRecords as $record) {
$records['MX'][] = [
'target' => $record['target'],
'priority' => $record['pri'],
'ttl' => $record['ttl']
];
}
// Nach Priorität sortieren
usort($records['MX'], fn($a, $b) => $a['priority'] <=> $b['priority']);
}
// NS-Records (Nameserver)
$nsRecords = @dns_get_record($domain, DNS_NS);
if ($nsRecords) {
foreach ($nsRecords as $record) {
$records['NS'][] = [
'target' => $record['target'],
'ttl' => $record['ttl']
];
}
}
// TXT-Records
$txtRecords = @dns_get_record($domain, DNS_TXT);
if ($txtRecords) {
foreach ($txtRecords as $record) {
$records['TXT'][] = [
'txt' => $record['txt'],
'ttl' => $record['ttl']
];
}
}
// CNAME-Records
$cnameRecords = @dns_get_record($domain, DNS_CNAME);
if ($cnameRecords) {
foreach ($cnameRecords as $record) {
$records['CNAME'][] = [
'target' => $record['target'],
'ttl' => $record['ttl']
];
}
}
// SOA-Record (Start of Authority)
$soaRecords = @dns_get_record($domain, DNS_SOA);
if ($soaRecords) {
foreach ($soaRecords as $record) {
$records['SOA'][] = [
'mname' => $record['mname'] ?? '',
'rname' => $record['rname'] ?? '',
'serial' => $record['serial'] ?? 0,
'refresh' => $record['refresh'] ?? 0,
'retry' => $record['retry'] ?? 0,
'expire' => $record['expire'] ?? 0,
'minimum_ttl' => $record['minimum-ttl'] ?? 0,
'ttl' => $record['ttl']
];
}
}
// Leere Arrays entfernen
return array_filter($records, fn($arr) => !empty($arr));
}