<?php

require 'cgi-bin/functions.php';
require 'cgi-bin/vars.php';
if (isset($_GET['year'])) {
    $year = $_GET['year'];
}
opening_html("Listing trips by year");
if (isset($year)) {
    echo "List all trips for year {$year}:\n\t<ul>";
    if (is_dir($activitiesdir . $year)) {
        if ($dir_handler = opendir($activitiesdir . $year . "/")) {
            while (($file = readdir($dir_handler)) !== false) {
                if (!is_dir($activitiesdir . $year . "/" . $file)) {
                    // && preg_match($file, "/\.(ini)/")) {
                    $filename_exp = explode(".", $file);
                    if ($filename_exp[0] != "") {
                        echo "<li><a href=\"activity.php?activity=" . $filename_exp[0] . "&year={$year}\">" . ucfirst($filename_exp[0]) . "</a></li>\r";
                    }
                }
            }
            closedir($dir_handler);
        }
    }
    echo "</ul>\n\t<hr>";
}
echo "Please choose a year:\n<form action=\"year.php\" method=\"get\">\n<select name=\"year\">";
if (is_dir($activitiesdir)) {
    if ($dir_handler = opendir($activitiesdir)) {
        while (($file = readdir($dir_handler)) !== false) {
            if (is_dir($activitiesdir . $file)) {
<?php

require 'cgi-bin/functions.php';
require 'cgi-bin/vars.php';
opening_html('All Trips');
if ($dir_handler = opendir($activitiesdir)) {
    while (($dir = readdir($dir_handler)) !== false) {
        if (is_dir($activitiesdir . $dir) && $dir != "." && $dir != ".." && $dir != "0000") {
            if ($file_handler = opendir($activitiesdir . $dir)) {
                echo "<H3>{$dir}</H3>\n\t\t\t\t<ul>";
                while (($file = readdir($file_handler)) !== false) {
                    if (!is_dir($activitiesdir . $dir . "/" . $file) && $file != "." && $file != ".." && $file != ".DS_Store") {
                        $mainfile = explode(".", $file);
                        echo "<li><a href=\"activity.php?activity=" . $mainfile[0] . "&amp;year={$dir}\">" . $mainfile[0] . "</a></li>\r";
                    }
                }
                echo "</ul>";
            }
        }
    }
}
navlinks(array(array("index.php", "Return home")));
closing_html();
<?php

require 'cgi-bin/functions.php';
require 'cgi-bin/vars.php';
opening_html();
echo "<h3>Welcome to {$orginization}'s history page!</h3>\n\nFeel free to browse using the links below.<br />\n<br />\n<a href=\"year.php\">Search by year</a><br />\n<br />\n<a href=\"trips.php\">List all trips</a><br />\n<br />\n<a href=\"about.php\">About this site</a>";
navlinks(array());
closing_html();
<?php

require 'cgi-bin/functions.php';
require 'cgi-bin/vars.php';
$filename = urldecode($_GET['file']) or die("Filename not set");
$file_ext = explode(DIRECTORY_SEPARATOR, $filename);
opening_html($file_ext[count($file_ext) - 1]);
echo "<br>\n<img src=\"{$filename}\" width=\"970\" alt=\"" . $file_ext[count($file_ext) - 1] . "\" /><br />\n\n<ul>\n<li><i>Filename</i>: " . $file_ext[count($file_ext) - 1] . "</li>\n<li><i>File Size</i>: " . round(filesize($filename) / 1024, 3) . " KB</li>\n<li><i>Last Modified</i>: " . date("F d, Y", filemtime($filename)) . "</li>\n</ul>";
echo "<div id=\"footernavlinks\">";
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
    navlinks(array(array($_SERVER['HTTP_REFERER'], "Go back"), array("index.php", "Return home")));
} else {
    navlinks(array(array("index.php", "Return home")));
}
closing_html();
if (!isset($_GET['activity']) || !isset($_GET['year'])) {
    $year = '0000';
    $activity = 'notset';
} else {
    $year = $_GET['year'];
    $activity = $_GET['activity'];
}
$location = "activities";
$file = $activity . ".ini";
if (file_exists(strtolower("{$location}/{$year}/{$file}"))) {
    $buffer = parse_ini_file(strtolower("{$location}/{$year}/{$file}"), true);
} else {
    $year = "0000";
    $buffer = parse_ini_file("{$location}/0000/notfound.ini", true);
}
opening_html(ucfirst($buffer['main']['name']));
if ($buffer['main']['dates'] != "-" && $buffer['main']['location'] != "-") {
    echo "<h2>" . $buffer['main']['location'] . " (" . $buffer['main']['dates'] . ")</h2>";
}
echo $buffer['main']['introtext'];
while ($daycount < count($buffer) - 1) {
    $daycount++;
    $day = "day " . $daycount;
    echo "<h4>" . ucfirst($day) . " (" . $buffer[$day]['day'] . ", " . $buffer[$day]['date'] . ")</h4>\r";
    echo nl2br($buffer[$day]['description'], true) . "\r\r";
}
echo "<br />\n";
if (is_dir("{$location}/{$year}/{$activity}")) {
    $count = 0;
    echo "<hr>\n<H3>Images</H3>\r";
    if ($dir_handler = opendir("{$location}/{$year}/{$activity}/")) {
<?php

require 'cgi-bin/vars.php';
require 'cgi-bin/functions.php';
opening_html("About this site");
?>

This is <?php 
echo $orginization . "'s";
?>
 history page, containing a record of all the past trips this unit has taken.  This site is maintained by <?php 
echo $historian . ", " . $orginization;
?>
 historian. <br /> <br />

This software is currently version <?php 
echo $version;
?>
, written by Matthew Bowker.

<?php 
navlinks(array(array("index.php", "Return home")));
closing_html();