jeg vil lige paste det selv....
I'm sorry, cooloj123.
After reading my post to myself, I guess it does sound a little crass. I wasn't trying to be a jerk or imply that you should award me the points for your question. I only meant that you would need another program that would accept commands passed from PHP and that somehting like exec() would not work with /usr/bin/passwd.
I do have something that may help you. passwd is going to ask you to enter your old password, enter a new password, and then confirm the new password - impossible with a single exec() command. This will allow you to do it without confirming anything:
root@Server:~# echo "username:newpassword" | chpasswd
Only problem: you have to be root to run it, which means that you are going to have to configure sudo to allow the web server user to run it as root also.
If you have sudo installed on your server and your webserver's user is in /etc/sudoers something like this might work:
exec('/path/to/sudo echo "username:newpassword" | chpasswd');
By default sudo will ask for user authentication, which means you have the same problem you would have with passwd. You can configure sudo to allow the webserver to run commands without authentication. In my opinion, this could be a huge security risk if other users on the system knew about this. Although you can limit the programs available to this user in the /etc/sudoers file, something like passwd or chpasswd is a pretty big risk.
I do not have sudo installed so I have not tested or verified any of the above. I do hope it helps though.
reference:
http://www.courtesan.com/sudo/man/sudo.htmlhttp://www.courtesan.com/sudo/man/sudoers.html#examplesP.S. This *might* be the right answer! :-)
[Source Experts Exchange LINK=http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20898421.html]