From a41fe924aefb1237c546fdebb55a4fd4c13d580c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 28 Apr 2017 14:34:14 +0100 Subject: [PATCH] captive: Code cleanup No functional changes Signed-off-by: Michael Tremer --- html/cgi-bin/captive.cgi | 270 +++++++++++++++++++-------------------- 1 file changed, 131 insertions(+), 139 deletions(-) diff --git a/html/cgi-bin/captive.cgi b/html/cgi-bin/captive.cgi index 2d2c792ad9..10198721f4 100755 --- a/html/cgi-bin/captive.cgi +++ b/html/cgi-bin/captive.cgi @@ -215,175 +215,177 @@ if ($cgiparams{'ACTION'} eq 'delete-client') { &Header::openpage($Lang::tr{'Captive menu'}, 1, ''); &Header::openbigbox(); -#call error() to see if we have to print an errormessage on website -&error(); - -#call config() to display the configuration box -&config(); - -sub getterms(){ - my @ret; - - open(FILE, "<:utf8", "/var/ipfire/captive/terms.txt"); - while() { - push(@ret, HTML::Entities::decode_entities($_)); - } - close(FILE); - - return join(/\n/, @ret); +# If an error message exists, show a box with the error message +if ($errormessage) { + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print $errormessage; + &Header::closebox(); } -sub config(){ - #prints the config box on the website - &Header::openbox('100%', 'left', $Lang::tr{'Captive config'}); - print <\n +# Prints the config box on the website +&Header::openbox('100%', 'left', $Lang::tr{'Captive config'}); +print <\n END ; - #check which parameters have to be enabled (from settings file) - $checked{'ENABLE_GREEN'}{'off'} = ''; - $checked{'ENABLE_GREEN'}{'on'} = ''; - $checked{'ENABLE_GREEN'}{$settings{'ENABLE_GREEN'}} = "checked='checked'"; - $checked{'ENABLE_BLUE'}{'off'} = ''; - $checked{'ENABLE_BLUE'}{'on'} = ''; - $checked{'ENABLE_BLUE'}{$settings{'ENABLE_BLUE'}} = "checked='checked'"; +#check which parameters have to be enabled (from settings file) +$checked{'ENABLE_GREEN'}{'off'} = ''; +$checked{'ENABLE_GREEN'}{'on'} = ''; +$checked{'ENABLE_GREEN'}{$settings{'ENABLE_GREEN'}} = "checked='checked'"; - $checked{'UNLIMITED'}{'off'} = ''; - $checked{'UNLIMITED'}{'on'} = ''; - $checked{'UNLIMITED'}{$settings{'UNLIMITED'}} = "checked='checked'"; +$checked{'ENABLE_BLUE'}{'off'} = ''; +$checked{'ENABLE_BLUE'}{'on'} = ''; +$checked{'ENABLE_BLUE'}{$settings{'ENABLE_BLUE'}} = "checked='checked'"; - if ($netsettings{'GREEN_DEV'}){ - print ""; - } - if ($netsettings{'BLUE_DEV'}){ - print ""; - } +$checked{'UNLIMITED'}{'off'} = ''; +$checked{'UNLIMITED'}{'on'} = ''; +$checked{'UNLIMITED'}{$settings{'UNLIMITED'}} = "checked='checked'"; + +if ($netsettings{'GREEN_DEV'}){ + print ""; +} +if ($netsettings{'BLUE_DEV'}){ + print ""; +} print< - - - + + + - +print ""; + +print< + + END ; - if ($settings{'AUTH'} eq 'TERMS') { - $selected{'SESSION_TIME'} = (); - $selected{'SESSION_TIME'}{'0'} = ""; - $selected{'SESSION_TIME'}{'3600'} = ""; - $selected{'SESSION_TIME'}{'86400'} = ""; - $selected{'SESSION_TIME'}{'604800'} = ""; - $selected{'SESSION_TIME'}{'18144000'} = ""; - $selected{'SESSION_TIME'}{$settings{'SESSION_TIME'}} = "selected"; - - my $terms = &getterms(); - print < - - - - - - - - -END - } - print< - - +if ($settings{'AUTH'} eq 'TERMS') { + $selected{'SESSION_TIME'} = (); + $selected{'SESSION_TIME'}{'0'} = ""; + $selected{'SESSION_TIME'}{'3600'} = ""; + $selected{'SESSION_TIME'}{'86400'} = ""; + $selected{'SESSION_TIME'}{'604800'} = ""; + $selected{'SESSION_TIME'}{'18144000'} = ""; + $selected{'SESSION_TIME'}{$settings{'SESSION_TIME'}} = "selected"; + + my $terms = &getterms(); + print < + - + - + END +} - # Logo Upload - print < - - - +print< + + + + + + + + + + END - if (-e $logo) { - print < - - - +# Logo Upload +print < + + + END - } +if (-e $logo) { print < - - + + +END +} + +print < + + +
$Lang::tr{'Captive active on'} Green
$Lang::tr{'Captive active on'} Blue
$Lang::tr{'Captive active on'} Green
$Lang::tr{'Captive active on'} Blue
- $Lang::tr{'Captive authentication'} - -
+ $Lang::tr{'Captive authentication'} + +
- -
$Lang::tr{'Captive client session expiry time'} - -
-
- $Lang::tr{'Captive branding'} -
- $Lang::tr{'Captive title'} - - +
$Lang::tr{'Captive brand color'}$Lang::tr{'Captive client session expiry time'} - +
- $Lang::tr{'Captive logo_upload'} -
- $Lang::tr{'Captive logo_upload1'} -
- -
+
+ $Lang::tr{'Captive branding'} +
+ $Lang::tr{'Captive title'} + + +
$Lang::tr{'Captive brand color'} + +
$Lang::tr{'Captive logo uploaded'}$Lang::tr{'yes'}
+ $Lang::tr{'Captive logo_upload'} +
+ $Lang::tr{'Captive logo_upload1'} +
+ +
- - $Lang::tr{'Captive logo uploaded'}$Lang::tr{'yes'}
+ +
END - &Header::closebox(); +&Header::closebox(); - #if settings is set to use coupons, the coupon part has to be displayed - if ($settings{'AUTH'} eq 'COUPON'){ - &coupons(); - }else{ - #otherwise we show the licensepart - &show_license_connections(); +#if settings is set to use coupons, the coupon part has to be displayed +if ($settings{'AUTH'} eq 'COUPON') { + &coupons(); +} else { + #otherwise we show the licensepart + &show_license_connections(); +} + +sub getterms() { + my @ret; + + open(FILE, "<:utf8", "/var/ipfire/captive/terms.txt"); + while() { + push(@ret, HTML::Entities::decode_entities($_)); } + close(FILE); + + return join(/\n/, @ret); } sub gencode(){ @@ -623,15 +625,5 @@ sub validremark return 1; } -sub error{ - #if an errormessage exits, show a box with errormessage - if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage\n"; - print " \n"; - &Header::closebox(); - } -} - &Header::closebigbox(); &Header::closepage(); -- 2.39.5