diff options
| author | Darkelarious <darkelarious@333networks.com> | 2017-08-22 11:00:13 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2017-08-22 11:00:13 +0200 |
| commit | c06322da38b4cb76b2036af1a5448083adb8ff20 (patch) | |
| tree | 189c9f0fec3325be927f763aba23cf18aa68cfe4 /lib/MasterServer/Database/SQLite/dbAppletActions.pm | |
| parent | e0d727670cbeda0db0812c5c9efc503d75f8d0a4 (diff) | |
| download | MasterServer-Perl-c06322da38b4cb76b2036af1a5448083adb8ff20.tar.gz MasterServer-Perl-c06322da38b4cb76b2036af1a5448083adb8ff20.zip | |
new server checking mechanism, complete recode of major functionsv2.4.0
Diffstat (limited to 'lib/MasterServer/Database/SQLite/dbAppletActions.pm')
| -rwxr-xr-x | lib/MasterServer/Database/SQLite/dbAppletActions.pm | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/lib/MasterServer/Database/SQLite/dbAppletActions.pm b/lib/MasterServer/Database/SQLite/dbAppletActions.pm index d2421fc..1d9c975 100755 --- a/lib/MasterServer/Database/SQLite/dbAppletActions.pm +++ b/lib/MasterServer/Database/SQLite/dbAppletActions.pm @@ -3,7 +3,6 @@ package MasterServer::Database::SQLite::dbAppletActions; use strict; use warnings; use Exporter 'import'; - our @EXPORT = qw| add_master_applet update_master_applet reset_master_applets @@ -18,19 +17,20 @@ sub add_master_applet { my %o = @_; my $u = $self->{dbh}->do( - "SELECT * FROM appletlist - WHERE ip = ? - AND port = ? + "SELECT * FROM appletlist + WHERE ip = ? + AND hostport = ? AND gamename = ?", - undef, $o{ip}, $o{port}, lc $o{gamename}); + undef, $o{ip}, $o{hostport}, lc $o{gamename}); # return if found return if ($u > 0); # insert applet data - return $self->{dbh}->do("INSERT INTO appletlist (ip, port, gamename) - SELECT ?, ?, ?", undef, - $o{ip}, $o{port}, lc $o{gamename}); + return $self->{dbh}->do( + "INSERT INTO appletlist (ip, hostport, gamename) + SELECT ?, ?, ?", + undef, $o{ip}, $o{hostport}, lc $o{gamename}); } ################################################################################ @@ -38,10 +38,11 @@ sub add_master_applet { ################################################################################ sub reset_master_applets { my $self = shift; - return $self->{dbh}->do("UPDATE appletlist - SET added = datetime(?, \'unixepoch\'), - updated = datetime(?, \'unixepoch\')", - undef, time, time); + return $self->{dbh}->do( + "UPDATE appletlist + SET added = datetime(?, \'unixepoch\'), + updated = datetime(?, \'unixepoch\')", + undef, time, time); } ################################################################################ @@ -50,12 +51,13 @@ sub reset_master_applets { sub update_master_applet { my ($self, %o) = @_; - return $self->{dbh}->do("UPDATE appletlist - SET updated = datetime(?, \'unixepoch\') - WHERE ip = ? - AND port = ? + return $self->{dbh}->do( + "UPDATE appletlist + SET updated = datetime(?, \'unixepoch\') + WHERE ip = ? + AND hostport = ? AND gamename = ?", - undef, time, $o{ip}, $o{port}, lc $o{gamename}); + undef, time, $o{ip}, $o{hostport}, lc $o{gamename}); } ################################################################################ @@ -66,10 +68,10 @@ sub get_masterserver_applets { my $self = shift; return $self->db_all( - "SELECT * - FROM appletlist - WHERE updated > datetime(?, \'unixepoch\')", - time-604800); + "SELECT * + FROM appletlist + WHERE updated > datetime(?, \'unixepoch\')", + time-604800); } ################################################################################ @@ -82,11 +84,12 @@ sub remove_unresponsive_applets { # remove entries my $u = $self->{dbh}->do( - "DELETE FROM appletlist - WHERE updated < datetime(?, \'unixepoch\')", undef, time-604800); + "DELETE FROM appletlist + WHERE updated < datetime(?, \'unixepoch\')", + undef, time-604800); # notify - $self->log("delete", "Removed $u entries from applet list.") if ($u > 0); + $self->log("delete", "Removed $u entries from applet list") if ($u > 0); } 1; |
