use Date::Manip;
use GDBM_File;
use Storable qw(nfreeze thaw);
use lib '/home/httpd/lib/perl/';
use LONCAPA;
use Apache::lonnet;

my $fname="/home/httpd/lonUsers/annarbor/9/7/7/9778182de3942c1annarborl2/slots.db";

my $db = &LONCAPA::locking_hash_tie($fname,&GDBM_WRCREAT());
if (! $db) {
    warn "Unable to tie to $fname";
    exit;
}

=pod

slots can have these parts;:

Required:
  starttime - unix time that a slot start
  endtime - unix time that a slot ends
  type - either 'preassigned' or 'schedulable_student'
         (controls whether slotrequest.pm will allow one to select it)

Optional:
  startreserve - unix time that a slot can start being reserved
  ip - comma seperated list of ip address or wildcard ranges or
       wilcard hostnames, or [] style range of allowable client IP
       addresses
  proctor - comma seperated list of user@domain that can checkin a user
  description - string that will displayed to people when talking about 
                this slot
  maxspace - integer (number of people that can schedule this space)
             (if unspecfied no limit is used)
  symb - arrayref of symbs that can be scheduled to be done in this slot
  uniqueperiod - if the user has a reservation that has a uniqueperiod
                 that overlaps this don't allow them to schedule this
                 slot
  secret - arrary ref of words that are the secret for this slot
Possibly Need: (but not yet supported)


=cut

$db->{'slot1'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'preassigned',
	'startreserve' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'endtime'   => &UnixDate("Aug 30th 01:00:00 2004","%s"),
	'ip'        => "*albertelli.com",
	'proctor'   => 'testuser@annarbor',
    });
$db->{'slot2'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'preassigned',
	'startreserve' => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'starttime' => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'ip'        => "*albertelli.com",
	'proctor'   => 'testuser@annarbor',
    });
$db->{'slot3'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'preassigned',
	'description' => 'slot3',
	'startreserve' => &UnixDate("Aug 29th 00:00:00 2004","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2006","%s"),
        'endtime'   => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'ip'        => "1.2.3.4",
	#'ip'        => "*albertelli.com",
	'proctor'   => 'testuser@annarbor',
    });
$db->{'slot4'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'preassigned',
	'startreserve' => &UnixDate("Aug 29th 00:00:00 2004","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'ip'        => "*albertelli.com",
	'proctor'   => 'testuser@annarbor',
    });
$db->{'slot5'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'schedulable_student',
	'description' => 'Aug 30th 4 P.M., Room 123 Kedzie',
	'startreserve' => &UnixDate("Aug 29th 00:00:00 2004","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'starttime' => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime' => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	#'endtime'   => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'ip'        => "*albertelli.com,"
	'proctor'   => 'testuser@annarbor',
	'uniqueperiod' => [&UnixDate("Aug 30th 00:00:00 2004","%s"),
			   &UnixDate("Aug 30th 00:00:00 2005","%s")],
	'maxspace' => 10,
	'secret'   => 'sauce'
    });
$db->{'slot6'}=
    &Apache::lonnet::freeze_escape({
	'type'      => 'schedulable_student',
	'description' => 'Aug 31th 4 P.M., Room 222 Computer Center',
	'startreserve' => &UnixDate("Aug 29th 00:00:00 2004","%s"),
	#'starttime' => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	'starttime' => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	'endtime'   => &UnixDate("Aug 30th 00:00:00 2006","%s"),
	#'endtime'   => &UnixDate("Aug 30th 00:00:00 2004","%s"),
	#'ip'        => "*albertelli.com",
	'proctor'   => 'testuser@annarbor',
	'uniqueperiod' => [&UnixDate("Aug 1st 00:00:00 2005","%s"),
			   &UnixDate("Aug 30th 00:00:00 2006","%s")],
	'maxspace' => 4,
    });

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at 
 root@localhost to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
