source: trunk/htdocs/index.php @ 183

Last change on this file since 183 was 183, checked in by MatthewWhiting, 17 years ago

Fixed up the cal query statements by using the full pathname rather than the file_id column.

File size: 14.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.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/process.js"></script>
235   
236    <h1> Pulsar Archive Project </h1>
237
238    <p>The pulsar archive provides data from historical observations .... </p>
239   
240    <table width="700">
241    <tr align="center">
242    <td>
243    <a class="top_menu" href="<?php echo $PHP_SELF; ?>?command=logout">Logout</a>
244    <!--a href="login?_action=logout">Logout</a-->
245
246    </td>
247        <td>
248        <a class="top_menu" href="change_password.html?prev_page=<?php echo urlencode("index.html"); ?>">Change Password</a>
249        </td>
250        <td size="30">
251        &nbsp;
252    </td>
253        <td>
254        <div id="divUsageToggle"></div>
255        </td>
256        <td size="30">
257        &nbsp;
258    </td>
259        <td>
260        <a href="pulsar_archive_guide.html">Users Guide</a>
261        </td>
262        </tr>
263
264        </table>
265
266        <div id="divUsage">
267
268        <h2>Instructions</h2>
269       
270        <dl class="top">
271        <dt>Project codes</dt>
272        <dd>Enter one or more project codes to match on. Multiple project codes may be separated by spaces, commas or semicolons.</dd>
273               
274        <dt>Wild card searches</dt>
275
276        <dd>Wild cards may be used with source name and surname. Both UNIX glob and SQL wildcards are permitted. <br />
277        <dl>
278        <dt>Single character</dt>
279        <dd>underscore (_) or question mark (?)</dd>
280                               
281        <dt>Multiple characters</dt>
282        <dd>percent (%) or asterisk (*)</dd>
283
284        </dl>
285        </dd>
286               
287        <dt>Band names</dt>
288        <dd>Multiple band names may be selected. This is usually performed by holding the control key
289        while clicking. The search will return files containing scans at <em>any</em> of the bands indicated.</dd>
290               
291        <dt>Minimum criteria</dt>
292                <dd>A value must be provided for at least one of:
293        <ul>
294
295        <li>Project Code</li>
296        <li>Date From</li>
297        <li>Date To</li>
298        <li>Surname</li>
299        <li>Source Name</li>
300        <li>Source Position</li>
301
302        </ul>
303        </dd>
304               
305        <dt>Form submission</dt>
306        <dd>To perform your query click on the find button or hit enter in any of the fields</dd>
307               
308        </dl>
309       
310        </div>
311
312
313<!--<table class="noborder">
314<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>
315</tr>
316</table>-->
317
318
319<form action="query.php" method="GET" name="data_archive_form" id="data_archive_form">
320<input type="hidden" name="state" value="results">
321
322<table class="noborder">
323
324        <tr>
325       
326        <td valign="top" class="form_field" rowspan="2">
327       
328        <fieldset>
329                <legend>Display Parameters</legend>
330                <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>
331                        <font size="-1"><a href="javascript:togglecomments('params', 'toggler1')" id="toggler1">Show all >></a></font><br>
332                        <span class="commenthidden" id="params">
333                        <div id="list">
334                                <?php
335                                // Special case for ra and dec
336                                $raj_count = 0;
337                                $decj_count = 0;
338                                $raj_field = "";
339                                $decj_field = "";
340                               
341                                $def_fields = Array( "filename", "src_name", "project_id", "raj", "decj",
342                                                     "data_type", "obsfreq", "bw", "scanlen", "date", "ut" );
343
344                                foreach ($fields as $field) {
345//                                      if (ereg("raj_.+", $field['Field'] )) {
346//                                              $raj_field .= "," . $field['Field'];
347//                                              $raj_count++;
348//                                              if ($raj_count == 3) {
349//                                                      $raj_field = trim($raj_field, " ,");
350//                                                      echo "<input onClick=\"updateSelectAll('ra',
351// '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$raj_field\" id=\"RA\" checked=\"true\">RA<br>\n";
352//                                              }
353//                                      }
354//                                      else if (ereg("decj_.+", $field['Field'] ) ){
355//                                              $decj_field .= "," . $field['Field'];
356//                                              $decj_count++;
357//                                              if ($decj_count == 3) {
358//                                                      $decj_field = trim($decj_field, " ,");
359//                                                      echo "<input onClick=\"updateSelectAll('dec', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$decj_field\" id=\"dec\" checked=\"true\">DecJ<br>\n";
360//                                              }
361//                                      }
362//                                      else {
363                                                echo "<input
364onClick=\"updateSelectAll('".$field['Field']."', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"".$field['Field']."\" id=\"".$field['Field']."\"";
365                                                if( in_array( $field['Field'], $def_fields ) )
366                                                  echo ' checked="true"';
367                                                echo " >".$field['Field']."<br>\n";
368//                                      }
369                                }
370                                ?>
371                        </div>
372                        </span>
373        </fieldset>
374                        <fieldset>
375                        <legend>Display Other</legend>
376                               
377                                <input type="checkbox" name="cals" value="cals" id="cals" checked="true" />Cals within
378                                <input type="text" name="cals_within_mins" value="30" maxlength="5" size="3"/> mins of obs
379                                <br>
380                                               
381                        </fieldset>                     
382        </td>
383
384        <td class="form_field" height="10%">
385        <!-- Filter Options -->
386        <fieldset id="flsPosition">
387                               
388                <legend>Filter Options</legend>
389
390                <!-- Obs Mode -->
391                <fieldset>
392                        <legend>Obs Mode</legend>
393
394                        <select name="obs_mode" onchange="ObsModeChanged()" id="ObsModeList">
395                                <option value="any"> Any </option>
396                                <option value="timing"> Just timing </option>
397                                <option value="search"> Just search </option>
398                        </select>
399
400                </fieldset>
401
402                <!-- Pulsar Name -->
403                <fieldset>
404                        <legend>Pulsar Name</legend>
405
406                        <input type="text" name="pulsar_name" size="10">
407
408                </fieldset>     
409
410                <!-- Data Type -->
411                <fieldset>
412                        <legend>Data Type</legend>
413
414                        <select name="data_type">
415                                <option value="" selected> Any
416                                <?php
417                                foreach ($data_types as $data_type) {
418                                        echo "
419                                        <option value=\"$data_type\"> $data_type";
420                                }
421                                ?>
422                        </select>
423
424                </fieldset>     
425
426                <!-- Date range -->
427                <fieldset>
428                        <legend>Date Range</legend>
429                       
430                        <select name="from_day">
431                                <?php
432                                        for ($i = 1; $i <= 31; $i++) {
433                                                echo "\t\t\t<option";
434                                                if ($i == $min_cal_assoc['day']) {
435                                                        echo " selected";
436                                                }
437                                                echo " value=\"$i\">$i</option>\n";
438                                        }
439                                ?>
440                        </select>
441                        <select name="from_month">
442                                <?php
443                                        for ($i = 1; $i <= 12; $i++) {
444                                                echo "\t\t\t<option";
445                                                if ($i == $min_cal_assoc['month']) {
446                                                        echo " selected";
447                                                }
448                                                echo " value=\"$i\">$i</option>\n";
449                                        }
450                                ?>
451                        </select>
452                        <input type="text" size="4" name="from_year" value="<?php echo $min_cal_assoc['year']; ?>">
453                        <?php echo "<font size=\"-1\" color=\"red\">$date_error</font>" ?>
454                        <br>to<br>
455                        <select name="to_day">
456                                <?php
457                                        for ($i = 1; $i <= 31; $i++) {
458                                                echo "\t\t\t<option";
459                                                if ($i == $max_cal_assoc['day']) {
460                                                        echo " selected";
461                                                }
462                                                echo " value=\"$i\">$i</option>\n";
463                                        }
464                                ?>
465                        </select>
466                        <select name="to_month">
467                                <?php
468                                        for ($i = 1; $i <= 12; $i++) {
469                                                echo "\t\t\t<option";
470                                                if ($i == $max_cal_assoc['month']) {
471                                                        echo " selected";
472                                                }
473                                                echo " value=\"$i\">$i</option>\n";
474                                        }
475                                ?>
476                        </select>
477                        <input type="text" size="4" name="to_year" value="<?php echo $max_cal_assoc['year']; ?>">
478                </fieldset>
479
480                </td></tr><tr><td>
481                <!-- Coordinates -->
482                <fieldset>
483                        <legend>Coordinates</legend>
484
485                        RAJ: <input type="text" name="raj" size="10">
486                        DecJ: <input type="text" name="decj" size="10">
487                        Search radius (degs): <input type="text" name="radius" size="10">
488
489
490                </fieldset>     
491
492        </fieldset>
493        <br>
494        <input type="submit" value="submit" name="submit_button">
495        </td>
496        </tr>   
497</table>
498
499
500</form>
501<?php
502   include "footer.html";
503}?>
504
505</body>
506
507</html>
508
509
510<?php //////////// Function definitions ///////////////
511
512
513// Initialise the input form variables. If the "New query" button is clicked
514// no argument is passed to init(), hence the need for a default NULL value
515// because there is no need for updating user access statistics
516function init($link=NULL) {
517
518        if ($link) {
519                // Update the users table
520                updateUsersTable($link);
521        }
522       
523        unset($_SESSION['cals']); // The result set of cals
524        unset($_SESSION['obs']); // The result set of observations
525        //unset($_SESSION['cart_items']); // The result set of observations
526}
527
528mysql_close($link);
529
530?>
Note: See TracBrowser for help on using the repository browser.