HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/ezdns-hostbill-implementation.md
# ezdns.support HostBill Integration Setup Guide

Dies ist ein umfassender Leitfaden zur Integration von ezdns.support in das HostBill Multibrand-System.

## 1. HostBill Multibrand-Konfiguration für ezdns.support

### Grundlegende Einstellungen (Tab 0)

**Pflichtfelder:**
- **Brand Name**: ezdns.support
- **Domain**: https://ezdns.support
- **Email**: support@ezdns.support
- **Theme**: Default oder Custom-Theme für DNS-Service

**Empfohlene Einstellungen:**
- **Language**: Deutsch (primary), Englisch (secondary)
- **Currency**: EUR (€)
- **Timezone**: Europe/Berlin
- **Date Format**: dd.mm.YYYY
- **Decimal Separator**: ,

### Support-Einstellungen (Tab 1)

- **Support Department**: DNS-Support
- **Ticket Priority**: Standard mit Escalation
- **Auto-Response**: Deaktivieren (für DNS-Services)
- **Knowledge Base**: DNS-Dokumentation

### API-Einstellungen (Tab 2)

- **API URL**: https://support.panomity.com/api/
- **API Key**: Generieren in HostBill Admin → API Keys
- **API Secret**: Sicher aufbewahren

## 2. HostBill API-Integration für ezdns.support

Die HostBill API unterstützt:
- **JWT Authentication** (empfohlen)
- **Basic Authentication** (Alternative)

### API-Endpoints für ezdns.support Integration

