]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
captive: Show a message when no coupon code was entered
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 May 2017 11:06:11 +0000 (12:06 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Sep 2017 17:56:04 +0000 (18:56 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
doc/language_issues.en
html/cgi-bin/captive/index.cgi
html/html/captive/template.html
langs/en/cgi-bin/en.pl

index a3cde91665cfbe34cb2757b0064392f604ca9fe1..ee4eb015192c14abbcce67b74f7d024b050a35ca 100644 (file)
@@ -14,6 +14,7 @@ WARNING: translation string unused: Captive invalid_voucher
 WARNING: translation string unused: Captive ip
 WARNING: translation string unused: Captive logo_set
 WARNING: translation string unused: Captive nr
+WARNING: translation string unused: Captive please enter a coupon code
 WARNING: translation string unused: Captive time
 WARNING: translation string unused: Captive voactive
 WARNING: translation string unused: Captive voucher
index 963b890e8c04a16742adb6b68541c3faf7950ff2..482ea9016be22118d6263907a34a67ad15f31040 100755 (executable)
@@ -78,36 +78,42 @@ if ($cgiparams{'ACTION'} eq "SUBMIT") {
        if ($settings{"AUTH"} eq "COUPON") {
                &General::readhasharray($coupons, \%couponhash);
 
-               # Convert coupon input to uppercase
-               $cgiparams{'COUPON'} = uc $cgiparams{'COUPON'};
+               if ($cgiparams{'COUPON'}) {
+                       # Convert coupon input to uppercase
+                       $cgiparams{'COUPON'} = uc $cgiparams{'COUPON'};
 
-               # Walk through all valid coupons and find the right one
-               my $found = 0;
-               foreach my $coupon (keys %couponhash) {
-                       if ($couponhash{$coupon}[1] eq $cgiparams{'COUPON'}) {
-                               $found = 1;
+                       # Walk through all valid coupons and find the right one
+                       my $found = 0;
+                       foreach my $coupon (keys %couponhash) {
+                               if ($couponhash{$coupon}[1] eq $cgiparams{'COUPON'}) {
+                                       $found = 1;
 
-                               # Copy expiry time
-                               $clientshash{$key}[3] = $couponhash{$coupon}[2];
+                                       # Copy expiry time
+                                       $clientshash{$key}[3] = $couponhash{$coupon}[2];
 
-                               # Save coupon code
-                               $clientshash{$key}[4] = $cgiparams{'COUPON'};
+                                       # Save coupon code
+                                       $clientshash{$key}[4] = $cgiparams{'COUPON'};
 
-                               # Copy coupon remark
-                               $clientshash{$key}[5] = $couponhash{$coupon}[3];
+                                       # Copy coupon remark
+                                       $clientshash{$key}[5] = $couponhash{$coupon}[3];
 
-                               # Delete used coupon
-                               delete $couponhash{$coupon};
-                               &General::writehasharray($coupons, \%couponhash);
+                                       # Delete used coupon
+                                       delete $couponhash{$coupon};
+                                       &General::writehasharray($coupons, \%couponhash);
 
-                               last;
+                                       last;
+                               }
+                       }
+
+                       if ($found == 1) {
+                               &General::log("Captive", "Internet access granted via coupon ($clientshash{$key}[4]) for $ip_address until $clientshash{$key}[3]");
+                       } else {
+                               $errormessage = $Lang::tr{"Captive invalid coupon"};
                        }
-               }
 
-               if ($found == 1) {
-                       &General::log("Captive", "Internet access granted via coupon ($clientshash{$key}[4]) for $ip_address until $clientshash{$key}[3]");
+               # No coupon given
                } else {
-                       $errormessage = $Lang::tr{"Captive invalid coupon"};
+                       $errormessage = $Lang::tr{"Captive please enter a coupon code"};
                }
 
        # License
index 504920c64f482b4a2ca89c6846b3a93081847ce6..a15c9a3ff378493d85eedddb71bdc8c08a674920 100644 (file)
@@ -38,7 +38,7 @@
                                                                <input type="hidden" name="url" value="<TMPL_VAR NAME="URL">">
 
                                                                <TMPL_IF NAME="COUPON">
-                                                                               <input class="form-text" type="text" name="COUPON">
+                                                                               <input class="form-text <TMPL_IF NAME="ERROR">error</TMPL_IF>" type="text" name="COUPON">
                                                                                <input class="form-submit" type="submit"
                                                                                        value="<TMPL_VAR NAME="L_ACTIVATE">">
                                                                <TMPL_ELSE>
                                                                                        value="<TMPL_VAR NAME="L_GAIN_ACCESS">">
                                                                </TMPL_IF>
 
+                                                               <TMPL_IF NAME="ERROR">
+                                                                       <p class="error">
+                                                                               <TMPL_VAR NAME="ERROR">
+                                                                       </p>
+                                                               </TMPL_IF>
+
                                                                <TMPL_IF NAME="TERMS">
                                                                        <div class="checkbox">
                                                                                <label>
-                                                                                       <input class="form-checkbox" type="checkbox">
+                                                                                       <input class="form-checkbox <TMPL_IF NAME="ERROR">error</TMPL_IF>" type="checkbox">
                                                                                        <TMPL_VAR NAME="L_AGREE_TERMS">
                                                                                </label>
                                                                        </div>
index e243f6bcb05bbfef0df66990dfab2e8a5fe1d649..f569f53b02f2064a96665d012443606b5f023a07 100644 (file)
@@ -42,6 +42,7 @@
 'Captive noexpiretime' => 'No valid connection time range given',
 'Captive nolimit' => 'unlimited',
 'Captive nr' => 'Number',
+'Captive please enter a coupon code' => 'Please enter a coupon code',
 'Captive terms' => 'Terms &amp; Conditions',
 'Captive terms short' => 'T&Cs',
 'Captive time' => 'Access time post activation (hours)',