#!/usr/bin/perl

use CGI qw(:standard);

$room=9;
$username=cookie('MazeID');
if($username) {
createPage();
} else {
print redirect('http://127.0.0.1/cgi-bin/maze/entry.pl');
}

sub createPage {
  open (COOKLIST, "C:/mazeperm/$username.txt") || die "open: $!";
  while (<COOKLIST>) {  
    $perm=$_;
  }
  close (COOKLIST);
  @perms=split(/,/, $perm);
  print header(),start_html("Room #$room");
  if (@perms[$room]) {
    print h1("Welcome to Room $room");

    print h2("Congratulations!");
    print p("You've completed the maze.  Rest and celebrate!");
 
  } else {
    print h1("No entry");
    print p("You don't have that key.  You may <A HREF='maze1.pl'>start over</A> if you like.");
  }
print close_html();
}