<?php
session_start();
require_once 'config.php';
if (!isset($_SESSION['user_id'])) { header("Location: index.php"); exit; }

$s = $_GET['s'] ?? 'offline';
if (!in_array($s, ['online','offline','dnd'])) $s = 'offline';

$pdo->prepare("UPDATE users SET role_status = ? WHERE id = ?")->execute([$s, (int)$_SESSION['user_id']]);

$back = $_SERVER['HTTP_REFERER'] ?? 'index.php';
header("Location: $back");
exit;
?>