```php
<?php
/**
 * ezDNS HostBill API Integration Class
 * 
 * Diese Klasse kapselt alle notwendigen API-Aufrufe
 * für die Integration von ezdns.support in HostBill
 */

class EzDNSHostBillIntegration {
    private $apiUrl;
    private $apiKey;
    private $apiSecret;
    private $token;
    private $brandId = 26; // ezdns.support Brand ID
    
    /**
     * Konstruktor
     * 
     * @param string $apiUrl HostBill API URL
     * @param string $apiKey API Key
     * @param string $apiSecret API Secret
     */
    public function __construct($apiUrl, $apiKey, $apiSecret) {
        $this->apiUrl = rtrim($apiUrl, '/');
        $this->apiKey = $apiKey;
        $this->apiSecret = $apiSecret;
    }
    
    /**
     * Authentication via JWT
     * 
     * @param string $username HostBill Username
     * @param string $password HostBill Password
     * @return array|null Token Daten oder null bei Fehler
     */
    public function authenticate($username, $password) {
        $endpoint = $this->apiUrl . '/login';
        
        $payload = json_encode([
            'username' => $username,
            'password' => $password
        ]);
        
        $response = $this->makeRequest('POST', $endpoint, $payload);
        
        if ($response && isset($response['token'])) {
            $this->token = $response['token'];
            return $response;
        }
        
        return null;
    }
    
    /**
     * API Request ausführen
     * 
     * @param string $method HTTP Methode
     * @param string $endpoint API Endpoint
     * @param string|null $data Request Daten
     * @return array|null Response Daten oder null bei Fehler
     */
    private function makeRequest($method, $endpoint, $data = null) {
        $headers = [
            'Content-Type: application/json',
            'Accept: application/json'
        ];
        
        if ($this->token) {
            $headers[] = 'Authorization: Bearer ' . $this->token;
        }
        
        $ch = curl_init($endpoint);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        
        if ($data) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        }
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        
        if ($httpCode === 200 || $httpCode === 201) {
            return json_decode($response, true);
        }
        
        error_log("API Error: HTTP $httpCode - $response");
        return null;
    }
    
    /**
     * Domain prüfen und/oder bestellen
     * 
     * @param string $domain Domain Name
     * @param string $tld TLD
     * @param int $years Anzahl Jahre
     * @return array|null Bestellungsdetails
     */
    public function orderDomain($domain, $tld, $years = 1) {
        $endpoint = $this->apiUrl . '/domain/order';
        
        $payload = json_encode([
            'name' => $domain,
            'tld_id' => $this->getTldId($tld),
            'years' => $years,
            'action' => 'register',
            'pay_method' => $this->getDefaultPaymentMethod()
        ]);
        
        return $this->makeRequest('POST', $endpoint, $payload);
    }
    
    /**
     * DNS-Check als Service bestellen
     * 
     * @param int $productId HostBill Produkt ID
     * @param string $domain Domain für Check
     * @param string $cycle Billing Cycle
     * @return array|null Bestellungsdetails
     */
    public function orderDNSService($productId, $domain, $cycle = 'm') {
        $endpoint = $this->apiUrl . '/order/' . $productId;
        
        $payload = json_encode([
            'domain' => $domain,
            'cycle' => $cycle,
            'pay_method' => $this->getDefaultPaymentMethod()
        ]);
        
        return $this->makeRequest('POST', $endpoint, $payload);
    }
    
    /**
     * Support Ticket erstellen
     * 
     * @param string $subject Ticket Subject
     * @param string $body Ticket Nachricht
     * @param int $deptId Department ID
     * @return array|null Ticket Details
     */
    public function createTicket($subject, $body, $deptId = 1) {
        $endpoint = $this->apiUrl . '/tickets';
        
        $payload = json_encode([
            'dept_id' => $deptId,
            'subject' => $subject,
            'body' => $body
        ]);
        
        return $this->makeRequest('POST', $endpoint, $payload);
    }
    
    /**
     * Zahlungsmethoden abrufen
     * 
     * @return array|null Zahlungsmethoden
     */
    public function getPaymentMethods() {
        $endpoint = $this->apiUrl . '/payment';
        return $this->makeRequest('GET', $endpoint);
    }
    
    /**
     * Standard-Zahlungsmethode abrufen
     * 
     * @return int Payment Method ID
     */
    private function getDefaultPaymentMethod() {
        $methods = $this->getPaymentMethods();
        
        if ($methods && isset($methods['payments'])) {
            // Stripe ist empfohlen für DNS-Services
            foreach ($methods['payments'] as $id => $name) {
                if (stripos($name, 'stripe') !== false) {
                    return $id;
                }
            }
            
            // PayPal als Fallback
            foreach ($methods['payments'] as $id => $name) {
                if (stripos($name, 'paypal') !== false) {
                    return $id;
                }
            }
        }
        
        return 1; // Standard-Fallback
    }
    
    /**
     * TLD ID abrufen
     * 
     * @param string $tld TLD (z.B. 'com', 'de')
     * @return int|null TLD ID
     */
    private function getTldId($tld) {
        $endpoint = $this->apiUrl . '/domain/order';
        $response = $this->makeRequest('GET', $endpoint);
        
        if ($response && isset($response['tlds'])) {
            foreach ($response['tlds'] as $tldData) {
                if ($tldData['tld'] === '.' . strtolower($tld)) {
                    return $tldData['id'];
                }
            }
        }
        
        return null;
    }
    
    /**
     * Service Details abrufen
     * 
     * @param int $serviceId Service ID
     * @return array|null Service Details
     */
    public function getService($serviceId) {
        $endpoint = $this->apiUrl . '/service/' . $serviceId;
        return $this->makeRequest('GET', $endpoint);
    }
    
    /**
     * Service canceln
     * 
     * @param int $serviceId Service ID
     * @param bool $immediate Sofortiger Cancel
     * @param string $reason Cancel Grund
     * @return array|null Cancel Bestätigung
     */
    public function cancelService($serviceId, $immediate = false, $reason = '') {
        $endpoint = $this->apiUrl . '/service/' . $serviceId . '/cancel';
        
        $payload = json_encode([
            'immediate' => $immediate ? 'true' : 'false',
            'reason' => $reason
        ]);
        
        return $this->makeRequest('POST', $endpoint, $payload);
    }
    
    /**
     * Client Details abrufen
     * 
     * @return array|null Client Details
     */
    public function getClientDetails() {
        $endpoint = $this->apiUrl . '/details';
        return $this->makeRequest('GET', $endpoint);
    }
    
    /**
     * Invoices auflisten
     * 
     * @return array|null Invoices
     */
    public function getInvoices() {
        $endpoint = $this->apiUrl . '/invoice';
        return $this->makeRequest('GET', $endpoint);
    }
    
    /**
     * Invoice Details abrufen
     * 
     * @param int $invoiceId Invoice ID
     * @return array|null Invoice Details
     */
    public function getInvoice($invoiceId) {
        $endpoint = $this->apiUrl . '/invoice/' . $invoiceId;
        return $this->makeRequest('GET', $endpoint);
    }
    
    /**
     * Logout
     * 
     * @return bool Erfolgreich oder nicht
     */
    public function logout() {
        $endpoint = $this->apiUrl . '/logout';
        $response = $this->makeRequest('POST', $endpoint);
        
        if ($response && isset($response['status'])) {
            $this->token = null;
            return $response['status'];
        }
        
        return false;
    }
}
?>
```

## 3. Produkte für ezdns.support konfigurieren

