From: Michael Tremer Date: Fri, 21 Apr 2017 16:34:59 +0000 (+0100) Subject: captive-portal: Use template engine to render HTML template X-Git-Tag: v2.19-core115~60^2~51 X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=a2c26388dbc9cd388da37aa326bb9e6806d94f12 captive-portal: Use template engine to render HTML template Signed-off-by: Michael Tremer --- diff --git a/config/rootfiles/common/web-user-interface b/config/rootfiles/common/web-user-interface index dbf5a869f2..b755e6e7bb 100644 --- a/config/rootfiles/common/web-user-interface +++ b/config/rootfiles/common/web-user-interface @@ -96,6 +96,7 @@ srv/web/ipfire/html/blob.gif srv/web/ipfire/html/captive/assets/captive.css srv/web/ipfire/html/captive/assets/favicon.ico srv/web/ipfire/html/captive/assets/internet.png +srv/web/ipfire/html/captive/template.html srv/web/ipfire/html/clwarn.cgi srv/web/ipfire/html/dial.cgi srv/web/ipfire/html/favicon.ico diff --git a/html/cgi-bin/captive/index.cgi b/html/cgi-bin/captive/index.cgi index c3f9d035f4..71bff37a29 100755 --- a/html/cgi-bin/captive/index.cgi +++ b/html/cgi-bin/captive/index.cgi @@ -23,6 +23,7 @@ use strict; use CGI ':standard'; use URI::Escape; use HTML::Entities(); +use HTML::Template; # enable only the following on debugging purpose #use warnings; @@ -134,107 +135,25 @@ if($redir == 1){ } #Open HTML Page, load header and css -&head(); -&error(); -&start(); +my $tmpl = HTML::Template->new( + filename => "/srv/web/ipfire/html/captive/template.html", + die_on_bad_params => 0 +); -#Functions -sub start(){ - if ($settings{'AUTH'} eq 'VOUCHER'){ - &voucher(); - }else{ - &agb(); - } -} - -sub error(){ - if ($errormessage){ - print "

$errormessage

"; - } -} +$tmpl->param(REDIRECT_URL => $url); -sub head(){ -print< - - - $settings{'TITLE'} - - - -END -; -} +$tmpl->param(AUTH => $settings{'AUTH'}); +$tmpl->param(TITLE => $settings{'TITLE'}); +$tmpl->param(ERROR => $errormessage); -sub agb(){ -print< -
-

$settings{'TITLE'}

-
-
-
- -
-
-
-
-
-
-
- - -END -; -} +# Print header +print "Pragma: no-cache\n"; +print "Cache-control: no-cache\n"; +print "Connection: close\n"; +print "Content-type: text/html\n\n"; -sub voucher(){ - print< -
-

$settings{'TITLE'}

-
-
- -
-
- -

-
- - -END -; -} +# Print rendered template +print $tmpl->output; sub getcgihash { my ($hash, $params) = @_; diff --git a/html/html/captive/template.html b/html/html/captive/template.html new file mode 100644 index 0000000000..20b79198c2 --- /dev/null +++ b/html/html/captive/template.html @@ -0,0 +1 @@ +TEMPLATE GOES HERE