]> ruin.nu Git - ndwebbie.git/commitdiff
Use ND::DB module instead of db.pl
authorMichael Andreen <harv@ruin.nu>
Sat, 12 Jan 2008 14:37:56 +0000 (15:37 +0100)
committerMichael Andreen <harv@ruin.nu>
Sat, 12 Jan 2008 14:37:56 +0000 (15:37 +0100)
scripts/fetchdumps.pl
scripts/ndrank.pl
scripts/parsedumps.pl
scripts/reset_hosts.pl
scripts/stats.pl
scripts/tick.pl

index efd124afc154c7688472c4e6219dab2ecace08e0..b8be1c36ca111561d5054337d18ecba75fc84b9b 100755 (executable)
@@ -27,17 +27,11 @@ use DBD::Pg qw(:pg_types);
 
 use LWP::Simple;
 
-$0 =~ /(.*\/)[^\/]/;
-my $dir = $1;
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
+use lib qw{/var/www/ndawn/};
+use ND::DB;
+
+our $dbh = ND::DB::DB();
+
 $dbh->do("SET CLIENT_ENCODING TO 'LATIN1';");
 
 my $insert = $dbh->prepare("INSERT INTO dumps(tick,type,modified,dump) VALUES(?,?,?,?)");
@@ -57,8 +51,8 @@ for my $type ("planet","alliance","galaxy"){
 }
 
 if ($updated){
-       `${dir}parsedumps.pl $updated`;
-       `${dir}ndrank.pl`;
+       `/var/www/ndawn/scripts/parsedumps.pl $updated`;
+       `/var/www/ndawn/scripts/ndrank.pl`;
        $dbh->do("UPDATE misc SET value = ? WHERE id = 'TICK'", undef, $updated);
 }
 
index cc7c12767e190b8681de3b72f44cdc663703998d..be8b1cc4f99f0cd084770c961984c97d1722290d 100755 (executable)
@@ -27,15 +27,10 @@ use DBD::Pg qw(:pg_types);
 
 use LWP::Simple;
 
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
+use lib qw{/var/www/ndawn/};
+use ND::DB;
+
+our $dbh = ND::DB::DB();
 
 $dbh->begin_work;
 my $st = $dbh->prepare(q{SELECT uid FROM current_planet_stats p JOIN users u ON p.id = u.planet WHERE alliance_id = 1 ORDER BY score DESC});
index f1738bf06efd7f54c9c916a08e6be40542250574..d22525fd87b776a83a393db456157ed97ac73507 100755 (executable)
@@ -30,17 +30,9 @@ use LWP::Simple;
 use lib qw{/var/www/ndawn/};
 
 use ND::Include;
+use ND::DB;
 
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
-#$dbh->trace("0","/tmp/parsedumps");
+our $dbh = ND::DB::DB();
 
 $ND::DBH = $dbh;
 
index 4932f051fd74e9005ec578047fea4f9633a026b1..a86ea3c6eb0959a63a32183984ecc346e7c6c2b0 100755 (executable)
@@ -6,18 +6,12 @@ use DBI;
 use DBD::Pg qw(:pg_types);
 
 use LWP::Simple;
+use lib qw{/var/www/ndawn/};
+use ND::DB;
 
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
+our $dbh = ND::DB::DB();
 
-$dbh->trace("0","/tmp/scanstest");
+#$dbh->trace("0","/tmp/scanstest");
 my $update = $dbh->prepare("UPDATE users SET hostmask = pnick || '.users.netgamers.org' where hostmask ilike '%.%' AND NOT hostmask ilike pnick || '.users.netgamers.org'");
 $update->execute();
 $dbh->disconnect;
index ad8fc0030f013edc9510f7c5b6c0e81e05ea1fed..bcac7fe8f81274b2d182b71b677db8728e64b436 100755 (executable)
@@ -26,18 +26,11 @@ use DBI;
 use DBD::Pg qw(:pg_types);
 
 use LWP::Simple;
+use lib qw{/var/www/ndawn/};
+use ND::DB;
+
+our $dbh = ND::DB::DB();
 
-$0 =~ /(.*\/)[^\/]/;
-my $dir = $1;
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
 $dbh->do("SET CLIENT_ENCODING TO 'LATIN1';");
 
 my %classes = (Fighter => 'Fi', Corvette => 'Co', Frigate => 'Fr', Destroyer => 'De', Cruiser => 'Cr', Battleship => 'Bs');
index bb652a875ab16a0528ad719831cf419dd8601918..6b97aa125445f78c3af359ff7c3f36d7a4a798a3 100755 (executable)
@@ -7,17 +7,11 @@ use DBD::Pg qw(:pg_types);
 
 use LWP::Simple;
 
-our $dbh;
-for my $file ("/home/whale/db.pl")
-{
-       unless (my $return = do $file){
-               warn "couldn't parse $file: $@" if $@;
-               warn "couldn't do $file: $!"    unless defined $return;
-               warn "couldn't run $file"       unless $return;
-       }
-}
+use lib qw{/var/www/ndawn/};
+use ND::DB;
+
+our $dbh = ND::DB::DB();
 
-$dbh->trace("0","/tmp/scanstest");
 my $update = $dbh->prepare("UPDATE misc SET value = value::int + 1 WHERE id = 'TICK'");
 $update->execute();
 $dbh->disconnect;