PDA

View Full Version : Protecting a directory on the server.



mbenson111
03-09-2009, 07:31 PM
Hey guys,

I have a password protected directory for all of my php includes. That's fine, as php can still get at the files it needs.

I am wondering if there is a way to protect a directory, and allow javascript/Ajax to get in. I have some php scripts called through Ajax var url... calls that pass form variables for processing. I tried using the password protection through the file manager at Bluehost, but when the javascript calls the php file, it prompts for the login.

Any ideas or other suggestions would be greatly appreciated.

-Mike

felgall
03-09-2009, 07:37 PM
Have the ajax call a PHP script outside the password protection and use that to retrieve the pasword protected data.

mbenson111
03-09-2009, 08:12 PM
Have the ajax call a PHP script outside the password protection and use that to retrieve the pasword protected data.

Genius.. lol.. I would have never thought of that..

thanks.

wysiwyg
03-09-2009, 09:00 PM
Are you password-protecting it simply to prevent access from outside your scripts? Because you could just use folder permissions for that.

mbenson111
03-10-2009, 07:41 AM
Are you password-protecting it simply to prevent access from outside your scripts? Because you could just use folder permissions for that.

Ahh.. yes, that is the idea. I can use the file manager to do this as well, right?

What permissions would I use? Assuming Unix style, right?

Thanks for piping in.

wysiwyg
03-10-2009, 08:34 AM
Just uncheck everything for "world".

mbenson111
03-10-2009, 09:29 AM
Just uncheck everything for "world".

Thanks a lot. I will try that out.

-Mike

mbenson111
03-10-2009, 05:00 PM
I set the directory to 751, so that world can execute, but not read or write the directory directly.

Do you think that is sufficient?

wysiwyg
03-11-2009, 02:53 AM
If "world" has execute privileges, and knows the filepath, everyone can still access the file.

On a directory, execute means you can read/write/execute contents.

Read means to get a directory listing.