home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Application.pm < prev    next >
Encoding:
Perl POD Document  |  2003-05-05  |  1.7 KB  |  76 lines

  1.  
  2. package Apache::ASP::Application;
  3.  
  4. use Apache::ASP::State;
  5. use Apache::ASP::Collection;
  6.  
  7. use strict;
  8. no strict qw(refs);
  9. use vars qw(@ISA);
  10. @ISA = qw(Apache::ASP::Collection Apache::ASP::State);
  11. use Fcntl qw(:flock O_RDWR O_CREAT );
  12.  
  13. sub new {
  14.     my($asp) = @_;
  15.     my(%self);
  16.  
  17.     unless(
  18.        tie(
  19.            %self,'Apache::ASP::State', $asp, 
  20.            'application', 'server', 
  21.            )
  22.        )
  23.     {
  24.     $asp->Error("can't tie to application state");
  25.     return;
  26.     }
  27.  
  28.     bless \%self;
  29. }
  30.  
  31. sub Lock { shift->SUPER::LOCK };
  32. sub UnLock { shift->SUPER::UNLOCK };
  33.  
  34. sub SessionCount {
  35.     my $asp = tied(%{$_[0]})->{asp};
  36.     if($asp->{session_count}) {
  37.     $asp->{Internal}{SessionCount};
  38.     } else {
  39.     undef;
  40.     }
  41. }
  42.  
  43. sub GetSession {
  44.     my($self, $id) = @_;
  45.     my $asp = tied(%$self)->{'asp'};
  46.     unless(defined $id and $id) {
  47.     $asp->Warn("session id not defined");
  48.     return;
  49.     }
  50.     unless(length($id) >= 8) {
  51.     $asp->Warn("session id must be of at least 8 in length");
  52.     return;
  53.     }
  54.  
  55.     if($asp->{Session} and $asp->{Session}->SessionID() eq $id) {
  56.     return $asp->{Session};
  57.     } else {
  58.     my $new_session = Apache::ASP::Session::new($asp, $id, O_RDWR, 'NOERR');
  59.     if($new_session) {
  60.         if ($asp->{get_session_last}) {
  61.         my $session_obj = tied %{$asp->{get_session_last}};
  62.         $asp->{dbg} && $asp->Debug("freeing last session $asp->{get_session_last} $session_obj");
  63.         $session_obj && $session_obj->DESTROY;
  64.         }
  65.         $asp->{get_session_last} = $new_session;
  66.         $asp->RegisterCleanup(sub {
  67.                       my $session_obj = tied %$new_session;
  68.                       $session_obj && $session_obj->DESTROY;
  69.                   });
  70.     }
  71.     $new_session;
  72.     }
  73. }
  74.  
  75. 1;
  76.