Index: /trunk/htdocs/conesearch.php
===================================================================
--- /trunk/htdocs/conesearch.php	(revision 211)
+++ /trunk/htdocs/conesearch.php	(revision 212)
@@ -17,12 +17,22 @@
 // Need to enclose the following in a <?php structure else having the <?xml will confuse things
 //
-echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-?> 
-<!DOCTYPE VOTABLE SYSTEM "http://us-vo.org/xml/VOTable.dtd">
-<VOTABLE version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/VOTable/v1.1">
-<?php
 include_once("database.php");
 include_once("utils.php");
 include_once("xmlFunctions.php");
+include_once("constants.php");
+
+echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+echo "<!DOCTYPE VOTABLE SYSTEM \"http://us-vo.org/xml/VOTable.dtd\">\n";
+echo "<VOTABLE version=\"1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.ivoa.net/xml/VOTable/VOTable/v1.1\">\n";
+
+echo "  <DESCRIPTION>\n";
+echo "     ATNF Pulsar Data Archive conesearch service.\n";
+echo "     The Archive holds data files from observations of pulsars made with the Parkes radio telescope.\n";
+echo "     This service provides information on what data files exist in the archive within the required cone search area.\n";
+echo "     Note that this service can only see non-proprietry data, which are more than ".PROPRIETRY_PERIOD_YR." years old.\n";
+echo "     To obtain the data, go to ".WEB_ARCHIVE_URL."\n";
+echo "     Usage: Provide three parameters: RA (right ascension), DEC (declination), SR (search radius) \n";
+echo "            All values in decimal degrees\n";
+echo "  </DESCRIPTION>\n";
 
 $raj_degs         = trim(get_param('RA', $HTTP_GET_VARS));
@@ -84,28 +94,12 @@
 // Else, continue!
 
-echo "<DESCRIPTION>\n";
-echo "ATNF Pulsar Archive: Conesearch Query\n";
-echo "</DESCRIPTION>\n";
-echo "<COOSYS ID=\"J2000\" equinox=\"J2000.\" epoch=\"J2000.\" system=\"eq_FK5\"/>\n";
-echo "<RESOURCE type=\"conesearch results\">\n";
-printf("<PARAM ID=\"RA\" name=\"RA\" datatype=\"float\" unit=\"degrees\" value=\"%10.6f\"></PARAM>\n",$raj_degs);
-printf("<PARAM ID=\"DEC\" name=\"DEC\" datatype=\"float\" unit=\"degrees\" value=\"%+11.6f\"></PARAM>\n",$decj_degs);
-printf("<PARAM ID=\"SR\" name=\"SR\" datatype=\"float\" unit=\"degrees\" value=\"%10.6f\"></PARAM>\n",$radius);
-
-
-///////////////////////////////////////////////////////////////////////////
-//  CONNECT TO THE MYSQL DATABASE AND STORE THE S70 DATA.
-//  THIS IS A TEMPORARY MEASURE -- IDEALLY THE DATA WILL BE IN PLACE 
-//   BEFOREHAND.
-//
+echo "  <COOSYS ID=\"J2000\" equinox=\"J2000.\" epoch=\"J2000.\" system=\"eq_FK5\"/>\n";
+echo "  <RESOURCE type=\"conesearch results\">\n";
+printf("  <PARAM ID=\"RA\" name=\"RA\" datatype=\"float\" unit=\"degrees\" value=\"%10.6f\"></PARAM>\n",$raj_degs);
+printf("  <PARAM ID=\"DEC\" name=\"DEC\" datatype=\"float\" unit=\"degrees\" value=\"%+11.6f\"></PARAM>\n",$decj_degs);
+printf("  <PARAM ID=\"SR\" name=\"SR\" datatype=\"float\" unit=\"degrees\" value=\"%10.6f\"></PARAM>\n",$radius);
 
 //$link = db_connect_admin();
 $link = db_connect();
