<?php
//    return an session's descriptor file (an xml file ). If &check=1, then check xml syntax first  and return html message
// if errors found. Else, return contents of file as is.

require("phpVars.php");

if (!array_key_exists('name',$_GET)) {
  header("Content-Type: text/plain");
  print 'Sorry. No NAME= argument in call to   returnSessDesc.php ';
  exit ;
}

$dafile=$sessions_dir . $_GET['name'] . '.XML' ;
$isfile=file_exists($dafile);
if (!$isfile) {
  header("Content-Type: text/plain");
  print "Sorry. No such session descriptor file $dafile  (returnSessDesc.php) ";
  exit ;
}

$stuff=file_get_contents($dafile);

if (array_key_exists('check',$_GET)) {
  if ($_GET['check']=='1') {
    $i=checkSyntaxXML($stuff,$dafile);
    if ($i!==0) {                                             // error detected: send error messages back
       echo $i;
       exit;
    }
  }
}

// no errors, or no checking: return file contents
header('Content-Type: text/xml; charset=iso-8859-1');
echo $stuff;
exit;


?>

