I'm trying to write a php script that allows me to add users to our admin page (htaccess), and I'm having trouble with the crypt function.
If I go to the command line, and add a user with 'htpasswd userfile user' I can get in (when trying to access the protected directory via a web browser). If I add it with my php script, and do 'crypt ($password)' it doesn't work (I can't get in via the web).
If I take the first two characters of the encrypted password from the users file (as added by the 'htpasswd' program) and put it in $salt, and do the following:
crypt ($password, $salt);
I get the same exact value (password) as the one in the htaccess user file (perfect match).
I don't know how to get the correct $salt value to make the crypt work properly. Is there a correlation to the username and the $salt value that htpasswd uses, or is there some other pattern to it? Or do I need to configure apache?
I'm using Mandrake 8.2 w/ whatever apache came with it (1.3.x)
Does anyone have any ideas? I'd be very grateful if anyone might be able to help.
Thanks