<?php
// ============================================================
// FORTIGATE DASHBOARD - COMPLETE CONFIGURATION
// ============================================================

// ===== FORTIGATE CONFIG =====
define('FORTIGATE_HOST', '10.20.11.254');
define('FORTIGATE_PORT', 443);
define('FORTIGATE_USERNAME', 'eto.resiliant');
define('FORTIGATE_PASSWORD', 'Admin@2026');
define('FORTIGATE_API_KEY', '');

// ===== AI CONFIG - GEMINI =====
define('AI_PROVIDER', 'gemini');
define('GEMINI_API_KEY', 'AQ.Ab8RN6ImCC0lowmVKHyKWqbDcKzXfbV743vXsR2QPJTusd6qcg');
define('GEMINI_API_URL', 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContent');
define('GEMINI_MODEL', 'gemini-3.5-flash');

// ===== SYSTEM =====
date_default_timezone_set('Asia/Kuala_Lumpur');

error_reporting(E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/../logs/php-error.log');

// ===== CORS =====
if (php_sapi_name() !== 'cli') {
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
    header('Access-Control-Allow-Headers: Content-Type, Authorization');
    header('Content-Type: application/json');
    
    if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
        http_response_code(200);
        exit();
    }
}

// ============================================================
// FORTIGATE KNOWLEDGE BASE + ARUBA INSTANT ON
// ============================================================
define('FORTIGATE_KNOWLEDGE', [
    'model' => 'FortiGate 100F',
    'firmware' => 'FortiOS v7.4.11 build2878 (GA)',
    'vdom_mode' => 'no-vdom',
    'ha_mode' => 'standalone',
    'interfaces' => [
        'wan1' => ['alias' => 'VSAT2', 'mode' => 'dhcp', 'role' => 'wan', 'ip' => 'DHCP'],
        'wan2' => ['alias' => 'Starlink2-KIT-357', 'mode' => 'dhcp', 'role' => 'wan', 'ip' => 'DHCP'],
        'port2' => ['alias' => 'Starlink1-KIT355', 'mode' => 'dhcp', 'role' => 'wan', 'ip' => 'DHCP'],
        'lan' => ['ip' => '10.20.11.254/23', 'role' => 'lan', 'type' => 'hard-switch'],
        'dmz' => ['ip' => '10.10.10.1/24', 'role' => 'dmz'],
        'port12' => ['alias' => 'PABX-System', 'ip' => '10.30.10.254/24'],
        'port20' => ['alias' => 'SWMGMT', 'ip' => '10.20.12.254/24'],
        'fortilink' => ['ip' => '10.255.1.1/24', 'role' => 'fortilink'],
        'mgmt' => ['ip' => '192.168.1.99/24', 'role' => 'mgmt'],
    ],
    'dhcp_servers' => [
        'lan' => ['range' => '10.20.11.1-10.20.11.253, 10.20.10.2-10.20.10.253', 'gateway' => '10.20.11.254'],
        'mgmt' => ['range' => '192.168.1.110-192.168.1.210', 'gateway' => '192.168.1.99'],
        'port12' => ['range' => '10.30.10.2-10.30.10.253', 'gateway' => '10.30.10.254'],
        'fortilink' => ['range' => '10.255.1.2-10.255.1.254', 'gateway' => '10.255.1.1'],
    ],
    'vlan_interfaces' => [
        'MarineCrewWifi' => ['ip' => '10.30.11.254/24', 'vlanid' => 30],
        'ClientCrewWifi' => ['ip' => '10.40.11.254/24', 'vlanid' => 40],
        'PMT Wifi' => ['ip' => '10.50.11.254/24', 'vlanid' => 50],
        'Client Office' => ['ip' => '10.60.11.254/24', 'vlanid' => 60],
        'AppUpdate' => ['ip' => '10.70.11.254/24', 'vlanid' => 70],
        'Resiliant-Wifi' => ['ip' => '10.9.10.254/24', 'vlanid' => 9],
    ],
    'security_profiles' => [
        'ips' => ['high_security', 'protect_http_server', 'protect_client', 'default'],
        'app_control' => ['APPCTRL-MRL', 'APPCTRL-PMT', 'block-high-risk', 'block_update'],
        'url_filter' => ['blocklist includes instagram, linode, gthost, apple, speedtest'],
        'dlp' => ['Large-File', 'Content_Summary', 'Content_Archive'],
    ],
    'dns' => ['primary' => '96.45.45.45', 'secondary' => '96.45.46.46', 'interface' => 'port2'],
    'ntp' => ['server' => 'fortiguard', 'interface' => 'lan, port2, wan1, wan2'],
    'admin_users' => ['carlo.l', 'eto.resiliant'],
    'logging' => ['fortianalyzer' => '10.71.10.3', 'fortiguard' => 'enabled'],
    'features' => [
        'sdwan' => 'disabled (using multiple WAN interfaces)',
        'ha' => 'standalone',
        'ssl_vpn' => 'enabled (10.212.134.200-210)',
        'ipsec_vpn' => 'configured (2DMC tunnel)',
        'ztna' => 'enabled',
        'fortilink' => 'enabled (10.255.1.1/24)',
    ],
    // ===== ARUBA INSTANT ON =====
    'aruba' => [
        'model' => 'Aruba Instant On 1930 Switch Series',
        'management_ip' => '10.20.11.241',
        'vlans' => [
            ['id' => 1, 'name' => 'Default', 'subnet' => '10.20.10.0/23'],
            ['id' => 30, 'name' => 'MarineCrewWifi', 'subnet' => '10.30.11.0/24'],
            ['id' => 40, 'name' => 'ClientCrewWifi', 'subnet' => '10.40.11.0/24'],
            ['id' => 50, 'name' => 'PMT Wifi', 'subnet' => '10.50.11.0/24'],
            ['id' => 60, 'name' => 'Client Office', 'subnet' => '10.60.11.0/24'],
            ['id' => 70, 'name' => 'AppUpdate', 'subnet' => '10.70.11.0/24'],
            ['id' => 9, 'name' => 'Resiliant-Wifi', 'subnet' => '10.9.10.0/24'],
        ],
        'uplink' => 'port20 (SWMGMT)',
        'status' => 'online',
        'ports' => [
            ['port' => 1, 'description' => 'Uplink to FortiGate', 'vlan' => 1],
            ['port' => 2, 'description' => 'AP MarineCrew', 'vlan' => 30],
            ['port' => 3, 'description' => 'AP ClientCrew', 'vlan' => 40],
            ['port' => 4, 'description' => 'AP PMT', 'vlan' => 50],
            ['port' => 5, 'description' => 'Client Office', 'vlan' => 60],
            ['port' => 6, 'description' => 'AppUpdate', 'vlan' => 70],
            ['port' => 7, 'description' => 'Resiliant-Wifi', 'vlan' => 9],
        ]
    ]
]);
?>