Remove unneeded file
[infodrom.org/service.infodrom.org] / src / changepasswd.wml
1 #include <maincolors.style>
2 #include <service.style>
3
4 <page title="Change your passwd" func="Main Menu">
5
6 <?
7   $htpasswd = "/etc/apache/.htpasswd";
8
9   function checkuser ($file, $user)
10   {
11     $f = fopen ($file, "r");
12     if ($f) {
13       while (!feof ($f)) {
14         $line = fgets ($f, 255);
15         $foo = explode (":", $line);
16
17         if (! strcmp($user, $foo[0])) {
18           fclose ($f);
19           return 1;
20         }
21       }
22       fclose ($f);
23     }
24     return 0;
25   }
26
27   function errmsg ($message, $help)
28   {
29     printf ("<p>%s.", $message);
30     if ($help) {
31       printf ("<p>Talk to Joey to find out what went wrong.", $message);
32     }
33   }
34
35 ?>
36
37 <? if ($REMOTE_USER) {
38      if (checkuser ($htpasswd, $REMOTE_USER)) {
39        if (strlen ($passwd) > 0 && strlen ($control) > 0) {
40          if (! strcmp ($passwd, $control)) {
41 ?>
42
43 <blockquote>
44
45 <p><strong>User</strong>: <? echo $REMOTE_USER ?>
46
47 <?
48   $passwd = escapeshellcmd($passwd);
49   $cmdline = sprintf ("htpasswd -b \"%s\" \"%s\" \"%s\"", $htpasswd, $REMOTE_USER, $passwd);
50   system ($cmdline);
51 ?>
52
53 <p><strong>Password changed</strong>
54
55 <p>You'll need to log in again.
56
57 </blockquote>
58
59 <?
60         } else {
61           errmsg ("You mistyped the passwd, please repeat.", 0);
62         }
63       } else {
64         errmsg ("Sorry, but empty passwords are not permitted.", 0);
65       }
66     } else {
67       errmsg ("Sorry, but the user is not registrated.", 1);
68     }
69   } else {
70     errmsg ("Sorry, but I cannot change the passwd for an invisible user.", 1);
71   }
72 ?>
73  
74 </page>
75
76 # Local variables:
77 # mode: indented-text
78 # mode: auto-fill
79 # end: