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