25 use CGI; |
25 use CGI; |
26 use Ius::Dav::Htpasswd qw(mkpasswd readconfig useradd); |
26 use Ius::Dav::Htpasswd qw(mkpasswd readconfig useradd); |
27 |
27 |
28 my $q = new CGI; |
28 my $q = new CGI; |
29 |
29 |
30 print $q->header(-charset => 'UTF-8'); |
30 print $q->header( -charset => 'UTF-8' ); |
31 print $q->start_html( |
31 print $q->start_html( |
32 -title => $0, |
32 -title => $0, |
33 -bgcolor => "white", |
33 -bgcolor => "white", |
34 ); |
34 ); |
35 |
35 |
36 my ($user, $pass, $expiry) = ( |
36 my ( $user, $pass, $expiry ) = |
37 $q->param('user'), |
37 ( $q->param('user'), $q->param('pass'), $q->param('expiry') ); |
38 $q->param('pass'), |
|
39 $q->param('expiry') |
|
40 ); |
|
41 |
38 |
42 unless (defined $user or defined $pass or defined $expiry) { |
39 unless ( defined $user or defined $pass or defined $expiry ) { |
43 |
40 |
44 print $q->start_form, |
41 print $q->start_form, |
45 'New User' => $q->textfield('user'), |
42 'New User' => $q->textfield('user'), |
46 'Password' => $q->password_field('pass'), |
43 'Password' => $q->password_field('pass'), |
47 'Expiry' => $q->textfield('expiry'), |
44 'Expiry' => $q->textfield('expiry'), |
48 $q->submit, |
45 $q->submit, |
49 $q->end_form; |
46 $q->end_form; |
50 |
47 |
51 } else { |
48 } |
|
49 else { |
52 |
50 |
53 my @cmd = (qw(sudo ius-dav-htuseradd -u), $user); |
51 my @cmd = ( qw(sudo ius-dav-htuseradd -u), $user ); |
54 push @cmd, '-e', $expiry if defined $expiry and $expiry ne ''; |
52 push @cmd, '-e', $expiry if defined $expiry and $expiry ne ''; |
55 |
53 |
56 if (my $pass = qx(@cmd)) { |
54 if ( my $pass = qx(@cmd) ) { |
57 chomp $pass; |
55 chomp $pass; |
58 print $q->p($pass); |
56 print $q->p($pass); |
59 } else { |
57 } |
60 print $q->p('Something went wrong'); |
58 else { |
61 } |
59 print $q->p('Something went wrong'); |
62 |
|
63 } |
60 } |
64 |
61 |
65 print $q->end_html; |
62 } |
|
63 |
|
64 print $q->end_html; |