3 /***************************************************************************
4 * Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
27 use DBD::Pg qw(:pg_types);
29 use LWP::Simple qw/head get $ua/;
30 $ua->agent("Stupid user agent check is stupid");
33 use lib "$FindBin::Bin/../lib";
37 our $dbh = ND::DB::DB();
39 my $insert = $dbh->prepare("INSERT INTO dumps(tick,type,modified,dump) VALUES(?,?,?,?)");
40 my $select = $dbh->prepare("SELECT 1 FROM dumps WHERE type = ? AND modified = ?");
42 for my $type ("planet","alliance","galaxy"){
43 my @head = head("http://game.planetarion.com/botfiles/${type}_listing.txt");
44 $select->execute($type,$head[2]);
45 unless ($select->fetchrow){
46 my $file = get("http://game.planetarion.com/botfiles/${type}_listing.txt");
47 if (defined $file && $file =~ /Tick: (\d+)/){
49 $insert->execute($1,$type,$head[2],$file);
56 system("$FindBin::Bin/parsetick.sh", $updated);
57 system("$FindBin::Bin/ndrank.pl");
58 $dbh->do(q{UPDATE misc SET value = ? WHERE id = 'TICK'}, undef, $updated);
59 system 'killall','-USR1', 'ndbot.pl';
60 local $dbh->{Warn} = 0;