From f84c4964bef5b1783f7797b30ce8a9a126eaccd0 Mon Sep 17 00:00:00 2001 From: swaggboi Date: Sun, 7 Mar 2021 20:44:58 -0500 Subject: [PATCH] Clean up some errors --- Dockerfile | 1 - cgi-bin/guest_mm.cgi | 4 ++-- www-swagg.pl | 34 ++++++++++------------------------ 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11d7806..9a1f51c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,6 @@ WORKDIR /opt COPY cgi-bin/ ./cgi-bin/ COPY public/ ./public/ COPY templates/ ./templates/ -COPY .counts . COPY .mmCreds.xml . COPY .msg.bans . COPY .name.bans . diff --git a/cgi-bin/guest_mm.cgi b/cgi-bin/guest_mm.cgi index 40103a7..3134eb6 100755 --- a/cgi-bin/guest_mm.cgi +++ b/cgi-bin/guest_mm.cgi @@ -139,14 +139,14 @@ sub params_in { # Parse the banned names list chomp(my @nameBan = <$nameBans>); for (@nameBan) { - last if $ban == 1; + last if $ban; $ban = 1 if $name =~ /$_/; } # Parse the banned phrases list chomp(my @thoughtCrime = <$thoughtCrimes>); for (@thoughtCrime) { - last if $ban == 1; + last if $ban; $ban = 1 if $message =~ /$_/; } diff --git a/www-swagg.pl b/www-swagg.pl index db20fa5..8c13818 100755 --- a/www-swagg.pl +++ b/www-swagg.pl @@ -6,30 +6,22 @@ use Mojolicious::Lite; use Regexp::Common qw{net}; use Digest::SHA qw{sha1_hex}; -use Fcntl qw{:flock :seek}; use Number::Format qw{format_number}; +# guest.cgi script +plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi']; + +# whoami.cgi script +plugin CGI => ['/cgi-bin/whoami' => './cgi-bin/whoami.cgi']; + # The main landing page; pass in the output of the fortune command get '/' => sub { my ($c) = @_; my $fortune = `/usr/games/fortune` || `fortune` || "huh??\n"; - my ($count, %serverSide); - - # Visitor counter ala the ol' count.cgi script - # TODO: clean up and variable-ize filehandles - open(IN,"+<.counts"); # Open it - flock(IN,LOCK_EX); # Lock the file (exclusive lock) - seek(IN,0,SEEK_SET); # Rewind it to the beginning - $count = ; # Read only the first line - $count = ++$count; # Increment counter - truncate(IN,0); # This erases the file to length=0 - seek(IN,0,SEEK_SET); # Rewind it to the beginning - print IN "$count\n"; # Write out the new count - close(IN); # Close the file. - $count = format_number($count); # Add commas + my $count = format_number time; # Grab epoch and add commas # Gather all our server-side stuff - %serverSide = ( + my %serverSide = ( count => $count, fortune => $fortune ); @@ -40,9 +32,6 @@ get '/' => sub { # Deprecation of IE page get '/die'; -# guest.cgi script -plugin CGI => ['/cgi-bin/guest' => './cgi-bin/guest_mm.cgi']; - get '/me'; get '/news'; @@ -55,10 +44,10 @@ get '/news'; # TODO: This ancient code could certainly be cleaned up get '/ula6' => sub { my ($c) = @_; - my $mac = lc $c->param('macaddr'); # Lower-case plz - my $ula6; + my ($mac, $ula6); # Check the MAC + $mac = ($c->param('macaddr')) ? lc $c->param('macaddr') : ''; if ($mac =~ /$RE{net}{MAC}/) { # Local vars for this bit my ( @@ -99,8 +88,5 @@ get '/ula6' => sub { $c->render(ula6 => $ula6); }; -# whoami.cgi script -plugin CGI => ['/cgi-bin/whoami' => './cgi-bin/whoami.cgi']; - # Send it app->start();