<?php
// ═══════════════════════════════════════════════════════════
// get_social_links.php — Widget এই API দিয়ে বর্তমান Link পড়ে।
// শুধু Read-Only, কোনো Sensitive Data নেই — Public হিসেবে
// Access করা নিরাপদ।
// ═══════════════════════════════════════════════════════════
include "conn.php";
header('Content-Type: application/json');

$links = ['telegram' => '#', 'facebook' => '#', 'whatsapp' => '#'];
$result = $conn->query("SELECT setting_key, setting_value FROM site_settings WHERE setting_key IN ('social_telegram','social_facebook','social_whatsapp')");
if ($result) {
    while ($row = $result->fetch_assoc()) {
        if ($row['setting_key'] === 'social_telegram' && !empty($row['setting_value'])) $links['telegram'] = $row['setting_value'];
        if ($row['setting_key'] === 'social_facebook' && !empty($row['setting_value'])) $links['facebook'] = $row['setting_value'];
        if ($row['setting_key'] === 'social_whatsapp' && !empty($row['setting_value'])) $links['whatsapp'] = $row['setting_value'];
    }
}
echo json_encode($links);
