commit d072e29ccf3c26d4a83677129c57b85ed93274b0
Author: Florent Chuffart <florent.chuffart@ens-lyon.fr>
Date:   Mon Sep 30 16:14:49 2013 +0200

    Adding main features, still working on TODOs and cosmetics.

diff --git a/README b/README
index 5877188..2a65019 100644
--- a/README
+++ b/README
@@ -63,7 +63,70 @@ Links
 Installation
 ------------
 
-...
+rsync -cauvz  --exclude="formatdb.log" --exclude=".DS_Store" ../src/ root@cremone:/var/www/labstocks/
+
+cd /var/www/labstocks
+# sudo vi connect_entry.php 
+sudo touch formatdb.log
+sudo chmod 440 connect_entry.php 
+sudo chown -R www-data:www-data connect_entry.php formatdb.log  plasmid_files raw_dirs
+
+
+Migration
+cd /var/www/labstocks
+sudo cp -r ../labstocks.bck2/plasmid_files/*.gb.gz plasmid_files/.
+sudo chmod -R a+r plasmid_files
+sudo chown -R www-data:www-data plasmid_files
+sudo cp -r ../labstocks.bck2/collections collections/.
+cd raw_dirs/antibodies/
+sudo mkdir `for ((a=1; a <= 24 ; a++)); do echo $a ; done`
+cd ../..
+sudo cp ../labstocks.bck2/antibody_files/10.Anti-H3K14ac\(07-353\).pdf                raw_dirs/antibodies/10/Anti-H3K14ac\(07-353\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/11.Anti-H3ac\(06-599\).pdf                   raw_dirs/antibodies/11/Anti-H3ac\(06-599\).pdf                               
+sudo cp ../labstocks.bck2/antibody_files/12.Anti-H3\(ab1791\).pdf                     raw_dirs/antibodies/12/Anti-H3\(ab1791\).pdf                                 
+sudo cp ../labstocks.bck2/antibody_files/13.Anti-FLAG\(F7425\).pdf                    raw_dirs/antibodies/13/Anti-FLAG\(F7425\).pdf                                
+sudo cp ../labstocks.bck2/antibody_files/14.Cre-Recombinase\(PRB-106C\).pdf           raw_dirs/antibodies/14/Cre-Recombinase\(PRB-106C\).pdf                        
+sudo cp ../labstocks.bck2/antibody_files/15.GAPDH-HRP\(ab85760\).pdf                  raw_dirs/antibodies/15/GAPDH-HRP\(ab85760\).pdf                              
+sudo cp ../labstocks.bck2/antibody_files/16.Anti-H3K9ac\(ab10812\).pdf                raw_dirs/antibodies/16/Anti-H3K9ac\(ab10812\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/17.Anti-H3K4me3\(CS-003-100\).pdf            raw_dirs/antibodies/17/Anti-H3K4me3\(CS-003-100\).pdf                         
+sudo cp ../labstocks.bck2/antibody_files/18.Anti-H3\(ab1791\).pdf                     raw_dirs/antibodies/18/Anti-H3\(ab1791\).pdf                                 
+sudo cp ../labstocks.bck2/antibody_files/19.Anti-H3K4me1\(07-436\).pdf                raw_dirs/antibodies/19/Anti-H3K4me1\(07-436\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/1.Anti-Actin-C4\(69100\).pdf                 raw_dirs/antibodies/1/Anti-Actin-C4\(69100\).pdf                             
+sudo cp ../labstocks.bck2/antibody_files/20.Anti-H3K14ac\(07-353\).pdf                raw_dirs/antibodies/20/Anti-H3K14ac\(07-353\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/21.Anti-H4K12ac\(07-595\).pdf                raw_dirs/antibodies/21/Anti-H4K12ac\(07-595\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/22.Anti-Htz1\(39647\).pdf                    raw_dirs/antibodies/22/Anti-Htz1\(39647\).pdf                                
+sudo cp ../labstocks.bck2/antibody_files/23.Anti-H2AFZ\(ab4626\).pdf                  raw_dirs/antibodies/23/Anti-H2AFZ\(ab4626\).pdf                              
+sudo cp ../labstocks.bck2/antibody_files/24.Anti-LexA-DBD\(39185\).pdf                raw_dirs/antibodies/24/Anti-LexA-DBD\(39185\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/2.Anti-Myc\(06-340\).pdf                     raw_dirs/antibodies/2/Anti-Myc\(06-340\).pdf                                 
+sudo cp ../labstocks.bck2/antibody_files/3.Anti-H3\(ab10799\).pdf                     raw_dirs/antibodies/3/Anti-H3\(ab10799\).pdf                                 
+sudo cp ../labstocks.bck2/antibody_files/4.Anti-H3\(ab24834\).pdf                     raw_dirs/antibodies/4/Anti-H3\(ab24834\).pdf                                 
+sudo cp ../labstocks.bck2/antibody_files/5.Anti-H3K4me2\(ab7766\).pdf                 raw_dirs/antibodies/5/Anti-H3K4me2\(ab7766\).pdf                             
+sudo cp ../labstocks.bck2/antibody_files/6.Anti-H3K4me3\(ab8580\).pdf                 raw_dirs/antibodies/6/Anti-H3K4me3\(ab8580\).pdf                             
+sudo cp ../labstocks.bck2/antibody_files/7.Anti-H3K27me3\(07-449\).pdf                raw_dirs/antibodies/7/Anti-H3K27me3\(07-449\).pdf                            
+sudo cp ../labstocks.bck2/antibody_files/8.Anti-H4K12ac\(06-761\).pdf                 raw_dirs/antibodies/8/Anti-H4K12ac\(06-761\).pdf                             
+sudo cp ../labstocks.bck2/antibody_files/9.Beta-Actin-AC74\(A2228\).pdf               raw_dirs/antibodies/9/Beta-Actin-AC74\(A2228\).pdf                           
+sudo chmod -R a+r raw_dirs
+sudo chown -R www-data:www-data raw_dirs
+# upload gene_synthesis_reports_pGY247.zip and gene_synthesis_reports_pGY248.zip
+
+
+
+
+
+scp -r stainer:Desktop/LBMC/projects/plasmapper/src/plasmid_files labstocks
+vi labstocks/connect_entry.php
+sudo cp -r labstocks /var/www/
+sudo chmod 440 /var/www/labstocks/connect_entry.php 
+sudo chown www-data:www-data /var/www/labstocks/connect_entry.php
+sudo chown -R www-data:www-data /var/www/labstocks/plasmid_files
+sudo chown -R www-data:www-data /var/www/labstocks/raw_dirs
+sudo touch /var/www/labstocks/formatdb.log
+sudo chown www-data:www-data /var/www/labstocks/formatdb.log
+
+
+
+
+
 
 Usage
 =====
@@ -73,3 +136,19 @@ fields `locus1`, `locus2`, `locus3`, `locus4`, `locus5`, `ADE2`, `HIS3`, `LEU2`,
 `LYS2`, `MET15`, `TRP1`, `URA3`, `HO_`, `Cytoplasmic_Character` or 
 `extrachromosomal_plasmid` contain the given expression. This filter is case 
 insensitive.
+
+Even in edit mode, users are not granted permission to directly edit a plasmid 
+sequence, nor the URL to the plasmid sequence file. If a new sequence must be 
+entered instead of the current one, users must upload a new sequence file, in 
+.gb or .gb.gz format. MyLabStocks then automatically reads the file and update 
+the sequence field and the URL. This ensures consistency between URL, sequence 
+and the file itself.
+
+TODO
+====
+
+  - Upload a .gb file, gzip it on fly for plasmids.
+  - Bug with plasmid 246, having a look on log file: tail -f /var/log/tomcat6/catalina.out
+  - Add persistence on advanced search form conditions.
+  - Remove file field for antibodies
+  - More error msg when an uploaded file is too big. (>2Mo).
\ No newline at end of file
diff --git a/src/admin.php b/src/admin.php
new file mode 100644
index 0000000..b64b1d1
--- /dev/null
+++ b/src/admin.php
@@ -0,0 +1,248 @@
+<?php
+session_start ();
+require("headers.php");
+
+
+
+if (! defined('PHP_EOL')) {
+	define('PHP_EOL', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? "\r\n"
+			: strtoupper(substr(PHP_OS, 0, 3) == 'MAC') ? "\r" : "\n");
+}
+
+$hn = SERVEUR;
+$un = NOM;
+$pw = PASSE;
+$db = BASE;
+$submit        = "Submit";
+$options       = 1;
+$baseFilename  = $tb;
+$pageTitle     = $tb;
+
+if (@$_REQUEST["action"] == "CHANGE_TB") {
+  $_SESSION["tb"] = $_REQUEST["tb"];
+} else {
+  if (!isset($_SESSION["tb"])) {
+    $_SESSION["tb"] = "lab_members";
+  }
+}
+$tb = $_SESSION["tb"];
+
+$phpExtension = '.php';
+if (isset($baseFilename) && $baseFilename != '') {
+	$phpFile = $baseFilename.$phpExtension;
+	//$contentFile = $baseFilename.'Content.inc';
+	$contentFile = $baseFilename.'.php';
+} elseif (isset($tb)) {
+	$phpFile = $tb.$phpExtension;
+	//$contentFile = $tb.'Content.inc';
+	$contentFile = $tb.'.php';
+} else {
+	$phpFile = 'index'.$phpExtension;
+	//$contentFile = 'Content.inc';
+	$contentFile = 'phpMyEdit-content.php';
+}
+
+$buffer = '';
+
+function echo_buffer($x)
+{
+	global $buffer;
+	$buffer .= $x.PHP_EOL;
+}
+
+function check_constraints($tb,$fd)
+{
+  $query    = "show create table $tb";
+  $result   = mysql_query($query);
+  $tableDef = preg_split('/\n/',mysql_result($result,0,1));
+
+  $constraint_arg="";
+  while (list($key,$val) = each($tableDef)) {
+    $words=preg_split("/[\s'`()]+/", $val);
+    if ($words[1] == "CONSTRAINT" && $words[6]=="REFERENCES") {
+      if ($words[5]==$fd) {
+        $constraint_arg="  'values' => array(\n".
+                        "    'table'  => '$words[7]',\n".
+                        "    'column' => '$words[8]'\n".
+                        "  ),\n";
+      }
+
+    }
+  }
+  return $constraint_arg;
+}
+
+$self = basename($_SERVER['PHP_SELF']);
+$dbl  = @mysql_pconnect($hn, $un, $pw);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$select_tb = "<form action='admin.php' method='POST'>";
+$select_tb .= "<input type='hidden' name='action' value='CHANGE_TB'/>";
+$select_tb .= "<select name='tb'>";
+$tbs     = @mysql_list_tables($db, $dbl);
+$num_tbs = @mysql_num_rows($tbs);
+for ($j = 0; $j < $num_tbs; $j++) {
+	$tb_choice = @mysql_tablename($tbs, $j);
+  $tb_choice = htmlspecialchars($tb_choice);
+  $checked = $tb_choice == $tb ? ' selected="selected" ' : '';
+	$select_tb .= "<option value='$tb_choice' $checked>$tb_choice</option>";
+}
+$select_tb .= "</select>";
+$select_tb .= "<input type='Submit' name='Submit' value='Show this table' />";
+$select_tb .= "</form>";
+
+echo $select_tb;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@mysql_select_db($db);
+$tb_desc = @mysql_query("DESCRIBE $tb");
+$fds     = @mysql_list_fields($db,$tb,$dbl);
+$j = 0; 
+$fd = @mysql_field_name($fds, $j);
+$ff = @mysql_field_flags($fds, $j);
+
+if (!stristr($ff, 'primary_key')) {
+  echo "ERROR, first field is not a primary_key.";
+  exit();
+}
+
+$id = htmlspecialchars($fd);
+
+{
+	echo_buffer("
+// MySQL host name, user name, password, database, and table
+\$opts['hn'] = '$hn';
+\$opts['un'] = '$un';
+\$opts['pw'] = '$pw';
+\$opts['db'] = '$db';
+\$opts['tb'] = '$tb';
+
+// Name of field which is the unique key
+\$opts['key'] = '$id';
+
+// Type of key field (int/real/string/date etc.)");
+
+	if ($id == '') {
+		echo_buffer("\$opts['key_type'] = '';");
+	} else {
+		$fds = @mysql_list_fields($db,$tb,$dbl);
+		for ($j = 0; ($fd = @mysql_field_name($fds, $j)) != ''; $j++) {
+			if ($fd == $id) {
+				echo_buffer("\$opts['key_type'] = '".@mysql_field_type($fds, $j)."';");
+				break;
+			}
+		}
+	}
+	echo_buffer("
+// Sorting field(s)
+\$opts['sort_field'] = array('$id');
+
+// Options you wish to give the users
+// A - add,  C - change, P - copy, V - view, D - delete,
+// F - filter, I - initial sort suppressed
+\$opts['options'] = \$privopt;
+");
+
+	@mysql_select_db($db);
+	$tb_desc = @mysql_query("DESCRIBE $tb");
+	$fds     = @mysql_list_fields($db, $tb, $dbl);
+	$num_fds = @mysql_num_fields($fds);
+	$ts_cnt  = 0;
+	for ($k = 0; $k < $num_fds; $k++) {
+		$fd = mysql_field_name($fds,$k);
+		$fm = mysql_fetch_field($fds,$k);
+		$fn = strtr($fd, '_-.', '   ');
+		$fn = preg_replace('/(^| +)id( +|$)/', '\\1ID\\2', $fn); // uppercase IDs
+		$fn = ucfirst($fn);
+		$row = @mysql_fetch_array($tb_desc);
+		echo_buffer('$opts[\'fdd\'][\''.$fd.'\'] = array('); // )
+		echo_buffer("  'name'     => '".str_replace('\'','\\\'',$fn)."',");
+		$auto_increment = strstr($row[5], 'auto_increment') ? 1 : 0;
+		if (substr($row[1],0,3) == 'set') {
+			echo_buffer("  'select'   => 'M',");
+		} else {
+			echo_buffer("  'select'   => 'T',");
+		}
+		if ($auto_increment) {
+			echo_buffer("  'options'  => 'AVCPDR', // auto increment");
+		}
+		// timestamps are read-only
+		else if (@mysql_field_type($fds, $k) == 'timestamp') {
+			if ($ts_cnt > 0) {
+				echo_buffer("  'options'  => 'AVCPD',");
+			} else { // first timestamp
+				echo_buffer("  'options'  => 'AVCPDR', // updated automatically (MySQL feature)");
+			}
+			$ts_cnt++;
+		}
+		echo_buffer("  'maxlen'   => ".@mysql_field_len($fds,$k).',');
+		// blobs -> textarea
+		if (@mysql_field_type($fds,$k) == 'blob') {
+			echo_buffer("  'textarea' => array(");
+			echo_buffer("    'rows' => 5,");
+			echo_buffer("    'cols' => 50),");
+		}
+		// SETs and ENUMs get special treatment
+		if ((substr($row[1],0,3) == 'set' || substr($row[1],0,4) == 'enum')
+				&& ! (($pos = strpos($row[1], '(')) === false)) {
+			$indent = str_repeat(' ', 18);
+			$outstr = substr($row[1], $pos + 2, -2);
+			$outstr = explode("','", $outstr);
+			$outstr = str_replace("''", "'",  $outstr);
+			$outstr = str_replace('"', '\\"', $outstr);
+			$outstr = implode('",'.PHP_EOL.$indent.'"', $outstr);
+			echo_buffer("  'values'   => array(".PHP_EOL.$indent.'"'.$outstr.'"),');
+		}
+		// automatic support for Default values
+		if ($row[4] != '' && $row[4] != 'NULL') {
+			echo_buffer("  'default'  => '".$row[4]."',");
+		} else if ($auto_increment) {
+			echo_buffer("  'default'  => '0',");
+		}
+		// check for table constraints
+		$outstr = check_constraints($tb, $fd);
+		if ($outstr != '') {
+			echo_buffer($outstr);
+		}
+		echo_buffer("  'sort'     => true");
+		//echo_buffer("  'nowrap'   => false,");
+		echo_buffer(');');
+	}
+
+   
+  eval($buffer);
+
+}
+
+require("footers.php");
+?>
diff --git a/src/antibodies.php b/src/antibodies.php
index e7dc926..0457f07 100644
--- a/src/antibodies.php
+++ b/src/antibodies.php
@@ -18,7 +18,6 @@ require("headers.php");
  *              generating setup script: 1.50
  */
 
