1 | <?php session_start(); ?> |
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> |
---|
3 | <?php |
---|
4 | // index.html |
---|
5 | // Albert Teoh 15.11.2005 |
---|
6 | // |
---|
7 | // The opening page for the ATNF Pulsar Data Archive |
---|
8 | // system. Used to search for observation archive |
---|
9 | // files. |
---|
10 | /* |
---|
11 | <!-- BEGIN Javascript for expansion blocks --> |
---|
12 | <!-- Thanks to: --> |
---|
13 | <!-- http://assn9.blogspot.com/ --> |
---|
14 | <!-- Douglas Bowman |
---|
15 | URL: www.stopdesign.com |
---|
16 | Used in: http://www.bloggerforum.com/modules/newbb/viewtopic.php?topic_id=8725&forum=6 |
---|
17 | Date: 26 Feb 2004 |
---|
18 | --> |
---|
19 | */ |
---|
20 | ?> |
---|
21 | <head> |
---|
22 | <link rel="stylesheet" type="text/css" href="styles/style.css" /> |
---|
23 | <link rel="stylesheet" type="text/css" href="styles/query.css" /> |
---|
24 | <link rel="stylesheet" type="text/css" href="styles/results.css" /> |
---|
25 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8759-1" /> |
---|
26 | <meta name="DC.Creator" lang="en" content="personalName=Teoh,Albert" /> |
---|
27 | <meta name="ATNF.Maintainer" content="contactName=Webmaster,the" /> |
---|
28 | <meta name="DC.Title.alt" lang="en" content="" /> |
---|
29 | <meta name="DC.Subject" lang="en" content="pulsar" /> |
---|
30 | <meta name="DC.Description" lang="en" content="Searches the data archives at the ATNF" /> |
---|
31 | <meta name="DC.Date.created" scheme="ISO8601" content="2002-12-12" /> |
---|
32 | <meta name="ATNF.Site" content="Marsfield" /> |
---|
33 | <meta name="ATNF.AccessPermission" content="Public" /> |
---|
34 | <meta name="ATNF.MetaVersion" content="1.0" /> |
---|
35 | </head> |
---|
36 | <script type="text/javascript" language="javascript1.2"><!-- |
---|
37 | function togglecomments (id1,id2) { |
---|
38 | |
---|
39 | var obj1 = document.getElementById(id1); |
---|
40 | var obj2 = document.getElementById(id2); |
---|
41 | (obj1.className=="commentshown") ? obj1.className="commenthidden" : obj1.className="commentshown"; |
---|
42 | (obj1.className=="commentshown") ? obj2.innerHTML="<< Hide" : obj2.innerHTML="Show all >>"; |
---|
43 | |
---|
44 | } |
---|
45 | |
---|
46 | function checkAll(objName, FormName, FieldName ) { |
---|
47 | |
---|
48 | var obj = document.getElementsByName(objName); |
---|
49 | var CheckValue = obj[0].checked; |
---|
50 | |
---|
51 | if(!document.forms[FormName]) |
---|
52 | return; |
---|
53 | var objCheckBoxes = document.forms[FormName].elements[FieldName]; |
---|
54 | if(!objCheckBoxes) |
---|
55 | return; |
---|
56 | var countCheckBoxes = objCheckBoxes.length; |
---|
57 | if(!countCheckBoxes) |
---|
58 | objCheckBoxes.checked = CheckValue; |
---|
59 | else |
---|
60 | // set the check value for all check boxes |
---|
61 | for(var i = 0; i < countCheckBoxes; i++) |
---|
62 | objCheckBoxes[i].checked = CheckValue; |
---|
63 | } |
---|
64 | |
---|
65 | function updateSelectAll(objId, allId) { |
---|
66 | var obj = document.getElementById(objId); |
---|
67 | var allCheckbox = document.getElementById(allId); |
---|
68 | |
---|
69 | if (!objId.checked && allCheckbox.checked) { |
---|
70 | allCheckbox.checked = false; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | } |
---|
75 | //--></script> |
---|
76 | |
---|
77 | <title>ATNF Pulsar Data Archive Home</title> |
---|
78 | |
---|
79 | <!-- Start Content --> |
---|
80 | <?php |
---|
81 | |
---|
82 | include_once("constants.php"); |
---|
83 | include_once("security.php"); |
---|
84 | include_once("database.php"); |
---|
85 | include_once("date.php"); |
---|
86 | |
---|
87 | $now_day = date("j"); |
---|
88 | $now_month = date("n"); |
---|
89 | $now_year = date("Y"); |
---|
90 | |
---|
91 | $all_params_id = "all_params"; |
---|
92 | $all_others_id = "all_others"; |
---|
93 | |
---|
94 | $link = db_connect(); |
---|
95 | //$link = db_connect_admin(); |
---|
96 | //loadNewTables(); |
---|
97 | ////////////////////////////// |
---|
98 | // Initialise error messages |
---|
99 | // |
---|
100 | |
---|
101 | $date_error = ""; |
---|
102 | |
---|
103 | /////////////////////////////////// |
---|
104 | // Find out the first and last dates |
---|
105 | //$query = "select min(mjd), max(mjd) from ".OBSERVATIONS_TABLE; |
---|
106 | $query = "select min(t.mjd), max(t.mjd) from ((select mjd from s70) union (select mjd from obs)) as t"; |
---|
107 | $result = mysql_query($query) or die('Query failed: ' . mysql_error()); |
---|
108 | |
---|
109 | $row = mysql_fetch_array($result); |
---|
110 | |
---|
111 | $min_mjd = $row[0]; |
---|
112 | $max_mjd = $row[1]; |
---|
113 | |
---|
114 | // Convert from MJD to JD |
---|
115 | $min_mjd += 2400000.5; |
---|
116 | $max_mjd += 2400000.5; |
---|
117 | |
---|
118 | // convert the mjd to a date |
---|
119 | $min_mjd = floor($min_mjd); |
---|
120 | $max_mjd = ceil($max_mjd); |
---|
121 | |
---|
122 | $min_cal_assoc = cal_from_jd($min_mjd, CAL_GREGORIAN); |
---|
123 | $max_cal_assoc = cal_from_jd($max_mjd, CAL_GREGORIAN); |
---|
124 | |
---|
125 | // Free resultset |
---|
126 | mysql_free_result($result); |
---|
127 | |
---|
128 | // Clear any old form inputs in session cache |
---|
129 | init($link); |
---|
130 | |
---|
131 | ////////////////////////////////////////////// |
---|
132 | // Get the field names to fill form checkboxes |
---|
133 | |
---|
134 | //$query = "SHOW COLUMNS FROM ".OBSERVATIONS_TABLE; |
---|
135 | $query = "SHOW COLUMNS FROM obs"; |
---|
136 | $result = mysql_query($query) or die ('Query failed: ' . mysql_error()); |
---|
137 | |
---|
138 | $fields = array(); |
---|
139 | if (mysql_num_rows($result)) { |
---|
140 | while($row = mysql_fetch_assoc($result)) { |
---|
141 | if(($row['Field'] != "data_loc") && ($row['Field'] != "file_size_bytes")) |
---|
142 | array_push($fields, $row); |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | /////////////////////////////////////////////// |
---|
147 | // Get the data types available in the database |
---|
148 | // |
---|
149 | |
---|
150 | //$query = "select distinct data_type from " . OBSERVATIONS_TABLE . " order by data_type"; |
---|
151 | $query = "(select distinct data_type from obs) union (select distinct data_type from s70)"; |
---|
152 | $result = mysql_query($query) or die ('Query failed: ' . mysql_error()); |
---|
153 | |
---|
154 | $data_types = array(); |
---|
155 | |
---|
156 | if (mysql_num_rows($result)) { |
---|
157 | while($row = mysql_fetch_array($result, MYSQL_NUM)) { |
---|
158 | array_push($data_types, $row[0]); |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | /////////////////////////////////////////////// |
---|
163 | // If the user clicked on the logout button |
---|
164 | if (isset($HTTP_GET_VARS['command'])) { |
---|
165 | $command = $HTTP_GET_VARS['command']; |
---|
166 | if ($command == 'logout') { |
---|
167 | //unset($_SESSION['auth_code']); |
---|
168 | //unset($_SESSION['username']); |
---|
169 | $_SESSION = array(); |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | // If the user hasn't logged in before or if the previous |
---|
174 | // session's authentication wasn't successful |
---|
175 | // Then use the submitted username and password |
---|
176 | if (!isset($_SESSION['auth_code']) || $_SESSION['auth_code'] != OK) { |
---|
177 | $username = $HTTP_POST_VARS["username"]; |
---|
178 | $password = $HTTP_POST_VARS["password"]; |
---|
179 | $auth_code = authenticate($username, $password); |
---|
180 | } |
---|
181 | else { |
---|
182 | $auth_code = $_SESSION['auth_code']; |
---|
183 | $username = $_SESSION['username']; |
---|
184 | } |
---|
185 | |
---|
186 | //echo "auth_code = $auth_code<br>\n"; |
---|
187 | |
---|
188 | /////////////////////////////////////////////////////////////// |
---|
189 | // Set the new maximum search range if not an atnf staff member |
---|
190 | // |
---|
191 | |
---|
192 | // if (!atnf_staff($username)) { |
---|
193 | // $max_cal_assoc['day'] = date("j"); |
---|
194 | // $max_cal_assoc['month'] = date("n"); |
---|
195 | // $max_cal_assoc['year'] = date("Y")-2; |
---|
196 | |
---|
197 | // echo "$username not atnf<br>\n"; |
---|
198 | // } |
---|
199 | |
---|
200 | // Initial state where no username or password supplied OR bad login state |
---|
201 | if ($auth_code != OK) { ?> |
---|
202 | <body class="front_page"> |
---|
203 | |
---|
204 | |
---|
205 | <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> |
---|
206 | |
---|
207 | <img class="front_page" src="images/front_page01.png"></img> |
---|
208 | <table class="login"> |
---|
209 | <?php if ( $auth_code == BAD_LOGIN){ ?> |
---|
210 | <tr><td class="form_field" colspan="2"><font color="red">Incorrect username and/or password</font></td></tr> |
---|
211 | <?php }?> |
---|
212 | <tr><td class="form_field"><font color="white">Username: </font></td><td><input type="text" name="username"></td></tr> |
---|
213 | <tr><td class="form_field"><font color="white">Password: </font></td><td><input type="password" name="password"></td></tr> |
---|
214 | <tr><td class="form_field" align="left"><font color="white"><a href="register.html">Register</a></font></td><td align="right" rowspan="2"><input type="submit" value="Log in"></td></tr> |
---|
215 | <tr><td class="form_field" align="left"><font color="white"><a href="forgot.php">Forgot your password?</a></font></td></tr> |
---|
216 | </table> |
---|
217 | </form> |
---|
218 | <?php } else { |
---|
219 | include_once("header.html"); |
---|
220 | $_SESSION['username'] = $username; |
---|
221 | $_SESSION['auth_code'] = $auth_code; |
---|
222 | |
---|
223 | $actions = $HTTP_GET_VARS['actions']; |
---|
224 | |
---|
225 | if ($actions == "new_query") { |
---|
226 | init(); |
---|
227 | } |
---|
228 | else if ($actions == "error") { |
---|
229 | $date_error = "You are only authorised to access data > 18 months old"; |
---|
230 | } |
---|
231 | ?> |
---|
232 | <body class="atoa"> |
---|
233 | <script type="text/javascript" src="scripts/process.js"></script> |
---|
234 | |
---|
235 | <table class="noborder"> |
---|
236 | <tr><td><a class="top_menu" href="<?php echo $PHP_SELF; ?>?command=logout">Logout</a> | <a class="top_menu" href="change_password.html?prev_page=<?php echo urlencode("index.html"); ?>">Change Password</a></td> |
---|
237 | </tr> |
---|
238 | </table> |
---|
239 | |
---|
240 | |
---|
241 | <form action="query.php" method="GET" name="data_archive_form" id="data_archive_form"> |
---|
242 | <input type="hidden" name="state" value="results"> |
---|
243 | |
---|
244 | <table class="noborder"> |
---|
245 | |
---|
246 | <tr> |
---|
247 | |
---|
248 | <td valign="top" class="form_field" rowspan="2"> |
---|
249 | |
---|
250 | <fieldset> |
---|
251 | <legend>Display Parameters</legend> |
---|
252 | <input type="checkbox" name="<?php echo $all_params_id; ?>" id="<?php echo $all_params_id; ?>" onClick="checkAll('<?php echo $all_params_id; ?>', 'data_archive_form', 'params[]')" checked="true">Select all<br> |
---|
253 | <font size="-1"><a href="javascript:togglecomments('params', 'toggler1')" id="toggler1">Show all >></a></font><br> |
---|
254 | <span class="commenthidden" id="params"> |
---|
255 | <div id="list"> |
---|
256 | <?php |
---|
257 | // Special case for ra and dec |
---|
258 | $raj_count = 0; |
---|
259 | $decj_count = 0; |
---|
260 | $raj_field = ""; |
---|
261 | $decj_field = ""; |
---|
262 | |
---|
263 | foreach ($fields as $field) { |
---|
264 | // if (ereg("raj_.+", $field['Field'] )) { |
---|
265 | // $raj_field .= "," . $field['Field']; |
---|
266 | // $raj_count++; |
---|
267 | // if ($raj_count == 3) { |
---|
268 | // $raj_field = trim($raj_field, " ,"); |
---|
269 | // echo "<input onClick=\"updateSelectAll('ra', |
---|
270 | // '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$raj_field\" id=\"RA\" checked=\"true\">RA<br>\n"; |
---|
271 | // } |
---|
272 | // } |
---|
273 | // else if (ereg("decj_.+", $field['Field'] ) ){ |
---|
274 | // $decj_field .= "," . $field['Field']; |
---|
275 | // $decj_count++; |
---|
276 | // if ($decj_count == 3) { |
---|
277 | // $decj_field = trim($decj_field, " ,"); |
---|
278 | // echo "<input onClick=\"updateSelectAll('dec', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$decj_field\" id=\"dec\" checked=\"true\">DecJ<br>\n"; |
---|
279 | // } |
---|
280 | // } |
---|
281 | // else { |
---|
282 | echo "<input |
---|
283 | onClick=\"updateSelectAll('".$field['Field']."', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"".$field['Field']."\" id=\"".$field['Field']."\" checked=\"true\">".$field['Field']."<br>\n"; |
---|
284 | // } |
---|
285 | } |
---|
286 | ?> |
---|
287 | </div> |
---|
288 | </span> |
---|
289 | </fieldset> |
---|
290 | <fieldset> |
---|
291 | <legend>Display Other</legend> |
---|
292 | |
---|
293 | <input type="checkbox" name="cals" value="cals" id="cals" checked="true" />Cals within |
---|
294 | <input type="text" name="cals_within_mins" value="30" maxlength="5" size="3"/> mins of obs |
---|
295 | <br> |
---|
296 | |
---|
297 | </fieldset> |
---|
298 | </td> |
---|
299 | |
---|
300 | <td class="form_field" height="10%"> |
---|
301 | <!-- Filter Options --> |
---|
302 | <fieldset id="flsPosition"> |
---|
303 | |
---|
304 | <legend>Filter Options</legend> |
---|
305 | |
---|
306 | <!-- Data Type --> |
---|
307 | <fieldset> |
---|
308 | <legend>Data Type</legend> |
---|
309 | |
---|
310 | <select name="data_type" onchange="DataTypeChanged()" id="DataTypeList"> |
---|
311 | <option value="timing"> timing </option> |
---|
312 | <option value="search"> search </option> |
---|
313 | </select> |
---|
314 | |
---|
315 | </fieldset> |
---|
316 | |
---|
317 | <!-- Pulsar Name --> |
---|
318 | <fieldset> |
---|
319 | <legend>Pulsar Name</legend> |
---|
320 | |
---|
321 | <input type="text" name="pulsar_name" size="10"> |
---|
322 | |
---|
323 | </fieldset> |
---|
324 | |
---|
325 | <!-- Data Type --> |
---|
326 | <fieldset> |
---|
327 | <legend>Data Type</legend> |
---|
328 | |
---|
329 | <select name="data_type"> |
---|
330 | <option value="" selected> Any |
---|
331 | <?php |
---|
332 | foreach ($data_types as $data_type) { |
---|
333 | echo " |
---|
334 | <option value=\"$data_type\"> $data_type"; |
---|
335 | } |
---|
336 | ?> |
---|
337 | </select> |
---|
338 | |
---|
339 | </fieldset> |
---|
340 | |
---|
341 | <!-- Date range --> |
---|
342 | <fieldset> |
---|
343 | <legend>Date Range</legend> |
---|
344 | |
---|
345 | <select name="from_day"> |
---|
346 | <?php |
---|
347 | for ($i = 1; $i <= 31; $i++) { |
---|
348 | echo "\t\t\t<option"; |
---|
349 | if ($i == $min_cal_assoc['day']) { |
---|
350 | echo " selected"; |
---|
351 | } |
---|
352 | echo " value=\"$i\">$i</option>\n"; |
---|
353 | } |
---|
354 | ?> |
---|
355 | </select> |
---|
356 | <select name="from_month"> |
---|
357 | <?php |
---|
358 | for ($i = 1; $i <= 12; $i++) { |
---|
359 | echo "\t\t\t<option"; |
---|
360 | if ($i == $min_cal_assoc['month']) { |
---|
361 | echo " selected"; |
---|
362 | } |
---|
363 | echo " value=\"$i\">$i</option>\n"; |
---|
364 | } |
---|
365 | ?> |
---|
366 | </select> |
---|
367 | <input type="text" size="4" name="from_year" value="<?php echo $min_cal_assoc['year']; ?>"> |
---|
368 | <?php echo "<font size=\"-1\" color=\"red\">$date_error</font>" ?> |
---|
369 | <br>to<br> |
---|
370 | <select name="to_day"> |
---|
371 | <?php |
---|
372 | for ($i = 1; $i <= 31; $i++) { |
---|
373 | echo "\t\t\t<option"; |
---|
374 | if ($i == $max_cal_assoc['day']) { |
---|
375 | echo " selected"; |
---|
376 | } |
---|
377 | echo " value=\"$i\">$i</option>\n"; |
---|
378 | } |
---|
379 | ?> |
---|
380 | </select> |
---|
381 | <select name="to_month"> |
---|
382 | <?php |
---|
383 | for ($i = 1; $i <= 12; $i++) { |
---|
384 | echo "\t\t\t<option"; |
---|
385 | if ($i == $max_cal_assoc['month']) { |
---|
386 | echo " selected"; |
---|
387 | } |
---|
388 | echo " value=\"$i\">$i</option>\n"; |
---|
389 | } |
---|
390 | ?> |
---|
391 | </select> |
---|
392 | <input type="text" size="4" name="to_year" value="<?php echo $max_cal_assoc['year']; ?>"> |
---|
393 | </fieldset> |
---|
394 | |
---|
395 | |
---|
396 | <!-- Coordinates --> |
---|
397 | <fieldset> |
---|
398 | <legend>Coordinates</legend> |
---|
399 | |
---|
400 | RAJ: <input type="text" name="raj" size="10"> |
---|
401 | DecJ: <input type="text" name="decj" size="10"> |
---|
402 | Search radius (degs): <input type="text" name="radius" size="10"> |
---|
403 | |
---|
404 | |
---|
405 | </fieldset> |
---|
406 | |
---|
407 | </fieldset> |
---|
408 | <br> |
---|
409 | <input type="submit" value="submit" name="submit_button"> |
---|
410 | </td> |
---|
411 | </tr> |
---|
412 | </table> |
---|
413 | |
---|
414 | |
---|
415 | </form> |
---|
416 | <?php } ?> |
---|
417 | |
---|
418 | </body> |
---|
419 | |
---|
420 | </html> |
---|
421 | |
---|
422 | |
---|
423 | <?php //////////// Function definitions /////////////// |
---|
424 | |
---|
425 | |
---|
426 | // Initialise the input form variables. If the "New query" button is clicked |
---|
427 | // no argument is passed to init(), hence the need for a default NULL value |
---|
428 | // because there is no need for updating user access statistics |
---|
429 | function init($link=NULL) { |
---|
430 | |
---|
431 | if ($link) { |
---|
432 | // Update the users table |
---|
433 | updateUsersTable($link); |
---|
434 | } |
---|
435 | |
---|
436 | unset($_SESSION['cals']); // The result set of cals |
---|
437 | unset($_SESSION['obs']); // The result set of observations |
---|
438 | //unset($_SESSION['cart_items']); // The result set of observations |
---|
439 | } |
---|
440 | |
---|
441 | mysql_close($link); |
---|
442 | |
---|
443 | ?> |
---|