| 1 | <?php | 
|---|
| 2 |  | 
|---|
| 3 | ini_set("display_errors", "On"); | 
|---|
| 4 |  | 
|---|
| 5 | include("plotinclude.php"); | 
|---|
| 6 | include("db.php"); | 
|---|
| 7 |  | 
|---|
| 8 | printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | 
|---|
| 9 | printf("<html>\n<head>\n"); | 
|---|
| 10 | printf("<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>\n"); | 
|---|
| 11 | printf("<title>show plots</title>\n"); | 
|---|
| 12 | printf("<link rel='stylesheet' type='text/css' href='lamouette.css'>\n"); | 
|---|
| 13 | printf("</head>\n"); | 
|---|
| 14 | printf("<body>\n"); | 
|---|
| 15 |  | 
|---|
| 16 | //init | 
|---|
| 17 | $source=""; | 
|---|
| 18 | if (!empty($_GET["source"])) | 
|---|
| 19 | $source=$_GET["source"]; | 
|---|
| 20 | $from=""; | 
|---|
| 21 | if (!empty($_GET["from"])) | 
|---|
| 22 | $from=$_GET["from"]; | 
|---|
| 23 | $to=""; | 
|---|
| 24 | if (!empty($_GET["to"])) | 
|---|
| 25 | $to=$_GET["to"]; | 
|---|
| 26 | $tabnum=1; | 
|---|
| 27 | if (!empty($_GET["tabnum"])) | 
|---|
| 28 | $tabnum=$_GET["tabnum"]; | 
|---|
| 29 | $type2="calib"; | 
|---|
| 30 | if (!empty($_GET["type2"])) | 
|---|
| 31 | $type2=$_GET["type2"]; | 
|---|
| 32 | $plot=""; | 
|---|
| 33 | $nextseq=0; | 
|---|
| 34 | $prevseq=0; | 
|---|
| 35 | $seq=0; | 
|---|
| 36 | if (!empty($_GET["prevseq"]) && !empty($_GET["prev"])) | 
|---|
| 37 | $seq=$_GET["prevseq"]; | 
|---|
| 38 | if (!empty($_GET["nextseq"]) && !empty($_GET["next"])) | 
|---|
| 39 | $seq=$_GET["nextseq"]; | 
|---|
| 40 | $next=0; | 
|---|
| 41 | $prev=0; | 
|---|
| 42 | $numseq=0; | 
|---|
| 43 | //$sequences=array(0,10,20); | 
|---|
| 44 | //$sequences=array(); | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | if (!empty($from) || !empty($to)) | 
|---|
| 48 | { | 
|---|
| 49 | //get sequences from db | 
|---|
| 50 | $query="SELECT fSequenceFirst FROM Sequences "; | 
|---|
| 51 | if (!empty($from) && !empty($to)) | 
|---|
| 52 | $query.="WHERE fSequenceFirst BETWEEN " . $from . " AND " . $to; | 
|---|
| 53 | else | 
|---|
| 54 | { | 
|---|
| 55 | if (!empty($from)) | 
|---|
| 56 | $query.="WHERE fSequenceFirst > " . $from; | 
|---|
| 57 | if (!empty($to)) | 
|---|
| 58 | $query.="WHERE fSequenceFirst < " . $to; | 
|---|
| 59 | } | 
|---|
| 60 | // WHERE has to be there as $from is given by default | 
|---|
| 61 | if (!empty($source)) | 
|---|
| 62 | $query.=" AND fSourceKEY=" . $source; | 
|---|
| 63 |  | 
|---|
| 64 | //connection to database | 
|---|
| 65 | $db_id = mysql_pconnect($host, $user, $pw); | 
|---|
| 66 | if ($db_id==FALSE) | 
|---|
| 67 | { | 
|---|
| 68 | printf("mysql_connect returned the following error: %s\n", mysql_error()); | 
|---|
| 69 | die(""); | 
|---|
| 70 | } | 
|---|
| 71 | mysql_select_db($db); | 
|---|
| 72 |  | 
|---|
| 73 | $result=mysql_query($query, $db_id); | 
|---|
| 74 | while ($row = mysql_fetch_row($result)) | 
|---|
| 75 | $sequences[] = $row[0]; | 
|---|
| 76 | mysql_free_result($result); | 
|---|
| 77 |  | 
|---|
| 78 | mysql_close($db_id); | 
|---|
| 79 |  | 
|---|
| 80 | if (isset($sequences)) | 
|---|
| 81 | { | 
|---|
| 82 | //get next, current and previous sequence | 
|---|
| 83 | foreach($sequences as $key => $sequ) | 
|---|
| 84 | { | 
|---|
| 85 | if ($seq==0) | 
|---|
| 86 | $seq=$sequ; | 
|---|
| 87 | if ($next==1) | 
|---|
| 88 | { | 
|---|
| 89 | $nextseq=$sequ; | 
|---|
| 90 | if ($prevseq!=0) | 
|---|
| 91 | break; | 
|---|
| 92 | $next=0; | 
|---|
| 93 | } | 
|---|
| 94 | if ($sequ==$seq) | 
|---|
| 95 | { | 
|---|
| 96 | $next=1; | 
|---|
| 97 | continue; | 
|---|
| 98 | } | 
|---|
| 99 | $prevseq=$sequ; | 
|---|
| 100 | } | 
|---|
| 101 | $numseq=count($sequences); | 
|---|
| 102 | //in case a dataset consists of less than 3 sequences | 
|---|
| 103 | if ($numseq==2) | 
|---|
| 104 | $nextseq=$prevseq; | 
|---|
| 105 | } | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 |  | 
|---|
| 109 | $type=gettypename($type2); | 
|---|
| 110 | $plot=getplotname($seq, $tabnum, $type, $type2); | 
|---|
| 111 |  | 
|---|
| 112 | printf("<form action='showplots-seq.php' method='GET'>\n"); | 
|---|
| 113 | printf("<table width='100%%' border='0'>\n<tr>\n"); | 
|---|
| 114 | PrintHomeHelp(); | 
|---|
| 115 | printf("<td align='center'>\n"); | 
|---|
| 116 | if (!empty($prevseq)) | 
|---|
| 117 | printf("%d  ", $prevseq); | 
|---|
| 118 | if ($numseq>1) | 
|---|
| 119 | printf("<input type='submit' value='<< Prev Plot' name='prev'>\n"); | 
|---|
| 120 | if (empty($from)) | 
|---|
| 121 | $from=34099;//21.8.2004 | 
|---|
| 122 |  | 
|---|
| 123 | $db_id = mysql_connect($host, $user, $pw); | 
|---|
| 124 | if ($db_id==FALSE) | 
|---|
| 125 | { | 
|---|
| 126 | printf("mysql_connect returned the following error:<br>"); | 
|---|
| 127 | printf("%s<br>", mysql_error()); | 
|---|
| 128 | die(""); | 
|---|
| 129 | } | 
|---|
| 130 | mysql_select_db($db); | 
|---|
| 131 |  | 
|---|
| 132 | $query="SELECT fSourceKEY, fSourceName FROM Source ORDER BY fSourceName"; | 
|---|
| 133 | $result=mysql_query($query); | 
|---|
| 134 | if (!$result) | 
|---|
| 135 | printf("-N/A-"); | 
|---|
| 136 | printf(" <select name='source' size='1' class='Width'>\n"); | 
|---|
| 137 | if (empty($source) || $source==0) | 
|---|
| 138 | printf("<option value='0' selected>--- ALL ---</option>\n"); | 
|---|
| 139 | else | 
|---|
| 140 | printf("<option value='0'>--- ALL ---</option>\n"); | 
|---|
| 141 | while ($row = mysql_fetch_row($result)) | 
|---|
| 142 | { | 
|---|
| 143 | if (!empty($source) && $source==$row[0]) | 
|---|
| 144 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]); | 
|---|
| 145 | else | 
|---|
| 146 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]); | 
|---|
| 147 | } | 
|---|
| 148 | printf("</select>\n"); | 
|---|
| 149 | mysql_free_result($result); | 
|---|
| 150 | mysql_close($db_id); | 
|---|
| 151 |  | 
|---|
| 152 | printf("from <input type='text' name='from' size='6' maxlength='8' value='%s'>\n", $from); | 
|---|
| 153 | printf(" to <input type='text' name='to' size='6' maxlength='8' value='%s'>\n", $to); | 
|---|
| 154 | PrintType2PullDown($type2); | 
|---|
| 155 | printf("<input type='text' name='tabnum' size='2' maxlenght='2' value='%s'>\n", $tabnum); | 
|---|
| 156 | printf("<input type='hidden' name='prevseq' size='2' maxlenght='2' value='%s'>\n", $prevseq); | 
|---|
| 157 | printf("<input type='hidden' name='nextseq' size='2' maxlenght='2' value='%s'>\n", $nextseq); | 
|---|
| 158 | if ($numseq>1) | 
|---|
| 159 | printf("<input type='submit' value='Next Plot >>' name='next'>\n"); | 
|---|
| 160 | else | 
|---|
| 161 | printf("<input type='submit' value='Plot' name='next'>\n"); | 
|---|
| 162 | if (!empty($nextseq)) | 
|---|
| 163 | printf(" %d ", $nextseq); | 
|---|
| 164 | if ($numseq>0) | 
|---|
| 165 | { | 
|---|
| 166 | printf("  [ %d sequence", $numseq); | 
|---|
| 167 | if ($numseq>1) | 
|---|
| 168 | printf("s"); | 
|---|
| 169 | print(" ] \n"); | 
|---|
| 170 | } | 
|---|
| 171 | printf("</td><td align='right'>\n"); | 
|---|
| 172 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"showplots-seq.php\"'>\n"); | 
|---|
| 173 | printf("</td>\n</tr>\n<tr>\n<td align='center' colspan='3'>\n"); | 
|---|
| 174 | if (!empty($seq)) | 
|---|
| 175 | { | 
|---|
| 176 | printf("<div onmouseover=\"this.innerHTML='%s'\" onmouseout=\"this.innerHTML='%s'\"> %s </div>", getinfofromdb($seq), $plot, $plot); | 
|---|
| 177 | printf("<img src='%s'>", $plot); | 
|---|
| 178 | } | 
|---|
| 179 | else | 
|---|
| 180 | printf("Choose a source and/or a range of sequences or just click 'Plot' for going through all sequences."); | 
|---|
| 181 | printf("</td>\n</tr>\n</table>\n"); | 
|---|
| 182 | printf("</form>\n"); | 
|---|
| 183 | printf("</body>\n"); | 
|---|
| 184 | printf("</html>\n"); | 
|---|
| 185 |  | 
|---|
| 186 | ini_set("display_errors", "Off"); | 
|---|
| 187 |  | 
|---|
| 188 | ?> | 
|---|