source: trunk/htdocs/index.php @ 185

Last change on this file since 185 was 185, checked in by DavidSmith, 17 years ago

makes the expandable usage panel work.

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