Multi-user authenticated file/directory browser

Posted on 2005-04-07
Last Modified: 2008-03-10
HI Folks.

I've been searching this and other sites... Here are aspects of the project:

1. Multiple directories for files for multiple users.
2. User logs in, can change password, add secret question / answer. (can do that part)
3. User then gets list of files in their directory (same as username) and can click on and view files. (rtf, pdf, zip files)
4. No cookies, must be session based since some on shared computers. (no problem with that)

Problems with approaches:

1. Tried .htaccess and .htpasswd and too complicated and cumbersome to set up and change.
2. Tried to find a way to get browser to grab file from dir above public_html but nothing worked (it would just show the code of the .rtf file instead of calling ms word)

I'm sure it's easier than it seems at this point!

Question by:ejoan
    LVL 1

    Expert Comment

    Since you mentioned .htaccess and .htpasswd I will assume you are running Apache, hopefully on a *nix box.  If this is the case you can see if mod_auth_mysql or other supported module for databases has been compiled in or can be added as a DSO.  This way you can use a database based authentication system, for password management and user authentication.  You will still need an .htaccess.

    A .htaccess file is about the only way you can absolutly secure a directory other than running a script to pull the file from outside the web root.

    You may want to look into .htaccess .htpasswd a little more, I have seen scripts out there before both PHP and PERL based that will manage the .htpasswd for you.

    Hope this helps...


    Author Comment

    Thanks for helping me to clarify. What I would really like is to store the docs outside the web root and serve them up. The password / db stuff is no sweat, just can't get the files to display. The .rtf file, for example keeps showing up the code instead of pulling up MS Word.
    LVL 1

    Expert Comment

    You may want to look into the header() function, and set the DocType, now this does mean you will have to set the differnet DocTypes for differnet requested files.  I don't have much experience in this area.


    Author Comment

    I tried that and it didn't work. Maybe I need some exact specs, but when I tried what people said it just gave the code. So, I did a post to get specifics.

    Author Comment

    Okay, here's the code that's not working:

    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$filename");
    header("Content-Transfer-Encoding: binary");
    $filename = $HTTP_POST_VARS['thefile'];
    $fp = fopen($filename, 'rb');

    It thinks the file being opened is the php file and so it doesn't know what program to use, instead of just opening it in MS Word like it should for an rtf  file.

    I verified and the filename / path is getting passed correctly.

    LVL 1

    Accepted Solution

    Have you seen this page?

    Specifically posts by:
         28-Dec-2004 05:17

         15-Mar-2005 09:47

    Basically the first post uses differnet Content-Types in the header for different document types and the second speaks with a bug in IE for compressed files.

    Hope this helps...


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now