<?php
include "includes/db_connect.php";
include "includes/auth.php";
checkAdmin();

$msisdn = $_GET['msisdn'];
$action = $_GET['action'];

if ($action == 'block') {
    mysqli_query($conn,"
        INSERT INTO msisdn_kill_switch (msisdn,blocked,reason)
        VALUES ('$msisdn',1,'MANUAL_BLOCK')
        ON DUPLICATE KEY UPDATE blocked=1, reason='MANUAL_BLOCK', updated_at=NOW()
    ");
}

if ($action == 'unblock') {
    mysqli_query($conn,"
        UPDATE msisdn_kill_switch
        SET blocked=0, reason='MANUAL_UNBLOCK', updated_at=NOW()
        WHERE msisdn='$msisdn'
    ");
}

header("Location: limit_violations.php");
