1 #include <maincolors.style>
2 #include <service.style>
4 <page title="Change your passwd" func="Main Menu">
7 $htpasswd = "/etc/apache/.htpasswd";
9 function checkuser ($file, $user)
11 $f = fopen ($file, "r");
14 $line = fgets ($f, 255);
15 $foo = explode (":", $line);
17 if (! strcmp($user, $foo[0])) {
27 function errmsg ($message, $help)
29 printf ("<p>%s.", $message);
31 printf ("<p>Talk to Joey to find out what went wrong.", $message);
37 <? if ($REMOTE_USER) {
38 if (checkuser ($htpasswd, $REMOTE_USER)) {
39 if (strlen ($passwd) > 0 && strlen ($control) > 0) {
40 if (! strcmp ($passwd, $control)) {
45 <p><strong>User</strong>: <? echo $REMOTE_USER ?>
48 $passwd = escapeshellcmd($passwd);
49 $cmdline = sprintf ("htpasswd -b \"%s\" \"%s\" \"%s\"", $htpasswd, $REMOTE_USER, $passwd);
53 <p><strong>Password changed</strong>
55 <p>You'll need to log in again.
61 errmsg ("You mistyped the passwd, please repeat.", 0);
64 errmsg ("Sorry, but empty passwords are not permitted.", 0);
67 errmsg ("Sorry, but the user is not registrated.", 1);
70 errmsg ("Sorry, but I cannot change the passwd for an invisible user.", 1);