[PHP] password protecting files, only allowing authorized users
Hello, I'm using php and apache2 on a freebsd box. I know about .htaccess that the web server can provide, but i'm looking for something php can do, i want it to pop up a page when a user requests certain files, asking for a username and password. If those are valid the user is taken to a page where the files requested can be downloaded. I'd rather not use a mysql database and keep this user information in a flat file, as what i am trying to do is on a small scale. I am also interested in blocking direct access to the files, for instance if someone puts in their direct url they should not be retrievable, but instead php should give an error msg. Any help appreciated. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password protecting files, only allowing authorized users
This is impossible with only PHP. You might need a combination of PHP and AJAX [Javascript]. On 1/11/07, Dave [EMAIL PROTECTED] wrote: Hello, I'm using php and apache2 on a freebsd box. I know about .htaccess that the web server can provide, but i'm looking for something php can do, i want it to pop up a page when a user requests certain files, asking for a username and password. If those are valid the user is taken to a page where the files requested can be downloaded. I'd rather not use a mysql database and keep this user information in a flat file, as what i am trying to do is on a small scale. I am also interested in blocking direct access to the files, for instance if someone puts in their direct url they should not be retrievable, but instead php should give an error msg. Any help appreciated. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password protecting files, only allowing authorized users
Dave wrote: Hello, I'm using php and apache2 on a freebsd box. I know about .htaccess that the web server can provide, but i'm looking for something php can do, i want it to pop up a page when a user requests certain files, asking for a username and password. http://www.php.net/features.http-auth has some nice examples, though the popup is the same as using htaccess. I am also interested in blocking direct access to the files, for instance if someone puts in their direct url they should not be retrievable, but instead php should give an error msg. If it's in a publicly accessible folder and only a php file to protect it, it won't work. Put the files in a non-public folder (outside the webroot) and get php to pipe them in. http://php.net/readfile or http://php.net/fpassthru will work for small files. For larger files you will need to use http://php.net/fread (specifically the loop example) so you don't blow out memory. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php