I am running a website where I want to control access to the various files.  I 
have the directory setup in httpd.conf with:

<Files ~ (\.asp)>
   SetHandler  perl-script
   PerlHandler Apache::ASP
   PerlSetVar  Global /storage/t212
   PerlSetVar  StateDir /tmp/asp
   PerlSetVar  RequestBinaryRead On
</Files>
<Files ~ (\.html)>
   SetHandler  perl-script
   PerlHandler Apache::ASP
   PerlSetVar  Global /storage/t212
   PerlSetVar  StateDir /tmp/asp
   PerlSetVar  RequestBinaryRead On
</Files>
<Files ~ (\.doc)>
   SetHandler  perl-script
   PerlHandler Apache::ASP
   PerlSetVar  Global /storage/t212
   PerlSetVar  StateDir /tmp/asp
   PerlSetVar  RequestBinaryRead On
</Files>
<Files ~ (\.pdf)>
   SetHandler  perl-script
   PerlHandler Apache::ASP
   PerlSetVar  Global /storage/t212
   PerlSetVar  StateDir /tmp/asp
   PerlSetVar  RequestBinaryRead On
</Files>

and the global.asa file that includes:

sub Script_OnStart {
    $Basename = basename($0);
    $Basename = 'index.asp' unless $Basename;
    $Logged = $Session->{"Logged"};

    $Response->Redirect("Login.asp")
        unless ($Logged or $Basename eq 'Login.asp');

    if ($Request->Form('logout')) {
        $Session->Abandon();
        $Response->Redirect("Login.asp");
    }

    if ($Basename =~ /\.css$/) {
        $Response->{ContentType} = 'text/css';
        open(FILE, $Basename) or die "File not found";
        my $temp = $/;
        $/ = undef;
        my $data = <FILE>;
        $Response->Clear;
        $Response->AddHeader('Content-Length', length $data);
        $Response->Write($data);
        $/ = $temp;
        $Response->End;
    }   

    if ($Basename =~ /\.doc$/) {
        $Response->{ContentType} = 'application/msword';
        open(FILE, $Basename) or die "File not found: $Basename";
        binmode FILE;
        my $temp = $/;
        $/ = undef;
        my $data = <FILE>;
        $Response->Clear;
        $Response->AddHeader('Content-Length', length $data);
        $Response->BinaryWrite($data);
        $/ = $temp;
        $Response->End;
    }
    if ($Basename =~ /\.pdf$/i) {
        $Response->{ContentType} = 'application/pdf';
        open(FILE, $Basename) or die "File not found: $Basename";
        binmode FILE;
        my $temp = $/;
        $/ = undef;
        my $data = <FILE>;
        $Response->Clear;
        $Response->AddHeader('Content-Length', length $data);
        $Response->BinaryWrite($data);
        $/ = $temp;
        $Response->End;
    }
    if ($Basename =~ /\.html$/) {
        $Response->{ContentType} = 'text/html';
        open(FILE, $Basename) or die "File not found";
        my $data = <FILE>;
        $Response->Clear;
        $Response->AddHeader('Content-Length', length $data);
        $Response->Write($data);
        $Response->End;
    }

    $Title = "$Name " . $Titles{$Basename};
    $Response->Include('header.inc');

    if ($Logged) {
        $Admin = $Session->{Admin};
        $User = $Session->{User};
        $UniqueID = $Session->{UID};
        $Perm = $Session->{Perm};
        my $Hash = $Session->{Hash};
        my $junk = $UniqueID . $User . $Perm;
        unless ($Hash == crypt($junk,$Hash)) {
            $Session->{"Logged"} = 0;
            $Response->Redirect("Login.asp");
        }
    }
}


This works well for the .doc, .css, .html, and .asp files, but the pdf files 
always crash with an error along the lines of:
[error] error compiling blah.pdf: Unrecognized character \\xF9 at (eval 37) 
line 265. <--> , /usr/lib/perl5/site_perl/5.8.3/Apache/ASP.pm line 1462

In fact, even if I change the global.asa script to die at the beginning of 
Script_OnStart, I still get the same error for PDF files (unlike the other file 
types, where I get the error from the die command).  This indicates to me that 
the PDF file is getting processed somehow differently from the other file types.

What am I overlooking here?  How do I get my site to follow the global.asa 
directives for the PDF file just the same as it does for the DOC files?

Thanks,

Jon Dixon
[EMAIL PROTECTED]
http://dixonjon.tripod.com/
-- 
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at 
once.
http://datingsearch.lycos.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to