Implement session cookie
This commit is contained in:
parent
f2c8b04d88
commit
3fecb71e1e
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -42,3 +42,6 @@ inc/
|
||||||
/.mmCreds.xml
|
/.mmCreds.xml
|
||||||
/.msg.bans
|
/.msg.bans
|
||||||
/.name.bans
|
/.name.bans
|
||||||
|
|
||||||
|
# Conf file
|
||||||
|
/www-swagg.conf
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
<link rel="stylesheet" type="text/css" href="/css/swagg.css">
|
<link rel="stylesheet" type="text/css" href="/css/swagg.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Import jQuery -->
|
|
||||||
<script src="/js/jquery.js"></script>
|
|
||||||
<script src="/js/jquery.cookie.js"></script>
|
|
||||||
<!-- Soundtrack -->
|
<!-- Soundtrack -->
|
||||||
<!-- <embed> doesn't work anymore SAD
|
<!-- <embed> doesn't work anymore SAD
|
||||||
<embed src="/misc/Smashmouth_-_All_Star.mid" width="100%" height="60">-->
|
<embed src="/misc/Smashmouth_-_All_Star.mid" width="100%" height="60">-->
|
||||||
<audio id="soundtrack" src="/Music/Smashmouth-All-Star.mp3" preload="auto">
|
<audio id="soundtrack" src="/Music/Smashmouth-All-Star.mp3" preload="auto">
|
||||||
</audio>
|
</audio>
|
||||||
|
<% unless (session('banner') eq 'seen') { %>
|
||||||
<!-- "GDPR" banner -->
|
<!-- "GDPR" banner -->
|
||||||
<div id="gdpr">
|
<div id="gdpr">
|
||||||
<b>Notice:</b> This site uses kickass MIDI technology instead of cookies.
|
<b>Notice:</b> This site uses kickass MIDI technology instead of cookies.
|
||||||
|
@ -27,22 +25,15 @@
|
||||||
<script>
|
<script>
|
||||||
function closeIt() {
|
function closeIt() {
|
||||||
document.getElementById("gdpr").style.display = "none";
|
document.getElementById("gdpr").style.display = "none";
|
||||||
if ($.cookie("banner")) {
|
document.cookie = "banner=seen; max-age=300;";
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
document.cookie = "banner=seen";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function playIt() {
|
function playIt() {
|
||||||
document.getElementById("soundtrack").play();
|
document.getElementById("soundtrack").play();
|
||||||
closeIt();
|
closeIt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($.cookie("banner") === "seen") {
|
|
||||||
closeIt();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
<% } %>
|
||||||
<!-- Bonzi buddy -->
|
<!-- Bonzi buddy -->
|
||||||
<div id="bonzi">
|
<div id="bonzi">
|
||||||
<img alt="a purple gorilla" src="/Pictures/Bonzi_Buddy.png">
|
<img alt="a purple gorilla" src="/Pictures/Bonzi_Buddy.png">
|
||||||
|
@ -63,10 +54,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="outer">
|
<div class="outer">
|
||||||
<center>
|
<center>
|
||||||
<a href="/">Home <img alt="american flag" src="/Pictures/patriotic45.gif" height="16"></a> -
|
<a href="/">Home <img alt="american flag" src="/Pictures/patriotic45.gif"
|
||||||
|
height="16"></a> -
|
||||||
<a href="/me">Me <img alt="BSOD" src="/Pictures/bluscrn.gif"
|
<a href="/me">Me <img alt="BSOD" src="/Pictures/bluscrn.gif"
|
||||||
height="16"></a> -
|
height="16"></a> -
|
||||||
<a href="/news">News <img alt="update" src="/Pictures/updat4.gif"></a><br>
|
<a href="/news">News <img alt="update" src="/Pictures/updat4.gif"></a> -
|
||||||
|
<a href="https://blog.swagg.net">Web Log <img alt="book"
|
||||||
|
src="/Pictures/Simple_book.gif"
|
||||||
|
height="18">
|
||||||
|
</a><br>
|
||||||
<br>
|
<br>
|
||||||
</center>
|
</center>
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -78,7 +74,7 @@
|
||||||
<p>
|
<p>
|
||||||
<i>contact:</i>
|
<i>contact:</i>
|
||||||
<a href="mailto:swaggboi@slackware.uk">swaggboi@slackware.uk</a> -
|
<a href="mailto:swaggboi@slackware.uk">swaggboi@slackware.uk</a> -
|
||||||
<a href="https://eattherich.club/@swaggboi">Mastodon (@swaggboi)</a> -
|
<a href="https://eattherich.club/@swaggboi">Social (@swaggboi)</a> -
|
||||||
<a href="https://steamcommunity.com/id/danielbowling">Steam</a> -
|
<a href="https://steamcommunity.com/id/danielbowling">Steam</a> -
|
||||||
<a href="https://chat.swagg.net">Chat (Mattermost)</a>
|
<a href="https://chat.swagg.net">Chat (Mattermost)</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
27
www-swagg.pl
27
www-swagg.pl
|
@ -8,16 +8,33 @@ use Regexp::Common qw{net};
|
||||||
use Digest::SHA qw{sha1_hex};
|
use Digest::SHA qw{sha1_hex};
|
||||||
use Number::Format qw{format_number};
|
use Number::Format qw{format_number};
|
||||||
|
|
||||||
|
## Let's set some things up first ##
|
||||||
|
|
||||||
|
plugin 'Config';
|
||||||
|
|
||||||
# CGI scripts
|
# CGI scripts
|
||||||
plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi'];
|
plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi'];
|
||||||
plugin CGI => ['/cgi-bin/whoami' => './cgi-bin/whoami.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
|
# The main landing page; pass in the output of the fortune command
|
||||||
get '/' => sub {
|
get '/' => sub {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
my $count = format_number time; # Grab epoch and add commas
|
my $count = format_number time; # Grab epoch and add commas
|
||||||
my $fortune = `/usr/games/fortune` || `fortune` || "huh??\n";
|
my $fortune = `/usr/games/fortune` || `fortune` || "huh??\n";
|
||||||
|
|
||||||
|
$c->swaggSession();
|
||||||
|
|
||||||
$c->stash(
|
$c->stash(
|
||||||
count => $count,
|
count => $count,
|
||||||
fortune => $fortune
|
fortune => $fortune
|
||||||
|
@ -38,7 +55,7 @@ get '/ula6' => sub {
|
||||||
|
|
||||||
# Check the MAC
|
# Check the MAC
|
||||||
$mac = ($c->param('macaddr')) ? lc $c->param('macaddr') : '';
|
$mac = ($c->param('macaddr')) ? lc $c->param('macaddr') : '';
|
||||||
if ($mac =~ /$RE{'net'}{'MAC'}/) {
|
if ($mac =~ /$RE{net}{MAC}/) {
|
||||||
# Local vars for this bit
|
# Local vars for this bit
|
||||||
my (
|
my (
|
||||||
$binfield,
|
$binfield,
|
||||||
|
@ -75,6 +92,8 @@ get '/ula6' => sub {
|
||||||
$ula6 = $uniqueid . ':/48';
|
$ula6 = $uniqueid . ':/48';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$c->swaggSession();
|
||||||
|
|
||||||
$c->render(ula6 => $ula6);
|
$c->render(ula6 => $ula6);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,8 +102,12 @@ get '/:route' => sub {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
my $route = $c->stash('route');
|
my $route = $c->stash('route');
|
||||||
|
|
||||||
|
$c->swaggSession();
|
||||||
|
|
||||||
$c->render(template => $route);
|
$c->render(template => $route);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Send it
|
## Send it ##
|
||||||
|
|
||||||
|
app->secrets(app->config->{secrets}) || die $!;
|
||||||
app->start();
|
app->start();
|
||||||
|
|
Loading…
Reference in a new issue