From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Marx To: development@lists.ipfire.org Subject: [PATCH] BUG11141: Redesign of configuration website Date: Thu, 07 Jul 2016 11:27:40 +0200 Message-ID: <1467883660-10425-1-git-send-email-alexander.marx@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1647807695648405835==" List-Id: --===============1647807695648405835== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To improve the user experience, the configuration part of generating new vouc= hers has been reworked. Signed-off-by: Alexander Marx --- html/cgi-bin/captive.cgi | 187 +++++++++++++++++++++------------------------= -- langs/de/cgi-bin/de.pl | 4 +- langs/en/cgi-bin/en.pl | 4 +- 3 files changed, 88 insertions(+), 107 deletions(-) diff --git a/html/cgi-bin/captive.cgi b/html/cgi-bin/captive.cgi index 50f4795..a8add4d 100755 --- a/html/cgi-bin/captive.cgi +++ b/html/cgi-bin/captive.cgi @@ -58,11 +58,6 @@ unless (-e $voucherout) { system("touch $voucherout"); } =20 #actions if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ - #Check Expiretime - if($cgiparams{'EXP_HOUR'}+$cgiparams{'EXP_DAY'}+$cgiparams{'EXP_WEEK'}+$cgi= params{'EXP_MONTH'} =3D=3D 0 && $cgiparams{'UNLIMITED'} =3D=3D ''){ - $errormessage=3D$Lang::tr{'Captive noexpiretime'}; - } - my $file =3D $cgiparams{'uploaded_file'}; if ($file){ #Check if extension is png @@ -76,11 +71,6 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ $settings{'ENABLE_GREEN'} =3D $cgiparams{'ENABLE_GREEN'}; $settings{'ENABLE_BLUE'} =3D $cgiparams{'ENABLE_BLUE'}; $settings{'AUTH'} =3D $cgiparams{'AUTH'}; - $settings{'EXPIRE'} =3D $cgiparams{'EXP_HOUR'}+$cgiparams{'EXP_DAY'}+$cg= iparams{'EXP_WEEK'}+$cgiparams{'EXP_MONTH'}; - $settings{'EXP_HOUR'} =3D $cgiparams{'EXP_HOUR'}; - $settings{'EXP_DAY'} =3D $cgiparams{'EXP_DAY'}; - $settings{'EXP_WEEK'} =3D $cgiparams{'EXP_WEEK'}; - $settings{'EXP_MONTH'} =3D $cgiparams{'EXP_MONTH'}; $settings{'TITLE'} =3D $cgiparams{'TITLE'}; $settings{'UNLIMITED'} =3D $cgiparams{'UNLIMITED'}; =20 @@ -108,14 +98,6 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ } } =20 - #saves the Captiveportal settings to disk - if ($cgiparams{'UNLIMITED'} eq 'on'){ - $cgiparams{'EXP_HOUR'} =3D '0'; - $cgiparams{'EXP_DAY'} =3D '0'; - $cgiparams{'EXP_WEEK'} =3D '0'; - $cgiparams{'EXP_MONTH'} =3D '0'; - } -=09 &General::writehash("$settingsfile", \%settings); =20 #write Licensetext if defined @@ -135,9 +117,22 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ } } =20 -if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive voucherout'}"){ +if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive genvoucher'}"){ #generates a voucher and writes it to /var/ipfire/voucher_out=09 =20 + #calculate expiredate + my $expire; + if ($settings{'UNLIMITED'} eq 'on'){ + $expire =3D $Lang::tr{'Captive nolimit'}; + }else{ + $settings{'EXPIRE'} =3D $cgiparams{'EXP_HOUR'}+$cgiparams{'EXP_DAY'}+$cgip= arams{'EXP_WEEK'}+$cgiparams{'EXP_MONTH'}; + $expire =3D sub{sprintf '%02d.%02d.%04d %02d:%02d', $_[3], $_[4]+1, $_[5]+= 1900, $_[2], $_[1] }->(localtime(time()+$settings{'EXPIRE'})); + } + + #Check Expiretime + if($cgiparams{'EXP_HOUR'}+$cgiparams{'EXP_DAY'}+$cgiparams{'EXP_WEEK'}+$cgi= params{'EXP_MONTH'} =3D=3D 0 && $cgiparams{'UNLIMITED'} =3D=3D ''){ + $errormessage=3D$Lang::tr{'Captive noexpiretime'}; + } #check if we already have a voucher with same code &General::readhasharray("$voucherout", \%voucherhash); foreach my $key (keys %voucherhash) { @@ -316,70 +311,6 @@ END print"$Lang::tr{'Captive logo_set'}"; print"
$Lang::tr{'no'}"; } - print"$Lang::tr{'Captive vouchervalid'}"; - print "
"; - print ""; - - #print hour-dropdownbox - my $hrs=3D3600; - print ""; - - print ""; - - print "
$Lang::tr{'hours'}$Lang::tr{'days'}$Lang::tr{'= weeks'}$Lang::tr{'months'}
"; - - #print day-dropdownbox - my $days=3D3600*24; - print ""; - - #print week-dropdownbox - my $week=3D3600*24*7; - print ""; - - #print month-dropdownbox - my $month=3D3600*24*30; - print "    $Lang::tr{'Captive nolimit'}
"; - print< @@ -431,27 +362,77 @@ sub gencode(){ =20 sub voucher(){ #show voucher part - #calculate expiredate - my $expire; - if ($settings{'UNLIMITED'} eq 'on'){ - $expire =3D $Lang::tr{'Captive nolimit'}; - }else{ - $expire =3D sub{sprintf '%02d.%02d.%04d %02d:%02d', $_[3], $_[4]+1, $_[5]+= 1900, $_[2], $_[1] }->(localtime(time()+$settings{'EXPIRE'})); - } - - &Header::openbox('100%', 'left', $Lang::tr{'Captive voucher'}); -print< - - - -END -; - + &Header::openbox('100%', 'left', $Lang::tr{'Captive genvoucher'}); + print ""; + print "
$Lang::tr{'Captive voucher'}$Lang::tr{'Captive expire'}$Lang::tr{'remark'}
"; + print ""; + print ""; + print "

$Lang::tr{'Captive vouchervalid'}

"; + + print ""; + print ""; + + #print hour-dropdownbox + my $hrs=3D3600; + print ""; + print ""; + print "
$Lang::tr{'hours'}$Lang::tr{'days'}$Lang::tr{= 'weeks'}$Lang::tr{'months'}
"; + + #print day-dropdownbox + my $days=3D3600*24; + print ""; + + #print week-dropdownbox + my $week=3D3600*24*7; + print ""; + + #print month-dropdownbox + my $month=3D3600*24*30; + print "    $Lang::tr{'Captive nolimit'}
"; + print "

$Lang::tr{'remark'}

 


"; $cgiparams{'CODE'} =3D &gencode(); - print "
$cgiparams{'CODE'}
$expire
"; - print "
"; - print "
"; + print "
"; + &Header::closebox(); if (! -z $voucherout) { &show_voucher_out();} if (! -z $clients) { &show_voucher_in_use();} diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 3b400f4..def1ae5 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -33,9 +33,9 @@ 'Captive time' =3D> 'Erlaubter Nutzungszeitraum nach Aktivierung (Stunden)', 'Captive title' =3D> 'Titel der Anmeldeseite', 'Captive voactive' =3D> 'Aktive Gutscheine', +'Captive genvoucher' =3D> 'Gutschein generieren', 'Captive voucher' =3D> 'Gutschein', -'Captive voucherout' =3D> 'Gutschein ausgeben', -'Captive vouchervalid' =3D> 'Verbindungszeitraum', +'Captive vouchervalid' =3D> 'Erlaubter Zeitraum f=C3=BCr Gutschein', 'Captive vout' =3D> 'Ausgegebene Gutscheine', 'Captive wrong ext' =3D> 'Die hochgeladene Datei hat den falschen Dateityp', 'Choose Rule' =3D> 'W=C3=A4hlen Sie eine der untenstehenden Regeln au= s.', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index c23470a..ace3f24 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -33,9 +33,9 @@ 'Captive time' =3D> 'Access time post activation (hours)', 'Captive title' =3D> 'Title of Login Page', 'Captive voactive' =3D> 'Active Vouchers', +'Captive genvoucher' =3D> 'Generate voucher', 'Captive voucher' =3D> 'Voucher', -'Captive voucherout' =3D> 'Ticket Transfer', -'Captive vouchervalid' =3D> 'Connection time range', +'Captive vouchervalid' =3D> 'Allowed time for this voucher', 'Captive vout' =3D> 'Issued Vouchers', 'Captive wrong ext' =3D> 'Uploaded file has wrong filetype', 'Choose Rule' =3D> 'Choose one of the following rules.', --=20 2.7.4 --===============1647807695648405835==--