--- a/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 12:53:04 2011 +0200
+++ b/cgi-bin/ius-dav-htuseradd.cgi Mon Jul 18 13:48:33 2011 +0200
@@ -25,35 +25,66 @@
use CGI;
use Ius::Dav::Htpasswd qw(mkpasswd readconfig useradd);
+my $css =<<EOC;
+body {
+ font-family: Helvetica, Arial, sans-serif;
+}
+h3#header {
+ background-color: #d60029;
+ color: #fff;
+ padding-top: 1em;
+ padding-bottom: 1em;
+}
+EOC
+
my $q = new CGI;
print $q->header( -charset => 'UTF-8' );
print $q->start_html(
-title => $0,
- -bgcolor => "white",
-);
+ -style => { -code => $css },
+ -onload => q{document.forms['add'].elements['user'].focus();}
+), $q->h3({ -id => 'header' }, 'Befristeten WebDAV Zugang einrichten'), $q->hr;
my ( $user, $pass, $expiry ) =
( $q->param('user'), $q->param('pass'), $q->param('expiry') );
-unless ( defined $user or defined $pass or defined $expiry ) {
+print $q->start_form(-id => 'add'),
+ $q->table(
+ $q->Tr(
+ $q->td('Nutzername'),
+ $q->td($q->textfield('user'))
+ ),
+ $q->Tr(
+ $q->td('Gültigkeitsdauer in Tagen (default: 1)'),
+ $q->td($q->textfield('expiry'))
+ ),
+ $q->Tr(
+ $q->td($q->submit('Anlegen'))
+ )
+ ),
+ $q->end_form;
- print $q->start_form,
- 'New User' => $q->textfield('user'),
- 'Password' => $q->password_field('pass'),
- 'Expiry' => $q->textfield('expiry'),
- $q->submit,
- $q->end_form;
+my $doit = 0;
+for ($user, $pass, $expiry) { $doit = 1 and last if defined and $_ ne ''; }
-}
-else {
-
+if ($doit) {
my @cmd = ( qw(sudo ius-dav-htuseradd -u), $user );
push @cmd, '-e', $expiry if defined $expiry and $expiry ne '';
+ print $q->hr;
if ( my $pass = qx(@cmd) ) {
chomp $pass;
- print $q->p($pass);
+ print $q->table(
+ $q->Tr(
+ $q->td('Url:'),
+ $q->td('not yet implemented')
+ ),
+ $q->Tr(
+ $q->td('Passwort:'),
+ $q->td($pass)
+ )
+ )
}
else {
print $q->p('Something went wrong');
@@ -61,4 +92,4 @@
}
-print $q->end_html;
+print $q->hr, $q->end_html;