<?php

require "../header.php";

define("FAILED", true);

function sendResponse($error = false, $message = "") {
   global $data;
   $data["error"] = $error;
   if ( $error ) $data["message"] = $message;
   header('Content-Type: application/json');
   echo json_encode($data);
   exit();
}

$data = array();
$data["error"] = false;
$data["message"] = "";
$data["validated"] = $_SESSION["validated"];

if ( !isset($_REQUEST["id"]) ) sendResponse(FAILED, "Invalid request");
$id = intval($_REQUEST["id"]);
$image = new MTGImage($id);
if ( $image->getId() == 0 ) {
   $data["id"] = $id;
   sendResponse(FAILED, "Image Not Found");
}
$data["image"] = $image;

sendResponse();