-
-//loadS70();
-//loadNewTables();
-
-///////////////////////////////////////////////////////////////////////////
-	
 
 
@@ -123,5 +117,5 @@
 }
 
-echo "<TABLE>\n";
+echo "  <TABLE>\n";
 print_column_headers_VO($result);
 
@@ -140,8 +134,14 @@
 }
 
+// Limit search to non-proprietry data, ie. > 2years old. 
+//  Do this based on the MJD of the data file.
+$today_mjd = cal_to_jd ( CAL_GREGORIAN, date("n"), date("j"), date("Y") ) - 2400000.5;
+$max_mjd = $today_mjd - PROPRIETRY_PERIOD_DAY;
+$whereString .= "AND MJD < $max_mjd";
+
 // Remove any leading or trailing AND and OR
 $whereString = trim($whereString, " AND OR");
 
-$query = "(SELECT *,$angsep_str as angsep FROM ".S70_TABLE." WHERE $whereString) UNION (SELECT *,$angsep_str as angsep FROM ".OBSERVATION_TABLE". WHERE $whereString) ORDER BY angsep";
+$query = "(SELECT *,$angsep_str as angsep FROM ".S70_TABLE." WHERE $whereString) UNION (SELECT *,$angsep_str as angsep FROM ".OBSERVATIONS_TABLE." WHERE $whereString) ORDER BY angsep";
 
 $result = mysql_query($query) or die('Conesearch Query failed: ' . mysql_error());
@@ -163,7 +163,7 @@
 print_data_VO($all_results);
 
-echo "</TABLE>\n";
-echo"</RESOURCE>\n";
-echo"</VOTABLE>\n";
+echo "  </TABLE>\n";
+echo "</RESOURCE>\n";
+echo "</VOTABLE>\n";
 
 ?>
Index: /trunk/htdocs/constants.php
===================================================================
--- /trunk/htdocs/constants.php	(revision 211)
+++ /trunk/htdocs/constants.php	(revision 212)
@@ -55,4 +55,9 @@
 define('NBEAM', 'nbeam');
 
+// Proprietry data period
+define('PROPRIETRY_PERIOD_YR', 2);
+define('PROPRIETRY_PERIOD_DAY', PROPRIETRY_PERIOD_YR * 365.25);
+define('PROPRIETRY_PERIOD_MONTH', PROPRIETRY_PERIOD_YR * 12);
+
 ////////////////////
 // Locations
@@ -60,4 +65,5 @@
 ////
 
+define('WEB_ARCHIVE_URL', "http://pulsararchive-int.atnf.csiro.au");
 define('DATA_ARCH_DIR', "/var/www/vhosts/pulsararchive.atnf.csiro.au/htdocs");
 define("FIX_LD_LIB","LD_LIBRARY_PATH=/pulsar/psr/packages/linux/qt/lib:/pulsar/psr/packages/linux/pgplot:/usr/local/lib ");
Index: /trunk/htdocs/query.php
===================================================================
--- /trunk/htdocs/query.php	(revision 211)
+++ /trunk/htdocs/query.php	(revision 212)
@@ -341,5 +341,5 @@
 
     $today_mjd = cal_to_jd ( CAL_GREGORIAN, date("n"), date("j"), date("Y") ) - 2400000.5;
-    $max_mjd = $today_mjd - 730;
+    $max_mjd = $today_mjd - PROPRIETRY_PERIOD_DAY;
     $max_date = cal_from_jd($max_mjd+2400000.5, CAL_GREGORIAN);
 
Index: /trunk/htdocs/testlogin.php
===================================================================
--- /trunk/htdocs/testlogin.php	(revision 211)
+++ /trunk/htdocs/testlogin.php	(revision 212)
@@ -99,5 +99,6 @@
 
 <p>The ATNF Pulsar Data Archive provides access to pulsar observations
-made with the Parkes radio Telescope. Data older than 24 months is
+made with the Parkes radio Telescope. Data older than 
+<?php echo PROPRIETRY_PERIOD_MONTH ?> months is
 publicly available, and can be accessed by simply providing your email
 address. More recent data is proprietry, and can only be accessed by
