diff options
| author | Darkelarious <darkelarious@333networks.com> | 2016-11-19 20:56:04 +0100 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2016-11-19 20:56:04 +0100 |
| commit | c3f8d65a4fb1f5674557ee67cf7f74369df86ad1 (patch) | |
| tree | 92aab2a394bda28da0ed7c7c75e633fdf386fc71 /lib/MasterServer/Database/mysql/dbCiphers.pm | |
| parent | 1de3da4b8027508a91144639455c934fd6ccb9b7 (diff) | |
| download | MasterServer-Perl-c3f8d65a4fb1f5674557ee67cf7f74369df86ad1.tar.gz MasterServer-Perl-c3f8d65a4fb1f5674557ee67cf7f74369df86ad1.zip | |
Massive improvements on efficiency, robustness, security, reliability and more
Diffstat (limited to 'lib/MasterServer/Database/mysql/dbCiphers.pm')
| -rwxr-xr-x | lib/MasterServer/Database/mysql/dbCiphers.pm | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/lib/MasterServer/Database/mysql/dbCiphers.pm b/lib/MasterServer/Database/mysql/dbCiphers.pm deleted file mode 100755 index 31db78b..0000000 --- a/lib/MasterServer/Database/mysql/dbCiphers.pm +++ /dev/null @@ -1,98 +0,0 @@ - -package MasterServer::Database::mysql::dbCiphers; - -use strict; -use warnings; -use Exporter 'import'; - -our @EXPORT = qw| clear_ciphers - insert_cipher - get_cipher - get_default_port |; - -################################################################################ -## Clear all existing ciphers from the database -################################################################################ -sub clear_ciphers { - my $self = shift; - - # delete ALL entries - my $u = $self->{dbh}->do("DELETE FROM games"); - - # notify - $self->log("delete", "Removed all ciphers") if ($u > 0); - - # removed from games - return 2 if ($u > 0); - - # or else report notice - $self->log("notice", "No ciphers deleted!"); - return -1; - -} - -################################################################################ -## Insert the list of supported games and their ciphers / default ports / -## descriptions included from the data/supportedgames.pl file. -################################################################################ -sub insert_cipher { - my ($self, %opt) = @_; - - # insert a single cipher/key combo - my $u = $self->{dbh}->do( - "INSERT INTO games ( - gamename, - cipher, - description, - default_qport) - VALUES(?, ?, ?, ?)", undef, - $opt{gamename}, $opt{cipher}, $opt{description}, $opt{default_qport}); - - # notify - $self->log("add", "Added cipher for $opt{gamename}") if ($u and $u > 0); - return 1 if ($u and $u > 0); - - # or else report error - $self->log("error", "An error occurred adding a cipher for $opt{gamename}"); - return -1; - -} - - -################################################################################ -## get the cipher that goes with gamename -################################################################################ -sub get_cipher { - my ($self, $gn) = @_; - - # no gamename specified? "undef" is not a known cipher, so send that instead. - return 'undef' if !$gn; - - # get cipher from db if gamename exists - my $cipher = $self->{dbh}->selectall_arrayref( - 'SELECT cipher FROM games WHERE gamename = ?', undef, - lc $gn)->[0]->[0]; - - # return a non-zero-length string - return ($cipher ? $cipher : 'undef'); -} - -################################################################################ -## get the default query port that goes with gamename -################################################################################ -sub get_default_port { - my ($self, $gn) = @_; - - # no gamename specified? default port is 0 - return 0 if !$gn; - - # get port from db if gamename exists - my $p = $self->{dbh}->selectall_arrayref( - 'SELECT default_qport FROM games WHERE gamename = ?', undef, - lc $gn)->[0]->[0]; - - # return port or zero - return $p || 0; -} - -1; |