-	
 /*************************/
 //
 // Pass phpMyEdit options
@@ -238,10 +237,8 @@ $opts['fdd']['DataSheet']['URL'] = '$value';
 $opts['fdd']['DataSheet']['URLprefix'] = 'antibody_files/';
 $opts['fdd']['DataSheet']['URLtarget'] = '_self';
 
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
-
+// TRIGGER
+// Before displaying the view page
 
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/connect_entry.php b/src/connect_entry.php
index d62edee..d413011 100644
--- a/src/connect_entry.php
+++ b/src/connect_entry.php
@@ -5,6 +5,7 @@ define ('SERVEUR', "localhost");
 define ('BASE', "gylab_stocks");
 define ('PLASMAPPER_HOME', "/var/lib/tomcat6/webapps/PlasMapper/");
 define ('PLASMAPPER_SERVER', "http://" . $_SERVER["HTTP_HOST"] . ":8080/PlasMapper/");
+define ('LABSTOCK_SERVER', "http://" . $_SERVER["HTTP_HOST"] . "/labstocks/");
 define ('WWWBLAST_SERVER', "http://" . $_SERVER["HTTP_HOST"] . "/blast/");
 define ('BLAST_HOME', "/var/www/blast/db/");
 define ('FORMATDB_CMD', "formatdb");
diff --git a/src/footers.php b/src/footers.php
new file mode 100644
index 0000000..88c63e3
--- /dev/null
+++ b/src/footers.php
@@ -0,0 +1,121 @@
+<?php
+// TRIGGER
+$opts['triggers']['select']['pre'][] = 'last_trigger.MVC.php';
+$opts['triggers']['update']['pre'][] = 'last_trigger.MVC.php';
+
+array_unshift($opts['triggers']['select']['pre'], 'raw_dir.MVC.php');
+array_unshift($opts['triggers']['update']['pre'], 'raw_dir.MVC.php');
+
+// Now important call to phpMyEdit
+require_once 'phpMyEdit.class.php';
+$pme_instance = new phpMyEdit($opts);
+
+
+if (!array_key_exists("PME_sys_operation", $_REQUEST)) {
+  $tmp_array = $pme_instance->fds;
+  if ($tb == "strains") {
+    array_unshift($tmp_array, "Genotype");
+  }
+  $json_cols = json_encode($tmp_array);
+  $adv_search = <<<EOD
+    <div id="adv_search">
+    <form action="">
+    <table id="adv_search_table">
+    </table>
+    <input type="hidden" name="action" value="ADV_SEARCH"/>
+    <input type="submit" value="Search"/>
+    </form>
+    </div>  
+
+    <script type="text/javascript"> 
+    nb_filter = 0;
+    function filter() {
+      var self = this;
+      cols = $json_cols;
+      conds = ["LIKE", "=", "<", "<=", ">=", ">", "!="];
+      ops = ["AND", "OR"];
+      table = document.getElementById("adv_search_table");
+      this.tmp_tr = document.createElement("tr");
+      table.appendChild(this.tmp_tr);
+      tmp_td = document.createElement("td");
+      if (nb_filter != 0) {
+        tmp_select = document.createElement("select")
+        tmp_select.setAttribute('name', 'op' + '_' + nb_filter)
+        ops.forEach(function(op) {
+          tmp_option = document.createElement("option");
+          tmp_option.appendChild(document.createTextNode(op));
+          tmp_select.appendChild(tmp_option);
+          });
+        tmp_td.appendChild(tmp_select);
+      }
+      this.tmp_tr.appendChild(tmp_td)
+      tmp_select = document.createElement("select")
+      tmp_select.setAttribute('name', 'col' + '_' + nb_filter)
+      cols.forEach(function(col) {
+        tmp_option = document.createElement("option");
+        tmp_option.appendChild(document.createTextNode(col));
+        tmp_select.appendChild(tmp_option);
+        });
+      tmp_td = document.createElement("td");
+      tmp_td.appendChild(tmp_select);
+      this.tmp_tr.appendChild(tmp_td)
+      tmp_select = document.createElement("select")
+      tmp_select.setAttribute('name', 'cond' + '_' + nb_filter)
+      conds.forEach(function(cond) {
+        tmp_option = document.createElement("option");
+        tmp_option.appendChild(document.createTextNode(cond));
+        tmp_select.appendChild(tmp_option);
+      });
+      tmp_td = document.createElement("td");
+      tmp_td.appendChild(tmp_select);
+      this.tmp_tr.appendChild(tmp_td)
+      tmp_input = document.createElement("input")
+      tmp_input.setAttribute('name', 'input' + '_' + nb_filter)
+      tmp_td = document.createElement("td");
+      tmp_td.appendChild(tmp_input);
+      this.tmp_tr.appendChild(tmp_td)
+      tmp_td = document.createElement("td");
+      tmp_td.innerHTML = "<input type='button' onclick='new filter();return false;' value='+'/>"
+      if (nb_filter != 0) {      
+        tmp_input = document.createElement("input");
+        tmp_input.setAttribute('value', '-');
+        tmp_input.setAttribute('type', 'button');
+        tmp_input.setAttribute('value', '-');
+        tmp_input.onclick = function(){self.tmp_tr.parentNode.removeChild(self.tmp_tr); return false;};
+        tmp_td.appendChild(tmp_input);
+      }
+      this.tmp_tr.appendChild(tmp_td);
+      nb_filter++;
+    }
+    new filter();
+    </script>
+EOD;
+
+  $to_be_pre_list_content .= $adv_search;
+}
+
+// echo "<pre>";
+// print_r(json_encode($pme_instance->fds));
+// echo "</pre>";
+
+echo <<<EOD
+<div id="to_be_pre_list">
+  $to_be_pre_list_content
+</div>
+EOD;
+?>
+
+<div id="post_list"></div>
+
+<script type="text/javascript"> 
+q = document.getElementById("to_be_post_list");
+if (q != null) {
+  o = document.getElementById("post_list");
+  o.appendChild(q.parentNode.removeChild(q));
+}
+q = document.getElementById("to_be_pre_list");
+if (q != null) {
+  o = document.getElementById("pre_list");
+  o.appendChild(q.parentNode.removeChild(q));
+}
+</script>
\ No newline at end of file
diff --git a/src/headers.php b/src/headers.php
index 408a89a..baa84dd 100644
--- a/src/headers.php
+++ b/src/headers.php
@@ -78,7 +78,8 @@ td.pme-stats   { text-align: right;  }
     <li id="wwwblast"><a href="wwwblast.php"> wwwBlast </a></li>
     <li id="antibodies"><a href="antibodies.php"> Antibodies </a></li>
     <li id="collections"><a href="collections.php"> Collections </a></li>
