X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FInclude.pm;fp=NDWeb%2FInclude.pm;h=0000000000000000000000000000000000000000;hb=49c23244b1ba61909b726bb9189665a33027a1af;hp=5794b469c4eef5f9a1b7e7c9f239b3239c4039ec;hpb=8250eb360c341a4eeaa76e5e3fc0f57cf0014a60;p=ndwebbie.git diff --git a/NDWeb/Include.pm b/NDWeb/Include.pm deleted file mode 100644 index 5794b46..0000000 --- a/NDWeb/Include.pm +++ /dev/null @@ -1,91 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# This program is free software; you can redistribute it and/or modify * -# it under the terms of the GNU General Public License as published by * -# the Free Software Foundation; either version 2 of the License, or * -# (at your option) any later version. * -# * -# This program is distributed in the hope that it will be useful, * -# but WITHOUT ANY WARRANTY; without even the implied warranty of * -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -# GNU General Public License for more details. * -# * -# You should have received a copy of the GNU General Public License * -# along with this program; if not, write to the * -# Free Software Foundation, Inc., * -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -#**************************************************************************/ - -package NDWeb::Include; -use strict; -use warnings; -use CGI qw{:standard}; -require Exporter; -use BBCode::Parser; - -our @ISA = qw/Exporter/; - -our @EXPORT = qw/parseMarkup min max - alliances intelquery /; - -sub parseMarkup ($) { - my ($text) = @_; - - #$text =~ s{\n}{\n
}g; - #$text =~ s{\[B\](.*?)\[/B\]}{$1}gi; - #$text =~ s{\[I\](.*?)\[/I\]}{$1}gi; - #$text =~ s{\[url\](.*?)\[/url\]}{$1}gi; - #$text =~ s{\[PRE\](.*?)\[/PRE\]}{
$1
}sgi; - #$text =~ s{\[PRE\](.*?)\[/PRE\]}{
$1
}sgi; - #$1 =~ s{
}{}g; - - eval{ - my $tree = BBCode::Parser->DEFAULT->parse($text); - $text = $tree->toHTML; - }; - $text =~ s/\x{3}\d\d?//g; #mirc color TODO: possibly match until \x{0F} and change to [color] block - $text =~ s/[^\x{9}\x{A}\x{D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]//g; - return $text; -} - - -sub min { - my ($x,$y) = @_; - return ($x > $y ? $y : $x); -} - -sub max { - my ($x,$y) = @_; - return ($x < $y ? $y : $x); -} - - -sub alliances { - my ($alliance) = @_; - my @alliances; - $alliance = -1 unless defined $alliance; - push @alliances,{Id => -1, Name => '', Selected => not $alliance}; - my $query = $ND::DBH->prepare(q{SELECT id,name FROM alliances ORDER BY LOWER(name)}); - $query->execute; - while (my $ally = $query->fetchrow_hashref){ - push @alliances,{Id => $ally->{id}, Name => $ally->{name}, Selected => $alliance == $ally->{id}}; - } - return @alliances; -} - -sub intelquery { - my ($columns,$where) = @_; - return qq{ -SELECT $columns, i.mission, i.tick AS landingtick,MIN(i.eta) AS eta, i.amount, i.ingal, u.username -FROM (fleets i NATURAL JOIN users u) - JOIN current_planet_stats t ON i.target = t.id - JOIN current_planet_stats o ON i.sender = o.id -WHERE $where -GROUP BY i.tick,i.mission,t.x,t.y,t.z,o.x,o.y,o.z,i.amount,i.ingal,u.username,t.alliance,o.alliance,t.nick,o.nick -ORDER BY i.tick DESC, i.mission}; -} - - - -1;