--- a/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 15:11:04 2011 +0200
+++ b/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 15:11:46 2011 +0200
@@ -43,13 +43,13 @@
print $q->start_html(
-title => $0,
-style => { -code => $css },
- -onload => q{document.forms['add'].elements['user'].focus();}
-), $q->h3({ -id => 'header' }, 'Befristeten WebDAV Zugang einrichten'), $q->hr;
+ -onload => q{document.forms['passwd'].elements['user'].focus();}
+), $q->h3({ -id => 'header' }, 'Befristete WebDAV Zugänge einrichten'), $q->hr;
my ( $user, $pass, $expiry ) =
( $q->param('user'), $q->param('pass'), $q->param('expiry') );
-print $q->start_form(-id => 'add'),
+print $q->start_form(-id => 'passwd'),
$q->table(
$q->Tr(
$q->td('Nutzername'),
@@ -60,7 +60,8 @@
$q->td($q->textfield('expiry'))
),
$q->Tr(
- $q->td($q->submit('Anlegen'))
+ $q->td($q->submit({ -name => 'add', -value => 'Anlegen' })),
+ $q->td($q->submit({ -name => 'del', -value => 'Löschen' }))
)
),
$q->end_form;
@@ -71,29 +72,48 @@
if ($doit) {
my $conf = readconfig or die "Can't readconfig";
- my @cmd = ( qw(sudo ius-dav-htuseradd -u), $user );
- push @cmd, '-e', $expiry if defined $expiry and $expiry ne '';
+ my $add = $q->param('add');
+ my $del = $q->param('del');
+
+ if ($add) {
- print $q->hr;
- if ( my $pass = qx(@cmd) ) {
+ print $q->hr;
+ my @cmd = ( qw(sudo ius-dav-htuseradd -u), $user );
+ push @cmd, '-e', $expiry if defined $expiry and $expiry ne '';
- my $url = "$conf->{dav_base_remote}/$user";
+ if ( my $pass = qx(@cmd) ) {
- chomp $pass;
+ my $url = "$conf->{dav_base_remote}/$user";
+
+ chomp $pass;
- print $q->table(
- $q->Tr(
- $q->td('Url:'),
- $q->td($q->a({ -href => $url }, $url))
- ),
- $q->Tr(
- $q->td('Passwort:'),
- $q->td($pass)
- )
- )
- }
- else {
- print $q->p('Something went wrong');
+ print $q->table(
+ $q->Tr(
+ $q->td('Url:'),
+ $q->td($q->a({ -href => $url }, $url))
+ ),
+ $q->Tr(
+ $q->td('Passwort:'),
+ $q->td($pass)
+ )
+ );
+
+
+ }
+ else {
+ print $q->p('Something went wrong');
+ }
+
+ } elsif ($del) {
+
+ my @cmd = ( qw(sudo ius-dav-htuserdel -u), $user );
+ print $q->hr, $q->p('Something went wrong') if system @cmd;
+
+ } else {
+
+ # should not happen
+ print $q->hr, $q->('Something went wrong');
+
}
}