<?php

/* Plan of action:
 * 1. Extract the date variable
 * 2. If a file exists with this date, then proceed; otherwise leave a nice
 *    message for the user
 * 3. Get the neighbor dates by examining the directory structure
 * 4. Spit out the header having filled in the date
 * 5. Spit out the body from the file selected
 * 6. Spit out the footer
 */

require_once ('date_finder.php');

// extract the date
if (isset($_GET['date']))
	$date = $_GET['date'];
else
	header("Location: .");

$dates =& get_dates();

// determine if this date exists:
$loc = array_search($date, $dates);
if ($loc === false)
	header("Location: .");

// get the neighbor values
if ($loc == count($dates))
	$previous = false;
else
	$previous = $dates[$loc+1];

if ($loc == 0)
	$next = false;
else
	$next = $dates[$loc-1];

include ('header');
include (DATES . "/" . $date);
include ('footer');

?>
