source: trunk/htdocs/index.php @ 193

Last change on this file since 193 was 193, checked in by MatthewWhiting, 17 years ago
  • Fixed bugs in view_profiles that meant some figures were not being plotted.
  • Updated scripts.
  • Fixed bug in query by pulsar name.
File size: 19.9 KB
Line 
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.php
5 // Matthew Whiting Nov 2007
6 // From the original by Albert Teoh
7 //
8 // The opening page for the ATNF Pulsar Data Archive
9 // system. Used to search for observation archive
10 // files.
11 
12 // BEGIN Javascript for expansion blocks
13 // Thanks to:
14 // http://assn9.blogspot.com/
15 // Douglas Bowman
16 // URL:      www.stopdesign.com
17 // Used in: http://www.bloggerforum.com/modules/newbb/viewtopic.php?topic_id=8725&forum=6
18 // Date:     26 Feb 2004
19 //
20
21?>
22<head>
23<link rel="stylesheet" type="text/css" href="styles/style.css" />
24<link rel="stylesheet" type="text/css" href="styles/query.css" />
25<link rel="stylesheet" type="text/css" href="styles/results.css" />
26<link rel="stylesheet" type="text/css" href="styles/atnf.css" />
27<meta http-equiv="Content-Type" content="text/html; charset=iso-8759-1" />
28<meta name="DC.Creator" lang="en" content="personalName=Teoh,Albert" />
29<meta name="ATNF.Maintainer" content="contactName=Webmaster,the" />
30<meta name="DC.Title.alt" lang="en" content="" />
31<meta name="DC.Subject" lang="en" content="pulsar" />
32<meta name="DC.Description" lang="en" content="Searches the data archives at the ATNF" />
33<meta name="DC.Date.created" scheme="ISO8601" content="2002-12-12" />
34<meta name="ATNF.Site" content="Marsfield" />
35<meta name="ATNF.AccessPermission" content="Public" />
36    <meta name="ATNF.MetaVersion" content="1.0" />
37   
38    <script type="text/javascript" src="scripts/atnf-oo-utils.js"></script>
39    <script type="text/javascript" src="scripts/atnf-string-utils.js"></script>
40    <script type="text/javascript" src="scripts/atnf-dom-utils.js"></script>
41    <script type="text/javascript" src="scripts/atnf-validation.js"></script>
42    <script type="text/javascript" src="scripts/atoa-query.js"></script>
43
44<!--
45   <script type="text/javascript" src="scripts/atnf-dom-utils.js"></script>
46   <script type="text/javascript" src="scripts/atoa-query.js"></script>
47   <script type="text/javascript" src="scripts/process.js"></script>
48-->
49
50
51<script type="text/javascript" language="javascript1.2">
52function togglecomments (id1,id2) {
53
54                var obj1 = document.getElementById(id1);
55                var obj2 = document.getElementById(id2);
56                (obj1.className=="commentshown") ? obj1.className="commenthidden" : obj1.className="commentshown";
57                (obj1.className=="commentshown") ? obj2.innerHTML="<< Hide" : obj2.innerHTML="Show all >>";
58
59}
60
61function checkAll(objName, FormName, FieldName ) {
62
63        var obj = document.getElementsByName(objName);
64        var CheckValue = obj[0].checked;
65
66        if(!document.forms[FormName])
67                return;
68        var objCheckBoxes = document.forms[FormName].elements[FieldName];
69        if(!objCheckBoxes)
70                return;
71        var countCheckBoxes = objCheckBoxes.length;
72        if(!countCheckBoxes)
73                objCheckBoxes.checked = CheckValue;
74        else
75                // set the check value for all check boxes
76                for(var i = 0; i < countCheckBoxes; i++)
77                        objCheckBoxes[i].checked = CheckValue;
78}
79
80function updateSelectAll(objId, allId) {
81        var obj = document.getElementById(objId);
82        var allCheckbox = document.getElementById(allId);       
83       
84        if (!objId.checked && allCheckbox.checked) {
85                allCheckbox.checked = false;
86        }
87               
88               
89}
90</script>
91
92</head>
93
94<title>ATNF Pulsar Data Archive Home</title>
95
96<!-- Start Content -->
97<?php
98       
99include_once("constants.php");
100include_once("security.php");
101include_once("database.php");
102include_once("date.php");
103
104$now_day = date("j");
105$now_month = date("n");
106$now_year = date("Y");
107
108$all_params_id = "all_params";
109$all_others_id = "all_others";
110
111$link = db_connect();
112//$link = db_connect_admin();
113//loadNewTables();
114//////////////////////////////
115// Initialise error messages
116//
117
118$date_error = "";
119
120///////////////////////////////////
121// Find out the first and last dates
122//$query = "select min(mjd), max(mjd) from ".OBSERVATIONS_TABLE;
123$query = "select min(t.mjd), max(t.mjd) from ((select mjd from s70) union (select mjd from obs)) as t";
124$result = mysql_query($query) or die('Query 1 failed: ' . mysql_error());
125
126$row = mysql_fetch_array($result);
127
128$min_mjd = $row[0];
129$max_mjd = $row[1];
130
131// Convert from MJD to JD
132$min_jd = $min_mjd + 2400000.5;
133$max_jd = $max_mjd + 2400000.5;
134
135// convert the mjd to a date
136$min_jd = floor($min_jd);
137$max_jd = ceil($max_jd);
138
139$min_unix = jdtounix($min_jd);
140$max_unix = jdtounix($max_jd);
141$min_date_text = date("j F Y", $min_unix);
142$max_date_text = date("j F Y", $max_unix);
143$minDay   = date("j",$min_unix);
144$minMonth = date("n",$min_unix);
145$minYear  = date("Y",$min_unix);
146$maxDay   = date("j",$max_unix);
147$maxMonth = date("n",$max_unix);
148$maxYear  = date("Y",$max_unix);
149
150// Free resultset
151mysql_free_result($result);
152
153// Clear any old form inputs in session cache
154init($link);
155
156//////////////////////////////////////////////
157// Get the field names to fill form checkboxes
158
159//$query = "SHOW COLUMNS FROM ".OBSERVATIONS_TABLE;
160$query = "SHOW COLUMNS FROM obs";
161$result = mysql_query($query) or die ('Query 2 failed: ' . mysql_error());
162
163$fields = array();
164if (mysql_num_rows($result)) {
165        while($row = mysql_fetch_assoc($result)) {
166          if(($row['Field'] != "data_loc") && ($row['Field'] != "file_size_bytes"))
167            array_push($fields, $row);
168        }
169}
170
171$field_names = Array("filename" => "Filename",
172                     "src_name" => "Source Name",
173                     "project_id" => "Project ID",
174                     "raj" => "RA (J2000, hh:mm:ss)",
175                     "decj" => "Dec (J2000, dd:mm:ss)",
176                     "data_type" => "Data Type",
177                     "obsfreq" => "Frequency",
178                     "bw" => "Bandwidth",
179                     "scanlen" => "Scan Length",
180                     "date" => "UT Date",
181                     "ut" => "UT Time",
182                     "MJD" => "MJD",
183                     "rajd" => "RA (J2000, degs)",
184                     "decjd" => "Dec (J2000, degs)",
185                     "gl" => "Gal. Long. (degs)",
186                     "gb" => "Gal. Lat. (degs)",
187                     "BMAJ" => "Beamsize: BMAJ",
188                     "BMIN" => "Beamsize: BMIN",
189                     "BPA" => "Beam: BPA",
190                     "dm" => "D.M.",
191                     "period" => "Period",
192                     "nchan" => "# channels",
193                     "npol" => "# polarisations",
194                     "nbin" => "# bins",
195                     "nsub" => "# subintegrations",
196                     "tsamp" => "Sample time",
197                     "nbits" => "# bits per sample",
198                     "nbeam" => "# beams",
199                     "cnfg" => "Configuration",
200                     "inst" => "Instrument",
201                     "rcvr" => "Receiver",
202                     "hdrver" => "PSRFITS version",
203                     "survey" => "Survey name",
204                     "telescope" => "Telescope",
205                     "site" => "Site ID",
206                     "obsrvr" => "Observer ID" );
207
208///////////////////////////////////////////////
209// Get the data types available in the database
210//
211
212//$query = "select distinct data_type from " . OBSERVATIONS_TABLE . " order by data_type";
213$query = "(select distinct data_type from obs) union (select distinct data_type from s70)";
214$result = mysql_query($query) or die ('Query 3 failed: ' . mysql_error());
215
216$data_types = array();
217
218if (mysql_num_rows($result)) {
219        while($row = mysql_fetch_array($result, MYSQL_NUM)) {
220                array_push($data_types, $row[0]);
221        }
222}
223
224///////////////////////////////////////////////
225// If the user clicked on the logout button
226if (isset($HTTP_GET_VARS['command'])) {
227        $command = $HTTP_GET_VARS['command'];
228        if ($command == 'logout') {
229                //unset($_SESSION['auth_code']);
230                //unset($_SESSION['username']);
231                $_SESSION = array();
232        }
233}
234
235// If the user hasn't logged in before or if the previous
236// session's authentication wasn't successful
237// Then use the submitted username and password
238if (!isset($_SESSION['auth_code']) || $_SESSION['auth_code'] != OK) {
239        $username = $HTTP_POST_VARS["username"];
240        $password = $HTTP_POST_VARS["password"];
241        $auth_code = authenticate($username, $password);
242}
243else {
244        $auth_code = $_SESSION['auth_code'];
245        $username = $_SESSION['username'];
246}
247
248//echo "auth_code = $auth_code<br>\n";
249
250///////////////////////////////////////////////////////////////
251// Set the new maximum search range if not an atnf staff member
252//
253
254// if (!atnf_staff($username)) {
255//      $max_cal_assoc['day'] = date("j");
256//      $max_cal_assoc['month'] = date("n");
257//      $max_cal_assoc['year'] = date("Y")-2;
258       
259//      echo "$username not atnf<br>\n";
260// }
261
262// Initial state where no username or password supplied OR bad login state
263if ($auth_code != OK) { ?>
264        <body class="front_page">
265
266
267        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
268       
269  <img class="front_page" src="images/front_page01.png"></img>
270        <table class="login">
271        <?php if ( $auth_code == BAD_LOGIN){ ?>
272                <tr><td class="form_field" colspan="2"><font color="red">Incorrect username and/or password</font></td></tr>
273        <?php }?>
274                <tr><td class="form_field"><font color="white">Username: </font></td><td><input type="text" name="username"></td></tr>
275                <tr><td class="form_field"><font color="white">Password: </font></td><td><input type="password" name="password"></td></tr>
276                <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>
277                <tr><td class="form_field" align="left"><font color="white"><a href="forgot.php">Forgot your password?</a></font></td></tr>
278        </table>
279        </form>
280<?php } else {
281        include_once("header.html");
282        $_SESSION['username'] = $username;
283        $_SESSION['auth_code'] = $auth_code;
284
285        $actions = $HTTP_GET_VARS['actions'];
286       
287        if ($actions == "new_query") {
288                init();
289        }
290        else if ($actions == "error") {
291                $date_error = "You are only authorised to access data > 18 months old";
292        }
293?>
294<body class="atoa">
295   
296    <h1>ATNF Pulsar Data Archive</h1>
297
298    <p>This archive provides access to pulsar observations taken at the Parkes radio telescope between the dates of <?php echo $min_date_text." and ".$max_date_text?>. <br>See the Users Guide link for more details. </p>
299   
300    <table width="700" style="border: 0px;">
301    <tr align="center">
302    <td>
303    <a class="top_menu" href="<?php echo $PHP_SELF; ?>?command=logout">Logout</a>
304    <!--a href="login?_action=logout">Logout</a-->
305
306    </td>
307        <td>
308        <a class="top_menu" href="change_password.html?prev_page=<?php echo urlencode("index.php"); ?>">Change Password</a>
309        </td>
310        <td size="30">
311        &nbsp;
312    </td>
313        <td>
314        <div id="divUsageToggle"></div>
315        </td>
316        <td size="30">
317        &nbsp;
318    </td>
319        <td>
320        <a href="pulsar_archive_guide.html">Users Guide</a>
321        </td>
322        </tr>
323
324        </table>
325
326        <div id="divUsage">
327
328        <h2>Instructions</h2>
329       
330            <dl class="top">
331              <dt> Display Parameters </dt>
332                <dd> Check the fields you want shown </dd>
333              <dt> Filter Options </dt>
334                <dd> You can select both timing data and search data. For search data the Pulsar name is
335                     ignored.
336                </dd>
337              <dt> Coordinates </dt>
338                <dd> ... </dd>
339              <dt> Display Other </dt>
340                <dd> ... </dd>
341              <dt> Perform Query </dt>
342                <dd> ... </dd>
343            </dl>
344           
345        </div>
346
347
348
349<!--<table class="noborder">
350<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.php"); ?>">Change Password</a></td>
351</tr>
352</table>-->
353
354
355<form action="query.php" method="GET" name="data_archive_form" id="data_archive_form">
356<input type="hidden" name="state" value="results">
357   
358
359   
360   
361<table class="noborder" cellpadding=0>
362
363    <tr><td colspan=3>
364        <br>
365        <center><input type="submit" value="submit" name="submit_button" style="float: center;"> &nbsp;
366        <input type="reset" value="reset" name="reset_button" style="float: center;"></center>
367        <br>
368    </td></tr>
369   
370    <tr>
371       
372<!-- **************************** -->
373    <td valign="top" class="form_field" rowspan="1">
374
375    <fieldset>
376                <legend>DISPLAY PARAMETERS</legend>
377                <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[]')" >Select all<br>
378                        <!--font size="-1"><a href="javascript:togglecomments('params', 'toggler1')" id="toggler1">Show all >></a></font--><br>
379                        <!span class="commenthidden" id="params">
380                        <div id="list">
381                                <?php
382                                $def_fields = Array( "filename", "src_name", "project_id", "raj", "decj",
383                                                     "data_type", "obsfreq", "bw", "scanlen", "date", "ut" );
384
385                                foreach ($fields as $field) {
386                                  echo "<input
387onClick=\"updateSelectAll('".$field['Field']."', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"".$field['Field']."\" id=\"".$field['Field']."\"";
388                                  if( in_array( $field['Field'], $def_fields ) )
389                                    echo ' checked="true"';
390                                  echo " >".$field_names[$field['Field']]."<br>\n";
391                                }
392                                ?>
393                        </div>
394                        </span>
395        </fieldset>
396                       
397        </td>
398
399<!-- **************************** -->
400
401        <td class="form_field" height="10%" rowspan="1">
402        <!-- Position Options -->
403
404        <table cellspacing=0 cellpadding=0 style="border: 0px;">
405        <tr><td>
406        <fieldset id="flsPosition">
407                <legend>POSITION REQUIREMENTS</legend>
408<br>
409               
410                <!-- Coordinates -->
411                <fieldset>
412                        <legend>Coordinates</legend>
413
414<!--
415                        RAJ: <input type="text" name="raj" size="10">
416                        DecJ: <input type="text" name="decj" size="10">
417                        Search radius (degs): <input type="text" name="radius" size="10">
418-->
419
420                            <fieldset>
421                            <legend>Right Ascension (J2000)</legend>
422                           
423                            <input type="text" id="txtRAHour" name="rahour" size="3" tabindex="1" />
424                            <label for="txtRAHour" class="coordinate"><abbr title="hours"><sup>h</sup></abbr></label>
425                                                     
426                            <input type="text" id="txtRAMinute" name="ramin" size="3" tabindex="1" />
427                            <label for="txtRAMinute" class="coordinate"><abbr title="minutes"><sup>m</sup></abbr></label>
428               
429                            <input type="text" id="txtRASecond" name="rasec" size="6" tabindex="1" />
430                            <label for="txtRASecond" class="coordinate"><abbr title="seconds"><sup>s</sup></abbr></label>
431                            </fieldset>
432       
433                            <fieldset>
434                                                       <legend>Declination (J2000)</legend>
435               
436                        <input type="text" id="txtDecDegree" name="decdeg" size="3" tabindex="1" />
437                        <label for="txtDecDegree" class="coordinate"><abbr title="degrees">&deg;</abbr></label>
438               
439                        <input type="text" id="txtDecMinute" name="decmin" size="3" tabindex="1" />
440                        <label for="txtDecMinute" class="coordinate"><abbr title="minutes">&prime;</abbr></label>
441               
442                        <input type="text" id="txtDecSecond" name="decsec" size="6" tabindex="1" />
443
444                        <label for="txtDecSecond" class="coordinate"><abbr title="seconds">&Prime;</abbr></label>
445               
446        </fieldset><br>
447     <fieldset>
448                <legend>Search Window (arcminutes)</legend>
449                <input type="text" id="txtSearchWindow" name="radius" size="30" tabindex="1" value="60"/>
450         </fieldset>
451     </fieldset>
452
453                </fieldset>     
454
455<br>
456                <!-- Pulsar Name -->
457                <fieldset>
458                        <legend>Pulsar Name</legend>
459
460                        <input type="text" name="pulsar_name" size="10">
461
462                </fieldset>     
463
464        </fieldset>
465        </td></tr>
466</table>
467</td>
468
469<!-- **************************** -->
470
471        <td class="form_field" height="10%">
472        <!-- Filter Options -->
473        <table cellspacing=0 cellpadding=0 style="border: 0px;">
474        <tr><td>
475        <fieldset id="flsObsDate">
476                               
477                <legend>FILTER OPTIONS</legend>
478<br>
479
480                <!-- Date range -->
481                <fieldset>
482                        <legend>Date Range</legend>
483                       
484                          From:                                                                       
485                            <select name="from_day">
486                            <?php
487                            for ($i = 1; $i <= 31; $i++) {
488                              echo "\t\t\t<option";
489                              if ($i == $minDay) { echo " selected"; }
490                              echo " value=\"$i\">$i</option>\n";
491                            }
492                                ?>
493                            </select>
494                        <select name="from_month">
495                                <?php
496                                $monthlist = cal_info(0);
497                                for ($i = 1; $i <= 12; $i++) {
498                                  echo "\t\t\t<option";
499                                  $month = $monthlist[abbrevmonths][$i];
500                                  if ($i == $minMonth) { echo " selected"; }
501                                  echo " value=\"$i\">$month</option>\n";
502                                }
503                                ?>
504                                  </select>
505<!-- <input type="text" size="4" name="from_year" value="<?php echo $min_cal_assoc['year']; ?>"> -->
506                      <select name="from_year">
507                                      <?php
508                                      for ($i = $minYear; $i <= $maxYear; $i++) {
509                                        echo "\t\t\t<option";
510                                        if ($i == $minYear) { echo " selected"; }
511                                  echo " value=\"$i\">$i</option>\n";
512                                }
513                                ?>
514                            </select>
515                        <?php echo "<font size=\"-1\" color=\"red\">$date_error</font>" ?>
516                                &nbsp To:
517                        <select name="to_day">
518                                <?php
519                                        for ($i = 1; $i <= 31; $i++) {
520                                          echo "\t\t\t<option";
521                                          if ($i == $maxDay) { echo " selected"; }
522                                          echo " value=\"$i\">$i</option>\n";
523                                        }
524                                ?>
525                        </select>
526                        <select name="to_month">
527                                <?php
528                            for ($i = 1; $i <= 12; $i++) {
529                              echo "\t\t\t<option";
530                              $month = $monthlist[abbrevmonths][$i];
531                              if ($i == $maxMonth) { echo " selected"; }
532                              echo " value=\"$i\">$month</option>\n";
533                            }
534                                ?>
535                        </select>
536<!-- <input type="text" size="4" name="to_year" value="<?php echo $max_cal_assoc['year']; ?>"> -->
537                      <select name="to_year">
538                                      <?php
539                                      for ($i = $minYear; $i <= $maxYear; $i++) {
540                                        echo "\t\t\t<option";
541                                        if ($i == $maxYear) { echo " selected"; }
542                                  echo " value=\"$i\">$i</option>\n";
543                                }
544                                ?>
545                            </select>
546                </fieldset>
547 
548<br>
549                <!-- Obs Mode -->
550                <fieldset>
551                        <legend>Obs Mode</legend>
552
553                        <select name="obs_mode" onchange="ObsModeChanged()" id="ObsModeList">
554                                <option value="any"> Any </option>
555                                <option value="timing"> Only timing data </option>
556                                <option value="search"> Only search data </option>
557                        </select>
558                </fieldset>
559
560                <!-- Data Type -->
561                <fieldset>
562                        <legend>Data Type</legend>
563
564                        <select name="data_type">
565                                <option value="" selected> Any </option>
566                                <?php
567                                foreach ($data_types as $data_type) {
568                                        echo "
569                                        <option value=\"$data_type\"> $data_type </option>";
570                                }
571                                ?>
572                        </select>
573                </fieldset>     
574
575                <!-- Frequency band -->
576                <fieldset>
577                        <legend>Band Name</legend>
578                            <select id="selBand" name="bandname[]" multiple="multiple" size="5">
579                            <option value="anyBand" selected="selected">Any</option>
580                            <option value="70cm"   >70cm (~0.44 GHz)</option>     
581                            <option value="50cm"   >50cm (~0.66 GHz)</option>     
582                            <option value="20cm">20/18cm (1.2-1.8 GHz)</option>     
583                            <option value="13cm"   >13cm (2.0-2.5 GHz)</option>     
584                            <option value="10cm"   >10cm (2.6-3.6 GHz)</option>     
585                            <option value="6cm"    >6cm (4.5-5.1 GHz)</option>     
586                            <option value="5cm"    >5cm (5.9-6.8 GHz)</option>     
587                            <option value="3cm"    >3cm (8.1-8.6 GHz)</option>     
588                            <option value="1.3cm"  >1.3cm (21.-24. GHz)</option>     
589          </select>
590     </fieldset>
591
592       </fieldset>
593        </td></tr>
594        <tr><td>
595                <fieldset>
596                    <legend>ORDER RESULTS BY</legend>
597                            <table cellspacing="0px" cellpadding="0px" style="border: 0px;">
598                            <tr><td>
599                      <select name="orderBy" id="OrderByList">
600                            <option selected value="distance">Distance
601                            <option value="date">Date
602                            <option value="obsfreq">Frequency
603                            <option value="filename">Filename
604                      </select>
605                            </td><td>
606                            &nbsp;<input type="radio" name="orderDir" id="orderDirectionSel" checked value="asc">Ascending
607                            <br>
608                            &nbsp;<input type="radio" name="orderDir" id="orderDirectionSel" value="desc">Descending
609                            </td></tr>
610                            </table>
611                    <br>
612                </fieldset>
613        </td></tr>
614        <tr><td>
615                <fieldset>
616                    <legend>DISPLAY OTHER DATA</legend>
617                               
618                    <input type="checkbox" name="cals" value="cals" id="cals" checked="true" />
619                                Display Cals taken within
620                    <input type="text" name="cals_within_mins" value="30" maxlength="5" size="3"/>
621                                mins of Observations
622                    <br>
623                                               
624                </fieldset>
625        </td></tr>
626        </table>
627        <br>
628        </td>
629        </tr>   
630</table>
631
632
633</form>
634<div style="min-height: 20px; max-height: 1000px;"> </div>
635<?php
636   include "footer.html";
637}?>
638
639</body>
640
641</html>
642
643
644<?php //////////// Function definitions ///////////////
645
646
647// Initialise the input form variables. If the "New query" button is clicked
648// no argument is passed to init(), hence the need for a default NULL value
649// because there is no need for updating user access statistics
650function init($link=NULL) {
651
652        if ($link) {
653                // Update the users table
654                updateUsersTable($link);
655        }
656       
657        unset($_SESSION['cals']); // The result set of cals
658        unset($_SESSION['obs']); // The result set of observations
659        //unset($_SESSION['cart_items']); // The result set of observations
660}
661
662mysql_close($link);
663
664?>
Note: See TracBrowser for help on using the repository browser.