]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Captive-Portal: add Errormessage when wrong code is entered
authorAlexander Marx <alexander.marx@ipfire.org>
Thu, 4 Feb 2016 12:26:35 +0000 (13:26 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Sep 2017 17:54:45 +0000 (18:54 +0100)
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
html/cgi-bin/captive/index.cgi

index 34908bd63c56b7ad5be4efdd52218838b021c2be..30fd055d8bf0b4d6bd7bd055971864d6297db6f0 100755 (executable)
@@ -85,7 +85,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'gpl i accept these terms and conditions'
 if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive activate'}"){
        my $ip_address;
        my $mac_address;
-
+       my $granted=0;
        #Convert voucherinput to uppercase
        $cgiparams{'VOUCHER'} = uc $cgiparams{'VOUCHER'};
        #Get Clients IP-Address
@@ -114,11 +114,16 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive activate'}"){
 
                        delete $voucherhash{$key};
                        &General::writehasharray("$voucherout", \%voucherhash);
+                       $granted=1;
                        last;
                }
        }
-       system("/usr/local/bin/captivectrl");
-       $redir=1;
+       if($granted==1){
+               system("/usr/local/bin/captivectrl");
+               $redir=1;
+       }else{
+               $errormessage="$Lang::tr{'Captive invalid_voucher'}";
+       }
 }
 
 if($redir == 1){
@@ -145,7 +150,7 @@ sub start(){
 
 sub error(){
        if ($errormessage){
-               print "<div id='title'><br>$errormessage<br></diV>";
+               print "<center><div class='title'><br><font color='red'>$errormessage</font><br></div><br>";
        }
 }
 
@@ -158,13 +163,13 @@ Content-type: text/html\n\n
                <title>$settings{'TITLE'}</title>
                <link href="../assets/captive.css" type="text/css" rel="stylesheet">
        </head>
+       <body>
 END
 ;
 }
 
 sub agb(){
 print<<END
-       <body>
        <center>
                <div class="title">
                        <h1>$settings{'TITLE'}</h1>
@@ -192,7 +197,6 @@ END
 
 sub voucher(){
        print<<END
-       <body>
        <center>
                <div class="title">
                        <h1>$settings{'TITLE'}</h1>