home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / cgi-bin / Japan / Theme / entry.cgi.sav < prev    next >
Text File  |  2017-09-21  |  8KB  |  324 lines

  1. #!/usr/local/bin/perl
  2.  
  3. $| = 1;
  4. # script for meeting room
  5.  
  6. # jrh
  7. $CgiPath      = '/stage/htdocs/cgi-bin/Japan/Theme';
  8. push(@INC, "$CgiPath");
  9. require 'jcode.pl'; # tends to be in /usr/local/lib/perl
  10. require 'read-form.pl'; # tends to be in your cgi path
  11. require 'meetinit.pl';
  12. require 'frames.pl';
  13.  
  14. $ThisFile = '/stage/htdocs/cgi-bin/Japan/Theme/entry.cgi';
  15.  
  16. # print "Content-type: text/html\n\n";
  17.  
  18. $UserName = '';
  19. &get_referer;
  20. &get_cookie;
  21. &read_in_data;
  22. if ($UserName ne '') {
  23.   &init_dbm;
  24.   &check_frames;
  25.   if ($Open == 1) {
  26.     &log_user;
  27.     &print_frames;
  28.   }
  29.   else {
  30.     if ($Present == 1) {
  31.       &reject_present;
  32.     }
  33.     else {
  34.       &reject_full;
  35.     }
  36.   }
  37. }
  38. else {
  39.   &reject_user;
  40. }
  41. &close_dbm;
  42.  
  43. #########################################################################
  44.  
  45.  
  46. sub get_referer {
  47.  
  48.   $Referer = $ENV{'HTTP_REFERER'};
  49. }
  50.  
  51. sub get_cookie {
  52.  
  53.   $CookieEnv = $ENV{'HTTP_COOKIE'};
  54.   @Cookies = split(/\;/,$CookieEnv);
  55.   foreach $Cookie (@Cookies) {
  56. #       print "Cookie : $Cookie\n";
  57.         
  58.     @CurrentCookie = split(/=/,$Cookie);
  59.     $CurrentCookie[0] =~ s/ //;
  60. #      print "Cookie0 : A$CurrentCookie[0]B\n\n";
  61. #      print "Cookie1 : $CurrentCookie[1]\n\n";
  62.     if ($CurrentCookie[0] eq 'NAME') {
  63.       $UserName = $CurrentCookie[1];
  64. #      print "Cookieif : $UserName";
  65.     }
  66.     if ($CurrentCookie[0] eq 'LOCATION') {
  67.       $Location = $CurrentCookie[1];
  68.     }
  69.     $UserName = "$UserName\@$Location";
  70.     $UserName =~ s/@@/@/;
  71.   }
  72. }
  73.  
  74. sub read_in_data {
  75.  
  76. # read in submitted form data contents into the hash %FormDataHash
  77. &ReadInFormData(\%FormDataHash);
  78.  
  79. foreach $Key (keys(%FormDataHash)) {
  80.  
  81. # print "//$Key:$FormDataHash{$Key}//\n";
  82. }
  83.  
  84. $OwnURL = 0;
  85. $GifName = "image/$FormDataHash{'gif'}";
  86. if ($GifName eq 'image/') {
  87.   $GifName = $FormDataHash{'urlgif'};
  88.   if ($GifName eq 'http://') {
  89.     $GifName = 'image/face1.gif';
  90.   }
  91.   else {
  92.     $OwnURL = 1;
  93.   }
  94. }
  95.  
  96. $ParkName = $FormDataHash{'park'};
  97.  
  98. if ($OwnURL == 0) {
  99.   $Temp = $GifName;
  100.   $GifName = "$ThemeURL/$ParkName/park/$Temp";
  101. }
  102. # print "$FormDataHash{'gif'}\n";
  103. # print "$UserName\n";
  104. }
  105.  
  106. sub init_dbm {
  107.  
  108.   $LastPath = "$ThemeDBMPath/$ParkName/$LastAccess";   
  109.   $UserPath = "$ThemeDBMPath/$ParkName/$UserAccess";   
  110.   $UpdatePath = "$ThemeDBMPath/$ParkName/$LastUpdate";   
  111.   $EntryPath = "$ThemeDBMPath/$ParkName/$EntryTime";   
  112.   $GifPath = "$ThemeDBMPath/$ParkName/$GifNumber";   
  113.   $ColorFilePath = "$ThemeDBMPath/$ParkName/$ColorFile";   
  114.   $ColorNamesPath = "$ThemeDBMPath/$ParkName/$ColorNames";   
  115.   dbmopen(%LastAccessToPage,$LastPath,0666);
  116.   dbmopen(%UserAccessToPage,$UserPath,0666);
  117.   dbmopen(%LastUpdateToPage,$UpdatePath,0666);
  118.   dbmopen(%EntryToPage,$EntryPath,0666);
  119.   dbmopen(%GifToPage,$GifPath,0666);
  120.   dbmopen(%Colors,$ColorFilePath,0666);
  121.   dbmopen(%ColorName,$ColorNamesPath,0666);
  122.  
  123. }
  124.  
  125.  
  126. sub check_frames  {
  127.  
  128.  
  129. # Set Up Constant factors
  130.   $ExpireTime = time - $ExpiryTime; 
  131.   $WhileNo = $FrameNo + 1;
  132.   $Key = 1;
  133. # Clean out expired frames
  134.  
  135.   while ($Key < $WhileNo) {
  136.     
  137.     if ($LastAccessToPage{$Key} > 0) {
  138.       if ($LastAccessToPage{$Key} < $ExpireTime) {
  139.         $CleanKey = $Key;
  140.         $UserAccessToPage{$Key} = "vacant";
  141.         $LastAccessToPage{$Key} = 0;
  142.         $LastUpdateToPage{$Key} = time;
  143.         $GifToPage{$Key} = "$ThemeSite$ThemeURL/$ParkName/park/image/vacancy.gif";
  144.         &clean_frame;
  145.       }
  146.     }
  147.     $Key++;
  148.   }
  149.  
  150. # Check for open frame
  151.  
  152.   $Present = 0;
  153.   $Open = 0;
  154.   $Key = 1;
  155.  
  156.   while ($Key < $WhileNo) {
  157.     
  158.     if ($UserAccessToPage{$Key} eq $UserName) {
  159.       $Present = 1;
  160.     }
  161.     if ($LastAccessToPage{$Key} == 0) {
  162.       $Open = 1;
  163.       $LastKey = $Key;
  164.     }
  165.     $Key++;
  166.   }
  167.   
  168.   if ($Present == 0) {
  169.     if ($Open == 1) {
  170.  
  171.       &replace_frame;
  172.       $EntryToPage{$LastKey} = time;
  173.       $LastUpdateToPage{$LastKey} = time;
  174.       $UserAccessToPage{$LastKey} = $UserName;
  175.       $LastAccessToPage{$LastKey} = time + 1;
  176.       if ($GifName =~ /http/) {
  177.         $GifToPage{$LastKey} = $GifName;
  178.       }
  179.       else {
  180.         $GifToPage{$LastKey} = "$ThemeSite/$GifName";
  181.  
  182.       }
  183.       $ColorName{$UserName} = $Colors{$LastKey};
  184.     }
  185.   }
  186.   else {
  187.     $Open = 0;
  188.   }
  189. }
  190.  
  191.  
  192. sub log_user {
  193.  
  194.   open (TEXT,">> $ThemePath/logs/$ParkName\.entry\.log");
  195.   select (TEXT);
  196.   print "$UserName : ".gmtime(time)." GMT\n";
  197.   select (STDOUT);
  198.   close (TEXT);
  199. }
  200.  
  201.  
  202. sub print_frames {
  203.  
  204.   select(STDOUT);
  205.   # tell the server that we're sending data back now
  206.   print "Content-type: text/html\n\n";
  207.  
  208.   # now send the server some html stuff
  209.   print "<HTML>\n\n";
  210.  
  211.   print "<HEAD>\n\n";
  212.   print "<TITLE>Entrance Room</TITLE>\n";
  213.   print "</HEAD>\n\n";
  214.  
  215.   print "<FRAMESET COLS=\"20,60,20\">";
  216.   print "<NOFRAMES>";
  217.  
  218.  
  219.   print "<BODY>\n\n";
  220.  
  221.   print "<H1>No Frames!! don't bother </H1>\n\n";
  222.  
  223.   print "<P></P>";
  224.  
  225.   print "</BODY>\n\n";
  226.  
  227.   print "</NOFRAMES>\n\n";
  228.   print "<FRAMESET ROWS=\"33,33,33\">\n\n";
  229.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park6.html\" NAME=\"FRAME6\">\n\n";
  230.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park4.html\" NAME=\"FRAME4\">\n\n";
  231.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park2.html\" NAME=\"FRAME2\">\n\n";
  232.   print "</FRAMESET>\n\n";
  233.   print "<FRAMESET ROWS=\"*,75\">\n\n";
  234.   print "<FRAME SRC=\"$ThemeCgi/meet.cgi?gif=$GifName&username=$UserName&park=$ParkName\" NAME=\"DISPLAY\">\n\n";
  235.   print "<FRAME SRC=\"$ThemeCgi/textpre.cgi?username=$UserName&park=$ParkName\" NAME=\"INPUT\">\n\n";
  236.   print "</FRAMESET>\n\n";
  237.   print "<FRAMESET ROWS=\"33,33,33\">\n\n";
  238.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park5.html\" NAME=\"FRAME5\">\n\n";
  239.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park3.html\" NAME=\"FRAME3\">\n\n";
  240.   print "<FRAME MARGINWIDTH=\"1\" MARGINHEIGHT=\"1\" SRC=\"$ThemeURL/$ParkName/park/park1.html\" NAME=\"FRAME1\">\n\n";
  241.   print "</FRAMESET>\n\n";
  242.   print "</FRAMESET>\n\n";
  243.   print "</HTML>\n\n";
  244. }
  245.  
  246. sub reject_user {
  247.  
  248.   select(STDOUT);
  249.   # tell the server that we're sending data back now
  250.   print "Content-type: text/html\n\n";
  251.  
  252.   # now send the server some html stuff
  253.   print "<HTML>\n\n";
  254.  
  255.   print "<HEAD>\n\n";
  256.   print "<TITLE>Pocket Park Checkin</TITLE>\n";
  257.   print "</HEAD>\n\n";
  258.  
  259.   print "<BODY BGCOLOR=\"\#ff ff ff\">\n\n";
  260.  
  261.   print "<H2>You need to check in to use the Pocket Park";
  262.   print "</H2>";
  263.   print "<HR>";
  264.   print "<P>";
  265.  
  266.   print "<FORM ACTION= \"$ThemeCgi/checkin.cgi\" METHOD=\"POST\">\n\n";
  267.  
  268.   print "Choose a UserName";
  269.   print "<BR>\n\n";
  270.  
  271.   print "<INPUT TYPE=\"TEXT\" NAME=\"your_name\" SIZE=10>";
  272.  
  273.   print "<BR>\n\n";
  274.   print "<BR>\n\n";
  275.   print "What is your location?"; 
  276.   print "<BR>\n\n";
  277.  
  278.   print "<INPUT TYPE=\"TEXT\" NAME=\"your_location\" SIZE=10>";
  279.   print "<BR>\n\n";
  280.   print "<BR>\n\n";
  281.   print "<INPUT TYPE=\"HIDDEN\" NAME=\"park\" VALUE=\"$ParkName\">";  
  282.   print "<INPUT TYPE=\"HIDDEN\" NAME=\"referer\" VALUE=\"$Referer\">";  
  283.  
  284.   print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Submit\">";
  285.   print "<INPUT TYPE=\"RESET\" NAME=\"Reset\">";
  286.   print "</FORM>";
  287.  
  288.   print "<HR>\n\n";
  289.  
  290.   print "</BODY>\n\n";
  291.  
  292.  
  293.   print "</HTML>\n\n";
  294.  
  295. }
  296.  
  297. sub reject_present {
  298.  
  299.   print "Location: $ThemeSite$ThemeURL/$ParkName/park/present.html\n";
  300.   print "Content-type: text/html\n\n";
  301.   print "<HTML><HEAD><TITLE>Redirect</TITLE></HEAD><BODY><H1>Redirect</H1></BODY></HTML>";
  302.  
  303. }
  304.  
  305. sub reject_full {
  306.  
  307.   print "Location: $ThemeSite$ThemeURL/$ParkName/park/full.html\n";
  308.   print "Content-type: text/html\n\n";
  309.   print "<HTML><HEAD><TITLE>Redirect</TITLE></HEAD><BODY><H1>Redirect</H1></BODY></HTML>";
  310.  
  311. }
  312.  
  313. sub close_dbm {
  314.  
  315.   dbmclose(%LastAccessToPage);
  316.   dbmclose(%UserAccessToPage);
  317.   dbmclose(%EntryToPage);
  318.   dbmclose(%GifToPage);
  319.   dbmclose(%Colors);
  320.   dbmclose(%ColorName);
  321.  
  322. }
  323.  
  324.