<?php
require_once('session.php');
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
    header("HTTP/1.1 403 Forbidden");
    echo "Access forbidden. Use HTTPS.";
    exit();
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
	if (isset($_POST['csrf_token']) && hash_equals($_POST['csrf_token'], $_SESSION['csrf_token'])){
        
       if($u['cuid'] == 1){ 
        $livechat = $_POST['livechat'];
        $wa = $_POST['wa'];
        $telegram = $_POST['telegram'];
        $instagram = $_POST['instagram'];
        $facebook = $_POST['facebook'];
        $query = mysqli_query($conn,"UPDATE `tb_social` SET `livechat` = '$livechat', `wa` = '$wa', `telegram` = '$telegram', `instagram` = '$instagram', `facebook` = '$facebook' WHERE cuid = 1") or die(mysqli_error());
        header('location:../social/?notif=1');
    } else {
        echo 'BOKEP CXFTEAMS';
    }
} else {
    // Regenerate CSRF token on each form request
    $_SESSION['csrf_token'] = bin2hex(random_bytes(32));

    // CSRF token is invalid, handle the error
    echo "Ngapain Bang Ngetamper Data Kah?";
    exit();
}
}

?>