$message"; exit(); } function getLine($f) { while (!feof($f)) { $line = trim(fgets($f, 4096)); if ($line != "") return $line; } return ""; } function value($line) { return trim(substr($line, 10)); } function field($line) { return trim(substr($line, 0, 9)); } function splinter($line) { preg_match_all("/({[^}]+})|(\"[^\"]+\")|([^ \t\n]+)/", $line, $a); $b = array(); foreach ($a[0] as $i) { $i = trim($i, "{}\""); if ($i != "") $b[] = $i; } return $b; } function readIndex($file) { global $Images, $People, $Others, $Events, $Locations; $f = fopen($file, "r"); while ($line = getLine($f)) { $field = field($line); $value = value($line); if ($field != "IMAGE") error("Error reading Index file"); $Images[] = $image = $value; $line = getLine($f); $field = field($line); if ($field != "CAPTION") error("Error reading Index file"); $line = getLine($f); $field = field($line); if ($field != "PEOPLE") error("Error reading Index file"); $items = splinter(value($line)); foreach ($items as $item) $People[$item]++; $line = getLine($f); $field = field($line); if ($field != "OTHER") error("Error reading Index file"); $items = splinter(value($line)); foreach ($items as $item) $Others[$item]++; $line = getLine($f); $field = field($line); if ($field != "EVENT") error("Error reading Index file"); $value = value($line); if ($value != "") $Events[$value]++; $line = getLine($f); $field = field($line); if ($field != "LOCATION") error("Error reading Index file"); $value = value($line); if ($value != "") $Locations[$value]++; $line = getLine($f); $field = field($line); if ($field != "DATE") error("Error reading Index file"); $line = getLine($f); $field = field($line); if ($field != "METHOD") error("Error reading Index file"); } ksort($People); ksort($Events); ksort($Locations); } readIndex("Index"); print "\n"; print "$title"; print "

Welcome to

$title

"; print "
"; print "
"; print "
"; print "

Search the Album:

"; print ""; print "
Person 1:"; print ""; print "
Person 2:"; print ""; print "
Other:"; print ""; print "
Event:"; print ""; print "
Location:"; print ""; print "
Date:"; print "From //"; print "  to  //"; print "
"; print ""; print "  "; print "
"; $N = count($Images); print "

The album now contains $N images.

"; print "

"; print "Created by Doug Rohde"; print ""; ?>