Révision d072e29c
b/README | ||
---|---|---|
63 | 63 |
Installation |
64 | 64 |
------------ |
65 | 65 |
|
66 |
... |
|
66 |
rsync -cauvz --exclude="formatdb.log" --exclude=".DS_Store" ../src/ root@cremone:/var/www/labstocks/ |
|
67 |
|
|
68 |
cd /var/www/labstocks |
|
69 |
# sudo vi connect_entry.php |
|
70 |
sudo touch formatdb.log |
|
71 |
sudo chmod 440 connect_entry.php |
|
72 |
sudo chown -R www-data:www-data connect_entry.php formatdb.log plasmid_files raw_dirs |
|
73 |
|
|
74 |
|
|
75 |
Migration |
|
76 |
cd /var/www/labstocks |
|
77 |
sudo cp -r ../labstocks.bck2/plasmid_files/*.gb.gz plasmid_files/. |
|
78 |
sudo chmod -R a+r plasmid_files |
|
79 |
sudo chown -R www-data:www-data plasmid_files |
|
80 |
sudo cp -r ../labstocks.bck2/collections collections/. |
|
81 |
cd raw_dirs/antibodies/ |
|
82 |
sudo mkdir `for ((a=1; a <= 24 ; a++)); do echo $a ; done` |
|
83 |
cd ../.. |
|
84 |
sudo cp ../labstocks.bck2/antibody_files/10.Anti-H3K14ac\(07-353\).pdf raw_dirs/antibodies/10/Anti-H3K14ac\(07-353\).pdf |
|
85 |
sudo cp ../labstocks.bck2/antibody_files/11.Anti-H3ac\(06-599\).pdf raw_dirs/antibodies/11/Anti-H3ac\(06-599\).pdf |
|
86 |
sudo cp ../labstocks.bck2/antibody_files/12.Anti-H3\(ab1791\).pdf raw_dirs/antibodies/12/Anti-H3\(ab1791\).pdf |
|
87 |
sudo cp ../labstocks.bck2/antibody_files/13.Anti-FLAG\(F7425\).pdf raw_dirs/antibodies/13/Anti-FLAG\(F7425\).pdf |
|
88 |
sudo cp ../labstocks.bck2/antibody_files/14.Cre-Recombinase\(PRB-106C\).pdf raw_dirs/antibodies/14/Cre-Recombinase\(PRB-106C\).pdf |
|
89 |
sudo cp ../labstocks.bck2/antibody_files/15.GAPDH-HRP\(ab85760\).pdf raw_dirs/antibodies/15/GAPDH-HRP\(ab85760\).pdf |
|
90 |
sudo cp ../labstocks.bck2/antibody_files/16.Anti-H3K9ac\(ab10812\).pdf raw_dirs/antibodies/16/Anti-H3K9ac\(ab10812\).pdf |
|
91 |
sudo cp ../labstocks.bck2/antibody_files/17.Anti-H3K4me3\(CS-003-100\).pdf raw_dirs/antibodies/17/Anti-H3K4me3\(CS-003-100\).pdf |
|
92 |
sudo cp ../labstocks.bck2/antibody_files/18.Anti-H3\(ab1791\).pdf raw_dirs/antibodies/18/Anti-H3\(ab1791\).pdf |
|
93 |
sudo cp ../labstocks.bck2/antibody_files/19.Anti-H3K4me1\(07-436\).pdf raw_dirs/antibodies/19/Anti-H3K4me1\(07-436\).pdf |
|
94 |
sudo cp ../labstocks.bck2/antibody_files/1.Anti-Actin-C4\(69100\).pdf raw_dirs/antibodies/1/Anti-Actin-C4\(69100\).pdf |
|
95 |
sudo cp ../labstocks.bck2/antibody_files/20.Anti-H3K14ac\(07-353\).pdf raw_dirs/antibodies/20/Anti-H3K14ac\(07-353\).pdf |
|
96 |
sudo cp ../labstocks.bck2/antibody_files/21.Anti-H4K12ac\(07-595\).pdf raw_dirs/antibodies/21/Anti-H4K12ac\(07-595\).pdf |
|
97 |
sudo cp ../labstocks.bck2/antibody_files/22.Anti-Htz1\(39647\).pdf raw_dirs/antibodies/22/Anti-Htz1\(39647\).pdf |
|
98 |
sudo cp ../labstocks.bck2/antibody_files/23.Anti-H2AFZ\(ab4626\).pdf raw_dirs/antibodies/23/Anti-H2AFZ\(ab4626\).pdf |
|
99 |
sudo cp ../labstocks.bck2/antibody_files/24.Anti-LexA-DBD\(39185\).pdf raw_dirs/antibodies/24/Anti-LexA-DBD\(39185\).pdf |
|
100 |
sudo cp ../labstocks.bck2/antibody_files/2.Anti-Myc\(06-340\).pdf raw_dirs/antibodies/2/Anti-Myc\(06-340\).pdf |
|
101 |
sudo cp ../labstocks.bck2/antibody_files/3.Anti-H3\(ab10799\).pdf raw_dirs/antibodies/3/Anti-H3\(ab10799\).pdf |
|
102 |
sudo cp ../labstocks.bck2/antibody_files/4.Anti-H3\(ab24834\).pdf raw_dirs/antibodies/4/Anti-H3\(ab24834\).pdf |
|
103 |
sudo cp ../labstocks.bck2/antibody_files/5.Anti-H3K4me2\(ab7766\).pdf raw_dirs/antibodies/5/Anti-H3K4me2\(ab7766\).pdf |
|
104 |
sudo cp ../labstocks.bck2/antibody_files/6.Anti-H3K4me3\(ab8580\).pdf raw_dirs/antibodies/6/Anti-H3K4me3\(ab8580\).pdf |
|
105 |
sudo cp ../labstocks.bck2/antibody_files/7.Anti-H3K27me3\(07-449\).pdf raw_dirs/antibodies/7/Anti-H3K27me3\(07-449\).pdf |
|
106 |
sudo cp ../labstocks.bck2/antibody_files/8.Anti-H4K12ac\(06-761\).pdf raw_dirs/antibodies/8/Anti-H4K12ac\(06-761\).pdf |
|
107 |
sudo cp ../labstocks.bck2/antibody_files/9.Beta-Actin-AC74\(A2228\).pdf raw_dirs/antibodies/9/Beta-Actin-AC74\(A2228\).pdf |
|
108 |
sudo chmod -R a+r raw_dirs |
|
109 |
sudo chown -R www-data:www-data raw_dirs |
|
110 |
# upload gene_synthesis_reports_pGY247.zip and gene_synthesis_reports_pGY248.zip |
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
scp -r stainer:Desktop/LBMC/projects/plasmapper/src/plasmid_files labstocks |
|
117 |
vi labstocks/connect_entry.php |
|
118 |
sudo cp -r labstocks /var/www/ |
|
119 |
sudo chmod 440 /var/www/labstocks/connect_entry.php |
|
120 |
sudo chown www-data:www-data /var/www/labstocks/connect_entry.php |
|
121 |
sudo chown -R www-data:www-data /var/www/labstocks/plasmid_files |
|
122 |
sudo chown -R www-data:www-data /var/www/labstocks/raw_dirs |
|
123 |
sudo touch /var/www/labstocks/formatdb.log |
|
124 |
sudo chown www-data:www-data /var/www/labstocks/formatdb.log |
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
67 | 130 |
|
68 | 131 |
Usage |
69 | 132 |
===== |
... | ... | |
73 | 136 |
`LYS2`, `MET15`, `TRP1`, `URA3`, `HO_`, `Cytoplasmic_Character` or |
74 | 137 |
`extrachromosomal_plasmid` contain the given expression. This filter is case |
75 | 138 |
insensitive. |
139 |
|
|
140 |
Even in edit mode, users are not granted permission to directly edit a plasmid |
|
141 |
sequence, nor the URL to the plasmid sequence file. If a new sequence must be |
|
142 |
entered instead of the current one, users must upload a new sequence file, in |
|
143 |
.gb or .gb.gz format. MyLabStocks then automatically reads the file and update |
|
144 |
the sequence field and the URL. This ensures consistency between URL, sequence |
|
145 |
and the file itself. |
|
146 |
|
|
147 |
TODO |
|
148 |
==== |
|
149 |
|
|
150 |
- Upload a .gb file, gzip it on fly for plasmids. |
|
151 |
- Bug with plasmid 246, having a look on log file: tail -f /var/log/tomcat6/catalina.out |
|
152 |
- Add persistence on advanced search form conditions. |
|
153 |
- Remove file field for antibodies |
|
154 |
- More error msg when an uploaded file is too big. (>2Mo). |
b/src/admin.php | ||
---|---|---|
1 |
<?php |
|
2 |
session_start (); |
|
3 |
require("headers.php"); |
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
if (! defined('PHP_EOL')) { |
|
8 |
define('PHP_EOL', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? "\r\n" |
|
9 |
: strtoupper(substr(PHP_OS, 0, 3) == 'MAC') ? "\r" : "\n"); |
|
10 |
} |
|
11 |
|
|
12 |
$hn = SERVEUR; |
|
13 |
$un = NOM; |
|
14 |
$pw = PASSE; |
|
15 |
$db = BASE; |
|
16 |
$submit = "Submit"; |
|
17 |
$options = 1; |
|
18 |
$baseFilename = $tb; |
|
19 |
$pageTitle = $tb; |
|
20 |
|
|
21 |
if (@$_REQUEST["action"] == "CHANGE_TB") { |
|
22 |
$_SESSION["tb"] = $_REQUEST["tb"]; |
|
23 |
} else { |
|
24 |
if (!isset($_SESSION["tb"])) { |
|
25 |
$_SESSION["tb"] = "lab_members"; |
|
26 |
} |
|
27 |
} |
|
28 |
$tb = $_SESSION["tb"]; |
|
29 |
|
|
30 |
$phpExtension = '.php'; |
|
31 |
if (isset($baseFilename) && $baseFilename != '') { |
|
32 |
$phpFile = $baseFilename.$phpExtension; |
|
33 |
//$contentFile = $baseFilename.'Content.inc'; |
|
34 |
$contentFile = $baseFilename.'.php'; |
|
35 |
} elseif (isset($tb)) { |
|
36 |
$phpFile = $tb.$phpExtension; |
|
37 |
//$contentFile = $tb.'Content.inc'; |
|
38 |
$contentFile = $tb.'.php'; |
|
39 |
} else { |
|
40 |
$phpFile = 'index'.$phpExtension; |
|
41 |
//$contentFile = 'Content.inc'; |
|
42 |
$contentFile = 'phpMyEdit-content.php'; |
|
43 |
} |
|
44 |
|
|
45 |
$buffer = ''; |
|
46 |
|
|
47 |
function echo_buffer($x) |
|
48 |
{ |
|
49 |
global $buffer; |
|
50 |
$buffer .= $x.PHP_EOL; |
|
51 |
} |
|
52 |
|
|
53 |
function check_constraints($tb,$fd) |
|
54 |
{ |
|
55 |
$query = "show create table $tb"; |
|
56 |
$result = mysql_query($query); |
|
57 |
$tableDef = preg_split('/\n/',mysql_result($result,0,1)); |
|
58 |
|
|
59 |
$constraint_arg=""; |
|
60 |
while (list($key,$val) = each($tableDef)) { |
|
61 |
$words=preg_split("/[\s'`()]+/", $val); |
|
62 |
if ($words[1] == "CONSTRAINT" && $words[6]=="REFERENCES") { |
|
63 |
if ($words[5]==$fd) { |
|
64 |
$constraint_arg=" 'values' => array(\n". |
|
65 |
" 'table' => '$words[7]',\n". |
|
66 |
" 'column' => '$words[8]'\n". |
|
67 |
" ),\n"; |
|
68 |
} |
|
69 |
|
|
70 |
} |
|
71 |
} |
|
72 |
return $constraint_arg; |
|
73 |
} |
|
74 |
|
|
75 |
$self = basename($_SERVER['PHP_SELF']); |
|
76 |
$dbl = @mysql_pconnect($hn, $un, $pw); |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
$select_tb = "<form action='admin.php' method='POST'>"; |
|
94 |
$select_tb .= "<input type='hidden' name='action' value='CHANGE_TB'/>"; |
|
95 |
$select_tb .= "<select name='tb'>"; |
|
96 |
$tbs = @mysql_list_tables($db, $dbl); |
|
97 |
$num_tbs = @mysql_num_rows($tbs); |
|
98 |
for ($j = 0; $j < $num_tbs; $j++) { |
|
99 |
$tb_choice = @mysql_tablename($tbs, $j); |
|
100 |
$tb_choice = htmlspecialchars($tb_choice); |
|
101 |
$checked = $tb_choice == $tb ? ' selected="selected" ' : ''; |
|
102 |
$select_tb .= "<option value='$tb_choice' $checked>$tb_choice</option>"; |
|
103 |
} |
|
104 |
$select_tb .= "</select>"; |
|
105 |
$select_tb .= "<input type='Submit' name='Submit' value='Show this table' />"; |
|
106 |
$select_tb .= "</form>"; |
|
107 |
|
|
108 |
echo $select_tb; |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
@mysql_select_db($db); |
|
128 |
$tb_desc = @mysql_query("DESCRIBE $tb"); |
|
129 |
$fds = @mysql_list_fields($db,$tb,$dbl); |
|
130 |
$j = 0; |
|
131 |
$fd = @mysql_field_name($fds, $j); |
|
132 |
$ff = @mysql_field_flags($fds, $j); |
|
133 |
|
|
134 |
if (!stristr($ff, 'primary_key')) { |
|
135 |
echo "ERROR, first field is not a primary_key."; |
|
136 |
exit(); |
|
137 |
} |
|
138 |
|
|
139 |
$id = htmlspecialchars($fd); |
|
140 |
|
|
141 |
{ |
|
142 |
echo_buffer(" |
|
143 |
// MySQL host name, user name, password, database, and table |
|
144 |
\$opts['hn'] = '$hn'; |
|
145 |
\$opts['un'] = '$un'; |
|
146 |
\$opts['pw'] = '$pw'; |
|
147 |
\$opts['db'] = '$db'; |
|
148 |
\$opts['tb'] = '$tb'; |
|
149 |
|
|
150 |
// Name of field which is the unique key |
|
151 |
\$opts['key'] = '$id'; |
|
152 |
|
|
153 |
// Type of key field (int/real/string/date etc.)"); |
|
154 |
|
|
155 |
if ($id == '') { |
|
156 |
echo_buffer("\$opts['key_type'] = '';"); |
|
157 |
} else { |
|
158 |
$fds = @mysql_list_fields($db,$tb,$dbl); |
|
159 |
for ($j = 0; ($fd = @mysql_field_name($fds, $j)) != ''; $j++) { |
|
160 |
if ($fd == $id) { |
|
161 |
echo_buffer("\$opts['key_type'] = '".@mysql_field_type($fds, $j)."';"); |
|
162 |
break; |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
echo_buffer(" |
|
167 |
// Sorting field(s) |
|
168 |
\$opts['sort_field'] = array('$id'); |
|
169 |
|
|
170 |
// Options you wish to give the users |
|
171 |
// A - add, C - change, P - copy, V - view, D - delete, |
|
172 |
// F - filter, I - initial sort suppressed |
|
173 |
\$opts['options'] = \$privopt; |
|
174 |
"); |
|
175 |
|
|
176 |
@mysql_select_db($db); |
|
177 |
$tb_desc = @mysql_query("DESCRIBE $tb"); |
|
178 |
$fds = @mysql_list_fields($db, $tb, $dbl); |
|
179 |
$num_fds = @mysql_num_fields($fds); |
|
180 |
$ts_cnt = 0; |
|
181 |
for ($k = 0; $k < $num_fds; $k++) { |
|
182 |
$fd = mysql_field_name($fds,$k); |
|
183 |
$fm = mysql_fetch_field($fds,$k); |
|
184 |
$fn = strtr($fd, '_-.', ' '); |
|
185 |
$fn = preg_replace('/(^| +)id( +|$)/', '\\1ID\\2', $fn); // uppercase IDs |
|
186 |
$fn = ucfirst($fn); |
|
187 |
$row = @mysql_fetch_array($tb_desc); |
|
188 |
echo_buffer('$opts[\'fdd\'][\''.$fd.'\'] = array('); // ) |
|
189 |
echo_buffer(" 'name' => '".str_replace('\'','\\\'',$fn)."',"); |
|
190 |
$auto_increment = strstr($row[5], 'auto_increment') ? 1 : 0; |
|
191 |
if (substr($row[1],0,3) == 'set') { |
|
192 |
echo_buffer(" 'select' => 'M',"); |
|
193 |
} else { |
|
194 |
echo_buffer(" 'select' => 'T',"); |
|
195 |
} |
|
196 |
if ($auto_increment) { |
|
197 |
echo_buffer(" 'options' => 'AVCPDR', // auto increment"); |
|
198 |
} |
|
199 |
// timestamps are read-only |
|
200 |
else if (@mysql_field_type($fds, $k) == 'timestamp') { |
|
201 |
if ($ts_cnt > 0) { |
|
202 |
echo_buffer(" 'options' => 'AVCPD',"); |
|
203 |
} else { // first timestamp |
|
204 |
echo_buffer(" 'options' => 'AVCPDR', // updated automatically (MySQL feature)"); |
|
205 |
} |
|
206 |
$ts_cnt++; |
|
207 |
} |
|
208 |
echo_buffer(" 'maxlen' => ".@mysql_field_len($fds,$k).','); |
|
209 |
// blobs -> textarea |
|
210 |
if (@mysql_field_type($fds,$k) == 'blob') { |
|
211 |
echo_buffer(" 'textarea' => array("); |
|
212 |
echo_buffer(" 'rows' => 5,"); |
|
213 |
echo_buffer(" 'cols' => 50),"); |
|
214 |
} |
|
215 |
// SETs and ENUMs get special treatment |
|
216 |
if ((substr($row[1],0,3) == 'set' || substr($row[1],0,4) == 'enum') |
|
217 |
&& ! (($pos = strpos($row[1], '(')) === false)) { |
|
218 |
$indent = str_repeat(' ', 18); |
|
219 |
$outstr = substr($row[1], $pos + 2, -2); |
|
220 |
$outstr = explode("','", $outstr); |
|
221 |
$outstr = str_replace("''", "'", $outstr); |
|
222 |
$outstr = str_replace('"', '\\"', $outstr); |
|
223 |
$outstr = implode('",'.PHP_EOL.$indent.'"', $outstr); |
|
224 |
echo_buffer(" 'values' => array(".PHP_EOL.$indent.'"'.$outstr.'"),'); |
|
225 |
} |
|
226 |
// automatic support for Default values |
|
227 |
if ($row[4] != '' && $row[4] != 'NULL') { |
|
228 |
echo_buffer(" 'default' => '".$row[4]."',"); |
|
229 |
} else if ($auto_increment) { |
|
230 |
echo_buffer(" 'default' => '0',"); |
|
231 |
} |
|
232 |
// check for table constraints |
|
233 |
$outstr = check_constraints($tb, $fd); |
|
234 |
if ($outstr != '') { |
|
235 |
echo_buffer($outstr); |
|
236 |
} |
|
237 |
echo_buffer(" 'sort' => true"); |
|
238 |
//echo_buffer(" 'nowrap' => false,"); |
|
239 |
echo_buffer(');'); |
|
240 |
} |
|
241 |
|
|
242 |
|
|
243 |
eval($buffer); |
|
244 |
|
|
245 |
} |
|
246 |
|
|
247 |
require("footers.php"); |
|
248 |
?> |
b/src/antibodies.php | ||
---|---|---|
18 | 18 |
* generating setup script: 1.50 |
19 | 19 |
*/ |
20 | 20 |
|
21 |
|
|
22 | 21 |
/*************************/ |
23 | 22 |
// |
24 | 23 |
// Pass phpMyEdit options |
... | ... | |
238 | 237 |
$opts['fdd']['DataSheet']['URLprefix'] = 'antibody_files/'; |
239 | 238 |
$opts['fdd']['DataSheet']['URLtarget'] = '_self'; |
240 | 239 |
|
241 |
// Now important call to phpMyEdit |
|
242 |
require_once 'phpMyEdit.class.php'; |
|
243 |
new phpMyEdit($opts); |
|
244 |
|
|
245 |
?> |
|
246 |
|
|
240 |
// TRIGGER |
|
241 |
// Before displaying the view page |
|
247 | 242 |
|
243 |
require("footers.php"); |
|
244 |
?> |
b/src/connect_entry.php | ||
---|---|---|
5 | 5 |
define ('BASE', "gylab_stocks"); |
6 | 6 |
define ('PLASMAPPER_HOME', "/var/lib/tomcat6/webapps/PlasMapper/"); |
7 | 7 |
define ('PLASMAPPER_SERVER', "http://" . $_SERVER["HTTP_HOST"] . ":8080/PlasMapper/"); |
8 |
define ('LABSTOCK_SERVER', "http://" . $_SERVER["HTTP_HOST"] . "/labstocks/"); |
|
8 | 9 |
define ('WWWBLAST_SERVER', "http://" . $_SERVER["HTTP_HOST"] . "/blast/"); |
9 | 10 |
define ('BLAST_HOME', "/var/www/blast/db/"); |
10 | 11 |
define ('FORMATDB_CMD', "formatdb"); |
b/src/footers.php | ||
---|---|---|
1 |
<?php |
|
2 |
// TRIGGER |
|
3 |
$opts['triggers']['select']['pre'][] = 'last_trigger.MVC.php'; |
|
4 |
$opts['triggers']['update']['pre'][] = 'last_trigger.MVC.php'; |
|
5 |
|
|
6 |
array_unshift($opts['triggers']['select']['pre'], 'raw_dir.MVC.php'); |
|
7 |
array_unshift($opts['triggers']['update']['pre'], 'raw_dir.MVC.php'); |
|
8 |
|
|
9 |
// Now important call to phpMyEdit |
|
10 |
require_once 'phpMyEdit.class.php'; |
|
11 |
$pme_instance = new phpMyEdit($opts); |
|
12 |
|
|
13 |
|
|
14 |
if (!array_key_exists("PME_sys_operation", $_REQUEST)) { |
|
15 |
$tmp_array = $pme_instance->fds; |
|
16 |
if ($tb == "strains") { |
|
17 |
array_unshift($tmp_array, "Genotype"); |
|
18 |
} |
|
19 |
$json_cols = json_encode($tmp_array); |
|
20 |
$adv_search = <<<EOD |
|
21 |
<div id="adv_search"> |
|
22 |
<form action=""> |
|
23 |
<table id="adv_search_table"> |
|
24 |
</table> |
|
25 |
<input type="hidden" name="action" value="ADV_SEARCH"/> |
|
26 |
<input type="submit" value="Search"/> |
|
27 |
</form> |
|
28 |
</div> |
|
29 |
|
|
30 |
<script type="text/javascript"> |
|
31 |
nb_filter = 0; |
|
32 |
function filter() { |
|
33 |
var self = this; |
|
34 |
cols = $json_cols; |
|
35 |
conds = ["LIKE", "=", "<", "<=", ">=", ">", "!="]; |
|
36 |
ops = ["AND", "OR"]; |
|
37 |
table = document.getElementById("adv_search_table"); |
|
38 |
this.tmp_tr = document.createElement("tr"); |
|
39 |
table.appendChild(this.tmp_tr); |
|
40 |
tmp_td = document.createElement("td"); |
|
41 |
if (nb_filter != 0) { |
|
42 |
tmp_select = document.createElement("select") |
|
43 |
tmp_select.setAttribute('name', 'op' + '_' + nb_filter) |
|
44 |
ops.forEach(function(op) { |
|
45 |
tmp_option = document.createElement("option"); |
|
46 |
tmp_option.appendChild(document.createTextNode(op)); |
|
47 |
tmp_select.appendChild(tmp_option); |
|
48 |
}); |
|
49 |
tmp_td.appendChild(tmp_select); |
|
50 |
} |
|
51 |
this.tmp_tr.appendChild(tmp_td) |
|
52 |
tmp_select = document.createElement("select") |
|
53 |
tmp_select.setAttribute('name', 'col' + '_' + nb_filter) |
|
54 |
cols.forEach(function(col) { |
|
55 |
tmp_option = document.createElement("option"); |
|
56 |
tmp_option.appendChild(document.createTextNode(col)); |
|
57 |
tmp_select.appendChild(tmp_option); |
|
58 |
}); |
|
59 |
tmp_td = document.createElement("td"); |
|
60 |
tmp_td.appendChild(tmp_select); |
|
61 |
this.tmp_tr.appendChild(tmp_td) |
|
62 |
tmp_select = document.createElement("select") |
|
63 |
tmp_select.setAttribute('name', 'cond' + '_' + nb_filter) |
|
64 |
conds.forEach(function(cond) { |
|
65 |
tmp_option = document.createElement("option"); |
|
66 |
tmp_option.appendChild(document.createTextNode(cond)); |
|
67 |
tmp_select.appendChild(tmp_option); |
|
68 |
}); |
|
69 |
tmp_td = document.createElement("td"); |
|
70 |
tmp_td.appendChild(tmp_select); |
|
71 |
this.tmp_tr.appendChild(tmp_td) |
|
72 |
tmp_input = document.createElement("input") |
|
73 |
tmp_input.setAttribute('name', 'input' + '_' + nb_filter) |
|
74 |
tmp_td = document.createElement("td"); |
|
75 |
tmp_td.appendChild(tmp_input); |
|
76 |
this.tmp_tr.appendChild(tmp_td) |
|
77 |
tmp_td = document.createElement("td"); |
|
78 |
tmp_td.innerHTML = "<input type='button' onclick='new filter();return false;' value='+'/>" |
|
79 |
if (nb_filter != 0) { |
|
80 |
tmp_input = document.createElement("input"); |
|
81 |
tmp_input.setAttribute('value', '-'); |
|
82 |
tmp_input.setAttribute('type', 'button'); |
|
83 |
tmp_input.setAttribute('value', '-'); |
|
84 |
tmp_input.onclick = function(){self.tmp_tr.parentNode.removeChild(self.tmp_tr); return false;}; |
|
85 |
tmp_td.appendChild(tmp_input); |
|
86 |
} |
|
87 |
this.tmp_tr.appendChild(tmp_td); |
|
88 |
nb_filter++; |
|
89 |
} |
|
90 |
new filter(); |
|
91 |
</script> |
|
92 |
EOD; |
|
93 |
|
|
94 |
$to_be_pre_list_content .= $adv_search; |
|
95 |
} |
|
96 |
|
|
97 |
// echo "<pre>"; |
|
98 |
// print_r(json_encode($pme_instance->fds)); |
|
99 |
// echo "</pre>"; |
|
100 |
|
|
101 |
echo <<<EOD |
|
102 |
<div id="to_be_pre_list"> |
|
103 |
$to_be_pre_list_content |
|
104 |
</div> |
|
105 |
EOD; |
|
106 |
?> |
|
107 |
|
|
108 |
<div id="post_list"></div> |
|
109 |
|
|
110 |
<script type="text/javascript"> |
|
111 |
q = document.getElementById("to_be_post_list"); |
|
112 |
if (q != null) { |
|
113 |
o = document.getElementById("post_list"); |
|
114 |
o.appendChild(q.parentNode.removeChild(q)); |
|
115 |
} |
|
116 |
q = document.getElementById("to_be_pre_list"); |
|
117 |
if (q != null) { |
|
118 |
o = document.getElementById("pre_list"); |
|
119 |
o.appendChild(q.parentNode.removeChild(q)); |
|
120 |
} |
|
121 |
</script> |
b/src/headers.php | ||
---|---|---|
78 | 78 |
<li id="wwwblast"><a href="wwwblast.php"> wwwBlast </a></li> |
79 | 79 |
<li id="antibodies"><a href="antibodies.php"> Antibodies </a></li> |
80 | 80 |
<li id="collections"><a href="collections.php"> Collections </a></li> |
81 |
<li id="pipethistory"><a href="pipethistory.php"> Pipet History </a></li> |
|
81 |
<li id="pip_stock"><a href="pip_stock.php"> Pipets </a></li> |
|
82 |
<li id="pip_history"><a href="pip_history.php"> Pipet History </a></li> |
|
82 | 83 |
<li id="notebooks"><a href="notebooks.php"> Lab's Notebooks </a></li> |
83 | 84 |
<li id="logout"><a href="logout.php"> Logout </a></li> |
84 | 85 |
<li id="admin"><a href="admin.php"> Admin </a></li> |
... | ... | |
95 | 96 |
</script> |
96 | 97 |
|
97 | 98 |
|
99 |
|
|
98 | 100 |
<?php |
99 | 101 |
|
100 |
$tb = split(".",array_reverse(split("/",$_SERVER["SCRIPT_FILENAME"]))[0])[0] |
|
102 |
$to_be_post_list_content = ""; |
|
103 |
$to_be_pre_list_content = ""; |
|
104 |
// print($_SERVER["SCRIPT_FILENAME"]); |
|
105 |
|
|
106 |
|
|
107 |
$tb = array_shift(split("\.php", array_pop(split("/", $_SERVER["SCRIPT_FILENAME"])))); |
|
101 | 108 |
/*************************/ |
102 | 109 |
// |
103 | 110 |
// Connect to DB and |
... | ... | |
106 | 113 |
/*************************/ |
107 | 114 |
|
108 | 115 |
require_once ("connect_entry.php"); |
109 |
require_once ("session.php");
|
|
116 |
require_once ("lib/session.lib.php");
|
|
110 | 117 |
// connect to DB |
111 | 118 |
$connexion = mysql_pconnect (SERVEUR, NOM, PASSE); |
112 | 119 |
if (!$connexion) |
... | ... | |
119 | 126 |
echo "Sorry, connexion to database " . BASE . " failed\n"; |
120 | 127 |
exit; |
121 | 128 |
} |
122 |
// authentification |
|
123 |
CleanOldSessions($connexion); |
|
124 |
$session = ControleAcces ("antibodies.php", $_POST, session_id(), $connexion); |
|
125 |
if (!is_object($session)) { |
|
126 |
exit; |
|
129 |
|
|
130 |
if (!(in_array($tb, array("home", "")))) { |
|
131 |
// authentification |
|
132 |
CleanOldSessions($connexion); |
|
133 |
$session = control_access ($tb.".php", $_POST, session_id(), $connexion); |
|
134 |
if (!is_object($session)) { |
|
135 |
exit; |
|
136 |
} |
|
137 |
|
|
138 |
// According to login: |
|
139 |
// Define priviledge options |
|
140 |
// to pass to phpMyEdit |
|
141 |
// |
|
142 |
//check that visitor is allowed to use this table |
|
143 |
if ($tb == "admin" && $session->mode != "super") { |
|
144 |
echo "<p>Sorry, your session is not granted access to admin panel. Please logout and try again with appropriate login...</p>"; |
|
145 |
exit; |
|
146 |
} else if ($session->target_table != $tb && $session->target_table != "all") { |
|
147 |
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>"; |
|
148 |
exit; |
|
149 |
} |
|
150 |
//define priv options and display warning accordingly |
|
151 |
if ($session->login == "superuser"){ |
|
152 |
$privopt = 'ACPVDF'; |
|
153 |
$colorband = "red"; |
|
154 |
$messageband = '<blink>WARNING</bink>: You are in <I><B> SUPERUSER </I></B> mode, at your own risk.'; |
|
155 |
} else if ($session->mode == "view"){ |
|
156 |
$privopt = 'VF'; |
|
157 |
$colorband = "#00ff00"; |
|
158 |
$messageband = "You are safely in VIEW mode"; |
|
159 |
} else if ($session->mode == "add"){ |
|
160 |
$privopt = 'APVF'; |
|
161 |
$colorband = "orange"; |
|
162 |
$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions'; |
|
163 |
} else if ($session->mode == "edit"){ |
|
164 |
$privopt = 'ACPVDF'; |
|
165 |
$colorband = "rgb(250,0,255)"; |
|
166 |
$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.'; |
|
167 |
} else{ |
|
168 |
$privopt = ''; |
|
169 |
$colorband = "grey"; |
|
170 |
} |
|
171 |
echo '<style type="text/css"> '; |
|
172 |
echo "h4 {background-color: $colorband }"; |
|
173 |
echo '</style>'; |
|
174 |
echo "<h4> $messageband </h4>"; |
|
175 |
echo "<HR>"; |
|
127 | 176 |
} |
177 |
// Fix a problem displaying |
|
178 |
// symbols (such as delta) |
|
179 |
mysql_query("SET NAMES 'UTF8'", $connexion); |
|
180 |
|
|
181 |
// // Include My own MVC (FCh.) |
|
182 |
// $mvc_filename = $tb . ".MVC.php"; |
|
183 |
// if (file_exists($mvc_filename)) { |
|
184 |
// require($mvc_filename); |
|
185 |
// } |
|
186 |
|
|
187 |
// Number of records to display on the screen |
|
188 |
// Value of -1 lists all records in a table |
|
189 |
$opts['inc'] = 15; |
|
190 |
|
|
191 |
// Number of lines to display on multiple selection filters |
|
192 |
$opts['multiple'] = '4'; |
|
193 |
|
|
194 |
// Navigation style: B - buttons (default), T - text links, G - graphic links |
|
195 |
// Buttons position: U - up, D - down (default) |
|
196 |
$opts['navigation'] = 'UDBG'; |
|
197 |
|
|
198 |
// Display special page elements |
|
199 |
$opts['display'] = array( |
|
200 |
'form' => true, |
|
201 |
'query' => true, |
|
202 |
'sort' => true, |
|
203 |
'time' => true, |
|
204 |
'tabs' => true |
|
205 |
); |
|
206 |
|
|
207 |
// Set default prefixes for variables |
|
208 |
$opts['js']['prefix'] = 'PME_js_'; |
|
209 |
$opts['dhtml']['prefix'] = 'PME_dhtml_'; |
|
210 |
$opts['cgi']['prefix']['operation'] = 'PME_op_'; |
|
211 |
$opts['cgi']['prefix']['sys'] = 'PME_sys_'; |
|
212 |
$opts['cgi']['prefix']['data'] = 'PME_data_'; |
|
213 |
|
|
214 |
/* Get the user's default language and use it if possible or you can |
|
215 |
specify particular one you want to use. Refer to official documentation |
|
216 |
for list of available languages. */ |
|
217 |
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8'; |
|
128 | 218 |
|
129 |
/*************************/ |
|
130 |
// |
|
131 |
// According to login: |
|
132 |
// Define priviledge options |
|
133 |
// to pass to phpMyEdit |
|
134 |
// |
|
135 |
/*************************/ |
|
219 |
?> |
|
136 | 220 |
|
137 |
//check that visitor is allowed to use this table |
|
138 |
if ($session->target_table != $tb && $session->target_table != "all") { |
|
139 |
echo "Sorry, your session is not granted access to table <B> $tb </B><p>"; |
|
140 |
echo "Please logout and try again with appropriate login<P>"; |
|
141 |
exit; |
|
142 |
} |
|
143 | 221 |
|
144 |
//define priv options and display warning accordingly |
|
145 |
if ($session->mode == "view"){ |
|
146 |
$privopt = 'VF'; |
|
147 |
$colorband = "#00ff00"; |
|
148 |
$messageband = "You are safely in VIEW mode"; |
|
149 |
} |
|
150 |
else if ($session->mode == "add"){ |
|
151 |
$privopt = 'APVF'; |
|
152 |
$colorband = "orange"; |
|
153 |
$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions'; |
|
154 |
} |
|
155 |
else if ($session->mode == "edit"){ |
|
156 |
$privopt = 'ACPVDF'; |
|
157 |
$colorband = "rgb(250,0,255)"; |
|
158 |
$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.'; |
|
159 |
} |
|
160 |
else{ |
|
161 |
$privopt = ''; |
|
162 |
$colorband = "grey"; |
|
222 |
<div id="pre_list"></div> |
|
223 |
|
|
224 |
<?php |
|
225 |
|
|
226 |
// MVC for ADV_SEARCH |
|
227 |
if (array_key_exists("action", $_REQUEST)) { |
|
228 |
if ($_REQUEST["action"] == "ADV_SEARCH") { |
|
229 |
$fltr = ""; |
|
230 |
$cols = preg_filter("/col_/","", array_keys($_REQUEST)); |
|
231 |
foreach ($cols as $index) { |
|
232 |
if ($index != 0) { |
|
233 |
$fltr .= " " . $_REQUEST["op_$index"]; |
|
234 |
} |
|
235 |
if ($_REQUEST["col_$index"] == "Genotype") { |
|
236 |
$k = $_REQUEST["input_$index"]; |
|
237 |
$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%')"; |
|
238 |
} else { |
|
239 |
$fltr .= " " . $_REQUEST["col_$index"]; |
|
240 |
$fltr .= " " . $_REQUEST["cond_$index"]; |
|
241 |
if ($_REQUEST["cond_$index"] == "LIKE") { |
|
242 |
$fltr .= " '%" . $_REQUEST["input_$index"] . "%'"; |
|
243 |
} else { |
|
244 |
$fltr .= " '" . $_REQUEST["input_$index"] . "'"; |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
$opts["filters"] = $fltr; |
|
249 |
} |
|
163 | 250 |
} |
164 |
echo '<style type="text/css"> '; |
|
165 |
echo "h4 {background-color: $colorband }"; |
|
166 |
echo '</style>'; |
|
167 |
echo "<h4> $messageband </h4>"; |
|
168 |
echo "<HR>"; |
|
169 |
?> |
|
170 | 251 |
|
252 |
?> |
b/src/home.php | ||
---|---|---|
2 | 2 |
session_start (); |
3 | 3 |
require("headers.php"); |
4 | 4 |
?> |
5 |
|
|
5 | 6 |
<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. |
6 | 7 |
|
7 | 8 |
<pre> |
8 |
[TODO] HERE IS A FUNNY PICTURE... |
|
9 |
`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;" |
|
10 |
`=`,'=/ `=`,'=/ `=`,'=/ `=`,'=/ |
|
11 |
y==/ y==/ y==/ y==/ |
|
12 |
,=,-<=`. ,=,-<=`. ,=,-<=`. ,=,-<=`. |
|
13 |
,-'-' `-=_,-'-' `-=_,-'-' `-=_,-'-' `-=_ |
|
9 | 14 |
</pre> |
10 | 15 |
|
11 | 16 |
<h3>Useful Lab Links</h3> |
... | ... | |
15 | 20 |
<li><a href="http://cremone.biologie.ens-lyon.fr:8888">Galaxy</a> |
16 | 21 |
<li><a href="http://cremone.biologie.ens-lyon.fr/~florent/dokuwiki/doku.php?do=index">FAQ around computer science</a> |
17 | 22 |
</ul> |
18 |
|
|
19 |
|
b/src/last_trigger.MVC.php | ||
---|---|---|
1 |
<?php |
|
2 |
$to_be_post_list = <<<EOD |
|
3 |
<div id="to_be_post_list"> |
|
4 |
$to_be_post_list_content |
|
5 |
</div> |
|
6 |
EOD; |
|
7 |
echo $to_be_post_list; |
|
8 |
?> |
b/src/lib/session.lib.php | ||
---|---|---|
1 |
<?php |
|
2 |
// Base sur Ph. Rigaux, OReilly 3e edition. |
|
3 |
// table visitors (login/pwd) |
|
4 |
// table websession |
|
5 |
// Les privileges de labmember_add sont: |
|
6 |
// SELECT sur visitors, |
|
7 |
// et ALL sur sessionWeb |
|
8 |
|
|
9 |
require_once 'lib/form.cls.php'; |
|
10 |
|
|
11 |
function execQry ($qry, $bd) |
|
12 |
{ |
|
13 |
$result = mysql_query($qry, $bd); |
|
14 |
if (!$result) |
|
15 |
{ |
|
16 |
echo "error in execQry ". mysql_error ($db); |
|
17 |
exit; |
|
18 |
} |
|
19 |
else |
|
20 |
return $result; |
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
function CleanOldSessions ($bd) |
|
25 |
{ |
|
26 |
//erase sessions outdated since 15 days |
|
27 |
$tooOld = date ("U") - 1296000; |
|
28 |
$qry = "DELETE FROM websession WHERE time_limit < $tooOld"; |
|
29 |
$resultat = execQry ($qry, $bd); |
|
30 |
} |
|
31 |
|
|
32 |
// uses form class from "form.cls.php" |
|
33 |
function LoginForm ($nom_script, $login_default = "view") |
|
34 |
{ |
|
35 |
$form = new form (); |
|
36 |
|
|
37 |
$form -> openForm (array ('action' => "$nom_script", 'id' => 'LoginForm')); |
|
38 |
$form -> openFieldset (array ('style' => 'border:1px dotted red; width: 300px;')); |
|
39 |
$form -> addLegend ('Please Login'); |
|
40 |
|
|
41 |
$form -> addInput ('text', array ('id' => 'Login', 'value' => "$login_default", 'name' => 'visitor_login', 'test' => 'test')); |
|
42 |
$form -> addLabel (' login', array ('for' => 'MyText', 'style' => 'margin: 5px;')); |
|
43 |
$form -> addAnything ('<br /><br />'); |
|
44 |
|
|
45 |
$form -> addInput ('password', array ('id' => 'Pwd', 'value' => '', 'name' => 'visitor_pwd', 'test' => 'test')); |
|
46 |
$form -> addLabel (' password', array ('for' => 'MyText', 'style' => 'margin: 5px;')); |
|
47 |
$form -> addAnything ('<br /><br />'); |
|
48 |
|
|
49 |
$form -> addInput ('submit', array ('id' => 'MyButton', 'value' => 'Submit', 'test' => 'test')); |
|
50 |
$form -> closeFieldset (); |
|
51 |
$form -> closeForm (); |
|
52 |
|
|
53 |
echo '<br><I>To login, cookies must be enabled on your browser</I><br><br>'; |
|
54 |
echo '<div >';//style="border: 1px solid darkgrey; text-align: center; width: 310px;">'; |
|
55 |
// on l'affiche |
|
56 |
echo $form; |
|
57 |
echo '</div>'; |
|
58 |
|
|
59 |
echo '</body>'; |
|
60 |
echo '</html>'; |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
function get_visitor ($login, $bd) { |
|
65 |
$log = substr($login, 0, 3); |
|
66 |
$qry = "SELECT * FROM visitors WHERE `login` LIKE '%$log%'"; |
|
67 |
$result = mysql_query($qry, $bd); |
|
68 |
while($vis = mysql_fetch_object($result)) { |
|
69 |
if ($vis->login == substr($login, 0, strlen($vis->login))) { |
|
70 |
if ($vis->target_table != "all"){ |
|
71 |
$vis->target_table = substr($login, strlen($vis->login)); |
|
72 |
} |
|
73 |
return $vis; |
|
74 |
} |
|
75 |
} |
|
76 |
return NULL; |
|
77 |
} |
|
78 |
|
|
79 |
function create_session ($bd, $login, $pwd, $id_session){ |
|
80 |
$visitor = get_visitor ($login, $bd); |
|
81 |
//L'internaute existe-t-il? |
|
82 |
if (is_object($visitor)) { |
|
83 |
//verif du mot de passe |
|
84 |
if ($visitor->pwd == md5($pwd)) { |
|
85 |
// on insere une session de trente minutes dans table websession |
|
86 |
$time_limit = date ("U") + 1800; |
|
87 |
$insSession = "INSERT INTO websession (id_session, login, " |
|
88 |
. "time_limit, target_table, " |
|
89 |
. "mode) VALUES ('$id_session', '$login', '$time_limit', '$visitor->target_table', '$visitor->mode')"; |
|
90 |
$resultat = execQry ($insSession, $bd); |
|
91 |
return TRUE; |
|
92 |
} else { |
|
93 |
echo "<B> Sorry, incorrect password for $login !</B><P>"; |
|
94 |
return FALSE; |
|
95 |
} |
|
96 |
} else { |
|
97 |
echo "<B>Sorry, $login is not a registered login!</B><P>"; |
|
98 |
return FALSE; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
//check session validity, destroy if not |
|
103 |
function is_valid_session ($session, $bd) { |
|
104 |
//is time over? |
|
105 |
$now = date ("U"); |
|
106 |
if ($session->time_limit < $now) { |
|
107 |
session_destroy(); |
|
108 |
$destr = "DELETE FROM websession WHERE id_session='$session->id_session'"; |
|
109 |
$resultat = execQry ($destr, $bd); |
|
110 |
} else { //session is valid |
|
111 |
return TRUE; |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
function get_session ($id_session, $bd) { |
|
117 |
$qry = "SELECT * FROM websession WHERE `id_session` = '$id_session'"; |
|
118 |
while($sess = mysql_fetch_object(execQry ($qry, $bd))) { |
|
119 |
if ($sess->id_session == $id_session) { |
|
120 |
return $sess; |
|
121 |
} |
|
122 |
} |
|
123 |
return NULL; |
|
124 |
} |
|
125 |
|
|
126 |
// main function for access control |
|
127 |
function control_access ($nom_script, $infos_login, $id_session, $bd) { |
|
128 |
//recherche la session |
|
129 |
$session_courante = get_session ($id_session, $bd); |
|
130 |
//cas 1: la session existe, on verifie sa validite |
|
131 |
if (is_object($session_courante)) { |
|
132 |
// la session existe, est-elle valide? |
|
133 |
if (is_valid_session ($session_courante, $bd)) { |
|
134 |
// on renvoie l'objet session |
|
135 |
return $session_courante; |
|
136 |
} else { |
|
137 |
echo "<B> Your session is not (or no longer) valid.<P></B>\n"; |
|
138 |
} |
|
139 |
} |
|
140 |
// Cas 2.a: La session n'existe pas mais un login et pwd ont ete fournis |
|
141 |
if (isset($infos_login['visitor_login']) & isset($infos_login['visitor_pwd'])) { |
|
142 |
// Les login/pwd sont-ils corrects? |
|
143 |
if (create_session ($bd, $infos_login['visitor_login'], $infos_login['visitor_pwd'], $id_session)) { |
|
144 |
// on renvoie l'object session |
|
145 |
return get_session ($id_session, $bd); |
|
146 |
} else { |
|
147 |
echo "<B> Identification failed.<P></B>\n"; |
|
148 |
} |
|
149 |
} |
|
150 |
// Cas 2.b: La session n'existe pas |
|
151 |
// et il faut afficher le formulaire d'identification |
|
152 |
LoginForm ($nom_script); |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
?> |
b/src/logout.php | ||
---|---|---|
1 | 1 |
<?php |
2 |
session_start ();
|
|
2 |
session_start(); |
|
3 | 3 |
require_once ("connect_entry.php"); |
4 |
require_once ("session.php");
|
|
4 |
require_once ("lib/session.lib.php");
|
|
5 | 5 |
|
6 | 6 |
// connect to DB |
7 | 7 |
$connexion = mysql_pconnect (SERVEUR, NOM, PASSE); |
8 |
if (!$connexion) |
|
9 |
{ |
|
8 |
if (!$connexion) { |
|
10 | 9 |
echo "Logout error: Sorry, connexion to " . SERVEUR . " failed\n"; |
11 | 10 |
exit; |
12 | 11 |
} |
13 |
if (!mysql_select_db (BASE, $connexion)) |
|
14 |
{ |
|
12 |
if (!mysql_select_db (BASE, $connexion)) { |
|
15 | 13 |
echo "Logout error: Sorry, connexion to database " . BASE . " failed\n"; |
16 | 14 |
exit; |
17 | 15 |
} |
... | ... | |
21 | 19 |
$qry = "DELETE FROM websession WHERE id_session = '$id'"; |
22 | 20 |
$resultat = execQry ($qry, $connexion); |
23 | 21 |
|
24 |
//go to welcome page |
|
25 |
header('Location: home.php'); |
|
26 |
session_destroy (); |
|
22 |
session_destroy(); |
|
23 |
header("Location: home.php"); |
|
27 | 24 |
?> |
b/src/notebooks.php | ||
---|---|---|
2 | 2 |
session_start (); |
3 | 3 |
require("headers.php"); |
4 | 4 |
|
5 |
|
|
6 | 5 |
/* |
7 | 6 |
* IMPORTANT NOTE: This generated file contains only a subset of huge amount |
8 | 7 |
* of options that can be used with phpMyEdit. To get information about all |
... | ... | |
19 | 18 |
* generating setup script: 1.50 |
20 | 19 |
*/ |
21 | 20 |
|
22 |
|
|
23 |
|
|
24 |
/*************************/ |
|
25 |
// |
|
26 |
// Connect to DB and |
|
27 |
// handle session/authentification |
|
28 |
// |
|
29 |
/*************************/ |
|
30 |
require_once ("connect_entry.php"); |
|
31 |
require_once ("session.php"); |
|
32 |
// connect to DB |
|
33 |
$connexion = mysql_pconnect (SERVEUR, NOM, PASSE); |
|
34 |
if (!$connexion) |
|
35 |
{ |
|
36 |
echo "Sorry, connexion to " . SERVEUR . " failed\n"; |
|
37 |
exit; |
|
38 |
} |
|
39 |
if (!mysql_select_db (BASE, $connexion)) |
|
40 |
{ |
|
41 |
echo "Sorry, connexion to database " . BASE . " failed\n"; |
|
42 |
exit; |
|
43 |
} |
|
44 |
// authentification |
|
45 |
CleanOldSessions($connexion); |
|
46 |
$session = ControleAcces ("notebooks.php", $_POST, session_id(), $connexion); |
|
47 |
if (!is_object($session)) |
|
48 |
exit; |
|
49 |
|
|
50 |
/*************************/ |
|
51 |
// |
|
52 |
// According to login: |
|
53 |
// Define priviledge options |
|
54 |
// to pass to phpMyEdit |
|
55 |
// |
|
56 |
/*************************/ |
|
57 |
|
|
58 |
//check that visitor is allowed to use this table |
|
59 |
$tb = "notebooks"; |
|
60 |
if ($session->target_table != $tb && $session->target_table != "all") |
|
61 |
{ |
|
62 |
echo "Sorry, your session is not granted access to table <B> $tb </B><p>"; |
|
63 |
echo "Please logout and try again with appropriate login<P>"; |
|
64 |
exit; |
|
65 |
} |
|
66 |
|
|
67 |
//define priv options and change background color accordingly |
|
68 |
if ($session->mode == "view"){ |
|
69 |
$privopt = 'VF'; |
|
70 |
$colorband = "#00ff00"; |
|
71 |
$messageband = "You are safely in VIEW mode"; |
|
72 |
} |
|
73 |
else if ($session->mode == "add"){ |
|
74 |
$privopt = 'APVF'; |
|
75 |
$colorband = "orange"; |
|
76 |
$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions'; |
|
77 |
} |
|
78 |
else if ($session->mode == "edit"){ |
|
79 |
$privopt = 'ACPVDF'; |
|
80 |
$colorband = "rgb(250,0,255)"; |
|
81 |
$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.'; |
|
82 |
} |
|
83 |
else{ |
|
84 |
$privopt = ''; |
|
85 |
$colorband = "grey"; |
|
86 |
} |
|
87 |
echo '<style type="text/css"> '; |
|
88 |
echo "h4 {background-color: $colorband }"; |
|
89 |
echo '</style>'; |
|
90 |
echo "<h4> $messageband </h4>"; |
|
91 |
echo "<HR>"; |
|
92 |
|
|
93 |
//************************/ |
|
94 |
// |
|
95 |
// Fix a problem displaying |
|
96 |
// symbols (such as delta) |
|
97 |
// |
|
98 |
//************************/ |
|
99 |
|
|
100 |
mysql_query("SET NAMES 'UTF8'", $connexion); |
|
101 |
|
|
102 | 21 |
/*************************/ |
103 | 22 |
// |
104 | 23 |
// Pass phpMyEdit options |
105 | 24 |
// |
106 | 25 |
/*************************/ |
107 | 26 |
|
108 |
|
|
109 | 27 |
$opts['dbh'] = $connexion; |
110 | 28 |
$opts['tb'] = $tb; |
111 | 29 |
|
... | ... | |
250 | 168 |
// Before displaying the view page |
251 | 169 |
|
252 | 170 |
|
253 |
// Now important call to phpMyEdit |
|
254 |
require_once 'phpMyEdit.class.php'; |
|
255 |
new phpMyEdit($opts); |
|
256 |
|
|
257 |
?> |
|
258 |
|
|
259 |
|
|
171 |
require("footers.php"); |
|
172 |
?> |
b/src/oligos.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
session_start (); |
3 |
|
|
4 |
|
|
5 | 3 |
require("headers.php"); |
6 | 4 |
|
7 |
|
|
8 | 5 |
/* |
9 | 6 |
* IMPORTANT NOTE: This generated file contains only a subset of huge amount |
10 | 7 |
* of options that can be used with phpMyEdit. To get information about all |
... | ... | |
23 | 20 |
|
24 | 21 |
/*************************/ |
25 | 22 |
// |
26 |
// Connect to DB and |
|
27 |
// handle session/authentification |
|
28 |
// |
|
29 |
/*************************/ |
|
30 |
require_once ("connect_entry.php"); |
|
31 |
require_once ("session.php"); |
|
32 |
// connect to DB |
|
33 |
$connexion = mysql_pconnect (SERVEUR, NOM, PASSE); |
|
34 |
if (!$connexion) |
|
35 |
{ |
|
36 |
echo "Sorry, connexion to " . SERVEUR . " failed\n"; |
|
37 |
exit; |
|
38 |
} |
|
39 |
if (!mysql_select_db (BASE, $connexion)) |
|
40 |
{ |
|
41 |
echo "Sorry, connexion to database " . BASE . " failed\n"; |
|
42 |
exit; |
|
43 |
} |
|
44 |
// authentification |
|
45 |
CleanOldSessions($connexion); |
|
46 |
$session = ControleAcces ("oligos.php", $_POST, session_id(), $connexion); |
|
47 |
if (!is_object($session)) |
|
48 |
exit; |
|
49 |
|
|
50 |
/*************************/ |
|
51 |
// |
|
52 |
// According to login: |
|
53 |
// Define priviledge options |
|
54 |
// to pass to phpMyEdit |
|
55 |
// |
|
56 |
/*************************/ |
|
57 |
|
|
58 |
//check that visitor is allowed to use this table |
|
59 |
$tb = "oligos"; |
|
60 |
if ($session->target_table != $tb && $session->target_table != "all") |
|
61 |
{ |
|
62 |
echo "Sorry, your session is not granted access to table <B> $tb </B><p>"; |
|
63 |
echo "Please logout and try again with appropriate login<P>"; |
|
64 |
exit; |
|
65 |
} |
|
66 |
|
|
67 |
//define priv options and display warning accordingly |
|
68 |
if ($session->mode == "view"){ |
|
69 |
$privopt = 'VF'; |
|
70 |
$colorband = "#00ff00"; |
|
71 |
$messageband = "You are safely in VIEW mode"; |
|
72 |
} |
|
73 |
else if ($session->mode == "add"){ |
|
74 |
$privopt = 'APVF'; |
|
75 |
$colorband = "orange"; |
|
76 |
$messageband = 'You are in <I><B> ADD </I></B> mode, please logout after you additions'; |
|
77 |
} |
|
78 |
else if ($session->mode == "edit"){ |
|
79 |
$privopt = 'ACPVDF'; |
|
80 |
$colorband = "rgb(250,0,255)"; |
|
81 |
$messageband = 'IMPORTANT: You are in <I><B> EDIT </I></B> mode, please logout after editing.'; |
|
82 |
} |
|
83 |
else{ |
|
84 |
$privopt = ''; |
|
85 |
$colorband = "grey"; |
|
86 |
} |
|
87 |
echo '<style type="text/css"> '; |
|
88 |
echo "h4 {background-color: $colorband }"; |
|
89 |
echo '</style>'; |
|
90 |
echo "<h4> $messageband </h4>"; |
|
91 |
echo "<HR>"; |
|
92 |
|
|
93 |
/*************************/ |
|
94 |
// |
|
95 | 23 |
// Pass phpMyEdit options |
96 | 24 |
// |
97 | 25 |
/*************************/ |
... | ... | |
248 | 176 |
'column' => 'type') |
249 | 177 |
); |
250 | 178 |
|
251 |
// Now important call to phpMyEdit |
|
252 |
require_once 'phpMyEdit.class.php'; |
|
253 |
new phpMyEdit($opts); |
|
254 |
|
|
255 |
?> |
|
179 |
require("footers.php"); |
|
180 |
?> |
b/src/pip_history.TSP.php | ||
---|---|---|
1 |
<?php |
|
2 |
// a Trigger to display pipet info |
|
3 |
$allevents = $this->myQuery("SELECT * FROM ".$this->tb); |
|
4 |
$allpipets = $this->myQuery("SELECT * FROM pip_stock"); |
|
5 |
|
|
6 |
/* there must be a more straightforward way to do this |
|
7 |
* but this seems to work |
|
8 |
*/ |
|
9 |
// reach the event displayed |
|
10 |
$foundevent = 0; |
|
11 |
while(!$foundevent && $event = mysql_fetch_object($allevents)){ |
|
12 |
if ($event->ID == $this->rec) |
|
13 |
$foundevent = 1; |
|
14 |
} |
|
15 |
// record Serial Number of the pipet considered |
|
16 |
if ($event){ |
|
17 |
$SerialNum = $event->Serial_Number ; |
|
18 |
} |
|
19 |
|
|
20 |
// reach the pipet displayed |
|
21 |
$foundpipet = 0; |
|
22 |
while(!$foundpipet && $pipet = mysql_fetch_object($allpipets)){ |
|
23 |
if ($pipet->Serial_Number == $SerialNum) |
|
24 |
$foundpipet = 1; |
|
25 |
} |
|
26 |
|
|
27 |
if ($pipet){ |
|
28 |
// print pipet infos |
|
29 |
echo " Pipet : ". |
|
30 |
$pipet->Marque . " " . |
|
31 |
$pipet->Type . " " . |
|
32 |
"<BR>" . |
|
33 |
"Serial Number: ". |
|
34 |
$pipet->Serial_Number . "<BR>". "<BR>"; |
|
35 |
} |
|
36 |
|
|
37 |
?> |
b/src/pip_history.php | ||
---|---|---|
1 |
<?php |
|
2 |
session_start (); |
|
3 |
require("headers.php"); |
|
4 |
|
|
5 |
/* |
|
6 |
* IMPORTANT NOTE: This generated file contains only a subset of huge amount |
|
7 |
* of options that can be used with phpMyEdit. To get information about all |
|
8 |
* features offered by phpMyEdit, check official documentation. It is available |
|
9 |
* online and also for download on phpMyEdit project management page: |
|
10 |
* |
|
11 |
* http://platon.sk/projects/main_page.php?project_id=5 |
|
12 |
* |
|
13 |
* This file was generated by: |
|
14 |
* |
|
15 |
* phpMyEdit version: unknown |
|
16 |
* phpMyEdit.class.php core class: 1.204 |
|
17 |
* phpMyEditSetup.php script: 1.50 |
|
18 |
* generating setup script: 1.50 |
|
19 |
*/ |
|
20 |
|
|
21 |
//************************/ |
|
22 |
// |
|
23 |
// Update list of pipet Users |
|
24 |
// |
|
25 |
//************************/ |
|
26 |
|
|
27 |
mysql_query("DELETE FROM pip_users", $connexion); |
|
28 |
mysql_query("INSERT INTO pip_users (User) SELECT id FROM lab_members", $connexion); |
|
29 |
mysql_query("INSERT INTO pip_users (User) SELECT User FROM pip_generic_user", $connexion); |
|
30 |
mysql_query("DELETE FROM pip_users WHERE User IN (SELECT User FROM pip_nonusers)", $connexion); |
|
31 |
|
|
32 |
/*************************/ |
|
33 |
// |
|
34 |
// Pass phpMyEdit options |
|
35 |
// |
|
36 |
/*************************/ |
|
37 |
|
|
38 |
|
|
39 |
$opts['dbh'] = $connexion; |
|
40 |
$opts['tb'] = $tb; |
|
41 |
|
|
42 |
// Name of field which is the unique key |
|
43 |
$opts['key'] = 'ID'; |
|
44 |
|
|
45 |
// Type of key field (int/real/string/date etc.) |
|
46 |
$opts['key_type'] = 'int'; |
|
47 |
|
|
48 |
// Sorting field(s) |
|
49 |
$opts['sort_field'] = array('ID'); |
|
50 |
|
|
51 |
// Number of records to display on the screen |
|
52 |
// Value of -1 lists all records in a table |
|
53 |
$opts['inc'] = 15; |
|
54 |
|
|
55 |
// Options you wish to give the users |
|
56 |
// A - add, C - change, P - copy, V - view, D - delete, |
|
57 |
// F - filter, I - initial sort suppressed |
|
58 |
$opts['options'] = $privopt; |
|
59 |
|
|
60 |
// Number of lines to display on multiple selection filters |
|
61 |
$opts['multiple'] = '4'; |
|
62 |
|
|
63 |
// Navigation style: B - buttons (default), T - text links, G - graphic links |
|
64 |
// Buttons position: U - up, D - down (default) |
|
65 |
$opts['navigation'] = 'UDBG'; |
|
66 |
|
|
67 |
// Display special page elements |
|
68 |
$opts['display'] = array( |
|
69 |
'form' => true, |
|
70 |
'query' => true, |
|
71 |
'sort' => true, |
|
72 |
'time' => true, |
|
73 |
'tabs' => true |
|
74 |
); |
|
75 |
|
|
76 |
// Set default prefixes for variables |
|
77 |
$opts['js']['prefix'] = 'PME_js_'; |
|
78 |
$opts['dhtml']['prefix'] = 'PME_dhtml_'; |
|
79 |
$opts['cgi']['prefix']['operation'] = 'PME_op_'; |
|
80 |
$opts['cgi']['prefix']['sys'] = 'PME_sys_'; |
|
81 |
$opts['cgi']['prefix']['data'] = 'PME_data_'; |
|
82 |
|
|
83 |
/* Get the user's default language and use it if possible or you can |
|
84 |
specify particular one you want to use. Refer to official documentation |
|
85 |
for list of available languages. */ |
|
86 |
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8'; |
|
87 |
|
|
88 |
/* Table-level filter capability. If set, it is included in the WHERE clause |
|
89 |
of any generated SELECT statement in SQL query. This gives you ability to |
|
90 |
work only with subset of data from table. |
|
91 |
|
|
92 |
$opts['filters'] = "column1 like '%11%' AND column2<17"; |
|
93 |
$opts['filters'] = "section_id = 9"; |
|
94 |
$opts['filters'] = "PMEtable0.sessions_count > 200"; |
|
95 |
*/ |
|
96 |
|
|
97 |
/* Field definitions |
|
98 |
|
|
99 |
Fields will be displayed left to right on the screen in the order in which they |
|
100 |
appear in generated list. Here are some most used field options documented. |
|
101 |
|
|
102 |
['name'] is the title used for column headings, etc.; |
|
103 |
['maxlen'] maximum length to display add/edit/search input boxes |
|
104 |
['trimlen'] maximum length of string content to display in row listing |
|
105 |
['width'] is an optional display width specification for the column |
|
106 |
e.g. ['width'] = '100px'; |
|
107 |
['mask'] a string that is used by sprintf() to format field output |
|
108 |
['sort'] true or false; means the users may sort the display on this column |
|
109 |
['strip_tags'] true or false; whether to strip tags from content |
|
110 |
['nowrap'] true or false; whether this field should get a NOWRAP |
|
111 |
['select'] T - text, N - numeric, D - drop-down, M - multiple selection |
|
112 |
['options'] optional parameter to control whether a field is displayed |
|
113 |
L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view |
|
114 |
Another flags are: |
|
115 |
R - indicates that a field is read only |
|
116 |
W - indicates that a field is a password field |
|
117 |
H - indicates that a field is to be hidden and marked as hidden |
|
118 |
['URL'] is used to make a field 'clickable' in the display |
|
119 |
e.g.: 'mailto:$value', 'http://$value' or '$page?stuff'; |
|
120 |
['URLtarget'] HTML target link specification (for example: _blank) |
|
121 |
['textarea']['rows'] and/or ['textarea']['cols'] |
|
122 |
specifies a textarea is to be used to give multi-line input |
|
123 |
e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10 |
|
124 |
['values'] restricts user input to the specified constants, |
|
125 |
e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99) |
|
126 |
['values']['table'] and ['values']['column'] restricts user input |
|
127 |
to the values found in the specified column of another table |
|
128 |
['values']['description'] = 'desc_column' |
|
129 |
The optional ['values']['description'] field allows the value(s) displayed |
|
130 |
to the user to be different to those in the ['values']['column'] field. |
|
131 |
This is useful for giving more meaning to column values. Multiple |
|
132 |
descriptions fields are also possible. Check documentation for this. |
|
133 |
*/ |
|
134 |
|
|
135 |
$opts['fdd']['ID'] = array( |
|
136 |
'name' => 'ID', |
|
137 |
'select' => 'N', |
|
138 |
'options' => 'LAVCPDR', // auto increment |
|
139 |
'maxlen' => 10, |
|
140 |
//'default' => '0', |
|
141 |
'sort' => true |
|
142 |
); |
|
143 |
$opts['fdd']['Date'] = array( |
|
144 |
'name' => 'Date', |
|
145 |
'options' => 'LFAVCPD', |
|
146 |
'select' => 'N', |
|
147 |
'maxlen' => 10, |
|
148 |
'sort' => true, |
|
149 |
'default' => date("Y-m-d", strtotime("now")) |
|
150 |
); |
|
151 |
$opts['fdd']['Event_Type'] = array( |
|
152 |
'name' => 'Type of Event', |
|
153 |
'select' => 'D', |
|
154 |
'maxlen' => 30, |
|
155 |
'default' => 'Misc', |
|
156 |
'values' => array( |
|
157 |
'table' => 'pip_events', |
|
158 |
'column' => 'Events'), |
|
159 |
'sort' => true |
|
160 |
); |
|
161 |
$opts['fdd']['Serial_Number'] = array( |
|
162 |
'name' => 'Pipet Serial Number', |
|
163 |
'select' => 'D', |
|
164 |
'maxlen' => 30, |
|
165 |
//'default' => '0', |
|
166 |
'values' => array( |
|
167 |
'table' => 'pip_stock', |
|
168 |
'column' => 'Serial_Number'), |
|
169 |
'sort' => true |
|
170 |
); |
|
171 |
$opts['fdd']['Usage_fromNowOn'] = array( |
|
172 |
'name' => 'Usage after this', |
|
173 |
'select' => 'D', |
|
174 |
'maxlen' => 25, |
|
175 |
'sort' => true, |
|
176 |
'default' => 'Misc', |
|
177 |
'values' => array( |
|
178 |
'table' => 'pip_usage', |
|
179 |
'column' => 'Usage') |
|
180 |
); |
|
181 |
$opts['fdd']['Owner_fromNowOn'] = array( |
|
182 |
'name' => 'Owner after this', |
|
183 |
'select' => 'D', |
|
184 |
'maxlen' => 25, |
|
185 |
'sort' => true, |
|
186 |
'values' => array( |
|
187 |
'table' => 'pip_users', |
|
188 |
'column' => 'User') |
|
189 |
); |
|
190 |
$opts['fdd']['Comments'] = array( |
|
191 |
'name' => 'Comments', |
|
192 |
'select' => 'T', |
|
193 |
'maxlen' => 1000000000, //4294967295, |
|
194 |
'textarea' => array( |
|
195 |
'rows' => 5, |
|
196 |
'cols' => 50), |
|
197 |
'sort' => true |
|
198 |
); |
|
199 |
// TRIGGER |
|
200 |
// Before displaying the view page |
|
201 |
$opts['triggers']['select']['pre'][] = 'pip_history.TSP.php'; |
|
202 |
|
|
203 |
require("footers.php"); |
|
204 |
?> |
b/src/pip_stock.php | ||
---|---|---|
1 |
<?php |
|
2 |
session_start (); |
|
3 |
require("headers.php"); |
|
4 |
|
|
5 |
/* |
|
6 |
* IMPORTANT NOTE: This generated file contains only a subset of huge amount |
|
7 |
* of options that can be used with phpMyEdit. To get information about all |
|
8 |
* features offered by phpMyEdit, check official documentation. It is available |
|
9 |
* online and also for download on phpMyEdit project management page: |
|
10 |
* |
|
11 |
* http://platon.sk/projects/main_page.php?project_id=5 |
|
12 |
* |
|
13 |
* This file was generated by: |
|
14 |
* |
|
15 |
* phpMyEdit version: unknown |
|
16 |
* phpMyEdit.class.php core class: 1.204 |
|
17 |
* phpMyEditSetup.php script: 1.50 |
|
18 |
* generating setup script: 1.50 |
|
19 |
*/ |
|
20 |
|
|
21 |
/*************************/ |
|
22 |
// |
|
23 |
// Pass phpMyEdit options |
|
24 |
// |
|
25 |
/*************************/ |
|
26 |
|
|
27 |
|
|
28 |
$opts['dbh'] = $connexion; |
|
29 |
$opts['tb'] = $tb; |
|
30 |
|
|
31 |
// Name of field which is the unique key |
|
32 |
$opts['key'] = 'ID'; |
|
33 |
|
|
34 |
// Type of key field (int/real/string/date etc.) |
|
35 |
$opts['key_type'] = 'int'; |
|
36 |
|
|
37 |
// Sorting field(s) |
|
38 |
$opts['sort_field'] = array('ID'); |
|
39 |
|
|
40 |
// Number of records to display on the screen |
|
41 |
// Value of -1 lists all records in a table |
|
42 |
$opts['inc'] = 15; |
Formats disponibles : Unified diff