<?php
session_start();

if (!isset($_SESSION['eggzie_iboPlayer'])) {
    header('Location: login.php');
    exit();
}

$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$origem = isset($_GET['from']) ? $_GET['from'] : 'meus_clientes';
$redirect = $origem === 'users' ? 'users.php' : 'meus_clientes.php';

if ($id > 0) {
    $db = new SQLite3(__DIR__ . '/a/.eggziedb.db');
    $stmt = $db->prepare('DELETE FROM ibo WHERE id = :id');

    if ($stmt) {
        $stmt->bindValue(':id', $id, SQLITE3_INTEGER);
        $stmt->execute();
    }

    $db->close();
}

header('Location: ' . $redirect);
exit();
?>