### Produktstruktur

**Kategorie**: DNS-Services

#### Produkt 1: DNS Check Free
- **Name**: DNS Check Free
- **Type**: Service
- **Description**: Grundlegender DNS-Check für eine Domain
- **Price**: €0.00
- **Setup Fee**: €0.00
- **Billing Cycle**: Once
- **Features**:
  - 1x DNS-Scan pro Monat
  - Basis-Delegation Check
  - Basis-DNSSEC Check
  - Online-Bericht
  - Keine Export-Funktion

#### Produkt 2: DNS Check Pro
- **Name**: DNS Check Pro
- **Type**: Service
- **Description**: Umfassender DNS-Check mit Reports
- **Price**: €9.00/Monat
- **Setup Fee**: €0.00
- **Billing Cycle**: Monthly
- **Features**:
  - Unbegrenzte DNS-Scans
  - Vollständiger Delegation Check
  - Vollständiger DNSSEC Check
  - Mail-Security Check (SPF/DKIM/DMARC)
  - Performance-Analyse
  - PDF-Export
  - CSV-Export
  - E-Mail-Benachrichtigungen
  - Historische Daten
  - API-Zugang

#### Produkt 3: DNS Check Business
- **Name**: DNS Check Business
- **Type**: Service
- **Description**: Multi-Domain DNS-Monitoring
- **Price**: €29.00/Monat
- **Setup Fee**: €0.00
- **Billing Cycle**: Monthly
- **Features**:
  - Bis zu 10 Domains
  - Alle Pro-Features
  - White-Label Reports
  - Priority-Support
  - Team-Zugang (5 User)
  - Webhook-Benachrichtigungen
  - Erweiterte API-Limits

#### Produkt 4: DNS Check Agency
- **Name**: DNS Check Agency
- **Type**: Service
- **Description**: Reseller-Programm für DNS-Services
- **Price**: €99.00/Monat
- **Setup Fee**: €0.00
- **Billing Cycle**: Monthly
- **Features**:
  - Unbegrenzte Domains
  - Alle Business-Features
  - Reseller-Preise
  - Custom-Branding
  - API-High-Limits
  - Dedicated Account Manager
  - 24/7 Support
  - Affiliate-Programm-Zugang

### Produkt-Konfiguration (PHP Skript)

