<?php
session_start();
include __DIR__ . '/../database/search_log_config.php';

if(!isset($_SESSION['admin_id'])){
    die("Unauthorized");
}

if(isset($_GET['ip'])){

    $ip = $_GET['ip'];

    // Prevent duplicate block
    $stmt = $log_conn->prepare("
        INSERT IGNORE INTO blocked_ips (ip_address)
        VALUES (?)
    ");
    $stmt->bind_param("s", $ip);
    $stmt->execute();
    $stmt->close();
}

header("Location: view_search_logs.php");
exit;
?>