Re: PHP Authenticate, then allow file access (centos)
- From: gordonb.1zm2y@xxxxxxxxxxx (Gordon Burditt)
- Date: Tue, 02 Jun 2009 16:39:02 -0500
The way the site is configured now, the user access a certain part of
the webpage, and they get a pop-up prompting them for user/pw. I
really don't like popups so I want to get rid of it. My solution is to
have them login via form. The code I am using work and forwards them
to the appropriate page, but when they are forwarded the popup still
comes up. But they have already entered their authentication
information.
This is the code I'm using that I found online. I get it, but I don't
understand how to get the popup to stop coming up. So I pose my
question: How do I get the pop-up to stop coming up?
Check the authentication. If the authentication is correct, don't
*forward* them to the file, *send them the file*. From the user's point
of view, they click on a link or fill in a form, submit, and they get
the file (and if I've got the content-disposition header right, they
get prompted to save the file).
... check the authentication ... ;
if (...authentication is correct...) {
/* authentication succeeded */
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=\"secret_file.pdf\"");
header("Content-length: " . filesize("/path/outside/document/root/secret.pdf"));
$f = fopen("/path/outside/document/root/secret.pdf", "r");
fpassthru($f);
exit();
} else {
/* authentication failed */
header("Content-type: text/plain");
echo "Access denied.\n";
exit();
}
Note: a bunch of stuff in the header() calls depends on the type of
the
.
- Follow-Ups:
- Re: PHP Authenticate, then allow file access (centos)
- From: Jerry Stuckle
- Re: PHP Authenticate, then allow file access (centos)
- References:
- Prev by Date: Re: PHP Authenticate, then allow file access (centos)
- Next by Date: Re: PHP, apache and extenstions.ini
- Previous by thread: Re: PHP Authenticate, then allow file access (centos)
- Next by thread: Re: PHP Authenticate, then allow file access (centos)
- Index(es):
Relevant Pages
|