<?php
// return a space delimited string containing names of available sessions
// (the instrumentDescriptor.xml files)

require("phpVars.php");


$dir=opendir($sessions_dir);
$dlist='';
$ltime=0; $latestName='n.a.';

while (!($filename= readdir($dir)) === FALSE) {
  if (!is_dir($sessions_dir . $filename)) {
     $apath=pathinfo($filename);
     $aext=$apath['extension'];
     $ttime=filectime($sessions_dir . $filename);
     if ($ttime > $ltime ) {
         $latestName=$apath['filename'];
         $ltime=$ttime;
     }
     if (strtoupper($aext)=='XML') {
//       $dlist=$dlist.' '.$apath['filename'];
       $dlist=$dlist.' '.$filename;

     }
  }
}
closedir($dir);
if (array_key_exists('latest',$_GET)) {
  $aa=$_GET['latest'];
  if ($aa=='1') {
    $dlist.= ' ; ' .  $latestName  ;
  }
}

header("Content-Type: text/plain");
print $dlist ;
?>