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 / mp_ctl.cgi < prev    next >
Text File  |  2017-09-21  |  5KB  |  242 lines

  1. #!/usr/local/bin/perl
  2.  
  3. $| = 1;
  4. # script for life section of the Theme Kan
  5. # make MeetingPlace frame...
  6.  
  7. # jrh
  8. $CgiPath      = '/stage/htdocs/cgi-bin/Japan/Theme';
  9. push(@INC, "$CgiPath");
  10. require 'jcode.pl'; # tends to be in /usr/local/lib/perl
  11. require 'read-form.pl'; # tends to be in your cgi path
  12. require 'meetinit.pl';
  13.  
  14. $ThisFile = '/stage/htdocs/cgi-bin/Japan/Theme/mp_ctl.cgi';
  15.  
  16. $UserName = '';
  17.  
  18. &init_dbm;
  19. &get_cookie;
  20. &check_users;
  21. &print_frames;
  22. &close_dbm;
  23.  
  24. #########################################################################
  25.  
  26.  
  27. sub init_dbm {
  28.     
  29.     $ListLastPath = "$ThemeDBMPath/$ListLast";   
  30.     $ListUsersPath = "$ThemeDBMPath/$ListUsers";   
  31.     $UpdatePath = "$ThemeDBMPath/$LastUpdate";   
  32.  
  33.     dbmopen(%LastAccessToPage,$ListLastPath,0666);
  34.     dbmopen(%UserAccessToPage,$ListUsersPath,0666);
  35.     dbmopen(%LastUpdateToPage,$UpdatePath,0666);
  36.  
  37. }
  38.  
  39. #
  40. # get username & location
  41. #
  42. sub get_cookie {
  43.  
  44.   $CookieEnv = $ENV{'HTTP_COOKIE'};
  45.   &jcode::convert(*CookieEnv, 'jis');
  46.   @Cookies = split(/\;/,$CookieEnv);
  47. #  print "Cookies! : $CookieEnv\n da";
  48.   foreach $Cookie (@Cookies) {
  49.     #   print "Cookie : $Cookie\n";
  50.         
  51.     @CurrentCookie = split(/=/,$Cookie);
  52.     $CurrentCookie[0] =~ s/ //;
  53. #      print "Cookie0 : A$CurrentCookie[0]B\n\n";
  54. #      print "Cookie1 : $CurrentCookie[1]\n\n";
  55.     if ($CurrentCookie[0] eq 'NAME') {
  56.       $UserName = $CurrentCookie[1];
  57. #      print "Cookieif : $UserName";
  58.     }
  59.     if ($CurrentCookie[0] eq 'LOCATION') {
  60.       $Location = $CurrentCookie[1];
  61.     }
  62.     $UserName = "$UserName\@$Location";
  63.     $UserName =~ s/@@/@/;
  64.   }
  65. }
  66.  
  67. #
  68. # check username in dbm-files
  69. #
  70. sub check_users  {
  71.  
  72.   $Accessing = 0;
  73.   $ExpireTime = time - $ExpiryTime; 
  74.   $Last = $LastAccessToPage{'1'};
  75.   $LastKey = 1;
  76.   $TrueNum = 1;
  77.   $Count = 1;
  78.   $WhileNo = $PeopleNo + 1;
  79.   $MyKey = $WhileNo;
  80.   $CleanKey = 0;
  81.  
  82.   while ($Count < $WhileNo) {
  83. #   print "$UserAccessToPage{$Count} : $Count\n";
  84.     if ($UserName eq $UserAccessToPage{$Count}) {
  85.       $Accessing = 1;
  86. #      $LastAccessToPage{$Count} = time;
  87.       $MyKey = $Count;
  88.     }
  89.     $Count++;
  90.   }  
  91.  
  92.     if  ($Accessing == 1) {
  93.         $Last = $LastAccessToPage{$MyKey};
  94.         $Key = 1;
  95.         while ($Key < $WhileNo) {
  96.             if ($ThisLast = $LastUpdateToPage{$Key}) {
  97.                 if ($UserAccessToPage{$Key} ne 'none' &&
  98.                     $UserAccessToPage{$Key} ne 'vacant' &&
  99.                     $UserAccessToPage{$Key} ne '') {
  100.                     if ($ThisLast gt $Last) {
  101.                         $NewCommer = 1;
  102.                     }
  103.                 }
  104.             }
  105.             $Key++;
  106.         }
  107.     }
  108.  
  109.   $Count = 1;
  110.  
  111.   while ($Count < $WhileNo) {
  112.     if ($LastAccessToPage{$Count} > 0) {
  113.       if ($LastAccessToPage{$Count} < $ExpireTime) {
  114.         $CleanKey = $Count;
  115.         $UserAccessToPage{$Count} = "none";
  116.         $LastAccessToPage{$Count} = 0;
  117.       }
  118.     }
  119.     $Count++;
  120.   }
  121.  
  122.   $Count = 1;
  123.  
  124.   if ($Accessing ne $TrueNum) {
  125.  
  126.     while ($Count < $WhileNo) {
  127.     
  128.       $ThisLast = $LastAccessToPage{$Count};
  129.  
  130.       if ($ThisLast < $Last) {
  131.   
  132.         $Last = $ThisLast;
  133.         $LastKey = $Count;
  134.       }
  135.       $Count++;
  136.     }
  137.  
  138.     $UserAccessToPage{$LastKey} = $UserName;
  139.     $LastUpdateToPage{$LastKey} = time;
  140.     $LastAccessToPage{$LastKey} = time + 1;
  141.     $NewCommer = 1;
  142.   } else {
  143.     $LastAccessToPage{$MyKey} = time;
  144.   }
  145.  
  146. }
  147.  
  148.  
  149. #
  150. # print html-codes when user is check-in
  151. #
  152. sub print_frames {
  153.  
  154.     if ($UserName) {
  155.         if ($NewCommer == 1 || $CleanKey ne 0) {
  156.             &print_mp_entry;
  157.         } else {
  158.             &print_blank;
  159.         }
  160.     } else {
  161.         &print_blank;
  162.     }
  163.  
  164. }
  165.  
  166. sub print_mp_entry {
  167.  
  168.     # for Kanji
  169.     open(NKF, "| /usr/local/bin/nkf -j");
  170.     select(NKF);
  171.      
  172.  
  173.     print "Content-type: text/html\n";
  174.     print "Window-target: MP_ENTRY\n\n";
  175.  
  176.     print "<HTML>\n";
  177.     print "<HEAD>\n";
  178.     print "<META HTTP-EQUIV=REFRESH CONTENT=\"$RefreshTime; URL=$ThemeCgi/mp_ctl.cgi\">";
  179.     print "<TITLE>Meeting Place Control Frame</TITLE>";
  180.     print "</HEAD>\n";
  181.  
  182.     # same as "print_frames in mp_entry.cgi"
  183.  
  184.     # now send the server some html stuff
  185.     print "<HTML>\n\n";
  186.  
  187.     print "<BASEFONT SIZE=\"3\">\n\n";
  188.     print "<BODY BGCOLOR=#669900>\n\n";
  189.  
  190.     print "<CENTER>\n";
  191.     print "<FONT SIZE=\"1\">";
  192.     print "<A HREF=\"$ThemeSite$ThemeURL/mplog/index.html\" TARGET=\"_top\">\n\n";
  193.     print "go Check-in log";
  194.     print "</A></FONT></BR>\n";
  195.     print "<IMG SRC=\"$ThemeSite$ThemeURL/image/pp.gif\" BORDER=0 VSPACE=\"5\"></BR>\n\n";
  196. #    print "<FONT SIZE=\"1\"><A HREF=\"$ThemeSite$ThemeURL/pp/index.html\" TARGET=\"_top\">go Pocket Park</FONT></A>\n\n";
  197.     print "<FONT SIZE=\"1\"><A HREF=\"$ThemeSite$ThemeURL/pp/index.html\" TARGET=\"_top\">go Pocket Park</FONT></A>\n\n";
  198.     print "</CENTER>\n\n";
  199.  
  200.     print "<HR>\n\n";
  201.     print "<FONT SIZE=\"1\"><I>Here comes...</I></FONT><P>\n\n";
  202.  
  203.     foreach $Key (sort(keys(%UserAccessToPage))) {
  204.         if ($UserAccessToPage{$Key} ne 'none') {
  205.             $UserName = $UserAccessToPage{$Key};
  206.             $UserName =~ s/\@/<img src=\"$ThemeSite$ThemeURL\/image\/people\.gif\">/;
  207.             print "$UserName\n\n";
  208.             print "<BR>\n\n";
  209.         }
  210.     }
  211.  
  212.     print "</BODY>\n\n";
  213.  
  214.     print "</HTML>\n\n";
  215. }
  216.  
  217.  
  218. sub print_blank {
  219.  
  220.     print "Content-type: text/html\n";
  221.     print "Window-target: MP_CTL\n\n";
  222.  
  223.     print "<HTML><HEAD>\n";
  224.     print "<META HTTP-EQUIV=REFRESH CONTENT=\"$RefreshTime; URL=$ThemeCgi/mp_ctl.cgi\">";
  225.     print "<TITLE>Meeting Place Control Frame</TITLE>";
  226.     print "</HEAD></HTML>";
  227.  
  228. }
  229.  
  230. sub close_dbm {
  231.  
  232.     dbmclose(%LastAccessToPage);
  233.     dbmclose(%UserAccessToPage);
  234.     dbmclose(%LastUpdateToPage);
  235.  
  236. }
  237.  
  238.  
  239.  
  240.  
  241.  
  242.