<?php
//    return an instrument'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('file',$_GET)) {
  header("Content-Type: text/plain");
  print 'Sorry. No FILE= argument in call to   returnInstDesc.php ';
  exit ;
}

$dafile=$instruments_dir . $_GET['file'];
$isfile=file_exists($dafile);
if (!$isfile) {
  header("Content-Type: text/plain");
  print "Sorry. No such instrument descriptor file $dafile  (returnInstDesc.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;


?>

