X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FPages%2FAddIntel.pm;fp=NDWeb%2FPages%2FAddIntel.pm;h=01d28505919079799f19159358993d7f5ee81d40;hb=d6c9085e748c4d61901aaea72f0e1546dcc7cdda;hp=0000000000000000000000000000000000000000;hpb=ac65e241f748773959b94d66691ee93019fcae84;p=ndwebbie.git diff --git a/NDWeb/Pages/AddIntel.pm b/NDWeb/Pages/AddIntel.pm new file mode 100644 index 0000000..01d2850 --- /dev/null +++ b/NDWeb/Pages/AddIntel.pm @@ -0,0 +1,93 @@ +#************************************************************************** +# 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 ND::Web::Pages::AddIntel; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use ND::Web::Forum; +use ND::Web::Include; + +use base qw/ND::Web::XMLPage/; + +$ND::Web::Page::PAGES{addintel} = 'ND::Web::Pages::AddIntel'; + +sub render_body { + my $self = shift; + my ($BODY) = @_; + + my $DBH = $self->{DBH}; + + $self->{TITLE} = 'Add Intel and Scans'; + + my $error; + + return $self->noAccess unless $self->isMember; + + if (defined param('cmd')){ + if (param('cmd') eq 'submit' || param('cmd') eq 'submit_message'){ + my $findscan = $DBH->prepare("SELECT scan_id FROM scans WHERE scan_id = ? AND tick >= tick() - 168"); + my $addscan = $DBH->prepare('INSERT INTO scans (scan_id,tick,"type") VALUES (?,tick(),?)'); + my $addpoint = $DBH->prepare('UPDATE users SET scan_points = scan_points + 1 WHERE uid = ? '); + my $intel = param('intel'); + my @scans; + while ($intel =~ m/http:\/\/game.planetarion.com\/.+?scan(?:_id)?=(\d+)/g){ + my %scan; + $scan{Scan} = $1; + $scan{Message} = "Scan $1: "; + $findscan->execute($1); + if ($findscan->rows == 0){ + if ($addscan->execute($1,$ND::UID)){ + $addpoint->execute($ND::UID); + $scan{Message} .= 'added'; + }else{ + $scan{Message} .= "something went wrong: $DBH->errstr"; + } + }else{ + $scan{Message} .= 'already exists'; + } + push @scans,\%scan; + } + $BODY->param(Scans => \@scans); + my $tick = $self->{TICK}; + $tick = param('tick') if $tick =~ /^(\d+)$/; + my $addintel = $DBH->prepare(qq{SELECT add_intel(?,?,?,?,?,?,?,?,?,?,?)}); + while ($intel =~ m/(\d+):(\d+):(\d+)\*?\s+(\d+):(\d+):(\d+)\*?\s+.+(?:Ter|Cat|Xan|Zik|Etd)?\s+(\d+)\s+(Attack|Defend)\s+(\d+)/g){ + $addintel->execute($tick,$9, $1,$2,$3,$4,$5,$6,$7,$8,$ND::UID) or $error .= $DBH->errstr; + } + } + if (param('cmd') eq 'submit_message'){ + my $board = {id => 12}; + my $subject = param('subject'); + unless ($subject){ + if (param('intel') =~ /(.*\w.*)/){ + $subject = $1; + } + + } + if (my $thread = addForumThread $DBH,$board,$ND::UID,$subject){ + $error .= p 'Intel message added' if addForumPost $DBH,$thread,$ND::UID,param('intel') + } + } + } + $BODY->param(Tick => $self->{TICK}); + $BODY->param(Error => $error); + return $BODY; +} +1;