diff options
| author | Darkelarious <darkelarious@333networks.com> | 2015-05-19 22:00:40 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2015-05-19 22:00:40 +0200 |
| commit | 2c7d62f38944f61e7eafea155c6128521d16aed9 (patch) | |
| tree | bd473e6fb9dbbf8e0fdc67b87f0a4ac251fada7b /lib/MasterServer/Database/SQLite/dbClientList.pm | |
| parent | 534626943a0a5e251e5465376f3de3fb71b25e91 (diff) | |
| download | MasterServer-Perl-2c7d62f38944f61e7eafea155c6128521d16aed9.tar.gz MasterServer-Perl-2c7d62f38944f61e7eafea155c6128521d16aed9.zip | |
Beta with support for Pg and SQLite
Diffstat (limited to 'lib/MasterServer/Database/SQLite/dbClientList.pm')
| -rwxr-xr-x | lib/MasterServer/Database/SQLite/dbClientList.pm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/MasterServer/Database/SQLite/dbClientList.pm b/lib/MasterServer/Database/SQLite/dbClientList.pm new file mode 100755 index 0000000..58c1392 --- /dev/null +++ b/lib/MasterServer/Database/SQLite/dbClientList.pm @@ -0,0 +1,45 @@ + +package MasterServer::Database::SQLite::dbClientList; + +use strict; +use warnings; +use Exporter 'import'; + +our @EXPORT = qw| get_gamenames + get_game_list |; + + +################################################################################ +## get a list of distinct gamenames currently in the database. it does not +## matter whether they are recent or old, as long as the game is currently in +## the database. +## +## returns: hashref of gamenames +################################################################################ +sub get_gamenames { + my $self = shift; + + return $self->{dbh}->selectall_arrayref( + "SELECT distinct gamename + FROM serverlist"); +} + +################################################################################ +## get the list of games of a certain $gamename, excluding the ones excempted +## via the blacklist +## only returns server addresses that are no more than 1 hours old +################################################################################ +sub get_game_list { + my ($self, $gamename) = @_; + + return $self->{dbh}->selectall_arrayref( + "SELECT ip, port + FROM serverlist + WHERE updated > datetime(CURRENT_TIMESTAMP, '-3600 seconds') + AND gamename = ? + AND NOT blacklisted", + undef, lc $gamename); +} + + +1; |
