note 41231 added to function.shell-exec
| From: | Jan dot besssai at gmx dot de | Date: | Sat, 03 Apr 2004 13:50:51 +0000 |
| Subject: | note 41231 added to function.shell-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67560@lists.php.net to get a copy of this message | ||
Here is a safe way to create .htpasswd files for .htacces:
<?
//first you need $pas (password), $nam (name) and $fname
//(filename)
if ($pas != "" && $nam!="" && $fname!="")
{
$stdout = shell_exec('htpasswd -n -b -m ' .$nam .' ' .$pas); //starts the
htpasswd and outputs the content of the new .passwd file (don't forget to edit the position of
the htpasswd executable)
$file = fopen($fname, "a") or
die ("Can't Open File!!");
fwrite($file, $stdout);
fclose($file);
}
else {
echo "Missing Parameters!";
}
?>
This way to do it seems to be strange but it is the only way that really worked for me under Win2k3.
You can't let htpasswd generate the .htpasswd file directly with windows because programms
started by programms started by apache don't have full write-access.
----
Manual Page -- http://www.php.net/manual/en/function.shell-exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41231
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41231&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41231&report=yes
Search -- http://master.php.net/manage/user-notes.php