Index: /trunk/htdocs/xmlFunctions.php
===================================================================
--- /trunk/htdocs/xmlFunctions.php	(revision 211)
+++ /trunk/htdocs/xmlFunctions.php	(revision 212)
@@ -11,54 +11,54 @@
   /// PRINT VOTABLE HEADERS (<FIELD>) FOR EACH OF THE COLUMNS TO BE INCLUDED
 
-  echo "<FIELD name=\"Filename\" ID=\"col1\" ucd=\"meta.id;meta.main\" datatype=\"char\" arraysize=\"30\">\n";
-  echo " <DESCRIPTION>\n  This is the name of the PSRFITS file at this position.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Filename\" ID=\"col1\" ucd=\"meta.id;meta.main\" datatype=\"char\" arraysize=\"30\">\n";
+  echo "   <DESCRIPTION>\n    This is the name of the PSRFITS file at this position.\n   </DESCRIPTION>\n  </FIELD>\n";
 
-  echo "<FIELD name=\"Distance\" ID=\"col2\" ucd=\"pos.angDistance\" datatype=\"double\" width=\"10\" precision=\"4\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n The angular separation from the queried position.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Distance\" ID=\"col2\" ucd=\"pos.angDistance\" datatype=\"double\" width=\"10\" precision=\"4\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n   The angular separation from the queried position.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Target Name\" ID=\"col3\" ucd=\"obs.field;meta.id\" datatype=\"char\" arraysize=\"20\">\n";
-  echo " <DESCRIPTION>\n  This is the name of the PSRFITS file at this position.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Target Name\" ID=\"col3\" ucd=\"obs.field;meta.id\" datatype=\"char\" arraysize=\"20\">\n";
+  echo "   <DESCRIPTION>\n    This is the name of the PSRFITS file at this position.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Survey\" ID=\"col4\" ucd=\"obs;meta.dataset;meta.id\" datatype=\"char\" arraysize=\"10\">\n";
-  echo " <DESCRIPTION>\n  The short code for the survey type: PKS70=70cm Parkes Southern Pulsar Survey; PM=Parkes Multibeam Pulsar Survey, PH=Parkes High-Latitude Pulsar Survey; blank means not part of a survey or unknown.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Survey\" ID=\"col4\" ucd=\"obs;meta.dataset;meta.id\" datatype=\"char\" arraysize=\"10\">\n";
+  echo "   <DESCRIPTION>\n    The short code for the survey type: PKS70=70cm Parkes Southern Pulsar Survey; PM=Parkes Multibeam Pulsar Survey, PH=Parkes High-Latitude Pulsar Survey; blank means not part of a survey or unknown.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"RA\" ID=\"col5\" ucd=\"pos.eq.ra;meta.main\" ref=\"J2000\" datatype=\"double\" width=\"10\" precision=\"6\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n  The Right Ascension of the central position of the pointing.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"RA\" ID=\"col5\" ucd=\"pos.eq.ra;meta.main\" ref=\"J2000\" datatype=\"double\" width=\"10\" precision=\"6\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n    The Right Ascension of the central position of the pointing.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"DEC\" ID=\"col6\" ucd=\"pos.eq.dec;meta.main\" ref=\"J2000\" datatype=\"double\" width=\"11\" precision=\"6\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n  The Declination of the central position of the pointing.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"DEC\" ID=\"col6\" ucd=\"pos.eq.dec;meta.main\" ref=\"J2000\" datatype=\"double\" width=\"11\" precision=\"6\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n    The Declination of the central position of the pointing.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"BMAJ\" ID=\"col7\" ucd=\"pos.angResolution;phys.angSize.smajAxis\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n  The full-width-half-maximum (FWHM) of the major-axis of the beam.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"BMAJ\" ID=\"col7\" ucd=\"pos.angResolution;phys.angSize.smajAxis\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n    The full-width-half-maximum (FWHM) of the major-axis of the beam.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"BMIN\" ID=\"col8\" ucd=\"pos.angResolution;phys.angSize.sminAxis\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n  The full-width-half-maximum (FWHM) of the minor-axis of the beam.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"BMIN\" ID=\"col8\" ucd=\"pos.angResolution;phys.angSize.sminAxis\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n    The full-width-half-maximum (FWHM) of the minor-axis of the beam.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"BPA\" ID=\"col9\" ucd=\"pos.angResolution;pos.posAng\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
-  echo " <DESCRIPTION>\n  The position angle of the beam.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"BPA\" ID=\"col9\" ucd=\"pos.angResolution;pos.posAng\" datatype=\"float\" width=\"6\" precision=\"4\" unit=\"deg\">\n";
+  echo "   <DESCRIPTION>\n    The position angle of the beam.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"UT Date of Observations\" ID=\"col10\" ucd=\"time.start\" datatype=\"char\" arraysize=\"30\">\n";
-  echo " <DESCRIPTION>\n  The UT Date of the start of the observation.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"UT Date of Observations\" ID=\"col10\" ucd=\"time.start\" datatype=\"char\" arraysize=\"30\">\n";
+  echo "   <DESCRIPTION>\n    The UT Date of the start of the observation.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"UT Time of Observations\" ID=\"col11\" ucd=\"time.start\" datatype=\"char\" arraysize=\"30\">\n";
-  echo " <DESCRIPTION>\n  The UT Time of the start of the observation.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"UT Time of Observations\" ID=\"col11\" ucd=\"time.start\" datatype=\"char\" arraysize=\"30\">\n";
+  echo "   <DESCRIPTION>\n    The UT Time of the start of the observation.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"MJD\" ID=\"col12\" ucd=\"time.start\" datatype=\"double\" width=\"14\" precision=\"8\">\n";
-  echo " <DESCRIPTION>\n  The Modified Julian Date of the observation.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"MJD\" ID=\"col12\" ucd=\"time.start\" datatype=\"double\" width=\"14\" precision=\"8\">\n";
+  echo "   <DESCRIPTION>\n    The Modified Julian Date of the observation.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"ObsFreq\" ID=\"col13\" ucd=\"em.freq.central\" datatype=\"double\" width=\"9\" precision=\"4\" unit=\"MHz\">\n";
-  echo " <DESCRIPTION>\n  The central observing frequency.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"ObsFreq\" ID=\"col13\" ucd=\"em.freq.central\" datatype=\"double\" width=\"9\" precision=\"4\" unit=\"MHz\">\n";
+  echo "   <DESCRIPTION>\n    The central observing frequency.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Channel Bandwidth\" ID=\"col14\" ucd=\"spect.binSize;em.freq\" datatype=\"double\" width=\"9\" precision=\"4\" unit=\"MHz\">\n";
-  echo " <DESCRIPTION>\n  The frequency width of each channel.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Channel Bandwidth\" ID=\"col14\" ucd=\"spect.binSize;em.freq\" datatype=\"double\" width=\"9\" precision=\"4\" unit=\"MHz\">\n";
+  echo "   <DESCRIPTION>\n    The frequency width of each channel.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Number of Channels\" ID=\"col15\" ucd=\"em.bin;meta.number\" datatype=\"int\" width=\"6\">\n";
-  echo " <DESCRIPTION>\n  The number of frequency channels.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Number of Channels\" ID=\"col15\" ucd=\"em.bin;meta.number\" datatype=\"int\" width=\"6\">\n";
+  echo "   <DESCRIPTION>\n    The number of frequency channels.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Scan length\" ID=\"col16\" ucd=\"obs.exposure;time.duration\" datatype=\"float\" width=\"9\" precision=\"4\" unit=\"s\">\n";
-  echo " <DESCRIPTION>\n  The total length of time taken for this observation.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Scan length\" ID=\"col16\" ucd=\"obs.exposure;time.duration\" datatype=\"float\" width=\"9\" precision=\"4\" unit=\"s\">\n";
+  echo "   <DESCRIPTION>\n    The total length of time taken for this observation.\n   </DESCRIPTION>\n  </FIELD>\n";
   
