The following function can be included and then used to write a new user/pass for http digest authentication with apache.
| <?php
// update htpasswd file with user/pass function htpasswd($filename,$user,$pass) {
$pw=array();
if (file_exists($filename)) { foreach (file($filename) as $line) { $pair=explode(':',$line); $pw[$pair[0]]=chop($pair[1]); } }
$pw[$user]=crypt($pass,CRYPT_STD_DES);
$fp=fopen($filename,"w+"); while (list($u,$p)=each($pw)) fputs($fp,"$u:$p\n"); fclose($fp); }
?> |
|
|