<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once __DIR__ . '/db.php';

$res = $conn->query("SELECT telegram_enabled FROM notification_settings WHERE id=1");
if (!$res || $res->num_rows == 0) {
    echo 'ERR';
    exit;
}

$row = $res->fetch_assoc();
$new = $row['telegram_enabled'] ? 0 : 1;

$conn->query("UPDATE notification_settings SET telegram_enabled=$new WHERE id=1");

if ($new === 1) {
    echo 'ON';
} else {
    echo 'OFF';
}
exit;