-  echo "<FIELD name=\"Sample time\" ID=\"col17\" ucd=\"time.resolution\" datatype=\"float\" width=\"9\" precision=\"4\" unit=\"s\">\n";
-  echo " <DESCRIPTION>\n  The time for each sample in the observation.\n </DESCRIPTION>\n</FIELD>\n";
+  echo "  <FIELD name=\"Sample time\" ID=\"col17\" ucd=\"time.resolution\" datatype=\"float\" width=\"9\" precision=\"4\" unit=\"s\">\n";
+  echo "   <DESCRIPTION>\n    The time for each sample in the observation.\n   </DESCRIPTION>\n  </FIELD>\n";
    
 }
@@ -66,10 +66,10 @@
 function print_data_VO($all_results) {
   
-  echo "<DATA>\n<TABLEDATA>\n";
+  echo "  <DATA>\n   <TABLEDATA>\n";
   for ($i=0; $i < count($all_results); $i++) {
     $line = $all_results[$i];
     print_data_line_VO($line);
   }
-  echo "</TABLEDATA>\n</DATA>\n";
+  echo "   </TABLEDATA>\n  </DATA>\n";
 
 }
@@ -77,23 +77,33 @@
 function print_data_line_VO($line) {
   // PRINT A SINGLE ROW OF DATA TO THE VOTABLE
-  echo "<TR>\n ";
-  printf("<TD>%s</TD>",$line['filename']);
-  printf("<TD>%8.6f</TD>",$line['angsep']);
-  printf("<TD>%s</TD>",$line['src_name']);
-  printf("<TD>%s</TD>",$line['survey']);
-  printf("<TD>%10.6f</TD>",$line['rajd']);
-  printf("<TD>%+11.6f</TD>",$line['decjd']);
-  printf("<TD>%6.4f</TD>",$line['bmaj']);
-  printf("<TD>%6.4f</TD>",$line['bmin']);
-  printf("<TD>%6.4f</TD>",$line['bpa']);
-  printf("<TD>%s</TD>",$line['date']);
-  printf("<TD>%s</TD>",$line['ut']);
-  printf("<TD>%14.8f</TD>",$line['MJD']);
-  printf("<TD>%9.4f</TD>",$line['obsfreq']);
-  printf("<TD>%9.4f</TD>",abs($line['bw']));
-  printf("<TD>%d</TD>",$line['nchan']);
-  printf("<TD>%9.4f</TD>",$line['scanlen']);
-  printf("<TD>%9.4f</TD>",$line['tsamp']);
-  echo "\n</TR>\n";
+  echo "    <TR>\n ";
+  print_datum($line['filename'],"%s");
+  print_datum($line['angsep'],"%8.6f");
+  print_datum($line['src_name'],"%s");
+  print_datum($line['survey'],"%s");
+  print_datum($line['rajd'],"%10.6f");
+  print_datum($line['decjd'],"%+11.6f");
+  print_datum($line['bmaj'],"%6.4f");
+  print_datum($line['bmin'],"%6.4f");
+  print_datum($line['bpa'],"%6.4f");
+  print_datum($line['date'],"%s");
+  print_datum($line['ut'],"%s");
+  print_datum($line['MJD'],"%14.8f");
+  print_datum($line['obsfreq'],"%9.4f");
+  print_datum($line['bw'],"%9.4f");
+  print_datum($line['nchan'],"%d");
+  print_datum($line['scanlen'],"%9.4f");
+  print_datum($line['tsamp'],"%9.4f");
+  echo "\n    </TR>\n";
+}
+
+function print_datum($datum, $format)
+{
+  if($datum == "NULL" || $datum == "") printf("     <TD></TD>");
+  else {
+    $output = "     <TD>".$format."</TD>";
+    printf($output,$datum);
+  }
+
 }
 
