<?php

require 'header.php';

if ( !isset($_REQUEST['queue']) ) {
   exit();
}
$newtarget = intval($_REQUEST['queue']);

$query = "SELECT id FROM " . QUEUESTABLE . " WHERE id=:newtarget";
$fields = array();
$fields[':newtarget'] = $newtarget;
$sth = $globaldbh->prepare($query);
$sth->execute($fields);

if ( ($newtarget == 0) || (false !== ($row = $sth->fetch())) ) {
   $_SESSION['queuetarget'] = $newtarget;
}

header('Content-Type: application/json');
echo json_encode($_SESSION['queuetarget']);
exit();

?>