Peter,

You are correct - I did this last year:

 $strEncryptedPasswd = crypt($Password, "\0");
 $strUserInfo = $UserID.":".$strEncryptedPasswd."\n";

where $Password is the input password & $UserID is the user id.

Just read your .htpasswd file into an array and cycle through it writing out
each line in turn if the user id doesn't match the one you are changing and
write out your new line if it matches.

For a new one just append to the end of the file.

Don't profess to understand the "Salt" component of this but it works for me.

Chris Fry

Peter Dudley wrote:

> can you write directly to the password file using crypt() instead of trying
> to run the htpasswd program?  I think I used to do this in Perl, but it's
> been a LONG time since I tried it.  I think it worked, though.
>
> Pete.
> PS:  I'm also pretty sure that if you can't write direclty to the .htpasswd
> file, you can specify multiple password files in your .htaccess file, and
> you should be able to write to an alternative password file.
>
> ""YoBro"" <[EMAIL PROTECTED]> wrote in message
> 9e1okc$3de$[EMAIL PROTECTED]">news:9e1okc$3de$[EMAIL PROTECTED]...
> > The .htpasswd file lives in the root of my user account.
> > ie:
> >
> > [www] directory
> >  .htpasswd file
> >
> > It then goes:
> >
> > [www]
> >      |
> >      [public_html]
> >      [htocs]
> >           |
> >           All website content etc
> >
> > If I go beyond the www directory, I get a list of hundreds of directories
> > and files.
> > This is where I found the the htpasswd executable under
> >
> > /usr/local/bin
> >
> > Even if i define that path in my code it is still not working
> > The output of ls the root beyond www dir is far to much to put into this
> > message.
> >
> > Is that what you were asking, or am on the wrong track?
> >
> > YoBro
> >
> >
> >
> >
> > "MaD dUCK" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > also sprach YoBro (on Fri, 18 May 2001 10:45:12AM +1200):
> > > > If I try su nobody it asks for nobody's password. If i enter no
> > > > password a I get Authentication denied.
> > >
> > > you aren't root.
> > >
> > > can you give me an output of 'ls -l <path/to/.htpasswdfile>'
> > >
> > > martin;              (greetings from the heart of the sun.)
> > >   \____ echo mailto: !#^."<*>"|tr "<*> mailto:"; net@madduck
> > > --
> > > printer not ready.
> > > could be a fatal error.
> > > have a pen handy?
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW  2217
Australia

Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http://www.quillsoft.com.au

You can download our Public CA Certificate from:-
https://ca.secureanywhere.com/htdocs/cacert.crt

**********************************************************************

This information contains confidential information intended only for
the use of the authorised recipient.  If you are not an authorised
recipient of this e-mail, please contact Quillsoft Pty Ltd by return
e-mail.
In this case, you should not read, print, re-transmit, store or act
in reliance on this e-mail or any attachments, and should destroy all
copies of them.
This e-mail and any attachments may also contain copyright material
belonging to Quillsoft Pty Ltd.
The views expressed in this e-mail or attachments are the views of
the author and not the views of Quillsoft Pty Ltd.
You should only deal with the material contained in this e-mail if
you are authorised to do so.

This notice should not be removed.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to