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