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");
|
---|
114 | printf("<tr><td valign='top'>\n");
|
---|
115 | printf("<a href='http://db.astro.uni-wuerzburg.de'>home</a>\n");
|
---|
116 | printf("</td><td align='center'>");
|
---|
117 | if (!empty($prevseq))
|
---|
118 | printf("%d ", $prevseq);
|
---|
119 | if ($numseq>1)
|
---|
120 | printf("<input type='submit' value='<< Prev Plot' name='prev'>\n");
|
---|
121 | if (empty($from))
|
---|
122 | $from=34099;//21.8.2004
|
---|
123 |
|
---|
124 | $db_id = mysql_connect($host, $user, $pw);
|
---|
125 | if ($db_id==FALSE)
|
---|
126 | {
|
---|
127 | printf("mysql_connect returned the following error:<br>");
|
---|
128 | printf("%s<br>", mysql_error());
|
---|
129 | die("");
|
---|
130 | }
|
---|
131 | mysql_select_db($db);
|
---|
132 |
|
---|
133 | $query="SELECT fSourceKEY, fSourceName FROM Source ORDER BY fSourceName";
|
---|
134 | $result=mysql_query($query);
|
---|
135 | if (!$result)
|
---|
136 | printf("-N/A-");
|
---|
137 | printf(" <select name='source' size='1' class='Width'>\n");
|
---|
138 | if (empty($source) || $source==0)
|
---|
139 | printf("<option value='0' selected>--- ALL ---</option>\n");
|
---|
140 | else
|
---|
141 | printf("<option value='0'>--- ALL ---</option>\n");
|
---|
142 | while ($row = mysql_fetch_row($result))
|
---|
143 | {
|
---|
144 | if (!empty($source) && $source==$row[0])
|
---|
145 | printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
146 | else
|
---|
147 | printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
148 | }
|
---|
149 | printf("</select>\n");
|
---|
150 | mysql_free_result($result);
|
---|
151 | mysql_close($db_id);
|
---|
152 |
|
---|
153 | printf("from <input type='text' name='from' size='5' maxlength='5' value='%s'>\n", $from);
|
---|
154 | printf(" to <input type='text' name='to' size='5' maxlength='5' value='%s'>\n", $to);
|
---|
155 | PrintType2PullDown($type2);
|
---|
156 | printf("<input type='text' name='tabnum' size='2' maxlenght='2' value='%s'>\n", $tabnum);
|
---|
157 | printf("<input type='hidden' name='prevseq' size='2' maxlenght='2' value='%s'>\n", $prevseq);
|
---|
158 | printf("<input type='hidden' name='nextseq' size='2' maxlenght='2' value='%s'>\n", $nextseq);
|
---|
159 | if ($numseq>1)
|
---|
160 | printf("<input type='submit' value='Next Plot >>' name='next'>\n");
|
---|
161 | else
|
---|
162 | printf("<input type='submit' value='Plot' name='next'>\n");
|
---|
163 | if (!empty($nextseq))
|
---|
164 | printf(" %d ", $nextseq);
|
---|
165 | if ($numseq>0)
|
---|
166 | {
|
---|
167 | printf(" [ %d sequence", $numseq);
|
---|
168 | if ($numseq>1)
|
---|
169 | printf("s");
|
---|
170 | print(" ] \n");
|
---|
171 | }
|
---|
172 | printf("</td><td align='right'>\n");
|
---|
173 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"showplots-seq.php\"'>\n");
|
---|
174 | printf("</td>\n</tr>\n<tr>\n<td align='center' colspan='3'>\n");
|
---|
175 | if (!empty($seq))
|
---|
176 | printf("%s <img src='%s'>", $plot, $plot);
|
---|
177 | else
|
---|
178 | printf("Choose a source and/or a range of sequences or just click 'Plot' for going through all sequences.");
|
---|
179 | printf("</td>\n</tr>\n</table>\n");
|
---|
180 | printf("</form>\n");
|
---|
181 | printf("</body>\n");
|
---|
182 | printf("</html>\n");
|
---|
183 |
|
---|
184 | ini_set("display_errors", "Off");
|
---|
185 |
|
---|
186 | ?>
|
---|