--- a/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 15:11:46 2011 +0200
+++ b/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 16:43:27 2011 +0200
@@ -46,8 +46,8 @@
-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') );
+my $p;
+$p->{$_} = $q->param($_) for qw(user expiry add del);
print $q->start_form(-id => 'passwd'),
$q->table(
@@ -67,54 +67,42 @@
$q->end_form;
my $doit = 0;
-for ($user, $pass, $expiry) { $doit = 1 and last if defined and $_ ne ''; }
-if ($doit) {
+my $conf = readconfig or die "Can't readconfig";
+
+if (defined $p->{add} and $p->{add} ne '') {
- my $conf = readconfig or die "Can't readconfig";
- my $add = $q->param('add');
- my $del = $q->param('del');
+ print $q->hr;
+ my @cmd = ( qw(sudo ius-dav-htuseradd -u), $p->{user} );
+ push @cmd, '-e', $p->{expiry} if defined $p->{expiry} and $p->{expiry} ne '';
- if ($add) {
+ 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}/$p->{user}";
- if ( my $pass = qx(@cmd) ) {
-
- my $url = "$conf->{dav_base_remote}/$user";
-
- chomp $pass;
+ 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)
- )
- );
+ 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) {
+ }
+ else {
+ print $q->p('Something went wrong');
+ }
- my @cmd = ( qw(sudo ius-dav-htuserdel -u), $user );
- print $q->hr, $q->p('Something went wrong') if system @cmd;
-
- } else {
+} elsif (defined $p->{del} and $p->{del} ne '') {
- # should not happen
- print $q->hr, $q->('Something went wrong');
-
- }
+ my @cmd = ( qw(sudo ius-dav-htuserdel -u), $p->{user} );
+ print $q->hr, $q->p('Something went wrong') if system @cmd;
}