}
                } else {
                    echo '<small><A href="JavaScript:compile(\'' . $opid . '\');">Uitvoeren</A></small>';
                }
            } else {
                echo '<small><A href="JavaScript:compile(\'' . $opid . '\');">Uitvoeren</A></small>';
            }
            echo '</SPAN></LI>';
        }
    }
    ?>
  </UL><br>
<?php 
} else {
    foreach (getEachOperatie() as $opid) {
        if ($op = readOperatie($opid)) {
            echo '<LI id="op' . $opid . '">' . $op->get_naam() . ': <i>geen script geladen</i> </LI>';
        }
    }
}
?>

  <P><textarea name="adltext" cols=100 rows=30><?php 
if ($file && !isset($_REQUEST['newFile'])) {
    //if () {  //user toevoegen aan meterkast.adl en juiste FILEPATH nemen.
    //} else {
    $i = 0;
    foreach (file(escapeshellcmd(FILEPATH . $file->getId() . '.adl')) as $line) {
        $i++;
        $line = preg_replace('/{-(\\d+)-}/', '', $line);
        echo '{-' . $i . '-}' . $line;
require "inc/Session.inc.php";
require "inc/Bestand.inc.php";
require "inc/Actie.inc.php";
require "inc/Operatie.inc.php";
require "inc/connectToDataBase.inc.php";
$ses = readSession($_SESSION["adlsessie"]) or exit('error:Cannot find session, ensure cookies are enabled');
//  if($ses->get_ip()!=$_SERVER['REMOTE_ADDR']){
//    exit('error:Cannot find a session for your IP, ensure cookies are enabled');
//  }
$file = readBestand($ses->get_file()) or exit('error:Cannot find the file to compile. Upload a file first');
if (!isset($_REQUEST['op'])) {
    exit('error:Variable \'op\' not given');
} else {
    $op = $_REQUEST['op'];
}
$opr = readOperatie($op) or exit('error:Operation op=\'' . $op . '\' unknown');
$target = escapeshellcmd(COMPILATIONS_PATH . $file->getId() . '_' . $op . '/');
$source = escapeshellcmd(FILEPATH . $file->getId() . '.adl');
$compileurl = '' . sprintf($opr->get_outputURL(), $target, $source, $file->getId(), USER);
//  function ok($i){
//    return '<A HREF="'.COMPILATIONS_PATH.$i.'/"><IMG SRC="'.IMGPATH.'ok.png" /></A>';
//  }
//  foreach($file->get_compilations() as $c){
//    if($op==$c['operatie']){
//      // check the progress of the compilation
//     if ($c->get_compiled()){
//        exit('ok:'.linkoutput($compileurl)); //the command output and error streams will disappear from screen
//      }else{
//        sleep(5); // wait some time before checking again
//        exit('hold:op='.$op);
//      }
}
$buttons = "";
if (isset($_REQUEST['new'])) {
    $new = true;
} else {
    $new = false;
}
if (isset($_REQUEST['edit']) || $new) {
    $edit = true;
} else {
    $edit = false;
}
$del = isset($_REQUEST['del']);
if (isset($_REQUEST['Operatie'])) {
    if (!$del || !delOperatie($_REQUEST['Operatie'])) {
        $Operatie = readOperatie($_REQUEST['Operatie']);
    } else {
        $Operatie = false;
    }
    // delete was a succes!
} else {
    if ($new) {
        $Operatie = new Operatie();
    } else {
        $Operatie = false;
    }
}
if ($Operatie) {
    writeHead("<TITLE>Operatie - Meterkast - ADL Prototype</TITLE>" . ($edit ? '<SCRIPT type="text/javascript" src="js/edit.js"></SCRIPT>' : '<SCRIPT type="text/javascript" src="js/navigate.js"></SCRIPT>') . "\n");
    if ($edit) {
        echo '<FORM name="editForm" action="' . $_SERVER['PHP_SELF'] . '" method="POST" class="Edit">';