1 | <?php
|
---|
2 |
|
---|
3 | function EnumQuery($name)
|
---|
4 | {
|
---|
5 | $var = $name . "Enum";
|
---|
6 | $txt = "";
|
---|
7 | switch ($_GET[$var])
|
---|
8 | {
|
---|
9 | case 0: $txt .= ""; break;
|
---|
10 | case 1: $txt .= $name . "='yes' AND "; break;
|
---|
11 | case 2: $txt .= $name . "='no' AND "; break;
|
---|
12 | case 3: $txt .= ""; break;
|
---|
13 | }
|
---|
14 | return $txt;
|
---|
15 | }
|
---|
16 |
|
---|
17 | function PrintEnumMenu($name, $text)
|
---|
18 | {
|
---|
19 | $var = $name . "Enum";
|
---|
20 |
|
---|
21 | if ($_GET[$name]=="On")
|
---|
22 | $checked = "checked";
|
---|
23 | else
|
---|
24 | $checked = "";
|
---|
25 |
|
---|
26 | printf(" <input type='checkbox' name='%s' value='On' %s>%s\n", $name, $checked, $text);
|
---|
27 | printf("<BR>");
|
---|
28 |
|
---|
29 | printf(" <select name='%s'>\n", $var);
|
---|
30 |
|
---|
31 | $status = array
|
---|
32 | ( 0 => "all",
|
---|
33 | 1 => "yes",
|
---|
34 | 2 => "no",
|
---|
35 | 3 => "group by"
|
---|
36 | );
|
---|
37 |
|
---|
38 | $stat=$_GET[$var];
|
---|
39 | for ($i=0; $i<4; $i++)
|
---|
40 | {
|
---|
41 | if ($stat==$i)
|
---|
42 | printf("<option value='%d' selected>%s</option>\n", $i, $status[$i]);
|
---|
43 | else
|
---|
44 | printf("<option value='%d'>%s</option>\n", $i, $status[$i]);
|
---|
45 | }
|
---|
46 |
|
---|
47 | printf(" </select>\n");
|
---|
48 | printf(" \n");
|
---|
49 |
|
---|
50 | }
|
---|
51 |
|
---|
52 | function StatusQuery($name, $needs, $timelimits)
|
---|
53 | {
|
---|
54 | if (empty($timelimits[$name]))
|
---|
55 | $timelimit="12";
|
---|
56 | else
|
---|
57 | $timelimit=$timelimits[$name];
|
---|
58 | $var = $name . "Status";
|
---|
59 | $txt = "";
|
---|
60 | switch ($_GET[$var])
|
---|
61 | {
|
---|
62 | case 0: $txt .= ""; break;
|
---|
63 | case 1: $txt .= "NOT (IsNull(" . $name . ") OR " . $name . "='1970-01-01 00:00:00') AND "; break;
|
---|
64 | // case 2: $txt .= "IsNull(" . $name . ") AND IsNull(fStartTime) AND IsNull(fFailedTime) AND NOT IsNull(" . $needs[$name] . ") AND "; break; //not done but step before is done
|
---|
65 | case 2: $txt .= "IsNull(" . $name . ") AND "; break; //not done no matter what status of previous step is
|
---|
66 | case 3: $txt .= $name ."='1970-01-01 00:00:00' AND "; break;
|
---|
67 | case 4: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval " . $timelimit . " hour) < fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
68 | case 5: $txt .= " (IsNull(" . $name . ") AND NOT IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
69 | case 6: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval " . $timelimit . " hour) > fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
70 | // case 6: $txt .= "crashed"; break;
|
---|
71 | case 7: $txt .= ""; break;
|
---|
72 | }
|
---|
73 | return $txt;
|
---|
74 | }
|
---|
75 |
|
---|
76 | function PrintStatusMenu($name, $text)
|
---|
77 | {
|
---|
78 | $var = $name . "Status";
|
---|
79 |
|
---|
80 | if ($_GET[$name]=="On")
|
---|
81 | $checked = "checked";
|
---|
82 | else
|
---|
83 | $checked = "";
|
---|
84 |
|
---|
85 | printf(" <input type='checkbox' name='%s' value='On' %s>%s\n", $name, $checked, $text);
|
---|
86 | printf("<BR>");
|
---|
87 |
|
---|
88 | printf(" <select name='%s'>\n", $var);
|
---|
89 |
|
---|
90 | $status = array
|
---|
91 | ( 0 => "ALL",
|
---|
92 | 1 => "done",
|
---|
93 | 2 => "not done",
|
---|
94 | 3 => "not to be done",
|
---|
95 | 4 => "running",
|
---|
96 | 5 => "failed",
|
---|
97 | 6 => "crashed",
|
---|
98 | 7 => "GROUP BY",
|
---|
99 | );
|
---|
100 |
|
---|
101 | $stat=$_GET[$var];
|
---|
102 | for ($i=0; $i<8; $i++)
|
---|
103 | {
|
---|
104 | if ($stat==$i)
|
---|
105 | printf("<option value='%d' selected>%s</option>\n", $i, $status[$i]);
|
---|
106 | else
|
---|
107 | printf("<option value='%d'>%s</option>\n", $i, $status[$i]);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | $status = array("all", "done", "not done", "not to be done");
|
---|
112 | $counter = 0;
|
---|
113 | foreach ($status as $element)
|
---|
114 | {
|
---|
115 | if ($counter==$_GET[$var])
|
---|
116 | printf("<option value=\"%d\" selected>%3s</option>\n", $counter++, $element);
|
---|
117 | else
|
---|
118 | printf("<option value=\"%d\">%3s</option>\n", $counter++, $element);
|
---|
119 | }*/
|
---|
120 | printf(" </select>\n");
|
---|
121 | printf(" \n");
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 | function PrintPullDown($host, $user, $pw, $db, $table, $name, $index, $descr)
|
---|
126 | {
|
---|
127 | $db_id = mysql_connect($host, $user, $pw);
|
---|
128 | if ($db_id==FALSE)
|
---|
129 | {
|
---|
130 | printf("mysql_connect returned the following error:<br>");
|
---|
131 | printf("%s<br>", mysql_error());
|
---|
132 | die("");
|
---|
133 | }
|
---|
134 |
|
---|
135 | $query = "SELECT " . $index . ", " . $name . " FROM " . $db . "." . $table . " ORDER BY " . $name;
|
---|
136 | $result = mysql_query($query);
|
---|
137 |
|
---|
138 | if (!$result)
|
---|
139 | {
|
---|
140 | printf("-N/A-");
|
---|
141 | return;
|
---|
142 | }
|
---|
143 |
|
---|
144 | $numrows = mysql_num_rows($result);
|
---|
145 |
|
---|
146 | if ($_GET[$name]=="On")
|
---|
147 | $checked = "checked";
|
---|
148 | else
|
---|
149 | $checked = "";
|
---|
150 |
|
---|
151 | printf(" <input type='checkbox' name='%s' value='On' %s><A HREF='printtable.php?fTable=%s'>%s</A>\n", $name, $checked, $table, $descr);
|
---|
152 |
|
---|
153 | printf(" <BR>\n");
|
---|
154 |
|
---|
155 | printf(" <select name='%s' size='1' class='Width'>\n", $index);
|
---|
156 |
|
---|
157 | if (empty($_GET[$index]) || $_GET[$index]==0)
|
---|
158 | printf(" <option value='0' selected>--- ALL ---</option>\n");
|
---|
159 | else
|
---|
160 | printf(" <option value='0'>--- ALL ---</option>\n");
|
---|
161 |
|
---|
162 | if (!empty($_GET[$index]) && $_GET[$index]==-1)
|
---|
163 | printf(" <option value='-1' selected>--- GROUP BY ---</option>\n");
|
---|
164 | else
|
---|
165 | printf(" <option value='-1'>--- GROUP BY ---</option>\n");
|
---|
166 |
|
---|
167 | while ($row = mysql_fetch_row($result))
|
---|
168 | {
|
---|
169 | if (!empty($_GET[$index]) && $_GET[$index]==$row[0])
|
---|
170 | printf(" <option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
171 | else
|
---|
172 | printf(" <option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
173 | }
|
---|
174 | printf(" </select>\n");
|
---|
175 | printf(" \n", $index);
|
---|
176 |
|
---|
177 | mysql_free_result($result);
|
---|
178 |
|
---|
179 | mysql_close($db_id);
|
---|
180 | }
|
---|
181 |
|
---|
182 | function GetMin($field, $table, $host, $user, $pw, $db)
|
---|
183 | {
|
---|
184 | $db_id = mysql_connect($host, $user, $pw);
|
---|
185 | if ($db_id==FALSE)
|
---|
186 | {
|
---|
187 | printf("mysql_connect returned the following error:<br>");
|
---|
188 | printf("%s<br>", mysql_error());
|
---|
189 | die("");
|
---|
190 | }
|
---|
191 |
|
---|
192 | $query = "SELECT MIN(" . $field . ") FROM " . $db . "." . $table;
|
---|
193 | $result = mysql_query($query);
|
---|
194 | if (!$result)
|
---|
195 | return "0";
|
---|
196 |
|
---|
197 | $row = mysql_fetch_row($result);
|
---|
198 |
|
---|
199 | $min = $row[0];
|
---|
200 |
|
---|
201 | mysql_free_result($result);
|
---|
202 | mysql_close($db_id);
|
---|
203 |
|
---|
204 | return $min;
|
---|
205 | }
|
---|
206 |
|
---|
207 | function GetMax($field, $table, $host, $user, $pw, $db)
|
---|
208 | {
|
---|
209 | $db_id = mysql_connect($host, $user, $pw);
|
---|
210 | if ($db_id==FALSE)
|
---|
211 | {
|
---|
212 | printf("mysql_connect returned the following error:<br>");
|
---|
213 | printf("%s<br>", mysql_error());
|
---|
214 | die("");
|
---|
215 | }
|
---|
216 |
|
---|
217 | $query = "SELECT MAX(" . $field . ") FROM " . $db . "." . $table;
|
---|
218 | $result = mysql_query($query);
|
---|
219 | if (!$result)
|
---|
220 | return "0";
|
---|
221 |
|
---|
222 | $row = mysql_fetch_row($result);
|
---|
223 |
|
---|
224 | $max = $row[0];
|
---|
225 |
|
---|
226 | mysql_free_result($result);
|
---|
227 | mysql_close($db_id);
|
---|
228 |
|
---|
229 | return $max;
|
---|
230 | }
|
---|
231 |
|
---|
232 | function GetMaxDate($field, $table, $host, $user, $pw, $db)
|
---|
233 | {
|
---|
234 | $db_id = mysql_connect($host, $user, $pw);
|
---|
235 | if ($db_id==FALSE)
|
---|
236 | {
|
---|
237 | printf("mysql_connect returned the following error:<br>");
|
---|
238 | printf("%s<br>", mysql_error());
|
---|
239 | die("");
|
---|
240 | }
|
---|
241 |
|
---|
242 | $query = "SELECT DATE_FORMAT(if(MAX(" . $field . ")<'13:00:00', MAX(" . $field . "), ADDDATE(MAX(" . $field . "), INTERVAL +1 DAY)), '%Y-%m-%d') FROM " . $db . "." . $table;
|
---|
243 | $result = mysql_query($query);
|
---|
244 | if (!$result)
|
---|
245 | return "0";
|
---|
246 |
|
---|
247 | $row = mysql_fetch_row($result);
|
---|
248 |
|
---|
249 | $maxdate = $row[0];
|
---|
250 |
|
---|
251 | mysql_free_result($result);
|
---|
252 | mysql_close($db_id);
|
---|
253 |
|
---|
254 | return $maxdate;
|
---|
255 | }
|
---|
256 |
|
---|
257 | //for download of output
|
---|
258 | function PrintText($result0)
|
---|
259 | {
|
---|
260 | while ($row0 = mysql_fetch_assoc($result0))
|
---|
261 | {
|
---|
262 | foreach ($row0 as $key => $element)
|
---|
263 | printf("%s\t", $element);
|
---|
264 | printf("\n");
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | function PrintSubmittedQuery($query0, $db, $old)
|
---|
269 | {
|
---|
270 | //diplay query on old websites
|
---|
271 | if (empty($old))
|
---|
272 | printf("<tr class='Block' id='showquery' style='display:none'><td>\n");
|
---|
273 | else
|
---|
274 | printf("<tr class='Block' id='showquery' style='display:block'><td>\n");
|
---|
275 | printf("<b>DB:</b> %s <br>\n", $db);
|
---|
276 | printf("<U><B>submitted query:</B></U><BR>%s<BR>\n", htmlspecialchars($query0));
|
---|
277 | printf("</td></tr>\n");
|
---|
278 | }
|
---|
279 |
|
---|
280 | function Checkbox($value, $text)
|
---|
281 | {
|
---|
282 | if ($_GET[$value]=="On")
|
---|
283 | $checked = "checked";
|
---|
284 | else
|
---|
285 | $checked = "";
|
---|
286 |
|
---|
287 | printf("<td><input type='checkbox' name='%s' value='On' %s>%s</td>\n", $value, $checked, $text);
|
---|
288 | }
|
---|
289 |
|
---|
290 | function RadioButton($name, $value, $text)
|
---|
291 | {
|
---|
292 | if ($_SESSION[$name]==$value)
|
---|
293 | $checked = "checked";
|
---|
294 | else
|
---|
295 | $checked = "";
|
---|
296 |
|
---|
297 | printf("<td><input type='radio' name='%s' value='%s' %s>%s</td>\n", $name, $value, $checked, $text);
|
---|
298 | }
|
---|
299 |
|
---|
300 | function CheckWhere($column)
|
---|
301 | {
|
---|
302 | foreach ($_GET as $key => $element)
|
---|
303 | {
|
---|
304 | if ($key==$column)
|
---|
305 | {
|
---|
306 | // if ($element>0)
|
---|
307 | // printf ("FIXED: %s<BR>", $column);
|
---|
308 | return $element;
|
---|
309 | }
|
---|
310 | }
|
---|
311 | return 0;
|
---|
312 | }
|
---|
313 |
|
---|
314 | function CheckGroup($column)
|
---|
315 | {
|
---|
316 | foreach ($_GET as $key => $element)
|
---|
317 | {
|
---|
318 | if ($key==$column)
|
---|
319 | {
|
---|
320 | //if ($element==-1)
|
---|
321 | // printf ("GROUP: %s<BR>", $column);
|
---|
322 | return $element;
|
---|
323 | }
|
---|
324 | }
|
---|
325 | return 0;
|
---|
326 | }
|
---|
327 |
|
---|
328 | function CheckStatusGroup($column)
|
---|
329 | {
|
---|
330 | foreach ($_GET as $key => $element)
|
---|
331 | if ($key==$column)
|
---|
332 | if ($element==7)
|
---|
333 | return -1;
|
---|
334 | return 0;
|
---|
335 | }
|
---|
336 |
|
---|
337 | function CheckEnumGroup($column)
|
---|
338 | {
|
---|
339 | foreach ($_GET as $key => $element)
|
---|
340 | if ($key==$column)
|
---|
341 | if ($element==3)
|
---|
342 | return -1;
|
---|
343 | return 0;
|
---|
344 | }
|
---|
345 |
|
---|
346 | function RemoveSortBy()
|
---|
347 | {
|
---|
348 | $menu = "";
|
---|
349 |
|
---|
350 | $uri = $_SERVER["REQUEST_URI"];
|
---|
351 | $pos = strpos($uri, "fSortBy");
|
---|
352 | $amp3=FALSE;
|
---|
353 | if ($pos!=FALSE)
|
---|
354 | {
|
---|
355 | $amp1 = substr($uri, 0, $pos-1);
|
---|
356 | $amp2 = substr($uri, $pos);
|
---|
357 | $amp3 = strchr($amp2, "&");
|
---|
358 |
|
---|
359 | $uri = $amp1;
|
---|
360 | }
|
---|
361 |
|
---|
362 | return $uri;
|
---|
363 | }
|
---|
364 |
|
---|
365 | function FindAlias($alias, $search)
|
---|
366 | {
|
---|
367 | foreach ($alias as $key => $element)
|
---|
368 | if ($element==$search)
|
---|
369 | return $key;
|
---|
370 |
|
---|
371 | if ($search=="# Runs")
|
---|
372 | return "NumRuns";
|
---|
373 | if ($search=="# Sequ")
|
---|
374 | return "NumSequ";
|
---|
375 | if ($search=="# Datasets")
|
---|
376 | return "NumDS";
|
---|
377 | if ($search=="# days")
|
---|
378 | return "NumDays";
|
---|
379 | return $search;
|
---|
380 | return "";
|
---|
381 | }
|
---|
382 |
|
---|
383 | //function for button in builddatasets.php
|
---|
384 | function GetClearedURL($all)
|
---|
385 | {
|
---|
386 | $url=$_SERVER["REQUEST_URI"];
|
---|
387 | if ($all=="yes")
|
---|
388 | {
|
---|
389 | $url=str_replace("&DisplaySelected=yes", "", $url);
|
---|
390 | $url=str_replace("&DisplaySelected=no", "", $url);
|
---|
391 | $url=str_replace("&DisplaySelected=inverse", "", $url);
|
---|
392 | //reset fNumStart
|
---|
393 | $url=preg_replace("/&fNumStart[=][0-9]*/", "", $url);
|
---|
394 | }
|
---|
395 | $url=str_replace("&insert=yes", "", $url);
|
---|
396 | $url=str_replace("&fSendTxt=2", "", $url);
|
---|
397 | $url=str_replace("&fSendTxt=1", "", $url);
|
---|
398 | $url=htmlspecialchars($url);
|
---|
399 | return $url;
|
---|
400 | }
|
---|
401 |
|
---|
402 | function PrintUpdateDataSetButton()
|
---|
403 | {
|
---|
404 | if (empty($_SESSION["insert"]))
|
---|
405 | printf("<input type='submit' value='Update Selection'> \n");
|
---|
406 | else
|
---|
407 | printf("<input type='button' value='Continue' onClick='self.location.href=\"%s\"'> \n", GetClearedURL());
|
---|
408 |
|
---|
409 | }
|
---|
410 |
|
---|
411 | //function for button in builddatasets.php
|
---|
412 | function PrintDisplaySequencesButtons()
|
---|
413 | {
|
---|
414 | if (!empty($_SESSION["DataSetSelection"]) && empty($_SESSION["DataSetAcknowledged"]))
|
---|
415 | return;
|
---|
416 |
|
---|
417 | if ((empty($_SESSION["DisplaySelected"]) || $_SESSION["DisplaySelected"]=="no")
|
---|
418 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
419 | {
|
---|
420 | PrintUpdateDataSetButton();
|
---|
421 | printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
|
---|
422 | printf(" <input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
|
---|
423 | printf("<br><br>\n");
|
---|
424 | }
|
---|
425 |
|
---|
426 | if ($_SESSION["DisplaySelected"]=="yes"
|
---|
427 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
428 | {
|
---|
429 | PrintUpdateDataSetButton();
|
---|
430 | printf("<input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
|
---|
431 | printf(" <input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
|
---|
432 | printf(" <i>Currently only selected sequences are displayed.</i><br><br>\n");
|
---|
433 | }
|
---|
434 |
|
---|
435 | if ($_SESSION["DisplaySelected"]=="inverse"
|
---|
436 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
437 | {
|
---|
438 | PrintUpdateDataSetButton();
|
---|
439 | printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
|
---|
440 | printf(" <input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
|
---|
441 | printf(" <i>Currently only NOT selected sequences are displayed.</i><br><br>\n");
|
---|
442 | }
|
---|
443 | }
|
---|
444 |
|
---|
445 |
|
---|
446 | function ReplaceInUri($name, $rows, $direction, $totalnumrows=0)
|
---|
447 | {
|
---|
448 | //direction:
|
---|
449 | // 0: Prev Link
|
---|
450 | // 1: Next Link
|
---|
451 | // 2: First Link
|
---|
452 | // 3: Last Link
|
---|
453 |
|
---|
454 | $uri = htmlspecialchars($_SERVER["REQUEST_URI"]);
|
---|
455 | //append string in case it is not in url
|
---|
456 | if (!preg_match("/&fNumStart[=][0-9]*/", $uri))
|
---|
457 | $uri.="&fNumStart=";
|
---|
458 |
|
---|
459 | switch($direction)
|
---|
460 | {
|
---|
461 | case 0:
|
---|
462 | $pos = $_GET["fNumStart"]-$rows;
|
---|
463 | if ($pos<0)
|
---|
464 | $pos=0;
|
---|
465 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>< Prev</A> \n";
|
---|
466 | break;
|
---|
467 | case 1:
|
---|
468 | //display link only if more results available
|
---|
469 | if ($_GET["fNumStart"]+$rows==$totalnumrows)
|
---|
470 | break;
|
---|
471 | $pos = $_GET["fNumStart"]+$rows;
|
---|
472 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>Next ></A> \n";
|
---|
473 | break;
|
---|
474 | case 2:
|
---|
475 | $pos = 0;
|
---|
476 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'><< First</A> \n";
|
---|
477 | break;
|
---|
478 | case 3:
|
---|
479 | //display link only if more results available
|
---|
480 | if ($_GET["fNumStart"]+$rows==$totalnumrows)
|
---|
481 | break;
|
---|
482 | $pos = $totalnumrows-$rows+1;
|
---|
483 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>Last >></A> \n";
|
---|
484 | break;
|
---|
485 | }
|
---|
486 |
|
---|
487 | return $link;
|
---|
488 | }
|
---|
489 |
|
---|
490 | function CreateMenu($rows, $totalnumrows)
|
---|
491 | {
|
---|
492 | $menu = "";
|
---|
493 |
|
---|
494 | if (empty($_GET["fNumResults"]))
|
---|
495 | return;
|
---|
496 |
|
---|
497 | if ($_GET["fNumStart"]!=0)
|
---|
498 | {
|
---|
499 | $menu .= ReplaceInUri("fNumStart", $rows, 2, $totalnumrows);
|
---|
500 | $menu .= ReplaceInUri("fNumStart", $rows, 0, $totalnumrows);
|
---|
501 | }
|
---|
502 |
|
---|
503 | $menu .= " --- <B>";
|
---|
504 | if (empty($_GET["fNumStart"]))
|
---|
505 | $menu .= "0";
|
---|
506 | else
|
---|
507 | $menu .= $_GET["fNumStart"];
|
---|
508 | $menu .= "</B> --- \n";
|
---|
509 |
|
---|
510 | if ($rows==$_GET["fNumResults"])
|
---|
511 | {
|
---|
512 | $menu .= ReplaceInUri("fNumStart", $rows, 1, $totalnumrows);
|
---|
513 | $menu .= ReplaceInUri("fNumStart", $rows, 3, $totalnumrows);
|
---|
514 | }
|
---|
515 | return $menu;
|
---|
516 | }
|
---|
517 |
|
---|
518 | function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, $form="")
|
---|
519 | {
|
---|
520 | $row1 = mysql_fetch_assoc($result1);
|
---|
521 | $totalnumrows=$row1["FOUND_ROWS()"];
|
---|
522 |
|
---|
523 | $col = FALSE;
|
---|
524 | $first = TRUE;
|
---|
525 |
|
---|
526 | $sigma = array
|
---|
527 | (
|
---|
528 | 1 => "#33CC00",
|
---|
529 | 2 => "#FFFF66",
|
---|
530 | 3 => "#FF9900",
|
---|
531 | 5 => "#FF0000",
|
---|
532 | );
|
---|
533 | $okcolour="#006600";
|
---|
534 |
|
---|
535 |
|
---|
536 | $menu = CreateMenu(mysql_num_rows($result0), $totalnumrows);
|
---|
537 |
|
---|
538 | if ($form)
|
---|
539 | {
|
---|
540 | printf("<form method='POST'>");
|
---|
541 | PrintDisplaySequencesButtons();
|
---|
542 | }
|
---|
543 | printf("\n<center>\n");
|
---|
544 | if (empty($_GET["fPrintTable"]))
|
---|
545 | printf("%s\n", $menu);
|
---|
546 |
|
---|
547 | printf("<table BORDER='0' style='margin-top:1ex'>\n");
|
---|
548 | $counter=0;
|
---|
549 | while ($row0 = mysql_fetch_assoc($result0))
|
---|
550 | {
|
---|
551 | if ($first)
|
---|
552 | {
|
---|
553 | printf(" <tr BGCOLOR='#C0C0C0'>\n<td BGCOLOR='#F0F0F0'><img src='plus.png' alt='+' onClick='showalllines(%d)'></td>\n", mysql_num_rows($result0));
|
---|
554 | $first = FALSE;
|
---|
555 | if ($form)
|
---|
556 | {
|
---|
557 | printf("<td>ON<br><input type='radio' name='SelectAllSequForDS' value='ON' onclick='selectallsequences(\"ON\");' %s></td>\n",
|
---|
558 | $_SESSION["SelectAllSequForDS"]=="ON"?"checked":"");
|
---|
559 | printf("<td>Off<br><input type='radio' name='SelectAllSequForDS' value='Off' onclick='selectallsequences(\"Off\");' %s></td>\n",
|
---|
560 | $_SESSION["SelectAllSequForDS"]=="Off"?"checked":"");
|
---|
561 | printf("<td>Not<br><input type='radio' name='SelectAllSequForDS' value='Not' onclick='selectallsequences(\"Not\");' %s></td>\n",
|
---|
562 | $_SESSION["SelectAllSequForDS"]=="Not"?"checked":"");
|
---|
563 | }
|
---|
564 | foreach ($row0 as $key => $element)
|
---|
565 | {
|
---|
566 | $col = FindAlias($alias, $key);
|
---|
567 |
|
---|
568 | $ord="-";
|
---|
569 | $issort = "";
|
---|
570 | if (!empty($_GET["fSortBy"]) && substr($_GET["fSortBy"], 0, -1)==$col)
|
---|
571 | {
|
---|
572 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
573 | {
|
---|
574 | $ord="+";
|
---|
575 | $issort=" <IMG SRC='down.gif'>";
|
---|
576 | }
|
---|
577 | else
|
---|
578 | $issort=" <IMG SRC='up.gif'>";
|
---|
579 | }
|
---|
580 | printf(" <th> <A HREF='%s&fSortBy=%s%s'>%s</A>%s </th>\n",
|
---|
581 | htmlspecialchars(RemoveSortBy()), $col, $ord, $key, $issort);
|
---|
582 | }
|
---|
583 | printf(" </tr>\n\n");
|
---|
584 | }
|
---|
585 |
|
---|
586 | $counter++;
|
---|
587 | if (!$col)
|
---|
588 | printf(" <tr id='line%s' BGCOLOR='#E0E0E0'>\n<td BGCOLOR='#F0F0F0'>\n<img id='line%sbutton' src='minus.png' alt='-' onClick='showhide(\"line%s\")'>\n</td>\n", $counter, $counter, $counter);
|
---|
589 | else
|
---|
590 | printf(" <tr id='line%s' BGCOLOR='#D0D0D0'>\n<td BGCOLOR='#F0F0F0'>\n<img id='line%sbutton' src='minus.png' alt='-' onClick='showhide(\"line%s\")'>\n</td>\n", $counter, $counter, $counter);
|
---|
591 | $col = !$col;
|
---|
592 |
|
---|
593 | if ($form)
|
---|
594 | {
|
---|
595 | RadioButton("DSSeq".$row0["Sequ"], "ON", "");
|
---|
596 | RadioButton("DSSeq".$row0["Sequ"], "Off", "");
|
---|
597 | RadioButton("DSSeq".$row0["Sequ"], "Not", "");
|
---|
598 | }
|
---|
599 | foreach ($row0 as $key => $element)
|
---|
600 | {
|
---|
601 | if (empty($rightalign[$key]))
|
---|
602 | printf(" <td align='left' valign='top'>");
|
---|
603 | else
|
---|
604 | printf(" <td align='right' valign='top'>");
|
---|
605 |
|
---|
606 | $colour='#000000';
|
---|
607 | //determine color of text in cell
|
---|
608 | if (!empty($limitsmean))
|
---|
609 | {
|
---|
610 | foreach($limitsmean as $key2 => $element2)
|
---|
611 | {
|
---|
612 | $mean=$key2 . "Mean";
|
---|
613 | $rms2=$key2 . "Rms";
|
---|
614 | if ($key==$alias[$element2] && !empty($_GET[$mean]) && !empty($_GET[$rms2]))
|
---|
615 | {
|
---|
616 | $colour=$okcolour;
|
---|
617 | foreach ($sigma as $margin => $newcolour)
|
---|
618 | {
|
---|
619 | $min=$_GET[$mean] - ($margin * $_GET[$rms2]);
|
---|
620 | $max=$_GET[$mean] + ($margin * $_GET[$rms2]);
|
---|
621 | if (!($min < $element && $element < $max))
|
---|
622 | $colour=$newcolour;
|
---|
623 | }
|
---|
624 | }
|
---|
625 | }
|
---|
626 | }
|
---|
627 | if (!empty($limitsmin))
|
---|
628 | {
|
---|
629 | foreach($limitsmin as $key2 => $element2)
|
---|
630 | {
|
---|
631 | $limit1=$key2 . "1";
|
---|
632 | $limit2=$key2 . "2";
|
---|
633 | if ($key==$alias[$element2] && !empty($_GET[$limit1]))
|
---|
634 | {
|
---|
635 | if ($colour=='#000000')
|
---|
636 | $colour=$okcolour;
|
---|
637 |
|
---|
638 | if (!empty($_GET[$limit2]) && $_GET[$limit2] > $element)
|
---|
639 | $colour=$sigma[5];
|
---|
640 |
|
---|
641 | if ($_GET[$limit1] > $element && $_GET[$limit2] <= $element)
|
---|
642 | $colour=$sigma[3];
|
---|
643 | }
|
---|
644 | }
|
---|
645 | }
|
---|
646 |
|
---|
647 | if (!empty($limitsmax))
|
---|
648 | {
|
---|
649 | foreach($limitsmax as $key2 => $element2)
|
---|
650 | {
|
---|
651 | $limit1=$key2 . "1";
|
---|
652 | $limit2=$key2 . "2";
|
---|
653 | if ($key==$alias[$element2] && !empty($_GET[$limit1]))
|
---|
654 | {
|
---|
655 | if ($colour=='#000000')
|
---|
656 | $colour=$okcolour;
|
---|
657 |
|
---|
658 | if (!empty($_GET[$limit2]) && $_GET[$limit2] < $element)
|
---|
659 | $colour=$sigma[5];
|
---|
660 |
|
---|
661 | if ($_GET[$limit1] < $element && $_GET[$limit2] >= $element)
|
---|
662 | $colour=$sigma[3];
|
---|
663 | }
|
---|
664 | }
|
---|
665 | }
|
---|
666 | if ($colour!='#000000' && (!empty($limitsmean) || !empty($limitsmin) || !empty($limitsmax)))
|
---|
667 | printf("<font color='%s' style='font-weight:bold'>", $colour);
|
---|
668 |
|
---|
669 | //fill text in cell
|
---|
670 | printf(" %s </td>\n", str_replace("&ws;", " ", str_replace(" ", " ", $element)));
|
---|
671 |
|
---|
672 | if ($colour!='#000000' && (!empty($limitsmean) || !empty($limitsmin) || !empty($limitsmax)))
|
---|
673 | printf("</font>");
|
---|
674 | }
|
---|
675 | printf(" </tr>\n");
|
---|
676 | }
|
---|
677 | printf("</table>\n");
|
---|
678 |
|
---|
679 | /*
|
---|
680 | $info = mysql_info();
|
---|
681 | if (!empty($info))
|
---|
682 | printf("%s<BR>\n", $info);
|
---|
683 | */
|
---|
684 |
|
---|
685 | printf("<P><B>Number of displayed results: %d of %s in total</B><P><P>\n", mysql_num_rows($result0), $totalnumrows);
|
---|
686 | if (empty($_GET["fPrintTable"]))
|
---|
687 | printf("%s\n", $menu);
|
---|
688 | printf("<P>\n");
|
---|
689 | printf("</center>\n");
|
---|
690 |
|
---|
691 | if (!$form)
|
---|
692 | {
|
---|
693 | printf("</td>\n");
|
---|
694 | printf("</tr>\n");
|
---|
695 | }
|
---|
696 | else
|
---|
697 | PrintDisplaySequencesButtons();
|
---|
698 | }
|
---|
699 |
|
---|
700 | ?>
|
---|