<?php
ini_set('display_errors', '0');
error_reporting(0);

define('SECURE_ACCESS', true);
$_SERVER['REQUEST_METHOD'] = 'POST';

require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/auth.php';

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
$_SESSION['user_id'] = 1;
$_SESSION['username'] = 'admin';
$_SESSION['role'] = 'admin';
$_SESSION['csrf_token'] = 'dummy_token';

$restore_file = $argv[1] ?? '';

$_POST['csrf_token'] = 'dummy_token';
$_FILES['backup_file'] = [
    'name' => 'backup_test.sql',
    'type' => 'application/sql',
    'tmp_name' => $restore_file,
    'error' => UPLOAD_ERR_OK,
    'size' => filesize($restore_file)
];

include __DIR__ . '/../api/db_restore.php';
