'Access denied. Admin key required.'])); // } $con = Database::get('main'); $name = filterRequest('name') ?: 'Super Admin'; $email = filterRequest('email') ?: ''; $phone = filterRequest('phone') ?: ''; $fingerprint = filterRequest('fingerprint') ?: ''; $password = filterRequest('password') ?: bin2hex(random_bytes(8)); try { $hashedPass = password_hash($password, PASSWORD_DEFAULT); $encName = $encryptionHelper->encryptData($name); $encPhone = $phone ? $encryptionHelper->encryptData($phone) : ''; $encEmail = $email ? $encryptionHelper->encryptData($email) : ''; $encFp = $fingerprint ? $encryptionHelper->encryptData($fingerprint) : ''; $fpHash = $fingerprint ? hash('sha256', $fingerprint) : ''; $uniqueId = bin2hex(random_bytes(16)); $check = $con->prepare("SELECT id FROM adminUser WHERE role = 'super_admin' LIMIT 1"); $check->execute(); if ($check->fetch()) { echo "

⚠️ Super Admin already exists.

"; exit; } $sql = "INSERT INTO adminUser (id, fingerprint, fingerprint_hash, name, phone, email, password, role, created_at) VALUES (:id, :fp, :fp_hash, :name, :phone, :email, :pass, 'super_admin', NOW())"; $stmt = $con->prepare($sql); $stmt->execute([ ':id' => $uniqueId, ':fp' => $encFp, ':fp_hash' => $fpHash, ':name' => $encName, ':phone' => $encPhone, ':email' => $encEmail, ':pass' => $hashedPass, ]); if ($stmt->rowCount() > 0) { echo "

✅ Super Admin created successfully!

"; echo "

ID: $uniqueId

"; echo "

Name: $name

"; echo "

Password: $password

"; echo "

⚠️ Save this password. Delete this file after use.

"; } else { echo "

❌ Failed to create Super Admin.

"; } } catch (Exception $e) { echo "

❌ Error: " . htmlspecialchars($e->getMessage()) . "

"; }