-    <li id="pipethistory"><a href="pipethistory.php"> Pipet History </a></li>
+    <li id="pip_stock"><a href="pip_stock.php"> Pipets </a></li>
+    <li id="pip_history"><a href="pip_history.php"> Pipet History </a></li>
     <li id="notebooks"><a href="notebooks.php"> Lab's Notebooks </a></li>
     <li id="logout"><a href="logout.php"> Logout </a></li>
     <li id="admin"><a href="admin.php"> Admin </a></li>
@@ -95,9 +96,15 @@ document.getElementById(id).setAttribute("class","active");
 </script>
 
 
+
 <?php
 
-$tb = split(".",array_reverse(split("/",$_SERVER["SCRIPT_FILENAME"]))[0])[0]
+$to_be_post_list_content = "";
+$to_be_pre_list_content = "";
+// print($_SERVER["SCRIPT_FILENAME"]);
+
+
+$tb = array_shift(split("\.php", array_pop(split("/", $_SERVER["SCRIPT_FILENAME"]))));
 /*************************/
 //
 // Connect to DB and 
@@ -106,7 +113,7 @@ $tb = split(".",array_reverse(split("/",$_SERVER["SCRIPT_FILENAME"]))[0])[0]
 /*************************/
 
 require_once ("connect_entry.php");
-require_once ("session.php");
+require_once ("lib/session.lib.php");
 // connect to DB
 $connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
 if (!$connexion)
