Page 1 of 1

Apache secured folders from Php

Posted: Fri Apr 27, 2007 6:27 am
by user___
Hi guys,
I am running Apache Server and I have some secured folders(Secured with passwords and usernames) but I have to update their passwords permanently from php and I do not know how to crypt the passwords. I used a Web-Site which did this for me but now I need to do this from Php.

How to do this?

BTW:I use a remote server and I do not have any access to the Apache configuration file. I know about the apache tool which can be used to solve the problem above but I have not access to it. I need to do it in Php.

Posted: Fri Apr 27, 2007 9:44 am
by guitarlvr
if your storing the passwords in a MySQL database you can use the SHA('$password') in your INSERT query.

Wayne

Reply

Posted: Fri Apr 27, 2007 12:07 pm
by user___
Sorry, I have submitted this by accident. Look at the next reply.

Sorry, again guys.

Reply

Posted: Fri Apr 27, 2007 12:08 pm
by user___
No , I do not. Actually, I save them in a password on the level of the root dir so they are not reachable from Web.

Do you know how to solve this?

Posted: Fri Apr 27, 2007 12:11 pm
by Chris Corbyn
You need to make the files writable to apache, then from within PHP, exec() the command htpasswd with the relevant arguments. Google htpasswd, or check the apache documentation.

Posted: Fri Apr 27, 2007 12:16 pm
by guitarlvr
How do you access a file that is outside of the root folder?

Wayne

Reply

Posted: Fri Apr 27, 2007 12:27 pm
by user___
There is not problem for this. I just use "../" until I reach where I want to. For example if my root is like this:
+www//Web Root
+passwds

I can reach the passwds folder from www by using this:"../passwds/...".

I have found something on the Internet and I wonder whether it would do the job for me(I t does it on my local host but my application must beportable and it is supposed to run on many systems.).

Link:http://elonen.iki.fi/code/misc-notes/ht ... passwd.inc