diff --git a/.gitignore b/.gitignore index 390239f..9f7c6bd 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ inc/ /.mmCreds.xml /.msg.bans /.name.bans + +# Conf file +/www-swagg.conf diff --git a/templates/layouts/swagg.html.ep b/templates/layouts/swagg.html.ep index 0df44b0..ef0d68c 100644 --- a/templates/layouts/swagg.html.ep +++ b/templates/layouts/swagg.html.ep @@ -7,14 +7,12 @@ - - - +<% unless (session('banner') eq 'seen') { %>
Notice: This site uses kickass MIDI technology instead of cookies. @@ -27,22 +25,15 @@ +<% } %>
a purple gorilla @@ -63,10 +54,15 @@
- Home american flag - + Home american flag - Me BSOD - - News update
+ News update - + Web Log book +


@@ -78,7 +74,7 @@

contact: swaggboi@slackware.uk - - Mastodon (@swaggboi) - + Social (@swaggboi) - Steam - Chat (Mattermost)

diff --git a/www-swagg.pl b/www-swagg.pl index b758b1b..41e3597 100755 --- a/www-swagg.pl +++ b/www-swagg.pl @@ -8,16 +8,33 @@ use Regexp::Common qw{net}; use Digest::SHA qw{sha1_hex}; use Number::Format qw{format_number}; +## Let's set some things up first ## + +plugin 'Config'; + # CGI scripts plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi']; plugin CGI => ['/cgi-bin/whoami' => './cgi-bin/whoami.cgi' ]; +# Handle the GDPR non-compliance banner via session cookie +helper swaggSession => sub { + my ($c) = @_; + + if ($c->cookie('banner') eq 'seen') { + $c->session->{banner} = 'seen' unless $c->session->{banner} + } +}; + +## Begin routes ## + # The main landing page; pass in the output of the fortune command get '/' => sub { my ($c) = @_; my $count = format_number time; # Grab epoch and add commas my $fortune = `/usr/games/fortune` || `fortune` || "huh??\n"; + $c->swaggSession(); + $c->stash( count => $count, fortune => $fortune @@ -38,7 +55,7 @@ get '/ula6' => sub { # Check the MAC $mac = ($c->param('macaddr')) ? lc $c->param('macaddr') : ''; - if ($mac =~ /$RE{'net'}{'MAC'}/) { + if ($mac =~ /$RE{net}{MAC}/) { # Local vars for this bit my ( $binfield, @@ -75,6 +92,8 @@ get '/ula6' => sub { $ula6 = $uniqueid . ':/48'; } + $c->swaggSession(); + $c->render(ula6 => $ula6); }; @@ -83,8 +102,12 @@ get '/:route' => sub { my ($c) = @_; my $route = $c->stash('route'); + $c->swaggSession(); + $c->render(template => $route); }; -# Send it +## Send it ## + +app->secrets(app->config->{secrets}) || die $!; app->start();