@@ -119,52 +126,127 @@ if (!mysql_select_db (BASE, $connexion))
  echo "Sorry, connexion to database " . BASE . " failed\n";
  exit;
 }
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("antibodies.php", $_POST, session_id(), $connexion);
-if (!is_object($session)) {
-	exit;
+
+if (!(in_array($tb, array("home", "")))) {
+  // authentification
+  CleanOldSessions($connexion);
+  $session = control_access ($tb.".php", $_POST, session_id(), $connexion);
+  if (!is_object($session)) {
+  	exit;
+  }
+
+  // According to login:
+  // Define priviledge options
+  // to pass to phpMyEdit
+  //
+  //check that visitor is allowed to use this table
+  if ($tb == "admin" && $session->mode != "super") {
+    echo "<p>Sorry, your session is not granted access to admin panel. Please logout and try again with appropriate login...</p>";
+    exit;
+  } else if ($session->target_table != $tb && $session->target_table != "all") {
+    echo "<p>Sorry, your session is not granted access to table <B> $tb </B> in <B>$session->mode</B> mode (login must be <b>$session->mode$tb</b>). Please logout and try again with appropriate login...</p>";
+    exit;
+  }
+  //define priv options and display warning accordingly
+  if ($session->login == "superuser"){
+  	$privopt = 'ACPVDF';
+  	$colorband = "red";
+  	$messageband = '<blink>WARNING</bink>: You are in <I><B> SUPERUSER </I></B> mode, at your own risk.';
+  } else if ($session->mode == "view"){
+  	$privopt = 'VF';
+  	$colorband = "#00ff00";
+  	$messageband = "You are safely in VIEW mode";
+  } else if ($session->mode == "add"){
+  	$privopt = 'APVF';
+  	$colorband = "orange";
+  	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
+  } else if ($session->mode == "edit"){
+  	$privopt = 'ACPVDF';
+  	$colorband = "rgb(250,0,255)";
+  	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
+  } else{
+  	$privopt = '';
+  	$colorband = "grey";
+  }
+  echo '<style type="text/css"> ';
+  echo	"h4 {background-color: $colorband }";
+  echo '</style>';
+  echo "<h4> $messageband </h4>";
+  echo "<HR>";
 }
+// Fix a problem displaying
+// symbols (such as delta)
+mysql_query("SET NAMES 'UTF8'", $connexion);
+
+// // Include My own MVC (FCh.)
+// $mvc_filename = $tb . ".MVC.php";
+// if (file_exists($mvc_filename)) {
+//   require($mvc_filename);
+// } 
+
+// Number of records to display on the screen
+// Value of -1 lists all records in a table
+$opts['inc'] = 15;
+
+// Number of lines to display on multiple selection filters
+$opts['multiple'] = '4';
+
+// Navigation style: B - buttons (default), T - text links, G - graphic links
+// Buttons position: U - up, D - down (default)
+$opts['navigation'] = 'UDBG';
+
+// Display special page elements
+$opts['display'] = array(
+	'form'  => true,
+	'query' => true,
+	'sort'  => true,
+	'time'  => true,
+	'tabs'  => true
+);
+
+// Set default prefixes for variables
+$opts['js']['prefix']               = 'PME_js_';
+$opts['dhtml']['prefix']            = 'PME_dhtml_';
+$opts['cgi']['prefix']['operation'] = 'PME_op_';
+$opts['cgi']['prefix']['sys']       = 'PME_sys_';
+$opts['cgi']['prefix']['data']      = 'PME_data_';
+
+/* Get the user's default language and use it if possible or you can
+   specify particular one you want to use. Refer to official documentation
+   for list of available languages. */
+$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
 
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
+?>
 
-//check that visitor is allowed to use this table
-if ($session->target_table != $tb && $session->target_table != "all") {
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
 
-//define priv options and display warning accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
+<div id="pre_list"></div>
+
+<?php
+
+// MVC for ADV_SEARCH
+if (array_key_exists("action", $_REQUEST)) {
+  if ($_REQUEST["action"] == "ADV_SEARCH") {
+    $fltr = "";
+    $cols = preg_filter("/col_/","", array_keys($_REQUEST));
+    foreach ($cols as $index) {
+      if ($index != 0) {
+        $fltr .= " " . $_REQUEST["op_$index"];
+      }
+      if ($_REQUEST["col_$index"] == "Genotype") {
+        $k = $_REQUEST["input_$index"];
+        $fltr .= " (`locus1` LIKE '%$k%' OR `locus2` LIKE '%$k%' OR `locus3` LIKE '%$k%' OR `locus4` LIKE '%$k%' OR `locus5` LIKE '%$k%' OR `ADE2` LIKE '%$k%' OR `HIS3` LIKE '%$k%' OR `LEU2` LIKE '%$k%' OR `LYS2` LIKE '%$k%' OR `MET15` LIKE '%$k%' OR `TRP1` LIKE '%$k%' OR `URA3` LIKE '%$k%' OR `HO_` LIKE '%$k%' OR `Cytoplasmic_Character` LIKE '%$k%' OR `extrachromosomal_plasmid` LIKE '%$k%')";
+      } else {
+        $fltr .= " " . $_REQUEST["col_$index"];
+        $fltr .= " " . $_REQUEST["cond_$index"];
+        if ($_REQUEST["cond_$index"] == "LIKE") {
+          $fltr .= " '%" . $_REQUEST["input_$index"] . "%'";                    
+        } else {
+          $fltr .= " '" . $_REQUEST["input_$index"] . "'";          
+        }
+      }
+    }
+    $opts["filters"] = $fltr;
+  }
 }
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-?>
 
+?>
diff --git a/src/home.php b/src/home.php
index 5fbfb67..22923e4 100644
--- a/src/home.php
+++ b/src/home.php
@@ -2,10 +2,15 @@
 session_start ();
 require("headers.php");
 ?>
+
 <p>Welcome to <b>GY lab stocks</b>. This web application allows you to manage, sort and filter the stocks of your lab. It is composed of several sections related to different parts of your stocks.
 
 <pre>
-[TODO] HERE IS A FUNNY PICTURE...
+  `-:-.   ,-;"`-:-.   ,-;"`-:-.   ,-;"`-:-.   ,-;"
+     `=`,'=/     `=`,'=/     `=`,'=/     `=`,'=/
+       y==/        y==/        y==/        y==/
+     ,=,-<=`.    ,=,-<=`.    ,=,-<=`.    ,=,-<=`.
+  ,-'-'   `-=_,-'-'   `-=_,-'-'   `-=_,-'-'   `-=_
 </pre>
 
 <h3>Useful Lab Links</h3>
@@ -15,5 +20,3 @@ require("headers.php");
     <li><a href="http://cremone.biologie.ens-lyon.fr:8888">Galaxy</a>
     <li><a href="http://cremone.biologie.ens-lyon.fr/~florent/dokuwiki/doku.php?do=index">FAQ around computer science</a>
   </ul>
-
-
diff --git a/src/last_trigger.MVC.php b/src/last_trigger.MVC.php
new file mode 100644
index 0000000..27b8fbc
--- /dev/null
+++ b/src/last_trigger.MVC.php
@@ -0,0 +1,8 @@
+<?php
+$to_be_post_list = <<<EOD
+<div id="to_be_post_list">
+  $to_be_post_list_content
+</div>
+EOD;
+echo $to_be_post_list;
+?>
diff --git a/src/lib/session.lib.php b/src/lib/session.lib.php
new file mode 100644
index 0000000..bf50b3f
--- /dev/null
+++ b/src/lib/session.lib.php
@@ -0,0 +1,156 @@
+<?php
+// Base sur Ph. Rigaux, OReilly 3e edition.
+// table visitors (login/pwd)
+// table websession
+// Les privileges de labmember_add sont:
+// SELECT sur visitors,
+// et ALL sur sessionWeb
+
+require_once 'lib/form.cls.php';
+
+function execQry ($qry, $bd)
+{
+  $result = mysql_query($qry, $bd);
+  if (!$result)
+  {
+    echo "error in execQry ". mysql_error ($db);
+    exit;
+  }
+  else
+   return $result;
+}
+
+
+function CleanOldSessions ($bd)
+{
+  //erase sessions outdated since 15 days
+  $tooOld = date ("U") - 1296000;
+  $qry = "DELETE FROM websession WHERE time_limit < $tooOld";
+  $resultat = execQry ($qry, $bd);
+}
+
+// uses form class from "form.cls.php"
+function LoginForm ($nom_script, $login_default = "view")
+{
+  $form = new form ();
+
+  $form -> openForm (array ('action' => "$nom_script", 'id' => 'LoginForm'));
+  $form -> openFieldset (array ('style' => 'border:1px dotted red; width: 300px;'));
+  $form -> addLegend ('Please Login');
+
+  $form -> addInput ('text', array ('id' => 'Login', 'value' => "$login_default", 'name' => 'visitor_login', 'test' => 'test'));
+  $form -> addLabel (' login', array ('for' => 'MyText', 'style' => 'margin: 5px;'));
+  $form -> addAnything ('<br /><br />');
+
+  $form -> addInput ('password', array ('id' => 'Pwd', 'value' => '', 'name' => 'visitor_pwd', 'test' => 'test'));
+  $form -> addLabel (' password', array ('for' => 'MyText', 'style' => 'margin: 5px;'));
+  $form -> addAnything ('<br /><br />');
+
+  $form -> addInput ('submit', array ('id' => 'MyButton', 'value' => 'Submit', 'test' => 'test'));
+  $form -> closeFieldset ();
+  $form -> closeForm ();  
+  
+  echo '<br><I>To login, cookies must be enabled on your browser</I><br><br>';
+  echo '<div >';//style="border: 1px solid darkgrey; text-align: center; width: 310px;">';
+  // on l'affiche
+  echo $form;
+  echo '</div>';
+  
+  echo '</body>';
+  echo '</html>';
+}
+
+
+function get_visitor ($login, $bd) {
+  $log = substr($login, 0, 3);
+  $qry = "SELECT * FROM visitors WHERE `login` LIKE '%$log%'";
+  $result = mysql_query($qry, $bd);
+  while($vis = mysql_fetch_object($result)) {
+    if ($vis->login == substr($login, 0, strlen($vis->login))) {
+      if ($vis->target_table != "all"){
+        $vis->target_table = substr($login, strlen($vis->login));        
+      }
+      return $vis;
+    }
+  }
+  return NULL;
+}
+
+function create_session ($bd, $login, $pwd, $id_session){
+  $visitor = get_visitor ($login, $bd);
+    //L'internaute existe-t-il?
+  if (is_object($visitor)) {
+    //verif du mot de passe
+    if ($visitor->pwd == md5($pwd)) {
+      // on insere une session de trente minutes dans table websession
+      $time_limit = date ("U") + 1800;
+      $insSession = "INSERT INTO websession (id_session, login, "
+        . "time_limit, target_table, "
+        . "mode) VALUES ('$id_session', '$login', '$time_limit', '$visitor->target_table', '$visitor->mode')";
+      $resultat = execQry ($insSession, $bd);
+      return TRUE;
+    } else {
+      echo "<B> Sorry, incorrect password for $login !</B><P>";
+      return FALSE;
+    }
+  } else {
+    echo "<B>Sorry, $login is not a registered login!</B><P>";
+    return FALSE;
+  }
+}
+
+//check session validity, destroy if not
+function is_valid_session ($session, $bd) {
+  //is time over?
+  $now = date ("U");
+  if ($session->time_limit < $now) {
+    session_destroy();
+    $destr = "DELETE FROM websession WHERE id_session='$session->id_session'";
+    $resultat = execQry ($destr, $bd);    
+  } else { //session is valid
+   return TRUE;
+  }
+}
+
+
+function get_session ($id_session, $bd) {
+  $qry = "SELECT * FROM websession WHERE `id_session` = '$id_session'";
+  while($sess = mysql_fetch_object(execQry ($qry, $bd))) {
+    if ($sess->id_session == $id_session) {
+      return $sess;
+    }
+  }
+  return NULL;
+}
+
+// main function for access control 
+function control_access ($nom_script, $infos_login, $id_session, $bd) {
+  //recherche la session
+  $session_courante = get_session ($id_session, $bd);
+  //cas 1: la session existe, on verifie sa validite
+  if (is_object($session_courante)) {
+     // la session existe, est-elle valide?
+     if (is_valid_session ($session_courante, $bd)) {
+        // on renvoie l'objet session
+        return $session_courante;
+     } else {
+        echo "<B> Your session is not (or no longer) valid.<P></B>\n";
+     }
+  }  
+  // Cas 2.a: La session n'existe pas mais un login et pwd ont ete fournis
+  if (isset($infos_login['visitor_login']) & isset($infos_login['visitor_pwd'])) {
+    // Les login/pwd sont-ils corrects?
+    if (create_session ($bd, $infos_login['visitor_login'], $infos_login['visitor_pwd'], $id_session)) {
+      // on renvoie l'object session
+      return get_session ($id_session, $bd);
+    } else {
+        echo "<B> Identification failed.<P></B>\n";
+    }
+  }  
+  // Cas 2.b: La session n'existe pas 
+  // et il faut afficher le formulaire d'identification
+  LoginForm ($nom_script);
+}
+
+
+?>
\ No newline at end of file
diff --git a/src/logout.php b/src/logout.php
index 728172f..f6a5a12 100644
--- a/src/logout.php
+++ b/src/logout.php
@@ -1,17 +1,15 @@
 <?php
-session_start ();
+session_start();
 require_once ("connect_entry.php");
-require_once ("session.php");
+require_once ("lib/session.lib.php");
 
 // connect to DB
 $connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
+if (!$connexion) {
  echo "Logout error: Sorry, connexion to " . SERVEUR . " failed\n";
  exit;
 }
-if (!mysql_select_db (BASE, $connexion))
-{
+if (!mysql_select_db (BASE, $connexion)) {
  echo "Logout error: Sorry, connexion to database " . BASE . " failed\n";
  exit;
 }
@@ -21,7 +19,6 @@ $id = session_id();
 $qry = "DELETE FROM websession WHERE id_session = '$id'";
 $resultat = execQry ($qry, $connexion);
 
-//go to welcome page
-header('Location: home.php');
-session_destroy ();
+session_destroy();
+header("Location: home.php");
 ?>
diff --git a/src/notebooks.php b/src/notebooks.php
index bdd8400..2920fc1 100644
--- a/src/notebooks.php
+++ b/src/notebooks.php
@@ -2,7 +2,6 @@
 session_start ();
 require("headers.php");
 
-
 /*
  * IMPORTANT NOTE: This generated file contains only a subset of huge amount
  * of options that can be used with phpMyEdit. To get information about all
@@ -19,93 +18,12 @@ require("headers.php");
  *              generating setup script: 1.50
  */
 
-
-
-/*************************/
-//
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("notebooks.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "notebooks";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and change background color accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-
-//************************/
-//
-// Fix a problem displaying
-// symbols (such as delta)
-//
-//************************/
-
-mysql_query("SET NAMES 'UTF8'", $connexion);
-
 /*************************/
 //
 // Pass phpMyEdit options
 //
 /*************************/
 
-
 $opts['dbh'] = $connexion;
 $opts['tb'] = $tb;
 
@@ -250,10 +168,5 @@ $opts['fdd']['End_Date'] = array(
 // Before displaying the view page
 
 
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
-
-
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/oligos.php b/src/oligos.php
index 2f798ce..5a19fdb 100644
--- a/src/oligos.php
+++ b/src/oligos.php
@@ -1,10 +1,7 @@
 <?php
 session_start ();
-
-
 require("headers.php");
 
-
 /*
  * IMPORTANT NOTE: This generated file contains only a subset of huge amount
  * of options that can be used with phpMyEdit. To get information about all
@@ -23,75 +20,6 @@ require("headers.php");
 
 /*************************/
 //
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("oligos.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "oligos";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and display warning accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-	
-/*************************/
-//
 // Pass phpMyEdit options
 //
 /*************************/
@@ -248,8 +176,5 @@ $opts['fdd']['Purif'] = array(
 	'column' => 'type')
 );
 
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/pip_history.TSP.php b/src/pip_history.TSP.php
new file mode 100644
index 0000000..9feb9c2
--- /dev/null
+++ b/src/pip_history.TSP.php
@@ -0,0 +1,37 @@
+<?php
+// a Trigger to display pipet info
+$allevents = $this->myQuery("SELECT * FROM ".$this->tb);
+$allpipets = $this->myQuery("SELECT * FROM pip_stock");
+
+/* there must be a more straightforward way to do this
+ * but this seems to work
+ */
+// reach the event displayed
+$foundevent = 0;
+while(!$foundevent && $event = mysql_fetch_object($allevents)){
+	if ($event->ID == $this->rec)
+		$foundevent = 1;
+}
+// record Serial Number of the pipet considered
+if ($event){
+  $SerialNum = $event->Serial_Number ;
+}
+
+// reach the pipet displayed
+$foundpipet = 0;
+while(!$foundpipet && $pipet = mysql_fetch_object($allpipets)){
+	if ($pipet->Serial_Number == $SerialNum)
+		$foundpipet = 1;
+}
+
+if ($pipet){
+   // print pipet infos
+   echo " Pipet : ".
+        $pipet->Marque . " " .
+	$pipet->Type . " " .
+	"<BR>" .
+	"Serial Number: ".
+        $pipet->Serial_Number . "<BR>". "<BR>";
+}
+
+?>
\ No newline at end of file
diff --git a/src/pip_history.php b/src/pip_history.php
new file mode 100644
index 0000000..3ad01a6
--- /dev/null
+++ b/src/pip_history.php
@@ -0,0 +1,204 @@
+<?php
+session_start ();
+require("headers.php");
+
+/*
+ * IMPORTANT NOTE: This generated file contains only a subset of huge amount
+ * of options that can be used with phpMyEdit. To get information about all
+ * features offered by phpMyEdit, check official documentation. It is available
+ * online and also for download on phpMyEdit project management page:
+ *
+ * http://platon.sk/projects/main_page.php?project_id=5
+ *
+ * This file was generated by:
+ *
+ *                    phpMyEdit version: unknown
+ *       phpMyEdit.class.php core class: 1.204
+ *            phpMyEditSetup.php script: 1.50
+ *              generating setup script: 1.50
+ */
+
+//************************/
+//
+// Update list of pipet Users
+//
+//************************/
+
+mysql_query("DELETE FROM pip_users", $connexion);
+mysql_query("INSERT INTO pip_users (User) SELECT id FROM lab_members", $connexion);
+mysql_query("INSERT INTO pip_users (User) SELECT User FROM pip_generic_user", $connexion);
+mysql_query("DELETE FROM pip_users WHERE User IN (SELECT User FROM pip_nonusers)", $connexion);
+
+/*************************/
+//
+// Pass phpMyEdit options
+//
+/*************************/
+
+
+$opts['dbh'] = $connexion;
+$opts['tb'] = $tb;
+
+// Name of field which is the unique key
+$opts['key'] = 'ID';
+
+// Type of key field (int/real/string/date etc.)
+$opts['key_type'] = 'int';
+
+// Sorting field(s)
+$opts['sort_field'] = array('ID');
+
+// Number of records to display on the screen
+// Value of -1 lists all records in a table
+$opts['inc'] = 15;
+
+// Options you wish to give the users
+// A - add,  C - change, P - copy, V - view, D - delete,
+// F - filter, I - initial sort suppressed
+$opts['options'] = $privopt;
+
+// Number of lines to display on multiple selection filters
+$opts['multiple'] = '4';
+
+// Navigation style: B - buttons (default), T - text links, G - graphic links
+// Buttons position: U - up, D - down (default)
+$opts['navigation'] = 'UDBG';
+
+// Display special page elements
+$opts['display'] = array(
+	'form'  => true,
+	'query' => true,
+	'sort'  => true,
+	'time'  => true,
+	'tabs'  => true
+);
+
+// Set default prefixes for variables
+$opts['js']['prefix']               = 'PME_js_';
+$opts['dhtml']['prefix']            = 'PME_dhtml_';
+$opts['cgi']['prefix']['operation'] = 'PME_op_';
+$opts['cgi']['prefix']['sys']       = 'PME_sys_';
+$opts['cgi']['prefix']['data']      = 'PME_data_';
+
+/* Get the user's default language and use it if possible or you can
+   specify particular one you want to use. Refer to official documentation
+   for list of available languages. */
+$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
+
+/* Table-level filter capability. If set, it is included in the WHERE clause
+   of any generated SELECT statement in SQL query. This gives you ability to
+   work only with subset of data from table.
+
+$opts['filters'] = "column1 like '%11%' AND column2<17";
+$opts['filters'] = "section_id = 9";
+$opts['filters'] = "PMEtable0.sessions_count > 200";
+*/
+
+/* Field definitions
+   
+Fields will be displayed left to right on the screen in the order in which they
+appear in generated list. Here are some most used field options documented.
+
+['name'] is the title used for column headings, etc.;
+['maxlen'] maximum length to display add/edit/search input boxes
+['trimlen'] maximum length of string content to display in row listing
+['width'] is an optional display width specification for the column
+          e.g.  ['width'] = '100px';
+['mask'] a string that is used by sprintf() to format field output
+['sort'] true or false; means the users may sort the display on this column
+['strip_tags'] true or false; whether to strip tags from content
+['nowrap'] true or false; whether this field should get a NOWRAP
+['select'] T - text, N - numeric, D - drop-down, M - multiple selection
+['options'] optional parameter to control whether a field is displayed
+  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
+            Another flags are:
+            R - indicates that a field is read only
+            W - indicates that a field is a password field
+            H - indicates that a field is to be hidden and marked as hidden
+['URL'] is used to make a field 'clickable' in the display
+        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
+['URLtarget']  HTML target link specification (for example: _blank)
+['textarea']['rows'] and/or ['textarea']['cols']
+  specifies a textarea is to be used to give multi-line input
+  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
+['values'] restricts user input to the specified constants,
+           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
+['values']['table'] and ['values']['column'] restricts user input
+  to the values found in the specified column of another table
+['values']['description'] = 'desc_column'
+  The optional ['values']['description'] field allows the value(s) displayed
+  to the user to be different to those in the ['values']['column'] field.
+  This is useful for giving more meaning to column values. Multiple
+  descriptions fields are also possible. Check documentation for this.
+*/
+
+$opts['fdd']['ID'] = array(
+  'name'     => 'ID',
+  'select'   => 'N',
+  'options'  => 'LAVCPDR', // auto increment
+  'maxlen'   => 10,
+  //'default'  => '0',
+  'sort'     => true
+);
+$opts['fdd']['Date'] = array(
+  'name'     => 'Date',
+  'options'  => 'LFAVCPD',
+  'select'   => 'N',
+  'maxlen'   => 10,
+  'sort'     => true,
+  'default'  => date("Y-m-d", strtotime("now"))
+);
+$opts['fdd']['Event_Type'] = array(
+  'name'     => 'Type of Event',
+  'select'   => 'D',
+  'maxlen'   => 30,
+  'default'  => 'Misc',
+  'values'   => array(
+  	'table'  => 'pip_events',
+	'column' => 'Events'),
+  'sort'     => true
+);
+$opts['fdd']['Serial_Number'] = array(
+  'name'     => 'Pipet Serial Number',
+  'select'   => 'D',
+  'maxlen'   => 30,
+  //'default'  => '0',
+  'values'   => array(
+  	'table'  => 'pip_stock',
+	'column' => 'Serial_Number'),
+  'sort'     => true
+);
+$opts['fdd']['Usage_fromNowOn'] = array(
+  'name'     => 'Usage after this',
+  'select'   => 'D',
+  'maxlen'   => 25,
+  'sort'     => true,
+  'default'  => 'Misc',
+  'values'   => array(
+  	'table'  => 'pip_usage',
+	'column' => 'Usage')
+);
+$opts['fdd']['Owner_fromNowOn'] = array(
+  'name'     => 'Owner after this',
+  'select'   => 'D',
+  'maxlen'   => 25,
+  'sort'     => true,
+  'values'   => array(
+  	'table'  => 'pip_users',
+	'column' => 'User')
+);
+$opts['fdd']['Comments'] = array(
+  'name'     => 'Comments',
+  'select'   => 'T',
+  'maxlen'   => 1000000000, //4294967295,
+  'textarea' => array(
+  	'rows' => 5,
+  	'cols' => 50),
+  'sort'     => true
+);
+// TRIGGER
+// Before displaying the view page
+$opts['triggers']['select']['pre'][]    = 'pip_history.TSP.php';
+
+require("footers.php");
+?>
diff --git a/src/pip_stock.php b/src/pip_stock.php
new file mode 100644
index 0000000..afe9aef
--- /dev/null
+++ b/src/pip_stock.php
@@ -0,0 +1,162 @@
+<?php
+session_start ();
+require("headers.php");
+
+/*
+ * IMPORTANT NOTE: This generated file contains only a subset of huge amount
+ * of options that can be used with phpMyEdit. To get information about all
+ * features offered by phpMyEdit, check official documentation. It is available
+ * online and also for download on phpMyEdit project management page:
+ *
+ * http://platon.sk/projects/main_page.php?project_id=5
+ *
+ * This file was generated by:
+ *
+ *                    phpMyEdit version: unknown
+ *       phpMyEdit.class.php core class: 1.204
+ *            phpMyEditSetup.php script: 1.50
+ *              generating setup script: 1.50
+ */
+
+/*************************/
+//
+// Pass phpMyEdit options
+//
+/*************************/
+
+
+$opts['dbh'] = $connexion;
+$opts['tb'] = $tb;
+
+// Name of field which is the unique key
+$opts['key'] = 'ID';
+
+// Type of key field (int/real/string/date etc.)
+$opts['key_type'] = 'int';
+
+// Sorting field(s)
+$opts['sort_field'] = array('ID');
+
+// Number of records to display on the screen
+// Value of -1 lists all records in a table
+$opts['inc'] = 15;
+
+// Options you wish to give the users
+// A - add,  C - change, P - copy, V - view, D - delete,
+// F - filter, I - initial sort suppressed
+$opts['options'] = $privopt;
+
+// Number of lines to display on multiple selection filters
+$opts['multiple'] = '4';
+
+// Navigation style: B - buttons (default), T - text links, G - graphic links
+// Buttons position: U - up, D - down (default)
+$opts['navigation'] = 'UDBG';
+
+// Display special page elements
+$opts['display'] = array(
+	'form'  => true,
+	'query' => true,
+	'sort'  => true,
+	'time'  => true,
+	'tabs'  => true
+);
+
+// Set default prefixes for variables
+$opts['js']['prefix']               = 'PME_js_';
+$opts['dhtml']['prefix']            = 'PME_dhtml_';
+$opts['cgi']['prefix']['operation'] = 'PME_op_';
+$opts['cgi']['prefix']['sys']       = 'PME_sys_';
+$opts['cgi']['prefix']['data']      = 'PME_data_';
+
+/* Get the user's default language and use it if possible or you can
+   specify particular one you want to use. Refer to official documentation
+   for list of available languages. */
+$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
+
+/* Table-level filter capability. If set, it is included in the WHERE clause
+   of any generated SELECT statement in SQL query. This gives you ability to
+   work only with subset of data from table.
+
+$opts['filters'] = "column1 like '%11%' AND column2<17";
+$opts['filters'] = "section_id = 9";
+$opts['filters'] = "PMEtable0.sessions_count > 200";
+*/
+
+/* Field definitions
+   
+Fields will be displayed left to right on the screen in the order in which they
+appear in generated list. Here are some most used field options documented.
+
+['name'] is the title used for column headings, etc.;
+['maxlen'] maximum length to display add/edit/search input boxes
+['trimlen'] maximum length of string content to display in row listing
+['width'] is an optional display width specification for the column
+          e.g.  ['width'] = '100px';
+['mask'] a string that is used by sprintf() to format field output
+['sort'] true or false; means the users may sort the display on this column
+['strip_tags'] true or false; whether to strip tags from content
+['nowrap'] true or false; whether this field should get a NOWRAP
+['select'] T - text, N - numeric, D - drop-down, M - multiple selection
+['options'] optional parameter to control whether a field is displayed
+  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
+            Another flags are:
+            R - indicates that a field is read only
+            W - indicates that a field is a password field
+            H - indicates that a field is to be hidden and marked as hidden
+['URL'] is used to make a field 'clickable' in the display
+        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
+['URLtarget']  HTML target link specification (for example: _blank)
+['textarea']['rows'] and/or ['textarea']['cols']
+  specifies a textarea is to be used to give multi-line input
+  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
+['values'] restricts user input to the specified constants,
+           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
+['values']['table'] and ['values']['column'] restricts user input
+  to the values found in the specified column of another table
+['values']['description'] = 'desc_column'
+  The optional ['values']['description'] field allows the value(s) displayed
+  to the user to be different to those in the ['values']['column'] field.
+  This is useful for giving more meaning to column values. Multiple
+  descriptions fields are also possible. Check documentation for this.
+*/
+
+$opts['fdd']['ID'] = array(
+  'name'     => 'ID',
+  'select'   => 'N',
+  //'options'  => 'LAVCPDR', // auto increment
+  'maxlen'   => 10,
+  'default'  => '0',
+  'sort'     => true
+);
+$opts['fdd']['Serial_Number'] = array(
+  'name'     => 'Serial Number',
+  'select'   => 'T',
+  'maxlen'   => 30,
+  //'default'  => '0',
+  'sort'     => true
+);
+$opts['fdd']['Marque'] = array(
+  'name'     => 'Marque',
+  'select'   => 'D',
+  'maxlen'   => 25,
+  'sort'     => true,
+  'values'   => array(
+  	'table'  => 'pip_marque',
+	'column' => 'Marque')
+);
+$opts['fdd']['Type'] = array(
+  'name'     => 'Type',
+  'select'   => 'D',
+  'maxlen'   => 25,
+  'sort'     => true,
+  'values'   => array(
+  	'table'  => 'pip_type',
+	'column' => 'Type')
+);
+
+// TRIGGER
+// Before displaying the view page
+
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/pipethistory.TSP.php b/src/pipethistory.TSP.php
deleted file mode 100644
index 9feb9c2..0000000
--- a/src/pipethistory.TSP.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-// a Trigger to display pipet info
-$allevents = $this->myQuery("SELECT * FROM ".$this->tb);
-$allpipets = $this->myQuery("SELECT * FROM pip_stock");
-
-/* there must be a more straightforward way to do this
- * but this seems to work
- */
-// reach the event displayed
-$foundevent = 0;
-while(!$foundevent && $event = mysql_fetch_object($allevents)){
-	if ($event->ID == $this->rec)
-		$foundevent = 1;
-}
-// record Serial Number of the pipet considered
-if ($event){
-  $SerialNum = $event->Serial_Number ;
-}
-
-// reach the pipet displayed
-$foundpipet = 0;
-while(!$foundpipet && $pipet = mysql_fetch_object($allpipets)){
-	if ($pipet->Serial_Number == $SerialNum)
-		$foundpipet = 1;
-}
-
-if ($pipet){
-   // print pipet infos
-   echo " Pipet : ".
-        $pipet->Marque . " " .
-	$pipet->Type . " " .
-	"<BR>" .
-	"Serial Number: ".
-        $pipet->Serial_Number . "<BR>". "<BR>";
-}
-
-?>
\ No newline at end of file
diff --git a/src/pipethistory.php b/src/pipethistory.php
deleted file mode 100644
index f8818cf..0000000
--- a/src/pipethistory.php
+++ /dev/null
@@ -1,289 +0,0 @@
-<?php
-session_start ();
-require("headers.php");
-
-/*
- * IMPORTANT NOTE: This generated file contains only a subset of huge amount
- * of options that can be used with phpMyEdit. To get information about all
- * features offered by phpMyEdit, check official documentation. It is available
- * online and also for download on phpMyEdit project management page:
- *
- * http://platon.sk/projects/main_page.php?project_id=5
- *
- * This file was generated by:
- *
- *                    phpMyEdit version: unknown
- *       phpMyEdit.class.php core class: 1.204
- *            phpMyEditSetup.php script: 1.50
- *              generating setup script: 1.50
- */
-
-
-
-/*************************/
-//
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("pipethistory.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "pip_history";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and change background color accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-
-//************************/
-//
-// Fix a problem displaying
-// symbols (such as delta)
-//
-//************************/
-
-mysql_query("SET NAMES 'UTF8'", $connexion);
-
-//************************/
-//
-// Update list of pipet Users
-//
-//************************/
-
-mysql_query("DELETE FROM pip_users", $connexion);
-mysql_query("INSERT INTO pip_users (User) SELECT id FROM lab_members", $connexion);
-mysql_query("INSERT INTO pip_users (User) SELECT User FROM pip_generic_user", $connexion);
-mysql_query("DELETE FROM pip_users WHERE User IN (SELECT User FROM pip_nonusers)", $connexion);
-
-/*************************/
-//
-// Pass phpMyEdit options
-//
-/*************************/
-
-
-$opts['dbh'] = $connexion;
-$opts['tb'] = $tb;
-
-// Name of field which is the unique key
-$opts['key'] = 'ID';
-
-// Type of key field (int/real/string/date etc.)
-$opts['key_type'] = 'int';
-
-// Sorting field(s)
-$opts['sort_field'] = array('ID');
-
-// Number of records to display on the screen
-// Value of -1 lists all records in a table
-$opts['inc'] = 15;
-
-// Options you wish to give the users
-// A - add,  C - change, P - copy, V - view, D - delete,
-// F - filter, I - initial sort suppressed
-$opts['options'] = $privopt;
-
-// Number of lines to display on multiple selection filters
-$opts['multiple'] = '4';
-
-// Navigation style: B - buttons (default), T - text links, G - graphic links
-// Buttons position: U - up, D - down (default)
-$opts['navigation'] = 'UDBG';
-
-// Display special page elements
-$opts['display'] = array(
-	'form'  => true,
-	'query' => true,
-	'sort'  => true,
-	'time'  => true,
-	'tabs'  => true
-);
-
-// Set default prefixes for variables
-$opts['js']['prefix']               = 'PME_js_';
-$opts['dhtml']['prefix']            = 'PME_dhtml_';
-$opts['cgi']['prefix']['operation'] = 'PME_op_';
-$opts['cgi']['prefix']['sys']       = 'PME_sys_';
-$opts['cgi']['prefix']['data']      = 'PME_data_';
-
-/* Get the user's default language and use it if possible or you can
-   specify particular one you want to use. Refer to official documentation
-   for list of available languages. */
-$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
-
-/* Table-level filter capability. If set, it is included in the WHERE clause
-   of any generated SELECT statement in SQL query. This gives you ability to
-   work only with subset of data from table.
-
-$opts['filters'] = "column1 like '%11%' AND column2<17";
-$opts['filters'] = "section_id = 9";
-$opts['filters'] = "PMEtable0.sessions_count > 200";
-*/
-
-/* Field definitions
-   
-Fields will be displayed left to right on the screen in the order in which they
-appear in generated list. Here are some most used field options documented.
-
-['name'] is the title used for column headings, etc.;
-['maxlen'] maximum length to display add/edit/search input boxes
-['trimlen'] maximum length of string content to display in row listing
-['width'] is an optional display width specification for the column
-          e.g.  ['width'] = '100px';
-['mask'] a string that is used by sprintf() to format field output
-['sort'] true or false; means the users may sort the display on this column
-['strip_tags'] true or false; whether to strip tags from content
-['nowrap'] true or false; whether this field should get a NOWRAP
-['select'] T - text, N - numeric, D - drop-down, M - multiple selection
-['options'] optional parameter to control whether a field is displayed
-  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
-            Another flags are:
-            R - indicates that a field is read only
-            W - indicates that a field is a password field
-            H - indicates that a field is to be hidden and marked as hidden
-['URL'] is used to make a field 'clickable' in the display
-        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
-['URLtarget']  HTML target link specification (for example: _blank)
-['textarea']['rows'] and/or ['textarea']['cols']
-  specifies a textarea is to be used to give multi-line input
-  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
-['values'] restricts user input to the specified constants,
-           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
-['values']['table'] and ['values']['column'] restricts user input
-  to the values found in the specified column of another table
-['values']['description'] = 'desc_column'
-  The optional ['values']['description'] field allows the value(s) displayed
-  to the user to be different to those in the ['values']['column'] field.
-  This is useful for giving more meaning to column values. Multiple
-  descriptions fields are also possible. Check documentation for this.
-*/
-
-$opts['fdd']['ID'] = array(
-  'name'     => 'ID',
-  'select'   => 'N',
-  'options'  => 'LAVCPDR', // auto increment
-  'maxlen'   => 10,
-  //'default'  => '0',
-  'sort'     => true
-);
-$opts['fdd']['Date'] = array(
-  'name'     => 'Date',
-  'options'  => 'LFAVCPD',
-  'select'   => 'N',
-  'maxlen'   => 10,
-  'sort'     => true,
-  'default'  => date("Y-m-d", strtotime("now"))
-);
-$opts['fdd']['Event_Type'] = array(
-  'name'     => 'Type of Event',
-  'select'   => 'D',
-  'maxlen'   => 30,
-  'default'  => 'Misc',
-  'values'   => array(
-  	'table'  => 'pip_events',
-	'column' => 'Events'),
-  'sort'     => true
-);
-$opts['fdd']['Serial_Number'] = array(
-  'name'     => 'Pipet Serial Number',
-  'select'   => 'D',
-  'maxlen'   => 30,
-  //'default'  => '0',
-  'values'   => array(
-  	'table'  => 'pip_stock',
-	'column' => 'Serial_Number'),
-  'sort'     => true
-);
-$opts['fdd']['Usage_fromNowOn'] = array(
-  'name'     => 'Usage after this',
-  'select'   => 'D',
-  'maxlen'   => 25,
-  'sort'     => true,
-  'default'  => 'Misc',
-  'values'   => array(
-  	'table'  => 'pip_usage',
-	'column' => 'Usage')
-);
-$opts['fdd']['Owner_fromNowOn'] = array(
-  'name'     => 'Owner after this',
-  'select'   => 'D',
-  'maxlen'   => 25,
-  'sort'     => true,
-  'values'   => array(
-  	'table'  => 'pip_users',
-	'column' => 'User')
-);
-$opts['fdd']['Comments'] = array(
-  'name'     => 'Comments',
-  'select'   => 'T',
-  'maxlen'   => 1000000000, //4294967295,
-  'textarea' => array(
-  	'rows' => 5,
-  	'cols' => 50),
-  'sort'     => true
-);
-// TRIGGER
-// Before displaying the view page
-$opts['triggers']['select']['pre']    = 'pipethistory.TSP.php';
-
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
-
-
diff --git a/src/pipetstocks.php b/src/pipetstocks.php
deleted file mode 100644
index 32bfbde..0000000
--- a/src/pipetstocks.php
+++ /dev/null
@@ -1,275 +0,0 @@
-<?php
-session_start ();
-?>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<style type="text/css">
-	body {background-color:  #FFF8DC}
-	input.btn { color: #050; font: bold 84%'trebuchet ms',helvetica,sans-serif; background-color: #fed;}
-	input.btn2{ color: #050; font: bold 84%'trebuchet ms',helvetica,sans-serif; background-color: #CC6633;}
-	hr.pme-hr		     { border: 0px solid; padding: 0px; margin: 0px; border-top-width: 1px; height: 1px; }
-	table.pme-main 	     { border: #004d9c 1px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
-	table.pme-navigation { border: #004d9c 0px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
-	td.pme-navigation-0, td.pme-navigation-1 { white-space: nowrap; }
-	th.pme-header	     { border: #004d9c 1px solid; padding: 4px; background: #add8e6; }
-	td.pme-key-0, td.pme-value-0, td.pme-help-0, td.pme-navigation-0, td.pme-cell-0,
-	td.pme-key-1, td.pme-value-1, td.pme-help-0, td.pme-navigation-1, td.pme-cell-1,
-	td.pme-sortinfo, td.pme-filter { border: #004d9c 1px solid; padding: 3px; }
-	td.pme-buttons { text-align: left;   }
-	td.pme-message { text-align: center; }
-	td.pme-stats   { text-align: right;  }
-</style>
-<h3> List of Pipets of the GY lab
-    <CENTER>
-    <FORM ACTION = 'logout.php' METHOD = 'POST'>
-      <INPUT TYPE='SUBMIT' VALUE = 'Logout' NAME = 'logout' class = "btn2">
-    </FORM> </CENTER>
-    <FORM ACTION = 'pipethistory.php' METHOD = 'POST'>
-      <INPUT TYPE='SUBMIT' VALUE = 'Go to Pipets History' NAME = 'gotohistory' class = "btn">
-    </FORM>
-</h3>
-<?php
-
-/*
- * IMPORTANT NOTE: This generated file contains only a subset of huge amount
- * of options that can be used with phpMyEdit. To get information about all
- * features offered by phpMyEdit, check official documentation. It is available
- * online and also for download on phpMyEdit project management page:
- *
- * http://platon.sk/projects/main_page.php?project_id=5
- *
- * This file was generated by:
- *
- *                    phpMyEdit version: unknown
- *       phpMyEdit.class.php core class: 1.204
- *            phpMyEditSetup.php script: 1.50
- *              generating setup script: 1.50
- */
-
-
-
-/*************************/
-//
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("pipetstocks.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "pip_stock";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and change background color accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-
-//************************/
-//
-// Fix a problem displaying
-// symbols (such as delta)
-//
-//************************/
-
-mysql_query("SET NAMES 'UTF8'", $connexion);
-
-/*************************/
-//
-// Pass phpMyEdit options
-//
-/*************************/
-
-
-$opts['dbh'] = $connexion;
-$opts['tb'] = $tb;
-
-// Name of field which is the unique key
-$opts['key'] = 'ID';
-
-// Type of key field (int/real/string/date etc.)
-$opts['key_type'] = 'int';
-
-// Sorting field(s)
-$opts['sort_field'] = array('ID');
-
-// Number of records to display on the screen
-// Value of -1 lists all records in a table
-$opts['inc'] = 15;
-
-// Options you wish to give the users
-// A - add,  C - change, P - copy, V - view, D - delete,
-// F - filter, I - initial sort suppressed
-$opts['options'] = $privopt;
-
-// Number of lines to display on multiple selection filters
-$opts['multiple'] = '4';
-
-// Navigation style: B - buttons (default), T - text links, G - graphic links
-// Buttons position: U - up, D - down (default)
-$opts['navigation'] = 'UDBG';
-
-// Display special page elements
-$opts['display'] = array(
-	'form'  => true,
-	'query' => true,
-	'sort'  => true,
-	'time'  => true,
-	'tabs'  => true
-);
-
-// Set default prefixes for variables
-$opts['js']['prefix']               = 'PME_js_';
-$opts['dhtml']['prefix']            = 'PME_dhtml_';
-$opts['cgi']['prefix']['operation'] = 'PME_op_';
-$opts['cgi']['prefix']['sys']       = 'PME_sys_';
-$opts['cgi']['prefix']['data']      = 'PME_data_';
-
-/* Get the user's default language and use it if possible or you can
-   specify particular one you want to use. Refer to official documentation
-   for list of available languages. */
-$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
-
-/* Table-level filter capability. If set, it is included in the WHERE clause
-   of any generated SELECT statement in SQL query. This gives you ability to
-   work only with subset of data from table.
-
-$opts['filters'] = "column1 like '%11%' AND column2<17";
-$opts['filters'] = "section_id = 9";
-$opts['filters'] = "PMEtable0.sessions_count > 200";
-*/
-
-/* Field definitions
-   
-Fields will be displayed left to right on the screen in the order in which they
-appear in generated list. Here are some most used field options documented.
-
-['name'] is the title used for column headings, etc.;
-['maxlen'] maximum length to display add/edit/search input boxes
-['trimlen'] maximum length of string content to display in row listing
-['width'] is an optional display width specification for the column
-          e.g.  ['width'] = '100px';
-['mask'] a string that is used by sprintf() to format field output
-['sort'] true or false; means the users may sort the display on this column
-['strip_tags'] true or false; whether to strip tags from content
-['nowrap'] true or false; whether this field should get a NOWRAP
-['select'] T - text, N - numeric, D - drop-down, M - multiple selection
-['options'] optional parameter to control whether a field is displayed
-  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
-            Another flags are:
-            R - indicates that a field is read only
-            W - indicates that a field is a password field
-            H - indicates that a field is to be hidden and marked as hidden
-['URL'] is used to make a field 'clickable' in the display
-        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
-['URLtarget']  HTML target link specification (for example: _blank)
-['textarea']['rows'] and/or ['textarea']['cols']
-  specifies a textarea is to be used to give multi-line input
-  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
-['values'] restricts user input to the specified constants,
-           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
-['values']['table'] and ['values']['column'] restricts user input
-  to the values found in the specified column of another table
-['values']['description'] = 'desc_column'
-  The optional ['values']['description'] field allows the value(s) displayed
-  to the user to be different to those in the ['values']['column'] field.
-  This is useful for giving more meaning to column values. Multiple
-  descriptions fields are also possible. Check documentation for this.
-*/
-
-$opts['fdd']['ID'] = array(
-  'name'     => 'ID',
-  'select'   => 'N',
-  //'options'  => 'LAVCPDR', // auto increment
-  'maxlen'   => 10,
-  'default'  => '0',
-  'sort'     => true
-);
-$opts['fdd']['Serial_Number'] = array(
-  'name'     => 'Serial Number',
-  'select'   => 'T',
-  'maxlen'   => 30,
-  //'default'  => '0',
-  'sort'     => true
-);
-$opts['fdd']['Marque'] = array(
-  'name'     => 'Marque',
-  'select'   => 'D',
-  'maxlen'   => 25,
-  'sort'     => true,
-  'values'   => array(
-  	'table'  => 'pip_marque',
-	'column' => 'Marque')
-);
-$opts['fdd']['Type'] = array(
-  'name'     => 'Type',
-  'select'   => 'D',
-  'maxlen'   => 25,
-  'sort'     => true,
-  'values'   => array(
-  	'table'  => 'pip_type',
-	'column' => 'Type')
-);
-
-// TRIGGER
-// Before displaying the view page
-
-
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
-
-
diff --git a/src/pl_features.php b/src/pl_features.php
index be0c0aa..320013c 100644
--- a/src/pl_features.php
+++ b/src/pl_features.php
@@ -1,6 +1,5 @@
 <?php
 session_start ();
-
 require("headers.php");
 
 /*
@@ -18,75 +17,6 @@ require("headers.php");
  *            phpMyEditSetup.php script: 1.50
  *              generating setup script: 1.50
  */
-
-/*************************/
-//
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("pl_features.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "pl_features";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and display warning accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
 	
 /*************************/
 //
@@ -252,11 +182,7 @@ $opts['fdd']['Comments'] = array(
 
 // TRIGGER
 // Before displaying the view page
-$opts['triggers']['select']['pre']    = 'pl_features.TSP.php';
-
-
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
+$opts['triggers']['select']['pre'][]    = 'pl_features.TSP.php';
 
-?>
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/plasmids.MVC.php b/src/plasmids.MVC.php
new file mode 100644
index 0000000..50fbdc4
--- /dev/null
+++ b/src/plasmids.MVC.php
@@ -0,0 +1,129 @@
+<?php
+
+
+require_once("lib/seq.lib.php");
+// a Trigger to display plsmid map image
+$all = $this->myQuery("SELECT * FROM " . $this->tb . " WHERE id=" . $this->rec);
+// reach the plasmid displayed
+$plasmid = mysql_fetch_object($all);
+
+if ($plasmid) {
+
+  if ($_REQUEST["action"] == "REMOVE_FILE_SEQ") {
+    if ($plasmid->Link_to_file != "") {
+      $to_rem_file = "plasmid_files/" . $plasmid->Link_to_file;
+      if (file_exists($to_rem_file)) {
+        unlink($to_rem_file);
+      }
+    }
+    $reqsql = "UPDATE  plasmids SET sequence='', Link_to_file=''  WHERE  id = $this->rec";
+    mysql_query($reqsql);
+    $all = $this->myQuery("SELECT * FROM " . $this->tb . " WHERE id=" . $this->rec);
+    $plasmid = mysql_fetch_object($all);
+  }
+
+  if ($_REQUEST["action"] == "ADD_GB_GZ_FILE") {
+    $userfile = $_FILES["userfile"]["tmp_name"];
+    $userfile_name = $_FILES["userfile"]["name"];
+    if (stristr($userfile_name, ".gb.gz")) {
+      $ext=".gb.gz";
+    } else {
+      if(file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 1, your file MUST have the extension .gb.gz (lowercase)). <br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    $dest_filename = str_replace(" ","_",substr($userfile_name, 0, strlen($userfile_name)-6)) . $ext;
+    $dest_filepath = "plasmid_files/" . $dest_filename;
+    if (file_exists($dest_filepath)) {
+      if (file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 2, this .gb.gz filename is already used. <br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    if (!copy($userfile, $dest_filepath)){
+      if (file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 3, problem copying file. <br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    if(file_exists($userfile)) {
+      unlink($userfile);
+    }
+
+    $url = "/var/www/labstocks/plasmid_files/" . $dest_filename;
+    $handle = gzopen($url, 'r');
+    if ($handle) {
+      $content = "";
+      while (!gzeof($handle)) {
+         $buffer = gzgets($handle, 4096);
+         $content .= $buffer;
+      }
+      gzclose($handle);
+      preg_match('#ORIGIN(.*)//#sm', $content, $matches);
+      $seq = $matches[0];
+      $seq = preg_replace("#ORIGIN#", "", $seq);
+      $seq = preg_replace("#[^a-zA-Z]#ms", "", $seq);
+      $reqsql = "UPDATE  plasmids SET sequence='$seq', Link_to_file='$dest_filename'  WHERE  id = $this->rec";
+      mysql_query($reqsql);
+      $all = $this->myQuery("SELECT * FROM " . $this->tb . " WHERE id=" . $this->rec);
+      $plasmid = mysql_fetch_object($all);
+    }
+  }
+
+
+  /*
+  * VIEW
+  */
+
+  $in_edit_mode = $_REQUEST["PME_sys_operation"] == "Change" || $_REQUEST["PME_sys_operation"] == "PME_op_Change";
+
+  if ($plasmid->sequence) {
+    if ($in_edit_mode) {  
+      $remove_gbgz_form = <<<EOD
+<form action='' method='post'>
+  Remove file, filename and sequence for this plasmid: 
+  <input type='hidden' name='PME_sys_operation' value='PME_op_Change'/>
+  <input type='hidden' name='PME_sys_rec' value='$this->rec'/>
+  <input type='hidden' name='action' value='REMOVE_FILE_SEQ'/>
+  <input type='button' name='send' value='Remove' onclick='if(confirm("Are you sure that you want to remove file, filename and sequence for this plasmid?")){this.form.submit()}else{return false;}'/>
+</form>
+EOD;
+    }
+    $imgurl = seq2png($plasmid->sequence, PLASMAPPER_SERVER);
+    $plasmapper_output = <<<EOD
+<img src="$imgurl"><br/>
+<textarea readonly rows="10" cols="100">$plasmid->sequence</textarea>
+EOD;
+
+    $wwwblast_url = WWWBLAST_SERVER . "blast.cgi?DATALIB=plfeatstock_db&PROGRAM=blastn&EXPECT=10&OOF_ALIGN=0&OVERVIEW=on&ALIGNMENT_VIEW=0&DESCRIPTIONS=100&ALIGNMENTS=50&COLOR_SCHEMA=0&SEQUENCE=$plasmid->sequence";
+    $fp = fopen($wwwblast_url, 'r', false);
+    $resp = stream_get_contents($fp);
+    $blast_output = preg_replace("/nph-viewgif.cgi/", WWWBLAST_SERVER . "nph-viewgif.cgi", $resp);
+
+  } else {
+    if ($in_edit_mode) {  
+      $add_gbgz_form = <<<EOD
+<form action='' method='post' enctype='multipart/form-data'>
+  Add a .gb.gz file to this plasmid: 
+  <input type='hidden' name='action' value='ADD_GB_GZ_FILE'/>
+  <input type='hidden' name='PME_sys_operation' value='PME_op_Change'/>
+  <input type='hidden' name='PME_sys_rec' value='$this->rec'/>
+  <input name='userfile' type='file' size='10'/>
+  <input type='button' name='send' value='Upload' onclick='return this.form.submit();'/>
+</form>
+EOD;
+    }
+  }
+}
+
+$to_be_post_list_content .= <<<EOD
+  $remove_gbgz_form
+  $add_gbgz_form
+  $plasmapper_output
+  <hr/>
+  $blast_output
+  <hr/>
+EOD;
+
+?>
diff --git a/src/plasmids.php b/src/plasmids.php
index c7c563f..2cd5f20 100644
--- a/src/plasmids.php
+++ b/src/plasmids.php
@@ -1,6 +1,5 @@
 <?php
 session_start ();
-
 require("headers.php");
 //$opts["filters"] = "`ID`=330";
 
@@ -22,77 +21,6 @@ require("headers.php");
 
 /*************************/
 //
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("plasmids.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
- $GLOBALS["session"] = $session;
-
- 
-/*************************/
-//
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-//
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "plasmids";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and display warning accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-	
-/*************************/
-//
 // Pass phpMyEdit options
 //
 /*************************/
@@ -222,6 +150,7 @@ $opts['fdd']['sequence'] = array(
 $opts['fdd']['Link_to_file'] = array(
   'name'     => 'Link',
   'select'   => 'T',
+   'options'  => 'LFPDV',
   'maxlen'   => 50,
   'sort'     => true,
   'sqlw' => 'IF($val_qas = "", NULL, $val_qas)' //to use real NULL instead of empty blanks
@@ -366,18 +295,8 @@ $opts['fdd']['Link_to_file']['URLprefix'] = 'plasmid_files/';
 $opts['fdd']['Link_to_file']['URLtarget'] = '_self';
 
 // TRIGGER
-// Before displaying the view page
-$opts['triggers']['select']['pre']    = 'plasmids.TSP.php';
-
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
+$opts['triggers']['select']['pre'][]    = 'plasmids.MVC.php';
+$opts['triggers']['update']['pre'][]    = 'plasmids.MVC.php';
 
-<div id="post_list"></div>"
-<script type="text/javascript"> 
-o = document.getElementById("post_list");
-q = document.getElementById("to_be_post_list");
-o.appendChild(q.parentNode.removeChild(q));
-</script>
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/raw_dir.MVC.php b/src/raw_dir.MVC.php
new file mode 100644
index 0000000..e6e4472
--- /dev/null
+++ b/src/raw_dir.MVC.php
@@ -0,0 +1,79 @@
+<?php
+$q = "SELECT * FROM $this->tb WHERE `$this->key`='$this->rec'";
+// echo "$q";
+// echo "<pre>";
+// print_r($this);
+// echo "</pre>";
+$all = $this->myQuery($q);
+$current_object = mysql_fetch_object($all);
+
+if ($current_object) {
+  $current_class_raw_dir = "raw_dirs/$this->tb";
+  $current_entry_raw_dir = "$current_class_raw_dir/$this->rec/";
+  if ($_REQUEST["action"] == "ADD_RAW_FILE") {
+    if (!file_exists($current_class_raw_dir)) {
+      mkdir($current_class_raw_dir);
+    }
+    $userfile = $_FILES["userfile"]["tmp_name"];
+    $userfile_name = $_FILES["userfile"]["name"];
+    $ext = strtolower(array_pop(explode("\.", $userfile_name)));
+    if (in_array($ext, array("php", "php5", "cgi"))) {
+      if(file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 1, your file CAN NOT have this extension.<br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    if (!file_exists($current_entry_raw_dir)) {
+      mkdir($current_entry_raw_dir);
+    }
+    $dest_filename = str_replace(" ","_",substr($userfile_name, 0, strlen($userfile_name)));
+    $dest_filepath = $current_entry_raw_dir . $dest_filename;
+    if (file_exists($dest_filepath)) {
+      if (file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 2, this filename is already used. <br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    if (!copy($userfile, $dest_filepath)){
+      if (file_exists($userfile)) {
+        unlink($userfile);
+      }
+      exit("ERROR 3, problem copying file. <br/><a href='".$_SERVER["HTTP_REFERER"]."'>Back</a>");
+    }
+    if(file_exists($userfile)) {
+      unlink($userfile);
+    }
+  }
+  /*
+  * VIEW
+  */
+  $in_edit_mode = $_REQUEST["PME_sys_operation"] == "Change" || $_REQUEST["PME_sys_operation"] == "PME_op_Change";
+
+  if ($in_edit_mode) {  
+    $raw_dir_form = <<<EOD
+  <form action='' method='post' enctype='multipart/form-data'>
+    Upload a file to the raw directory of this entry: 
+    <input type='hidden' name='PME_sys_operation' value='PME_op_Change'/>
+    <input type='hidden' name='PME_sys_rec' value='$this->rec'/>
+    <input type='hidden' name='action' value='ADD_RAW_FILE'/>
+    <input name='userfile' type='file' size='10'/>
+    <input type='button' name='send' value='Upload' onclick='return this.form.submit();'/>
+  </form>
+EOD;
+  }
+
+  if (file_exists($current_entry_raw_dir)) {
+    $fp = fopen(LABSTOCK_SERVER . $current_entry_raw_dir, 'r', false);
+    $raw_dir_content = preg_replace("/a href=\"/", "a href=\"" . LABSTOCK_SERVER . $current_entry_raw_dir, stream_get_contents($fp));
+    preg_match("'<table>(.*?)</table>'si", $raw_dir_content, $match);
+    // print_r($match);
+    $raw_dir_frame = "<table>" . $match[1] . "</table>";
+  }
+}
+
+$to_be_post_list_content .= <<<EOD
+  $raw_dir_form
+  $raw_dir_frame
+  <hr/>
+EOD;
+?>
diff --git a/src/strains.php b/src/strains.php
index 4b13d8e..9a07bb1 100644
--- a/src/strains.php
+++ b/src/strains.php
@@ -1,8 +1,39 @@
 <?php
 session_start ();
+require("headers.php");
 
+// if (array_key_exists("action", $_REQUEST)) {
+//   if ($_REQUEST["action"] == "SEARCH_IN_GENOTYPE") {
+//     $keys = split(" ", $_REQUEST["geno"]); 
+//     print_r($keys );
+// 
+//     $tmp_filter = "ynl095c:PBY-306-ynl095C";
+//     $likes = "";
+//     foreach ($keys as $k) {
+//       if ($k != "") {
+//         $likes .= "`locus1` LIKE '%$k%' OR `locus2` LIKE '%$k%' OR `locus3` LIKE '%$k%' OR `locus4` LIKE '%$k%' OR `locus5` LIKE '%$k%' OR `ADE2` LIKE '%$k%' OR `HIS3` LIKE '%$k%' OR `LEU2` LIKE '%$k%' OR `LYS2` LIKE '%$k%' OR `MET15` LIKE '%$k%' OR `TRP1` LIKE '%$k%' OR `URA3` LIKE '%$k%' OR `HO_` LIKE '%$k%' OR `Cytoplasmic_Character` LIKE '%$k%' OR `extrachromosomal_plasmid` LIKE '%$k%'";
+//       }
+//     }
+//     $opts["filters"] = $likes . " " ;
+//   }
+// }
+// 
+// if (!array_key_exists("PME_sys_operation", $_REQUEST)) {
+//   if (array_key_exists("geno", $_REQUEST)) {
+//     $geno = $_REQUEST["geno"]; 
+//   } else {
+//     $geno = "";
+//   }
+//   echo "<form action='' method='post'>";
+//   //echo "<fieldset style='border:1px plain black; width: 300px;'>";
+//   //echo "<legend>Search in genotype</legend>";
+//   echo "Search in genotype: <input type='hidden' name='action' value='SEARCH_IN_GENOTYPE'/>";
+//   echo "<input type='text' name='geno' value='$geno'/>";
+//   echo "<input type='button' name='send' value='Search' onclick='return this.form.submit();'/>";
+// //  echo "</fieldset>";
+//   echo "</form>";
+// }
 
-require("headers.php");
 /*
  * IMPORTANT NOTE: This generated file contains only a subset of huge amount
  * of options that can be used with phpMyEdit. To get information about all
@@ -19,117 +50,6 @@ require("headers.php");
  *              generating setup script: 1.50
  */
 
-/*************************/
-// Connect to DB and 
-// handle session/authentification
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("strains.php", $_POST, session_id(), $connexion);
-if (!is_object($session))
-	exit;
-
-/*************************/
-// According to login:
-// Define priviledge options
-// to pass to phpMyEdit
-/*************************/
-
-//check that visitor is allowed to use this table
-$tb = "strains";
-if ($session->target_table != $tb && $session->target_table != "all")
-{
-   echo "Sorry, your session is not granted access to table <B> $tb </B><p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-//define priv options and change background color accordingly
-if ($session->mode == "view"){
-	$privopt = 'VF';
-	$colorband = "#00ff00";
-	$messageband = "You are safely in VIEW mode";
-}
-else if ($session->mode == "add"){
-	$privopt = 'APVF';
-	$colorband = "orange";
-	$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions';
-}
-else if ($session->mode == "edit"){
-	$privopt = 'ACPVDF';
-	$colorband = "rgb(250,0,255)";
-	$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.';
-}
-else{
-	$privopt = '';
-	$colorband = "grey";
-}
-echo '<style type="text/css"> ';
-echo	"h4 {background-color: $colorband }";
-echo '</style>';
-echo "<h4> $messageband </h4>";
-echo "<HR>";
-
-
-  //print_r($_REQUEST );
-
-if (array_key_exists("action", $_REQUEST)) {
-  if ($_REQUEST["action"] == "SEARCH_IN_GENOTYPE") {
-    $keys = split(" ", $_REQUEST["geno"]); 
-    print_r($keys );
-
-    $tmp_filter = "ynl095c:PBY-306-ynl095C";
-    $likes = "";
-    foreach ($keys as $k) {
-      if ($k != "") {
-        $likes .= "`locus1` LIKE '%$k%' OR `locus2` LIKE '%$k%' OR `locus3` LIKE '%$k%' OR `locus4` LIKE '%$k%' OR `locus5` LIKE '%$k%' OR `ADE2` LIKE '%$k%' OR `HIS3` LIKE '%$k%' OR `LEU2` LIKE '%$k%' OR `LYS2` LIKE '%$k%' OR `MET15` LIKE '%$k%' OR `TRP1` LIKE '%$k%' OR `URA3` LIKE '%$k%' OR `HO_` LIKE '%$k%' OR `Cytoplasmic_Character` LIKE '%$k%' OR `extrachromosomal_plasmid` LIKE '%$k%'";
-      }
-    }
-    $opts["filters"] = $likes . " " ;
-  }
-}
-
-if (!array_key_exists("PME_sys_operation", $_REQUEST)) {
-  if (array_key_exists("geno", $_REQUEST)) {
-    $geno = $_REQUEST["geno"]; 
-  } else {
-    $geno = "";
-  }
-  echo "<form action='' method='post'>";
-  //echo "<fieldset style='border:1px plain black; width: 300px;'>";
-  //echo "<legend>Search in genotype</legend>";
-  echo "Search in genotype: <input type='hidden' name='action' value='SEARCH_IN_GENOTYPE'/>";
-  echo "<input type='text' name='geno' value='$geno'/>";
-  echo "<input type='button' name='send' value='Search' onclick='return this.form.submit();'/>";
-//  echo "</fieldset>";
-  echo "</form>";
-}
-
-
-
-
-//************************/
-//
-// Fix a problem displaying
-// symbols (such as delta)
-//
-//************************/
-
-mysql_query("SET NAMES 'UTF8'", $connexion);
 
 /*************************/
 //
@@ -137,7 +57,6 @@ mysql_query("SET NAMES 'UTF8'", $connexion);
 //
 /*************************/
 
-
 $opts['dbh'] = $connexion;
 $opts['tb'] = $tb;
 
@@ -454,13 +373,6 @@ $opts['fdd']['Date_'] = array(
 
 // TRIGGER
 // Before displaying the view page
-$opts['triggers']['select']['pre'] = 'strains.TSP.php';
-$opts['triggers']['select']['before'] = 'strains.test.php';
-
-// Now important call to phpMyEdit
-require_once 'phpMyEdit.class.php';
-new phpMyEdit($opts);
-
-?>
-
-
+$opts['triggers']['select']['pre'][] = 'strains.TSP.php';
+require("footers.php");
+?>
\ No newline at end of file
diff --git a/src/wwwblast.php b/src/wwwblast.php
index 25b6e4d..cc68f24 100644
--- a/src/wwwblast.php
+++ b/src/wwwblast.php
@@ -2,48 +2,7 @@
 session_start ();
 require("headers.php");
 
-/*************************/
-//
-// Connect to DB and 
-// handle session/authentification
-//
-/*************************/
-require_once ("connect_entry.php");
-require_once ("session.php");
-// connect to DB
-$connexion = mysql_pconnect (SERVEUR, NOM, PASSE);
-if (!$connexion)
-{
- echo "Sorry, connexion to " . SERVEUR . " failed\n";
- exit;
-}
-if (!mysql_select_db (BASE, $connexion))
-{
- echo "Sorry, connexion to database " . BASE . " failed\n";
- exit;
-}
-// authentification
-CleanOldSessions($connexion);
-$session = ControleAcces ("wwwblast.php", $_POST, session_id(), $connexion);
-if (!is_object($session)) {
-  exit;
-}
-
-/*************************/
-//
-// Verify login and priviledges
-//
-/*************************/
-
-// just in case:
-// check that visitor is in read-only mode
-if ($session->mode != "view" && $session->login != "superuser"){
-   echo "Sorry, you should log in <B> view </B> mode<p>";
-   echo "Please logout and try again with appropriate login<P>";
-   exit;
-}
-
-require_once("seq2fasta.php");
+require_once("lib/seq.lib.php");
 
 // Create an updated fasta
 // file of all oligos
@@ -170,26 +129,18 @@ while($feat = mysql_fetch_object($result)) {
     $fasta_content .= $toprint[$i] . "\n";
   }
 }
-
 fclose($FastaFile);
-
-/*************************/
-//
 // Using the fasta file
 // Create the blast database
 // and place it in the appropriate directory for wwwblast
-//
-/*************************/
-
 $cmd_formatdb = FORMATDB_CMD." -i $blastbasename -p F -o T";
 echo "<pre>$cmd_formatdb</pre>";
 system($cmd_formatdb, $retval1);
 
 if ($retval1 != 0){
-   echo "<b><font color='red'>ERROR!</font></b> while formatting the FASTA database into BLAST format. <a href=formatdb.log>formatdb.log</a>";
+   echo "Error while formatting the FASTA database into BLAST format";
    exit;
 }
-
 $html_feat_cnt = <<<EOD
 <html>
 <head>
@@ -206,39 +157,13 @@ $fasta_content
 </body>
 </html>
 EOD;
-
 $html_feat_filename = PLASMAPPER_HOME . "html/feature.html";
 $fp = fopen($html_feat_filename, 'w');
 fwrite($fp, $html_feat_cnt);
 fclose($fp);
-
 echo "Blast has updated PlasMapper with the latest plasmid's features.";
-
 ?>
 
-
-
-
-
-
-
-
-
-
-
 <center>
 <iframe src="/blast/blast.html" width="100%" height="90%" border="0"/>
-</center>
-
-
-
-
-
-
-
-
-
-
-
-
-
+</center>
\ No newline at end of file