```php
<?php
/**
 * Produkt-Konfiguration für ezdns.support
 * 
 * Dieses Skript erstellt die Produkte im HostBill-System
 */

require_once '/home/support.panomity.com/public_html/includes/config.php';
require_once '/home/support.panomity.com/public_html/includes/db.php';

class EzDNSProductSetup {
    private $db;
    private $brandId = 26; // ezdns.support Brand ID
    
    public function __construct() {
        global $db;
        $this->db = $db;
    }
    
    /**
     * Produkte erstellen
     */
    public function createProducts() {
        $products = [
            [
                'name' => 'DNS Check Free',
                'type' => 'Service',
                'category' => 'DNS Services',
                'description' => 'Grundlegender DNS-Check für eine Domain mit basis Analytik',
                'price' => 0.00,
                'setup' => 0.00,
                'billing_cycle' => 'Once',
                'active' => 1,
                'brand_id' => $this->brandId,
                'features' => json_encode([
                    'scans_per_month' => 1,
                    'delegation_check' => true,
                    'dnssec_check' => true,
                    'mail_security_check' => false,
                    'performance_check' => false,
                    'pdf_export' => false,
                    'csv_export' => false,
                    'email_notifications' => false,
                    'historical_data' => false,
                    'api_access' => false
                ])
            ],
            [
                'name' => 'DNS Check Pro',
                'type' => 'Service',
                'category' => 'DNS Services',
                'description' => 'Umfassender DNS-Check mit Reports und Benachrichtigungen',
                'price' => 9.00,
                'setup' => 0.00,
                'billing_cycle' => 'Monthly',
                'active' => 1,
                'brand_id' => $this->brandId,
                'features' => json_encode([
                    'scans_per_month' => -1, // Unbegrenzt
                    'delegation_check' => true,
                    'dnssec_check' => true,
                    'mail_security_check' => true,
                    'performance_check' => true,
                    'pdf_export' => true,
                    'csv_export' => true,
                    'email_notifications' => true,
                    'historical_data' => true,
                    'api_access' => true
                ])
            ],
            [
                'name' => 'DNS Check Business',
                'type' => 'Service',
                'category' => 'DNS Services',
                'description' => 'Multi-Domain DNS-Monitoring mit erweiterten Features',
                'price' => 29.00,
                'setup' => 0.00,
                'billing_cycle' => 'Monthly',
                'active' => 1,
                'brand_id' => $this->brandId,
                'features' => json_encode([
                    'scans_per_month' => -1,
                    'max_domains' => 10,
                    'delegation_check' => true,
                    'dnssec_check' => true,
                    'mail_security_check' => true,
                    'performance_check' => true,
                    'pdf_export' => true,
                    'csv_export' => true,
                    'email_notifications' => true,
                    'historical_data' => true,
                    'api_access' => true,
                    'white_label_reports' => true,
                    'priority_support' => true,
                    'team_users' => 5,
                    'webhook_notifications' => true,
                    'extended_api_limits' => true
                ])
            ],
            [
                'name' => 'DNS Check Agency',
                'type' => 'Service',
                'category' => 'DNS Services',
                'description' => 'Reseller-Programm für DNS-Services mit vollem Support',
                'price' => 99.00,
                'setup' => 0.00,
                'billing_cycle' => 'Monthly',
                'active' => 1,
                'brand_id' => $this->brandId,
                'features' => json_encode([
                    'scans_per_month' => -1,
                    'max_domains' => -1, // Unbegrenzt
                    'delegation_check' => true,
                    'dnssec_check' => true,
                    'mail_security_check' => true,
                    'performance_check' => true,
                    'pdf_export' => true,
                    'csv_export' => true,
                    'email_notifications' => true,
                    'historical_data' => true,
                    'api_access' => true,
                    'white_label_reports' => true,
                    'priority_support' => true,
                    'team_users' => -1,
                    'webhook_notifications' => true,
                    'extended_api_limits' => true,
                    'custom_branding' => true,
                    'reseller_pricing' => true,
                    'dedicated_account_manager' => true,
                    'support_24_7' => true,
                    'affiliate_access' => true
                ])
            ]
        ];
        
        foreach ($products as $product) {
            $this->insertProduct($product);
        }
    }
    
    /**
     * Produkt in Datenbank einfügen
     * 
     * @param array $product Produktdaten
     */
    private function insertProduct($product) {
        // HostBill Produkttabelle (je nach Version anpassen)
        $query = "INSERT INTO hb_products (
            name, 
            type, 
            category, 
            description, 
            price, 
            setup, 
            billing_cycle, 
            active, 
            brand_id,
            features,
            created_at
        ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())";
        
        try {
            $stmt = $this->db->prepare($query);
            $stmt->execute([
                $product['name'],
                $product['type'],
                $product['category'],
                $product['description'],
                $product['price'],
                $product['setup'],
                $product['billing_cycle'],
                $product['active'],
                $product['brand_id'],
                $product['features']
            ]);
            
            echo "Produkt erstellt: " . $product['name'] . "\n";
        } catch (Exception $e) {
            echo "Fehler beim Erstellen des Produkts " . $product['name'] . ": " . $e->getMessage() . "\n";
        }
    }
    
    /**
     * Support Department erstellen
     */
    public function createSupportDepartment() {
        $query = "INSERT INTO hb_departments (
            name,
            description,
            email,
            brand_id,
            created_at
        ) VALUES (?, ?, ?, ?, NOW())";
        
        try {
            $stmt = $this->db->prepare($query);
            $stmt->execute([
                'DNS Support',
                'Support für DNS-Services, DNSSEC, SPF/DKIM/DMARC und Performance-Checks',
                'dns@ezdns.support',
                $this->brandId
            ]);
            
            echo "Support Department erstellt: DNS Support\n";
        } catch (Exception $e) {
            echo "Fehler beim Erstellen des Support Departments: " . $e->getMessage() . "\n";
        }
    }
    
    /**
     * Zahlungsmethoden für ezdns.support konfigurieren
     */
    public function configurePaymentGateways() {
        // Stripe ist empfohlen für DNS-Services
        $gateways = [
            [
                'name' => 'Stripe',
                'gateway' => 'stripe',
                'settings' => json_encode([
                    'publishable_key' => '', // Hier Stripe Publishable Key einfügen
                    'secret_key' => '', // Hier Stripe Secret Key einfügen
                    'currency' => 'EUR'
                ]),
                'active' => 1,
                'brand_id' => $this->brandId
            ],
            [
                'name' => 'PayPal',
                'gateway' => 'paypal',
                'settings' => json_encode([
                    'email' => '', // Hier PayPal Email einfügen
                    'currency' => 'EUR'
                ]),
                'active' => 1,
                'brand_id' => $this->brandId
            ],
            [
                'name' => 'SEPA Direct Debit',
                'gateway' => 'sepa_direct_debit',
                'settings' => json_encode([
                    'creditor_id' => '', // Hier Gläubiger-ID einfügen
                    'currency' => 'EUR'
                ]),
                'active' => 1,
                'brand_id' => $this->brandId
            ]
        ];
        
        foreach ($gateways as $gateway) {
            $this->insertPaymentGateway($gateway);
        }
    }
    
    /**
     * Zahlungsmethode einfügen
     * 
     * @param array $gateway Gateway-Daten
     */
    private function insertPaymentGateway($gateway) {
        $query = "INSERT INTO hb_payment_gateways (
            name,
            gateway,
            settings,
            active,
            brand_id,
            created_at
        ) VALUES (?, ?, ?, ?, ?, NOW())";
        
        try {
            $stmt = $this->db->prepare($query);
            $stmt->execute([
                $gateway['name'],
                $gateway['gateway'],
                $gateway['settings'],
                $gateway['active'],
                $gateway['brand_id']
            ]);
            
            echo "Zahlungsmethode konfiguriert: " . $gateway['name'] . "\n";
        } catch (Exception $e) {
            echo "Fehler beim Konfigurieren der Zahlungsmethode " . $gateway['name'] . ": " . $e->getMessage() . "\n";
        }
    }
}

// Ausführung
try {
    $setup = new EzDNSProductSetup();
    echo "=== ezdns.support Produkt-Setup ===\n\n";
    
    echo "1. Produkte erstellen...\n";
    $setup->createProducts();
    
    echo "\n2. Support Department erstellen...\n";
    $setup->createSupportDepartment();
    
    echo "\n3. Zahlungsmethoden konfigurieren...\n";
    $setup->configurePaymentGateways();
    
    echo "\n=== Setup abgeschlossen ===\n";
} catch (Exception $e) {
    echo "Setup-Fehler: " . $e->getMessage() . "\n";
}
?>
```

