Apache secured folders from Php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Apache secured folders from Php

Post 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.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

if your storing the passwords in a MySQL database you can use the SHA('$password') in your INSERT query.

Wayne
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Sorry, I have submitted this by accident. Look at the next reply.

Sorry, again guys.
Last edited by user___ on Fri Apr 27, 2007 12:12 pm, edited 1 time in total.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

How do you access a file that is outside of the root folder?

Wayne
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post 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
Post Reply