if ($pasted ne "0") {
my ($player, $points, $koo) = ("", -1, "");
my $id;
foreach (split(/\n/, $pasted)) {
($player, $points, $koo) = ("", 0, "");
my $regex = Ogame::translate(/Nachricht_schreiben/);
if (/$regex/) {
# firefox:
#9 Giggel Nachricht schreiben Ratsmitglied 251235 2:280:11 - On
my @foo = split(/\t/);
($player, $points, $koo) = ($foo[1], $foo[4], $foo[5]);
# print 'found1 ($player, $points, $koo) ='." ($foo[1], $foo[4], $foo[5])
";
} elsif (/^\d+\t(.*)\t\t.*?\t\s*(\d+)\t\s*([0-9:]+)\s*\t/) {
# opera
#10 Julia Drohne 35098 7:88:4 2006-03-31 12:31:39 On
($player, $points, $koo) = ($1, $2, $3);
# print 'found2 ($player, $points, $koo) ='." ($1, $2, $3)
";
} elsif (/^\d+\s+(.*)\s+[\wü]+\s+(\d+)\s+(.*?)\s+/) {
($player, $points, $koo) = ($1, $2, $3);
# print 'found3 ($player, $points, $koo) ='." ($1, $2, $3)
";
}
if (($player ne "") && ($points > -1) && ($koo ne "")) {
$sth = $dbh->prepare("select id from $uni{'name'}_allymember where player=?;");
$sth->execute($player);
if ($sth->rows == 0) {
$sth = $dbh->prepare("insert into $uni{'name'}_allymember set player=?, koo=?;");
$sth->execute($player, $koo);
$sth = $dbh->prepare("select id from $uni{'name'}_allymember where player=?;");
$sth->execute($player);
print "new player: $player ($koo)
";
# print "
insert into $uni{'name'}_allymember set player='$player', koo='$koo'
";
}
$id = $sth->fetchrow_array;
$sth = $dbh->prepare("update $uni{'name'}_allymember set timestamp=NOW() where id=?;");
$sth->execute($id);
$sth = $dbh->prepare("select age from $uni{'name'}_allymember_points where player_id=? and age=?;");
$sth->execute($id, $age);
if ($sth->rows == 0) {
$sth = $dbh->prepare("insert into $uni{'name'}_allymember_points set player_id=?, points=?, age=?;");
$sth->execute($id, $points, $age);
} else {
$sth = $dbh->prepare("update $uni{'name'}_allymember_points set points=? where player_id=? and age=?;");
$sth->execute($points, $id, $age);
}
} else {
# print "Parse error: $_
";
}
}
}