diff options
| author | Darkelarious <darkelarious@333networks.com> | 2021-10-17 19:22:40 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2021-10-17 19:22:40 +0200 |
| commit | 690e8f4e4522b69b5963689bc96e9ac9507a0100 (patch) | |
| tree | 118e1267da328dff3e0fd8e7cf32b7456e0ea221 /lib/MasterWebInterface | |
| parent | 68ac0baa0e8c19a49e50c1c8753579028141b10c (diff) | |
| download | WebInterface-Perl-690e8f4e4522b69b5963689bc96e9ac9507a0100.tar.gz WebInterface-Perl-690e8f4e4522b69b5963689bc96e9ac9507a0100.zip | |
additional Json API support
Diffstat (limited to 'lib/MasterWebInterface')
| -rwxr-xr-x | lib/MasterWebInterface/Database/Servers.pm | 6 | ||||
| -rwxr-xr-x | lib/MasterWebInterface/Handler/Json/JsonServerList.pm | 16 | ||||
| -rwxr-xr-x | lib/MasterWebInterface/Util/BrowseHTML.pm | 1 |
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/MasterWebInterface/Database/Servers.pm b/lib/MasterWebInterface/Database/Servers.pm index a305ce8..f9ad636 100755 --- a/lib/MasterWebInterface/Database/Servers.pm +++ b/lib/MasterWebInterface/Database/Servers.pm @@ -17,11 +17,13 @@ sub dbServerListGet { my %where = ( # gamename and char are "all" or value + $o{updated} ? ('dt_updated > ?' => (time-$o{updated})) : (), $o{gamename} !~ /all/ ? ('serverlist.gamename = ?' => $o{gamename}) : (), $o{nolist} ? ('serverlist.gamename <> ?' => $o{nolist}) : (), $o{search} ? ('LOWER(hostname) LIKE LOWER(?)' => "%$o{search}%") : (), - $o{gametype} ? ('LOWER(gametype) LIKE LOWER(?)' => $o{gametype}) : (), - $o{updated} ? ('dt_updated > ?' => (time-$o{updated})) : (), + $o{gametype} ? ('LOWER(gametype) LIKE LOWER(?)' => lc $o{gametype}) : (), + $o{popserv} ? ('numplayers > ?' => 0) : (), + $o{utdemo} ? ('gamever = ?' => '348') : (), ('hostport > ?' => 0), # sanity check (unresponsive servers or faulty queries tools) ); diff --git a/lib/MasterWebInterface/Handler/Json/JsonServerList.pm b/lib/MasterWebInterface/Handler/Json/JsonServerList.pm index ecd6c36..7781d94 100755 --- a/lib/MasterWebInterface/Handler/Json/JsonServerList.pm +++ b/lib/MasterWebInterface/Handler/Json/JsonServerList.pm @@ -16,10 +16,8 @@ TUWF::register( ################################################################################ sub serverlist_json { - my($self, $gamename, $char) = @_; + my($self, $gamename) = @_; $gamename = "all" unless $gamename; - - # TODO DEPRECATE $char # sorting, page my $f = $self->formValidate( @@ -59,6 +57,12 @@ sub serverlist_json default => '', maxlength => 90 }, + { + get => 'a', + required => 0, + default => '', + maxlength => 200 + }, ); return $self->resNotFound if $f->{_err}; @@ -71,7 +75,11 @@ sub serverlist_json page => $f->{p}, results => $f->{r}, updated => $self->{window_time}, - gametype => $f->{g}, # TODO: implement in DB query + gametype => $f->{g}, + + # parse extra request parameters like version, populated, etc + ($f->{a} =~ m/popserv/ig) ? (popserv => 1) : (), + ($f->{a} =~ m/utdemo/ig) ? (utdemo => 1) : (), ); # get total number of players diff --git a/lib/MasterWebInterface/Util/BrowseHTML.pm b/lib/MasterWebInterface/Util/BrowseHTML.pm index f32e088..0be45dd 100755 --- a/lib/MasterWebInterface/Util/BrowseHTML.pm +++ b/lib/MasterWebInterface/Util/BrowseHTML.pm @@ -27,7 +27,6 @@ sub htmlSearchBox fieldset class => 'search'; a href => '/g', $opt{sel} eq 'g' ? (class => 'sel') : (), 'Games'; a href => '/s', $opt{sel} eq 's' ? (class => 'sel') : (), 'Servers'; - #a href => '/json', $opt{sel} eq 'j' ? (class => 'sel') : (), 'Json API'; input type => 'text', name => 'q', id => 'q', class => 'text', value => $opt{fq} || 'search...'; input type => 'submit', class => 'submit', value => 'submit'; |
