X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fcaptive.cgi;h=113c29f412a7428507926f4129ede3ff565ea9a0;hp=629acaee2be4420322eb750f836298fff1567408;hb=ad1204e4eb397b4f7d10c3bdfa9214aa8c0a0575;hpb=f32174956eb8dc6d961c0fe09796e092b6846ae4 diff --git a/html/cgi-bin/captive.cgi b/html/cgi-bin/captive.cgi index 629acaee2b..113c29f412 100755 --- a/html/cgi-bin/captive.cgi +++ b/html/cgi-bin/captive.cgi @@ -34,6 +34,19 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +my %session_times = ( + 3600 => $Lang::tr{'one hour'}, + 14400 => $Lang::tr{'four hours'}, + 28800 => $Lang::tr{'eight hours'}, + 43200 => $Lang::tr{'twelve hours'}, + 86400 => $Lang::tr{'24 hours'}, + 604800 => $Lang::tr{'one week'}, + 1209600 => $Lang::tr{'two weeks'}, + 2592000 => $Lang::tr{'one month'}, + 31536000 => $Lang::tr{'one year'}, + 0 => "- $Lang::tr{'unlimited'} -", +); + my %selected = (); my $coupons = "${General::swroot}/captive/coupons"; @@ -129,12 +142,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { } } -if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupon'}") { - # Check expiry time - if ($cgiparams{'EXP_HOUR'} + $cgiparams{'EXP_DAY'} + $cgiparams{'EXP_WEEK'} + $cgiparams{'EXP_MONTH'} == 0 && $cgiparams{'UNLIMITED'} == '') { - $errormessage = $Lang::tr{'Captive noexpiretime'}; - } - +if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupons'}") { #check valid remark if ($cgiparams{'REMARK'} ne '' && !&validremark($cgiparams{'REMARK'})){ $errormessage=$Lang::tr{'fwhost err remark'}; @@ -142,7 +150,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupon'}") { if (!$errormessage) { # Remember selected values - foreach my $val (("UNLIMITED", "EXP_HOUR", "EXP_DAY", "EXP_WEEK", "EXP_MONTH")) { + foreach my $val (("SESSION_TIME", "COUNT", "REMARK")) { $settings{$val} = $cgiparams{$val}; } &General::writehash($settingsfile, \%settings); @@ -150,17 +158,10 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupon'}") { &General::readhasharray($coupons, \%couponhash) if (-e $coupons); my $now = time(); - # Calculate expiry time in seconds - my $expires = 0; - - if ($settings{'UNLIMITED'} ne 'on') { - $expires += $settings{'EXP_HOUR'}; - $expires += $settings{'EXP_DAY'}; - $expires += $settings{'EXP_WEEK'}; - $expires += $settings{'EXP_MONTH'}; - } + # Expiry time in seconds + my $expires = $settings{'SESSION_TIME'}; - my $count = $cgiparams{'COUNT'} || 1; + my $count = $settings{'COUNT'} || 1; while($count-- > 0) { # Generate a new code my $code = &gencode(); @@ -186,7 +187,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupon'}") { $couponhash{$key}[0] = $now; $couponhash{$key}[1] = $code; $couponhash{$key}[2] = $expires; - $couponhash{$key}[3] = $cgiparams{'REMARK'}; + $couponhash{$key}[3] = $settings{'REMARK'}; } # Save everything to disk @@ -317,12 +318,9 @@ END if ($settings{'AUTH'} eq 'TERMS') { $selected{'SESSION_TIME'} = (); - $selected{'SESSION_TIME'}{'0'} = ""; - $selected{'SESSION_TIME'}{'3600'} = ""; - $selected{'SESSION_TIME'}{'28800'} = ""; - $selected{'SESSION_TIME'}{'86400'} = ""; - $selected{'SESSION_TIME'}{'604800'} = ""; - $selected{'SESSION_TIME'}{'18144000'} = ""; + foreach my $session_time (keys %session_times) { + $selected{'SESSION_TIME'}{$session_time} = ""; + } $selected{'SESSION_TIME'}{$settings{'SESSION_TIME'}} = "selected"; print <$Lang::tr{'Captive client session expiry time'} END - #print hour-dropdownbox - my $hrs=3600; - print ""; - print ""; - for (my $i = 1; $i<8; $i++){ - my $exp_sec = $i * $days; - print ""; - } - print ""; - - #print week-dropdownbox - my $week=3600*24*7; - print ""; - print ""; - for (my $i = 1; $i<13; $i++){ - my $exp_sec = $i * $month; - print ""; - } + foreach my $session_time (sort { $a <=> $b } keys %session_times) { print < - - - - - + +END + } + + print < $Lang::tr{'remark'} - + + + + + $Lang::tr{'Captive generated coupon no'} + +
- - - +
END