<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include("includes/function.php");

// Initialize success flag
$success = false;

// Use session database year if available
if (isset($_SESSION["zdbyear_" . $dbname])) {
    $zdb = $_SESSION["zdbyear_" . $dbname];
    mysqli_select_db($conn, $zdb);
}

// Only users with usertype = 3 are considered successful
if (isset($_SESSION["usertype"]) && $_SESSION["usertype"] == 3) {
    $success = true;
}

// Set response header and return JSON
header("Content-Type: application/json");
echo json_encode(['success' => $success]);
?>