## 4. ezdns.support Frontend Integration

### Client-Side Integration

```javascript
/**
 * ezDNS Client-Side API Integration
 * 
 * JavaScript-Klasse für die Integration von ezdns.support
 * mit HostBill API
 */

class EzDNSClient {
    constructor(apiUrl, brandId = 26) {
        this.apiUrl = apiUrl;
        this.brandId = brandId;
        this.token = localStorage.getItem('ezdns_token') || null;
    }
    
    /**
     * Login durchführen
     */
    async login(email, password) {
        const response = await fetch(`${this.apiUrl}/login`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                username: email,
                password: password
            })
        });
        
        const data = await response.json();
        
        if (data.token) {
            this.token = data.token;
            localStorage.setItem('ezdns_token', data.token);
            localStorage.setItem('ezdns_refresh', data.refresh);
            return { success: true, data };
        }
        
        return { success: false, error: 'Login fehlgeschlagen' };
    }
    
    /**
     * DNS-Scan durchführen und Service bestellen
     */
    async orderDNSScan(domain, productId, cycle = 'm') {
        const response = await fetch(`${this.apiUrl}/order/${productId}`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.token}`
            },
            body: JSON.stringify({
                domain: domain,
                cycle: cycle,
                pay_method: this.getDefaultPaymentMethod()
            })
        });
        
        return await response.json();
    }
    
    /**
     * Support Ticket erstellen
     */
    async createTicket(subject, message, deptId = 1) {
        const response = await fetch(`${this.apiUrl}/tickets`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.token}`
            },
            body: JSON.stringify({
                dept_id: deptId,
                subject: subject,
                body: message
            })
        });
        
        return await response.json();
    }
    
    /**
     * Prüfen ob Authentifiziert
     */
    isAuthenticated() {
        return !!this.token;
    }
    
    /**
     * Logout durchführen
     */
    async logout() {
        if (this.token) {
            await fetch(`${this.apiUrl}/logout`, {
                method: 'POST',
                headers: {
                    'Authorization': `Bearer ${this.token}`
                }
            });
        }
        
        this.token = null;
        localStorage.removeItem('ezdns_token');
        localStorage.removeItem('ezdns_refresh');
    }
}
```

## 5. DNS-Check Service Integration

### Backend-Integration für DNS-Scans

```php
<?php
/**
 * DNS-Check Service Integration
 * 
 * Verbindet ezdns.support mit HostBill für Service-Bestellungen
 */

require_once 'EzDNSHostBillIntegration.php';

class DNSServiceManager {
    private $hostbill;
    private $db;
    
    public function __construct($apiUrl, $apiKey, $apiSecret) {
        $this->hostbill = new EzDNSHostBillIntegration($apiUrl, $apiKey, $apiSecret);
        
        // Database connection für lokale DNS-Scan-Speicherung
        $this->db = new PDO('mysql:host=localhost;dbname=ezdns_support', 'username', 'password');
    }
    
    /**
     * DNS-Scan durchführen und speichern
     * 
     * @param string $domain Domain
     * @param int $userId HostBill User ID
     * @param int $productId HostBill Produkt ID
     * @return array Scan-Ergebnis
     */
    public function performDNSScan($domain, $userId, $productId) {
        // DNS-Scans durchführen
        $scanResult = $this->executeDNSChecks($domain);
        
        // Ergebnis in lokaler Datenbank speichern
        $this->saveScanResult($domain, $userId, $scanResult);
        
        // HostBill Service bestellen (wenn nötig)
        if ($productId) {
            $orderResult = $this->hostbill->orderDNSService($productId, $domain);
            
            if ($orderResult) {
                // Service ID mit Scan verknüpfen
                $this->linkScanToService(
                    $scanResult['id'],
                    $orderResult['order_num'],
                    $orderResult['items']['id']
                );
            }
        }
        
        return $scanResult;
    }
    
    /**
     * DNS-Checks durchführen
     * 
     * @param string $domain Domain
     * @return array Scan-Ergebnis
     */
    private function executeDNSChecks($domain) {
        $checks = [
            'delegation' => $this->checkDelegation($domain),
            'dnssec' => $this->checkDNSSEC($domain),
            'spf' => $this->checkSPF($domain),
            'dkim' => $this->checkDKIM($domain),
            'dmarc' => $this->checkDMARC($domain),
            'mx' => $this->checkMX($domain),
            'performance' => $this->checkPerformance($domain)
        ];
        
        // Gesamtbewertung berechnen
        $score = $this->calculateScore($checks);
        
        return [
            'domain' => $domain,
            'checks' => $checks,
            'score' => $score,
            'status' => $score >= 80 ? 'good' : ($score >= 50 ? 'ok' : 'critical'),
            'scanned_at' => date('Y-m-d H:i:s')
        ];
    }
    
    /**
     * Delegation Check
     */
    private function checkDelegation($domain) {
        $result = [
            'status' => 'pending',
            'parent_ns' => [],
            'child_ns' => [],
            'issues' => []
        ];
        
        // Parent NS abfragen
        $parentNS = dns_get_record($domain, DNS_NS);
        $result['parent_ns'] = $parentNS;
        
        // Child NS abfragen (von ezDNS System)
        $childNS = $this->getChildNameservers($domain);
        $result['child_ns'] = $childNS;
        
        // Vergleichen und Issues identifizieren
        if (count($parentNS) !== count($childNS)) {
            $result['issues'][] = 'Anzahl der Nameservers stimmt nicht überein';
            $result['status'] = 'critical';
        }
        
        foreach ($parentNS as $parent) {
            $found = false;
            foreach ($childNS as $child) {
                if ($parent['target'] === $child['target']) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $result['issues'][] = "Parent NS {$parent['target']} nicht in Child gefunden";
                $result['status'] = 'critical';
            }
        }
        
        if (empty($result['issues'])) {
            $result['status'] = 'good';
        }
        
        return $result;
    }
    
    /**
     * DNSSEC Check
     */
    private function checkDNSSEC($domain) {
        $result = [
            'status' => 'pending',
            'ds_records' => [],
            'dnskey_records' => [],
            'issues' => []
        ];
        
        // DS Records abfragen
        $dsRecords = dns_get_record($domain, DNS_DS);
        $result['ds_records'] = $dsRecords;
        
        // DNSKEY Records abfragen
        $dnskeyRecords = dns_get_record($domain, DNS_DNSKEY);
        $result['dnskey_records'] = $dnskeyRecords;
        
        if (empty($dsRecords)) {
            $result['issues'][] = 'Keine DS Records gefunden - DNSSEC nicht aktiviert';
            $result['status'] = 'critical';
        } elseif (empty($dnskeyRecords)) {
            $result['issues'][] = 'Keine DNSKEY Records gefunden';
            $result['status'] = 'critical';
        } else {
            $result['status'] = 'good';
        }
        
        return $result;
    }
    
    /**
     * SPF Check
     */
    private function checkSPF($domain) {
        $result = [
            'status' => 'pending',
            'spf_record' => null,
            'issues' => []
        ];
        
        $txtRecords = dns_get_record($domain, DNS_TXT);
        
        foreach ($txtRecords as $record) {
            if (strpos($record['txt'], 'v=spf1') !== false) {
                $result['spf_record'] = $record['txt'];
                
                // SPF Record validieren
                if ($this->validateSPFRecord($record['txt'])) {
                    $result['status'] = 'good';
                } else {
                    $result['issues'][] = 'SPF Record ungültig';
                    $result['status'] = 'critical';
                }
                break;
            }
        }
        
        if (!$result['spf_record']) {
            $result['issues'][] = 'Kein SPF Record gefunden';
            $result['status'] = 'critical';
        }
        
        return $result;
    }
    
    /**
     * DMARC Check
     */
    private function checkDMARC($domain) {
        $result = [
            'status' => 'pending',
            'dmarc_record' => null,
            'issues' => []
        ];
        
        $dmarcDomain = '_dmarc.' . $domain;
        $txtRecords = dns_get_record($dmarcDomain, DNS_TXT);
        
        foreach ($txtRecords as $record) {
            if (strpos($record['txt'], 'v=DMARC1') !== false) {
                $result['dmarc_record'] = $record['txt'];
                
                // DMARC Record validieren
                if ($this->validateDMARCRecord($record['txt'])) {
                    $result['status'] = 'good';
                } else {
                    $result['issues'][] = 'DMARC Record ungültig';
                    $result['status'] = 'critical';
                }
                break;
            }
        }
        
        if (!$result['dmarc_record']) {
            $result['issues'][] = 'Kein DMARC Record gefunden';
            $result['status'] = 'critical';
        }
        
        return $result;
    }
    
    /**
     * Performance Check
     */
    private function checkPerformance($domain) {
        $result = [
            'status' => 'pending',
            'p50' => null,
            'p95' => null,
            'score' => null,
            'issues' => []
        ];
        
        // DNS-Query-Zeiten messen
        $queries = [];
        $nameservers = $this->getNameservers($domain);
        
        foreach ($nameservers as $ns) {
            $start = microtime(true);
            dns_get_record($domain, DNS_A);
            $duration = (microtime(true) - $start) * 1000; // ms
            $queries[] = $duration;
        }
        
        if (!empty($queries)) {
            sort($queries);
            
            $result['p50'] = $queries[floor(count($queries) * 0.5)];
            $result['p95'] = $queries[floor(count($queries) * 0.95)];
            
            // Score basierend auf Performance berechnen
            if ($result['p50'] < 50 && $result['p95'] < 100) {
                $result['score'] = 100;
                $result['status'] = 'good';
            } elseif ($result['p50'] < 100 && $result['p95'] < 200) {
                $result['score'] = 80;
                $result['status'] = 'ok';
            } else {
                $result['score'] = 50;
                $result['status'] = 'critical';
                $result['issues'][] = 'DNS-Performance langsam';
            }
        } else {
            $result['issues'][] = 'Keine Performance-Daten verfügbar';
            $result['status'] = 'critical';
        }
        
        return $result;
    }
    
    /**
     * Score berechnen
     */
    private function calculateScore($checks) {
        $score = 0;
        $weights = [
            'delegation' => 20,
            'dnssec' => 15,
            'spf' => 15,
            'dkim' => 15,
            'dmarc' => 15,
            'mx' => 10,
            'performance' => 10
        ];
        
        foreach ($checks as $type => $check) {
            if (isset($weights[$type])) {
                $checkScore = 0;
                switch ($check['status']) {
                    case 'good':
                        $checkScore = 100;
                        break;
                    case 'ok':
                        $checkScore = 70;
                        break;
                    case 'critical':
                        $checkScore = 0;
                        break;
                }
                
                $score += ($checkScore / 100) * $weights[$type];
            }
        }
        
        return round($score);
    }
    
    /**
     * Scan-Ergebnis speichern
     */
    private function saveScanResult($domain, $userId, $scanResult) {
        $query = "INSERT INTO dns_scans (
            domain, 
            user_id, 
            checks, 
            score, 
            status, 
            scanned_at
        ) VALUES (?, ?, ?, ?, ?, ?)";
        
        $stmt = $this->db->prepare($query);
        $stmt->execute([
            $domain,
            $userId,
            json_encode($scanResult['checks']),
            $scanResult['score'],
            $scanResult['status'],
            $scanResult['scanned_at']
        ]);
        
        return $this->db->lastInsertId();
    }
    
    /**
     * Scan mit HostBill Service verknüpfen
     */
    private function linkScanToService($scanId, $orderNum, $serviceId) {
        $query = "UPDATE dns_scans SET 
            order_num = ?, 
            service_id = ? 
            WHERE id = ?";
        
        $stmt = $this->db->prepare($query);
        $stmt->execute([$orderNum, $serviceId, $scanId]);
    }
}
?>
```

## 6. Implementierungsschritte

### Schritt 1: HostBill Multibrand konfigurieren
1. Loggen Sie sich in HostBill Admin ein
2. Navigieren Sie zu: Settings → Multi Brand Management
3. Öffnen Sie Brand ID 26 (ezdns.support)
4. Konfigurieren Sie alle Tabs wie oben beschrieben
5. Speichern Sie die Einstellungen

### Schritt 2: API-Zugang einrichten
1. Navigieren Sie zu: Settings → API Keys
2. Erstellen Sie einen neuen API-Key für ezdns.support
3. Speichern Sie API Key und Secret sicher
4. Tragen Sie diese in das Integrationsskript ein

### Schritt 3: Produkte erstellen
1. Führen Sie das Produkt-Setup-Skript aus
2. Überprüfen Sie die erstellten Produkte
3. Aktivieren Sie die Produkte für Brand ID 26

### Schritt 4: Zahlungsmethoden konfigurieren
1. Stripe-Details eintragen
2. PayPal-Details eintragen
3. SEPA-Details eintragen
4. Test-Transaktionen durchführen

### Schritt 5: Support-Einrichtung
1. DNS Support Department erstellen
2. Ticket-Templates erstellen
3. Auto-Responder konfigurieren
4. Knowledge Base Artikel erstellen

### Schritt 6: Frontend-Integration
1. JavaScript API-Klasse einbinden
2. Login-Formular integrieren
3. Bestell-Formular erstellen
4. Support-Ticket-Formular einbinden

### Schritt 7: DNS-Check Service einrichten
1. Backend-Integration deployen
2. DNS-Scan-Engine konfigurieren
3. HostBill-Service-Verbindung testen
4. Monitoring-System einrichten

## 7. Testing und Validierung

### Test-Checkliste

**API-Tests:**
- [ ] Login funktioniert
- [ ] Domain-Bestellung funktioniert
- [ ] Service-Bestellung funktioniert
- [ ] Support-Ticket-Erstellung funktioniert
- [ ] Invoice-Abruf funktioniert

**DNS-Check-Tests:**
- [ ] Delegation Check funktioniert
- [ ] DNSSEC Check funktioniert
- [ ] SPF Check funktioniert
- [ ] DMARC Check funktioniert
- [ ] Performance Check funktioniert
- [ ] Score-Berechnung korrekt

**Integrationstests:**
- [ ] HostBill Services werden erstellt
- [ ] Invoices werden generiert
- [ ] Support-Tickets werden erstellt
- [ ] Zahlungen werden verarbeitet
- [ ] Frontend zeigt korrekte Daten

**Benutzer-Tests:**
- [ ] Login im Frontend möglich
- [ ] DNS-Scan kann durchgeführt werden
- [ ] Upgrade zu Premium möglich
- [ ] Support-Ticket kann erstellt werden
- [ ] Zahlung kann durchgeführt werden

## 8. Wartung und Monitoring

### Regelmäßige Aufgaben

- **Täglich**: DNS-Scan-Ergebnisse überprüfen
- **Wöchentlich**: HostBill-Sync prüfen
- **Monatlich**: Invoice-Status prüfen
- **Quartalsweise**: Performance-Analyse durchführen

### Monitoring

- API-Verfügbarkeit überwachen
- DNS-Scan-Performance überwachen
- HostBill-Verbindungsstatus überwachen
- Fehler-Logs regelmäßig überprüfen

## 9. Support und Dokumentation

### Benutzer-Dokumentation
- Kurzanleitung erstellen
- API-Dokumentation erstellen
- FAQ erstellen
- Video-Tutorials erstellen

### Admin-Dokumentation
- Setup-Anleitung erstellen
- Troubleshooting-Guide erstellen
- Best Practices dokumentieren

### Support-Setup
- Ticket-Kategorien definieren
- SLA definieren
- Escalation-Prozesse einrichten
- Notfall-Plan erstellen

---

**Zusammenfassung**: Dieses Setup stellt eine vollständige Integration von ezdns.support in das HostBill Multibrand-System sicher, einschließlich Produktmanagement, API-Integration, Zahlungsverarbeitung, Support-System und DNS-Check-Services.