#!/usr/local/bin/perl5 $| = 1; # script for meeting room # jrh $CgiPath = '/stage/htdocs/cgi-bin/Japan/Theme'; push(@INC, "$CgiPath"); require 'jcode.pl'; # tends to be in /usr/local/lib/perl require 'read-form.pl'; # tends to be in your cgi path require 'meetinit.pl'; require 'frames.pl'; $ThisFile = '/stage/htdocs/cgi-bin/Japan/Theme/entry.cgi'; # print "Content-type: text/html\n\n"; $UserName = ''; &get_referer; &get_cookie; &read_in_data; if ($UserName ne '') { &init_dbm; &check_frames; if ($Open == 1) { &log_user; &print_frames; } else { &reject_full; } } else { &reject_user; } &close_dbm; ######################################################################### sub get_referer { $Referer = $ENV{'HTTP_REFERER'}; } sub get_cookie { $CookieEnv = $ENV{'HTTP_COOKIE'}; @Cookies = split(/\;/,$CookieEnv); foreach $Cookie (@Cookies) { # print "Cookie : $Cookie\n"; @CurrentCookie = split(/=/,$Cookie); $CurrentCookie[0] =~ s/ //; # print "Cookie0 : A$CurrentCookie[0]B\n\n"; # print "Cookie1 : $CurrentCookie[1]\n\n"; if ($CurrentCookie[0] eq 'NAME') { $UserName = $CurrentCookie[1]; # print "Cookieif : $UserName"; } if ($CurrentCookie[0] eq 'LOCATION') { $Location = $CurrentCookie[1]; } $UserName = "$UserName\@$Location"; $UserName =~ s/@@/@/; } } sub read_in_data { # read in submitted form data contents into the hash %FormDataHash &ReadInFormData(\%FormDataHash); foreach $Key (keys(%FormDataHash)) { # print "//$Key:$FormDataHash{$Key}//\n"; } $GifName = "image/$FormDataHash{'gif'}"; if ($GifName eq 'image/') { $GifName = $FormDataHash{'urlgif'}; if ($GifName eq 'http://') { $GifName = 'image/face1.gif'; } } $ParkName = $FormDataHash{'park'}; # print "$FormDataHash{'gif'}\n"; # print "$UserName\n"; } sub init_dbm { $LastPath = "$ThemePath/$ParkName/park/dbm/$LastAccess"; $UserPath = "$ThemePath/$ParkName/park/dbm/$UserAccess"; $EntryPath = "$ThemePath/$ParkName/park/dbm/$EntryTime"; $GifPath = "$ThemePath/$ParkName/park/dbm/$GifNumber"; $ColorFilePath = "$ThemePath/$ParkName/park/dbm/$ColorFile"; $ColorNamesPath = "$ThemePath/$ParkName/park/dbm/$ColorNames"; dbmopen(%LastAccessToPage,$LastPath,0666); dbmopen(%UserAccessToPage,$UserPath,0666); dbmopen(%EntryToPage,$EntryPath,0666); dbmopen(%GifToPage,$GifPath,0666); dbmopen(%Colors,$ColorFilePath,0666); dbmopen(%ColorName,$ColorNamesPath,0666); } sub check_frames { # Set Up Constant factors $ExpireTime = time - $ExpiryTime; $WhileNo = $FrameNo + 1; $Key = 1; # Clean out expired frames while ($Key < $WhileNo) { if ($LastAccessToPage{$Key} > 0) { if ($LastAccessToPage{$Key} < $ExpireTime) { $CleanKey = $Key; $UserAccessToPage{$Key} = "vacant"; $LastAccessToPage{$Key} = 0; $GifToPage{$Key} = "$ThemeSite$ThemeURL/$ParkName/park/image/vacancy.gif"; &clean_frame; } } $Key++; } # Check for open frame $Open = 0; $Key = 1; while ($Key < $WhileNo) { if ($LastAccessToPage{$Key} == 0) { $Open = 1; $LastKey = $Key; } $Key++; } if ($Open == 1) { &replace_frame; $UserAccessToPage{$LastKey} = $UserName; $LastAccessToPage{$LastKey} = time; $EntryToPage{$LastKey} = time; if ($GifName =~ /http/) { $GifToPage{$LastKey} = $GifName; } else { $GifToPage{$LastKey} = "$ThemeSite$ThemeURL/$ParkName/park/$GifName"; } $ColorName{$UserName} = $Colors{$LastKey}; } } sub log_user { open (TEXT,">> $ThemePath/logs/$ParkName\.entry\.log"); select (TEXT); print "$UserName : ".gmtime(time)." GMT\n"; select (STDOUT); close (TEXT); } sub print_frames { select(STDOUT); # tell the server that we're sending data back now print "Content-type: text/html\n\n"; # now send the server some html stuff print "\n\n"; print "
\n\n"; print ""; print "
"; print "