Index: trunk/FACT++/www/viewer/index.php
===================================================================
--- trunk/FACT++/www/viewer/index.php	(revision 17726)
+++ trunk/FACT++/www/viewer/index.php	(revision 17727)
@@ -111,4 +111,5 @@
     switch ($format)
     {
+    case 'd': $size = 8; break;
     case 'L': $size = 4; break;
     case 'S': $size = 2; break;
@@ -143,11 +144,19 @@
 $filename = "/daq/raw/".$y."/".$m."/".$d."/".$y.$m.$d."_".$r.".fits.fz";
 
+if (!file_exists($filename))
+    return header("HTTP/1.0 400 File '".$file."' not found.");
+
 $file = popen("/home/fact/FACT++/getevent ".$filename." ".$event." 2> /dev/null", "r");
 if (!$file)
-    return header('HTTP/1.0 400 Could not open file.');
+    return header('HTTP/1.0 400 Could not open pipe.');
 
 $evt = array();
-
-$evt['numEvents']     = get($file, "L");
+$fil = array();
+
+$fil['runType']       = fread($file, 80);
+$fil['runStart']      = get($file, "d");
+$fil['runEnd']        = get($file, "d");
+$fil['drsFile']       = get($file, "s");
+$fil['numEvents']     = get($file, "L");
 $evt['numRoi']        = get($file, "L");
 $evt['numPix']        = get($file, "L");
@@ -161,5 +170,4 @@
     // Read the data and copy it from an associative array to an Array
     // (this is just nicer and seems more logical)
-    //$data   = array();
     $binary = array();
     for ($i=0; $i<$evt['numPix']; $i++)
@@ -176,15 +184,38 @@
 }
 
-//if (feof($file))
-//   return;
+if (feof($file))
+   return header('HTTP/1.0 400 Data from file incomplete.');
 
 pclose($file);
 
-if ($evt['numEvents']==0)
+if ($fil['numEvents']==0)
     return header('HTTP/1.0 400 Could not read event.');
 
-// =============================== Copy waveform =============================
-
+// =========================== Decode trigger type ===========================
+
+$typ = $evt['triggerType'];
+$evt['trigger'] = array();
+if ($typ!=0 && ($typ & 0x8703)==0)
+    array_push($evt['trigger'], "PHYS");
+if (($typ&0x0100)!=0)
+    array_push($evt['trigger'], "LPext");
+if (($typ&0x0200)!=0)
+    array_push($evt['trigger'], "LPint");
+if (($typ&0x0400)!=0)
+    array_push($evt['trigger'], "PED");
+if (($typ&0x8000)!=0)
+    array_push($evt['trigger'], "TIM");
+if (($typ&0x0001)!=0)
+    array_push($evt['trigger'], "EXT1");
+if (($typ&0x0002)!=0)
+    array_push($evt['trigger'], "EXT2");
+
+// =============================== Some data =================================
+
+require_once("neighbors.php");
+
+$rc['neighbors'] = $neighbors;
 $rc['event'] = $evt;
+$rc['file']  = $fil;
 $rc['event']['index'] = $event;
 $rc['event']['pixel'] = $pixel;
@@ -237,7 +268,12 @@
     //$v8->test   = array();;
     //$v8->data   = array();
-    $v8->event  = $evt;
-    $v8->clone  = function($data) { return $data; };
-    $v8->unpack = function($i)
+    $v8->nroi      = $evt['numRoi'];
+    $v8->npix      = $evt['numPix'];
+    $v8->trigger   = $evt['trigger'];
+    $v8->event     = $evt;
+    $v8->file      = $fil;
+    $v8->neighbors = $neighbors;
+    $v8->clone     = function($data) { return $data; };
+    $v8->unpack    = function($i)
     {
         global $binary, $roi;
