[163] | 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" /> |
---|
[170] | 25 | <link rel="stylesheet" type="text/css" href="styles/atnf.css" /> |
---|
[163] | 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"><!-- |
---|
| 38 | function 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 | |
---|
| 47 | function 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 | |
---|
| 66 | function 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 | |
---|
| 83 | include_once("constants.php"); |
---|
| 84 | include_once("security.php"); |
---|
| 85 | include_once("database.php"); |
---|
| 86 | include_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 |
---|
| 127 | mysql_free_result($result); |
---|
| 128 | |
---|
| 129 | // Clear any old form inputs in session cache |
---|
| 130 | init($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(); |
---|
| 140 | if (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 | |
---|
| 157 | if (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 |
---|
| 165 | if (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 |
---|
| 177 | if (!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 | } |
---|
| 182 | else { |
---|
| 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 |
---|
| 202 | if ($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 | <table class="noborder"> |
---|
| 237 | <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> |
---|
| 238 | </tr> |
---|
| 239 | </table> |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | <form action="query.php" method="GET" name="data_archive_form" id="data_archive_form"> |
---|
| 243 | <input type="hidden" name="state" value="results"> |
---|
| 244 | |
---|
| 245 | <table class="noborder"> |
---|
| 246 | |
---|
| 247 | <tr> |
---|
| 248 | |
---|
| 249 | <td valign="top" class="form_field" rowspan="2"> |
---|
| 250 | |
---|
| 251 | <fieldset> |
---|
| 252 | <legend>Display Parameters</legend> |
---|
| 253 | <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> |
---|
| 254 | <font size="-1"><a href="javascript:togglecomments('params', 'toggler1')" id="toggler1">Show all >></a></font><br> |
---|
| 255 | <span class="commenthidden" id="params"> |
---|
| 256 | <div id="list"> |
---|
| 257 | <?php |
---|
| 258 | // Special case for ra and dec |
---|
| 259 | $raj_count = 0; |
---|
| 260 | $decj_count = 0; |
---|
| 261 | $raj_field = ""; |
---|
| 262 | $decj_field = ""; |
---|
| 263 | |
---|
| 264 | foreach ($fields as $field) { |
---|
| 265 | // if (ereg("raj_.+", $field['Field'] )) { |
---|
| 266 | // $raj_field .= "," . $field['Field']; |
---|
| 267 | // $raj_count++; |
---|
| 268 | // if ($raj_count == 3) { |
---|
| 269 | // $raj_field = trim($raj_field, " ,"); |
---|
| 270 | // echo "<input onClick=\"updateSelectAll('ra', |
---|
| 271 | // '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$raj_field\" id=\"RA\" checked=\"true\">RA<br>\n"; |
---|
| 272 | // } |
---|
| 273 | // } |
---|
| 274 | // else if (ereg("decj_.+", $field['Field'] ) ){ |
---|
| 275 | // $decj_field .= "," . $field['Field']; |
---|
| 276 | // $decj_count++; |
---|
| 277 | // if ($decj_count == 3) { |
---|
| 278 | // $decj_field = trim($decj_field, " ,"); |
---|
| 279 | // echo "<input onClick=\"updateSelectAll('dec', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"$decj_field\" id=\"dec\" checked=\"true\">DecJ<br>\n"; |
---|
| 280 | // } |
---|
| 281 | // } |
---|
| 282 | // else { |
---|
| 283 | echo "<input |
---|
| 284 | onClick=\"updateSelectAll('".$field['Field']."', '$all_params_id')\" type=\"checkbox\" name=\"params[]\" value=\"".$field['Field']."\" id=\"".$field['Field']."\" checked=\"true\">".$field['Field']."<br>\n"; |
---|
| 285 | // } |
---|
| 286 | } |
---|
| 287 | ?> |
---|
| 288 | </div> |
---|
| 289 | </span> |
---|
| 290 | </fieldset> |
---|
| 291 | <fieldset> |
---|
| 292 | <legend>Display Other</legend> |
---|
| 293 | |
---|
| 294 | <input type="checkbox" name="cals" value="cals" id="cals" checked="true" />Cals within |
---|
| 295 | <input type="text" name="cals_within_mins" value="30" maxlength="5" size="3"/> mins of obs |
---|
| 296 | <br> |
---|
| 297 | |
---|
| 298 | </fieldset> |
---|
| 299 | </td> |
---|
| 300 | |
---|
| 301 | <td class="form_field" height="10%"> |
---|
| 302 | <!-- Filter Options --> |
---|
| 303 | <fieldset id="flsPosition"> |
---|
| 304 | |
---|
| 305 | <legend>Filter Options</legend> |
---|
| 306 | |
---|
[164] | 307 | <!-- Obs Mode --> |
---|
[163] | 308 | <fieldset> |
---|
[164] | 309 | <legend>Obs Mode</legend> |
---|
[163] | 310 | |
---|
[164] | 311 | <select name="obs_mode" onchange="ObsModeChanged()" id="ObsModeList"> |
---|
| 312 | <option value="any"> Any </option> |
---|
| 313 | <option value="timing"> Just timing </option> |
---|
| 314 | <option value="search"> Just search </option> |
---|
[163] | 315 | </select> |
---|
| 316 | |
---|
| 317 | </fieldset> |
---|
| 318 | |
---|
| 319 | <!-- Pulsar Name --> |
---|
| 320 | <fieldset> |
---|
| 321 | <legend>Pulsar Name</legend> |
---|
| 322 | |
---|
| 323 | <input type="text" name="pulsar_name" size="10"> |
---|
| 324 | |
---|
| 325 | </fieldset> |
---|
| 326 | |
---|
| 327 | <!-- Data Type --> |
---|
| 328 | <fieldset> |
---|
| 329 | <legend>Data Type</legend> |
---|
| 330 | |
---|
| 331 | <select name="data_type"> |
---|
| 332 | <option value="" selected> Any |
---|
| 333 | <?php |
---|
| 334 | foreach ($data_types as $data_type) { |
---|
| 335 | echo " |
---|
| 336 | <option value=\"$data_type\"> $data_type"; |
---|
| 337 | } |
---|
| 338 | ?> |
---|
| 339 | </select> |
---|
| 340 | |
---|
| 341 | </fieldset> |
---|
| 342 | |
---|
| 343 | <!-- Date range --> |
---|
| 344 | <fieldset> |
---|
| 345 | <legend>Date Range</legend> |
---|
| 346 | |
---|
| 347 | <select name="from_day"> |
---|
| 348 | <?php |
---|
| 349 | for ($i = 1; $i <= 31; $i++) { |
---|
| 350 | echo "\t\t\t<option"; |
---|
| 351 | if ($i == $min_cal_assoc['day']) { |
---|
| 352 | echo " selected"; |
---|
| 353 | } |
---|
| 354 | echo " value=\"$i\">$i</option>\n"; |
---|
| 355 | } |
---|
| 356 | ?> |
---|
| 357 | </select> |
---|
| 358 | <select name="from_month"> |
---|
| 359 | <?php |
---|
| 360 | for ($i = 1; $i <= 12; $i++) { |
---|
| 361 | echo "\t\t\t<option"; |
---|
| 362 | if ($i == $min_cal_assoc['month']) { |
---|
| 363 | echo " selected"; |
---|
| 364 | } |
---|
| 365 | echo " value=\"$i\">$i</option>\n"; |
---|
| 366 | } |
---|
| 367 | ?> |
---|
| 368 | </select> |
---|
| 369 | <input type="text" size="4" name="from_year" value="<?php echo $min_cal_assoc['year']; ?>"> |
---|
| 370 | <?php echo "<font size=\"-1\" color=\"red\">$date_error</font>" ?> |
---|
| 371 | <br>to<br> |
---|
| 372 | <select name="to_day"> |
---|
| 373 | <?php |
---|
| 374 | for ($i = 1; $i <= 31; $i++) { |
---|
| 375 | echo "\t\t\t<option"; |
---|
| 376 | if ($i == $max_cal_assoc['day']) { |
---|
| 377 | echo " selected"; |
---|
| 378 | } |
---|
| 379 | echo " value=\"$i\">$i</option>\n"; |
---|
| 380 | } |
---|
| 381 | ?> |
---|
| 382 | </select> |
---|
| 383 | <select name="to_month"> |
---|
| 384 | <?php |
---|
| 385 | for ($i = 1; $i <= 12; $i++) { |
---|
| 386 | echo "\t\t\t<option"; |
---|
| 387 | if ($i == $max_cal_assoc['month']) { |
---|
| 388 | echo " selected"; |
---|
| 389 | } |
---|
| 390 | echo " value=\"$i\">$i</option>\n"; |
---|
| 391 | } |
---|
| 392 | ?> |
---|
| 393 | </select> |
---|
| 394 | <input type="text" size="4" name="to_year" value="<?php echo $max_cal_assoc['year']; ?>"> |
---|
| 395 | </fieldset> |
---|
| 396 | |
---|
| 397 | |
---|
| 398 | <!-- Coordinates --> |
---|
| 399 | <fieldset> |
---|
| 400 | <legend>Coordinates</legend> |
---|
| 401 | |
---|
| 402 | RAJ: <input type="text" name="raj" size="10"> |
---|
| 403 | DecJ: <input type="text" name="decj" size="10"> |
---|
| 404 | Search radius (degs): <input type="text" name="radius" size="10"> |
---|
| 405 | |
---|
| 406 | |
---|
| 407 | </fieldset> |
---|
| 408 | |
---|
| 409 | </fieldset> |
---|
| 410 | <br> |
---|
| 411 | <input type="submit" value="submit" name="submit_button"> |
---|
| 412 | </td> |
---|
| 413 | </tr> |
---|
| 414 | </table> |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | </form> |
---|
[170] | 418 | <?php } |
---|
| 419 | include "footer.html"; |
---|
| 420 | |
---|
| 421 | ?> |
---|
[163] | 422 | |
---|
| 423 | </body> |
---|
| 424 | |
---|
| 425 | </html> |
---|
| 426 | |
---|
| 427 | |
---|
| 428 | <?php //////////// Function definitions /////////////// |
---|
| 429 | |
---|
| 430 | |
---|
| 431 | // Initialise the input form variables. If the "New query" button is clicked |
---|
| 432 | // no argument is passed to init(), hence the need for a default NULL value |
---|
| 433 | // because there is no need for updating user access statistics |
---|
| 434 | function init($link=NULL) { |
---|
| 435 | |
---|
| 436 | if ($link) { |
---|
| 437 | // Update the users table |
---|
| 438 | updateUsersTable($link); |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | unset($_SESSION['cals']); // The result set of cals |
---|
| 442 | unset($_SESSION['obs']); // The result set of observations |
---|
| 443 | //unset($_SESSION['cart_items']); // The result set of observations |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | mysql_close($link); |
---|
| 447 | |
---|
| 448 | ?> |
---|