<?php
  //use environmental variables for my path
// Works as of PHP 4.3.0
$home = getenv('WEB');
error_log($home);
#home=$_ENV['WEB'];
set_include_path("$home/html/include");
// Works in all PHP versions
ini_set('include_path', "$home/html/iscbulletin/collected/reports/include");

// Get a list of all agencies
# DB
$user = "web";
$pass = "webuser";
$host = getenv('PGHOSTADDR');
$port = "5432";
$dbne = "isc";

#Open database connection	
$dbh = pg_connect("host=$host port=$port dbname=$dbne user=$user password=$pass") or die("Could not connect") ;
pg_query($dbh, "set search_path to isc");

#Database command 
$cmd = "SELECT distinct code 
FROM isc.agency 
WHERE code is not null";
#Execute the query
$result = pg_query($dbh, $cmd);
$allagencies= array();
// fetch_row is supposed to be faster than fetch_array
while ($row = pg_fetch_row($result)) {

  $agency  = $row[0];

  # Push the network into an array
  array_push($allagencies, $agency);
 }

pg_close($dbh);


date_default_timezone_set('UTC');
$nowyear = date("Y");
$nowmonth = date("m");
error_log($nowmonth);
$nowday = date("d");

$yester = mktime(0,0,0,$nowmonth,$nowday-1,$nowyear);
$yesteryear= date("Y",$yester);
$yestermonth= date("m",$yester);
$yesterday= date("d",$yester);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>Collected data</title>
    <link rel="icon" href="/images/favicon.ico" type="image/ico" />
    <link rel="stylesheet" type="text/css" href="/css/iscschema.css">
  </head>
   <body>
  <div id="container">
   <?php include("$home/html/include/header.php"); ?>

   <div id="maingeneral">
	 <div id="content">
  <?php include("$home/html/iscbulletin/include/leftmenu.php"); ?>
    <div id="rightinner">
<div id=lefttitle>
  <h3>Collected data</h3>
</div>
  <p>All data that is sent to the ISC for inclusion in the ISC Bulletin is available in its original format. The data is received at the ISC using an automated email 'capture' system. The 'capture' system was first implemented in October 1999, with the earliest data available from 1997.</p>

  <p>The raw data can be accessed by searching for a data report sent to the ISC, either by date (1999 and later) and optionally by agency:</p>

<p><a href=/iscbulletin/collected/reports/>Search reports</a></p>

  <p>The ISC also provides access to all station readings stored at the ISC. This includes those data that are unable to be associated to events and are therefore not included in the ISC Bulletin. The readings can be searched using specific station codes or by defining a region to search for stations. Please note: this is the <i>collected data</i> received at the ISC and should not be used as data from the ISC Bulletin. A <a href=/iscbulletin/search/arrivals/>separate page</a> is available to search for arrivals in the Bulletin.<p>

<p><a href=/iscbulletin/collected/readings/>Search collected readings</a></p>

</div>												     
  </div>

  </div> 
<?php include("$home/html/include/footer.php"); ?>
   <?php 
//close the container div 
?>
</div>
</body>
</html>
