aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2021-09-05 20:49:38 +0200
committerDarkelarious <darkelarious@333networks.com>2021-09-05 20:49:38 +0200
commit153b89b5bc58eb239289698c3f483509911db20d (patch)
tree2d902f2e1bfb61b4af0c1b508dbb59f95bdc7de2 /lib
parent3470e2605595bf52b3ba07bf0b3886e5a61d3e06 (diff)
downloadWebInterface-Perl-153b89b5bc58eb239289698c3f483509911db20d.tar.gz
WebInterface-Perl-153b89b5bc58eb239289698c3f483509911db20d.zip
functional masterinterface with styles
Diffstat (limited to 'lib')
-rwxr-xr-xlib/MasterWebInterface/Database/Servers.pm2
-rwxr-xr-xlib/MasterWebInterface/Handler/ErrorPages.pm12
-rwxr-xr-xlib/MasterWebInterface/Handler/Games.pm2
-rwxr-xr-xlib/MasterWebInterface/Handler/Json/ApiDoc.pm437
-rwxr-xr-xlib/MasterWebInterface/Handler/ServInfo.pm261
-rwxr-xr-xlib/MasterWebInterface/Util/Layout.pm11
-rwxr-xr-xlib/SkinFile.pm67
7 files changed, 157 insertions, 635 deletions
diff --git a/lib/MasterWebInterface/Database/Servers.pm b/lib/MasterWebInterface/Database/Servers.pm
index d02bcd7..a305ce8 100755
--- a/lib/MasterWebInterface/Database/Servers.pm
+++ b/lib/MasterWebInterface/Database/Servers.pm
@@ -22,7 +22,7 @@ sub dbServerListGet {
$o{search} ? ('LOWER(hostname) LIKE LOWER(?)' => "%$o{search}%") : (),
$o{gametype} ? ('LOWER(gametype) LIKE LOWER(?)' => $o{gametype}) : (),
$o{updated} ? ('dt_updated > ?' => (time-$o{updated})) : (),
- ('hostport >= ?' => 0), # sanity check
+ ('hostport > ?' => 0), # sanity check (unresponsive servers or faulty queries tools)
);
my @select = ( qw| id ip hostport hostname serverlist.gamename country numplayers maxplayers maptitle mapname gametype dt_added label dt_updated| );
diff --git a/lib/MasterWebInterface/Handler/ErrorPages.pm b/lib/MasterWebInterface/Handler/ErrorPages.pm
index dc386fc..7a74355 100755
--- a/lib/MasterWebInterface/Handler/ErrorPages.pm
+++ b/lib/MasterWebInterface/Handler/ErrorPages.pm
@@ -57,14 +57,12 @@ sub handle500
br;
txt 'and will be fixed shortly. Please try again later.';
end;
- end;
- if ($self->debug)
- {
- div class => "code warning";
- txt $error;
- end;
- }
+ if ($self->debug)
+ {
+ p $error;
+ }
+ end;
end;
$self->htmlFooter;
}
diff --git a/lib/MasterWebInterface/Handler/Games.pm b/lib/MasterWebInterface/Handler/Games.pm
index bf50655..50e1d57 100755
--- a/lib/MasterWebInterface/Handler/Games.pm
+++ b/lib/MasterWebInterface/Handler/Games.pm
@@ -98,7 +98,7 @@ sub gamelist
}) : (),
header => [
['Release Title', 'label' ],
- ['Game', ''],
+ ['Game', 'gamename'],
['Servers', 'num_total' ],
],
row => sub
diff --git a/lib/MasterWebInterface/Handler/Json/ApiDoc.pm b/lib/MasterWebInterface/Handler/Json/ApiDoc.pm
deleted file mode 100755
index bbfe620..0000000
--- a/lib/MasterWebInterface/Handler/Json/ApiDoc.pm
+++ /dev/null
@@ -1,437 +0,0 @@
-package MasterWebInterface::Handler::Json::ApiDoc;
-use strict;
-use TUWF ':html';
-use Exporter 'import';
-use JSON;
-
-TUWF::register(
- qr{json} => \&json_docs,
-);
-
-################################################################################
-# Json Documentation
-# Documentation about the Json API
-################################################################################
-sub json_docs
-{
- my $self = shift;
- $self->htmlHeader(title => "Json API");
- $self->htmlSearchBox(title => "Servers", action => "/s", sel => 'j', fq => '');
-
- div class => "mainbox apidoc";
- div class => "header";
- h1 "Json API";
- p "333networks has a Json API. With this API, it is possible to obtain server lists and specific server information for your own banners, ubrowser or other application.";
- end;
-
- #
- # ToS
- #
-
- h2 "Permission & Terms of Use";
- p;
- txt "The following permissions and conditions are in effect for making use of the Json API: ";
- end;
-
- p "You are allowed to access our API with any application and/or script, self-made or not, to obtain our server lists and server information on the condition that somewhere, anywhere in your application or script you mention that the information is obtained from 333networks.";
-
- p "You are not allowed to flood the API with requests or query our API continuously or with a short interval. If you draw too much network traffic from 333networks, we consider this flooding and will terminate your ability to query our API. Server information is updated every 15 minutes, there is no point in requesting information at a faster rate as there will be no new information available.";
-
- p "Intended use: use the serverlist request to get show a list of all servers. After loading the list, your visitors/users can select a single server to display detailed information. Do NOT use the serverlist to immediately show detailed information for ALL servers, this causes a ludicrous amount of information requests and will get you excluded from our API. Not sure whether you are doing it right? Contact us!";
-
- #
- # use
- #
- h2 "Use";
- p "The Json API consists of three functions to query for information. The methods occur over HTTP and are presented as Json data. The first function requests the \"Message of the Day\", often used to make announcements about the game. The second method returns a list of servers and can be manipulated by gamename. The third method returns detailed server information for an individual server.";
-
-
- h2 "Message of the Day";
- p;
- txt "It is possible to pull announcements from the 333networks Json API with the ";
- span class => "code", "motd";
- txt " command. This command returns an html string with the current 333networks announcements for the selected ";
- span class => "code", "gamename";
- txt ". This string is suitable for direct JQuery's ";
- span class => "code", ".html()";
- txt " function. Additionally, it contains the amount of servers and players as described for the serverlist. This method can be used to announce service messages.";
- end;
-
- div class => "code";
- txt "$self->{site_url}/json/(.[\\w]{1,20})/motd";
- end;
-
-
- h2 "Serverlist";
- p "With the API you can pull a serverlist directly from the masterserver. The API applies the following regex to process your request:";
- div class => "code";
- txt "$self->{site_url}/json/(.[\\w]{1,20})";
- end;
- p;
- txt "In this regex, ";
- span class => "code", "(.[\\w]{1,20})";
- txt " refers to the ";
- span class => "ext", "gamename";
- txt ". This is the abbreviation that every game specifies in their masterserver protocol. A comprehensive list of gamenames is found on the ";
- a href => "/g/all", "games";
- txt " page by looking at the last part of the URL.";
- end;
-
- p;
- txt "It is also possible to provide ";
- span class => "code", "GET";
- txt " information in the url. Allowed options are:";
- end;
-
- ul;
- li;
- span class => "code", "s";
- txt " - sort by country, hostname, gametype, ip, hostport, numplayers and mapname.";
- end;
- li;
- span class => "code", "o";
- txt " - sorting order: 'a' for ascending and 'd' for descending.";
- end;
- li;
- span class => "code", "r";
- txt " - number of results. Defaults to 50 if not specified. Minimum 1, maximum 1000.";
- end;
- li;
- span class => "code", "p";
- txt " - page. Show the specified page with results. Total number of entries is included in the result.";
- end;
- li;
- span class => "code", "q";
- txt " - search query. Identical to the search query on the ";
- a href => "/s", "servers";
- txt " page. Maximum query length is 90 characters.";
- end;
- end;
-
- #
- # list request format
- #
-
- h2 "Serverlist request examples:";
- p;
- txt "The following examples have different outcomes. In the first example, we request a serverlist of ";
- span class => "code", "all";
- txt " servers, regardless of type and/or name. The second example requests only servers of the game ";
- span class => "code", "Unreal";
- txt ". In the last example, we request a serverlist with the gamename ";
- span class => "code", "333networks";
- txt ", with only ";
- span class => "code", "2";
- txt " results per page, page ";
- span class => "code", "1";
- txt " and with the search word ";
- span class => "code", "master";
- txt ".";
- end;
-
- div class => "code";
- txt "$self->{site_url}/json/";
- span class => "ext", "all";
- br;
- txt "$self->{site_url}/json/";
- span class => "ext", "unreal";
- br;
- txt "$self->{site_url}/json/";
- span class => "ext", "333networks";
- txt "?r=";
- span class => "ext", "2";
- txt "&p=";
- span class => "ext", "1";
- txt "&q=";
- span class => "ext", "master";
- end;
-
- h2 "Serverlist result examples:";
- p "The API returns Json data in the following format, using the third request as an example. This is example data and may vary from what you receive when performing the same query.";
-
- div class => "code";
- pre json_result_1();
- end;
-
- p;
- txt "The result contains an array of server entries and the ";
- span class => "code", "total";
- txt " amount of entries. In this case, that is ";
- span class => "code", "2";
- txt " entries listed and ";
- span class => "code", "5";
- txt " total entries, implying that there is one more server not shown or on a next page. With the specified number of results specified by the user and the total amount of servers provided by the API, you can calculate how many pages there are to be specified. If applicable, it also shows the current number of ";
- span class => "code", "players";
- txt " that are currently in the selected servers. Every server entry has a number of unsorted keywords. Timestamps are linux epoch, in UTC.";
- end;
-
- p "The available keywords that are returned by the API are: ";
- div class => "code", join (" ", qw| id ip hostport hostname gamename label country numplayers maxplayers maptitle mapname gametype dt_added dt_updated|);
-
- p "There are more keywords available for individual servers. Detailed information about a server is obtained with the individual request as described below. Keywords of both requests are described in the tables below. ";
-
-
- h2 "Server details";
- p "Your application or script can also request detailed information for a single server. This is done in a similar way as requesting a server list. The following general regex is used by 333networks:";
-
- div class => "code";
- txt "$self->{site_url}/json/(.[\\w]{1,20})/([\\:\\.\\w]{9,35})";
- end;
-
- p;
- txt "This restricts requests to the correct url with a gamename ";
- span class => "code", "(.[\\w]{1,20})";
- txt " and an IP:port ";
- span class => "code", "([\\:\\.\\w]{9,35})";
- txt " for IPv4 and IPv6 addresses and numerical port number. There are no additional query options or GET options. It is possible that the gamename specified does not match the ";
- txt "gamename";
- txt " as stored in our database. The result will include the correct gamename that was specified in our database.";
- end;
-
- p "The following example requests detailed information by IP address and hostport.";
-
- #
- # individual server details request format
- #
-
- h3 "Server details request:";
- div class => "code";
- txt "$self->{site_url}/json/";
- span class => "ext", "333networks";
- txt "/";
- span class => "ext", "84.83.176.234";
- txt ":";
- span class => "ext", "28900";
- end;
-
- h3 "Server details result:";
- p "The API returns Json data in the following format, using the requests above as an example. This is example data and may vary from what you receive when performing the same query.";
-
- div class => "code";
- # snippet 1, below
- pre json_result_2();
- end;
-
- p "The result has a single entry of parameters with a number of unsorted keywords. The available keywords are in addition to the keywords are specified in multiple tables below.";
-
- p;
- txt "The player object ";
- span class => "code", "player_n";
- txt " represent the players in the server. This is a Json object as part of the larger object above. The available keywords are specified in the table below.";
- end;
-
- h2 "Keyword reference";
- p "Values, type and descriptions of fields that are returned by the Json API:";
-
- # generate reference tables
- json_database_ref();
-
- h2 "Feedback";
- p;
- txt "We wrote the Json API with the intention to make the 333networks masterserver data as accessible as possible. If you feel like any functionality is missing or incorrectly shared, do not hesitate to contact us to provide feedback. Additionally, we request that you follow the advise on usage as we described under the Terms of Use on top of this page, so we can keep providing this API.";
- end;
-
- end; # mainbox
- $self->htmlFooter(last_change => "May 2021");
-}
-
-# list of value / type / descriptions directly from database
-sub json_database_ref
-{
- my @keyval = (
- { title => "Server identifier information",
- table => [
- ["id", "int", "gameserver ID in list database"],
- ["sid", "int", "reference ID for detailed information"],
- ["ip", "text", "server IP address (in IPv6 format)"],
- ["queryport", "int", "UDP status query port"],
- ["hostport", "int", "hostport to join the server"],
- ["hostname", "text", "name of the specific server"],
- ["country", "text", "2-letter country code where the server is hosted"],
- ["location", "text", "GameSpy regional indication (continent index or 0 for world)"],
- ],
- },
- { title => "Server flags \& datetime",
- table => [
- ["f_protocol", "int", "protocol index to distinguish between GameSpy v0 and others"],
- ["f_blacklist", "int", "server blacklisted?"],
- ["f_auth", "int", "authenticated response to the secure/validate challenge?"],
- ["f_direct", "int", "direct beacon to the masterserver?"],
- ["dt_added", "long", "UTC epoch time that the server was added"],
- ["dt_beacon", "long", "UTC epoch time that the server sent a heartbeat"],
- ["dt_sync", "long", "UTC epoch time that the server was last synced from another masterserver"],
- ["dt_updated", "long", "UTC epoch time that the server information was updated"],
- ["dt_serverinfo", "long", "UTC epoch time that the detailed server information was updated"],
- ],
- },
- { title => "Gamedata",
- table => [
- # gamedata
- ["gamename", "text", "gamename of the server"],
- ["label", "text", "comprehensible game title associated with gamename"],
- ["gamever", "text", "game version of the server"],
- ["minnetver", "text", "minimal required game version to join"],
- ],
- },
- { title => "Game settings (detailed information)",
- table => [
- ["listenserver", "text", "dedicated server indication"],
- ["adminname", "text", "server administrator's name"],
- ["adminemail", "text", "server administrator's contact information"],
- ["password", "text", "passworded or non-public server"],
- ["gametype", "text", "type of game: capture the flag, deathmatch, assault and more"],
- ["gamestyle", "text", "in-game playing style"],
- ["changelevels", "text", "automatically change levels after match end"],
- ["mapurl", "text", "direct url of the map thumbnail relative from this site's domain"],
- ["mapname", "text", "filename of current map"],
- ["maptitle", "text", "title or description of current map"],
- ["minplayers", "int", "minimum number of players to start the game"],
- ["numplayers", "int", "current number of players"],
- ["maxplayers", "int", "maximum number of players simultaneously allowed on the server"],
- ["botskill", "text", "skill level of bots"],
- ["balanceteams", "text", "team balancing on join"],
- ["playersbalanceteams", "text", "players can toggle automatic team balancing"],
- ["friendlyfire", "text", "friendly fire rate"],
- ["maxteams", "text", "maximum number of teams"],
- ["timelimit", "text", "time limit per match"],
- ["goalteamscore", "text", "score limit per match"],
- ["fraglimit", "text", "score limit per deathmatch"],
- ["mutators", "text", "comma-separated mutator/mod list"],
- ["misc", "text", "miscellaneous server attributes (reserved)"],
- ["player_#", "text", "player information as Json object for player #, see table below"],
- ],
- },
- { title => "Player information",
- table => [
- ["sid", "int", "associated server ID (per player)"],
- ["name", "text", "player display name"],
- ["team", "text", "player indication as team number, color code or text string"],
- ["frags", "int", "number of frags or points"],
- ["mesh", "text", "player model / mesh"],
- ["skin", "text", "player body texture"],
- ["face", "text", "player facial texture"],
- ["ping", "int", "player ping"],
- ["misc", "text", "miscellaneous player attributes (reserved)"],
- ["dt_player", "long", "UTC epoch time that the player information was updated"],
- ],
- },
- );
-
-
- use Data::Dumper 'Dumper';
-
- for my $keytype (@keyval)
- {
- h3 $keytype->{title};
- table class => "keyval";
- Tr;
- th class => "tc1", "Value";
- th class => "tc2", "Type";
- th "Description";
- end;
-
- for my $r (@{$keytype->{table}})
- {
- my @tr = @{$r};
- Tr;
- td class => "tc1";
- span class => "code", $tr[0];
- end;
- td class => "tc2", $tr[1];
- td $tr[2];
- end;
- }
- end;
- }
-}
-
-# json output for example 1
-sub json_result_1
-{
- return '[
- [
- {
- "id":1990,
- "ip":"::ffff:84.83.176.234"
- "hostport":28900,
- "hostname":"master.333networks.com (333networks MasterServer)",
- "gamename":"333networks",
- "gametype":"MasterServer",
- "label":"333networks Masterserver",
- "country":"NL",
- "numplayers":15,
- "maxplayers":2966,
- "maptitle":null,
- "mapname":"333networks",
- "dt_added":1616895602,
- "dt_updated":1621019250,
- },
- {
- "id":1117,
- "ip":"::ffff:162.154.33.129",
- "hostport":28900
- "hostname":"master.gonespy.com",
- "gamename":"333networks",
- "gametype":"Masterserver",
- "label":"333networks Masterserver",
- "country":"US",
- "numplayers":5,
- "maxplayers":847,
- "maptitle":"",
- "mapname":"333networks",
- "dt_added":1616593343,
- "dt_updated":1621019247,
- }
- ],
- {
- "players":20,
- "total":5
- }
-]';
-}
-
-sub json_result_2
-{
- return '{
- "id":3,
- "ip":"::ffff:45.74.100.250",
- "hostport":10205,
- "mapname":"DXMP_iceworld2",
- "adminname":"Canna the visionary l Disciple Derp191 and RoninMastaFX",
- "hostname":"~Canna\'s Buddhist Server~",
- "mapurl":"/map/default/333networks.jpg",
- "gamever":"1100",
- "gametype":"CDX BDM",
- "gamename":"deusex",
- "country":"CA",
- "dt_updated":1621022768,
- "player_0":
- {
- "sid":3,
- "name":"Dark191",
- "team":"0",
- "frags":8,
- "mesh":"cmJCDenton",
- "skin":"None",
- "face":""
- "ping":63,
- "dt_player":1621022768,
- "misc":"",
- },
- "player_1":
- {
- "sid":3,
- "name":"Anya",
- "team":"0",
- "frags":12,
- "mesh":"cmJCDenton",
- "skin":"None",
- "face":""
- "ping":54,
- "dt_player":1621022768,
- "misc":"",
- },
- }';
-}
-
-1;
diff --git a/lib/MasterWebInterface/Handler/ServInfo.pm b/lib/MasterWebInterface/Handler/ServInfo.pm
index be30fd0..7dc5e55 100755
--- a/lib/MasterWebInterface/Handler/ServInfo.pm
+++ b/lib/MasterWebInterface/Handler/ServInfo.pm
@@ -16,7 +16,7 @@ TUWF::register(
# values as possible.
# Display error pages if not found or incorrect.
################################################################################
-sub show_server
+sub show_server
{
my ($self, $gamename, $s_addr) = @_;
@@ -96,10 +96,35 @@ sub show_server
# serverinfo box
div class => "mainbox detail";
-
div class => "header";
+ # server data flags in header (not country flags)
+ div class => "serverflags";
+
+ # uplink or manually added/through applet
+ if ( $info->{f_direct} )
+ { div class => "direct", title => "This server uplinks directly to $self->{site_name}.", ""; }
+ else
+ { div class => "manual", title => "This server was added through master synchronisation and does not uplink to $self->{site_name}.", ""; }
+
+ # authenticated through secure/validate
+ if ( $info->{f_auth} )
+ { div class => "authed", title => "This server authenticated through the secure/validate challenge.", ""; }
+ else
+ { div class => "noauthed", title => "This server failed the secure/validate challenge or did not reply.", ""; }
+
+ # server blacklisted?
+ if ( $info->{f_blacklist} )
+ { div class => "blacklist", title => "This server is blacklisted for violating the $self->{site_name} Terms of Use or by request from the administrator.", ""; }
+ else
+ { div class => "noblacklist", title => "This server is not blacklisted by $self->{site_name}.", ""; }
+
+ if ( $info->{passworded} and $info->{passworded} =~ /(true|1)/i )
+ { div class => "passwd", title => "This server requires a password to join.", ""; }
+ else
+ { div class => "nopasswd", title => "This server is accessible for everybody.", "";}
+ end;
h1 title => $info->{hostname} // "[unnamed $gamename server]",
- $info->{hostname} // "[unnamed $gamename server]";
+ $info->{hostname} // "[unnamed $gamename server]";
end;
#
@@ -143,36 +168,31 @@ sub show_server
span $maptitle;
end;
- table class => "mapinfo";
- # numplayer field
- Tr;
- td class => "wc1", "Players:";
- td;
- txt $info->{numplayers} // 0;
- txt "/";
- txt $info->{maxplayers} // 0;
- end;
- end;
-
-
- Tr;
- td "Bots:";
- td;
- if ($info->{botskill} or $info->{minplayers})
+ # added / last seen
+ div class => "updatenote";
+ span title => ("Server was added on ". strftime "%e %b %Y", gmtime ($info->{dt_added} // 0) );
+
+ txt "information updated ";
+ my @t = gmtime( time - ( $info->{dt_updated} // 0 ) );
+
+ my $diff;
+ $diff .= ($t[5]-70)*365 + $t[7] > 0 ? ( ($t[5]-70)*365 + $t[7])."d" : "" ; # years+days
+ $diff .= ($t[2] ? $t[2]."h" : ""); # hours
+ $diff .= ($t[1] ? $t[1]."m" : ""); # minutes
+ $diff .= ($t[0] ? sprintf "%02ds", $t[0] : ""); # seconds
+
+
+ if ( length $diff )
{
- txt $info->{minplayers} // 0;
- txt " ";
- txt $info->{botskill} // "";
- txt " bot";
- txt ($info->{minplayers} && $info->{minplayers} == 1 ? "" : "s");
+ span class => ( ($t[5]-70 or $t[7]) ? "r" : ($t[2] ? "o" : "g") ), $diff;
+ txt " ago.";
}
else
{
- txt "No";
+ span class => "g", "right now.";
}
- end;
- end;
- end; #table
+ end; #span
+ end; # updatenote
end; # container
#
@@ -205,19 +225,7 @@ sub show_server
# always display contact
Tr;
td class => "wc1", "Contact:";
- td;
- if ($info->{adminemail})
- {
- txt $info->{adminemail}
- }
- else
- {
- i;
- txt "This server has no contact information listed ";
- a href => "https://ut99.org/viewtopic.php?f=33&t=6660", "[?]";
- end;
- }
- end;
+ td ($info->{adminemail} ? $info->{adminemail} : "-") ;
end;
# location data
@@ -230,86 +238,36 @@ sub show_server
txt " ". $country;
end;
end;
-
- # added / updated
- Tr;
- {
- td "Added:";
- my @t = gmtime( time - ( $info->{dt_added} // 0 ) );
- my $sig = 0;
- my $diff = "";
- if ($t[5]-70)
- {
- $diff .= $t[5]-70
- . " year"
- . ( ($t[5]-70==1) ? "" : "s" );
- $sig++;
- }
- if ($t[7])
- {
- $diff .= ($sig?", ":"")
- . $t[7]
- . " day"
- . ( ($t[7]==1) ? "" : "s")
- }
-
- if ($diff eq "")
- {
- $diff = "Less than one day";
- }
- td $diff . " ago (" . (strftime "%e %b %Y", gmtime ($info->{dt_added} // 0) ) .")";
- }
- end;
-
+
+ # numplayer field
Tr;
- {
- td "Last seen:";
+ td class => "wc1", "Players:";
td;
- my @t = gmtime( time - ( $info->{dt_updated} // 0 ) );
- if ($t[5]-70 // $t[7])
- {
- # more than 1 day? show date
- span class => "r", (strftime "%e %b %Y", gmtime ($info->{dt_updated} // 0) );
- }
- else
- {
- # less than 1 day? show "time ago"
- my $diff = "";
- $diff .= ($t[2] ? $t[2]." hour" . ( $t[2]>1 ? "s, " : ", ") : "");
- $diff .= ($t[1] ? $t[1]." minute". ( $t[1]>1 ? "s, " : ", ") : "");
- $diff .= ($t[0] ? $t[0]." second". ( $t[0]>1 ? "s" : " " ) : "0 seconds");
- $diff .= " ago";
- span $diff;
- }
+ txt $info->{numplayers} // 0;
+ txt "/";
+ txt $info->{maxplayers} // 0;
end;
- }
end;
- # TODO: move flags to header
Tr;
- td "Flags: ";
+ td "Bots:";
td;
- # uplink/sync
- span title => "direct uplink or manually added?",
- ($info->{f_direct} ? "💻 uplink" : "🤚 manual");
-
- txt ", ";
-
- span title => "authenticated game server?",
- ($info->{f_auth} ? "✅ authed" : "❌ insecure");
- txt ", ";
-
- span title => "server blacklisted for violating 333networks policy?",
- ($info->{f_blacklist} ? "blacklisted" : "compliant");
-
- txt ", ";
- span title => "does the server require a password to join?",
- ($info->{passworded} ?
- ($info->{passworded} =~ /(true|1)/i ? "🔒 password" : "🔓 open")
- : "🔓 open");
+ if ($info->{botskill} or $info->{minplayers})
+ {
+ txt $info->{minplayers} // 0;
+ txt " ";
+ txt $info->{botskill} // "";
+ txt " bot";
+ txt ($info->{minplayers} && $info->{minplayers} == 1 ? "" : "s");
+ }
+ else
+ {
+ txt "No";
+ }
end;
end;
+
end; # table serverinfo
#
@@ -420,7 +378,10 @@ sub show_server
end;
}
end; # playerinfo
-
+
+ # disable stats that are considered irrelevant. can be re-enabled with "if (1)"
+ if (0)
+ {
#
# Team info
table class => "teaminfo";
@@ -468,81 +429,19 @@ sub show_server
td ($info->{fraglimit} // 0);
end;
end;
+ }
#
- # Share options (copy fields)
- my $url = $self->{site_url}
- . "/"
- . $gamename
- . "/"
- . ( $self->to_ipv4_str($info->{ip}) // "0.0.0.0" )
- . ":"
- . ($info->{hostport} // 0);
-
+ # JSON URL (code inactive)
table class => "shareopts";
Tr;
- th class => "wc1", "Share";
- th "";
- end;
- Tr;
- td class => "tc1", "Link";
- td class => "tc2";
- input type => 'text',
- class => 'text',
- name => 'url',
- value => $url;
+ th;
+ a href => "http://333networks.com/json", title => "For more info, click to go to 333networks.com/json", "Json API";
end;
end;
- Tr;
- td class => "tc1";
- a href => "/json",
- title => "The url to access this server over the 333networks Json API",
- "Json API";
- end;
- td class => "tc2";
- input type => 'text',
- class => 'text',
- name => 'url',
- value => $self->{site_url}
- . "/json/"
- . $gamename
- . "/"
- . ( $self->to_ipv4_str($info->{ip}) // "0.0.0.0" )
- . ":"
- . ($info->{hostport} // 0);
- end;
- end;
- Tr;
- td "Forum Link";
- td;
- textarea type => 'textarea',
- class => 'text',
- rows => 3,
- name => 'paste';
- txt "\[url=$url\]";lit "\n";
- txt $info->{hostname} // "[unnamed $gamename server]";
- lit "\n";
- txt "\[/url\]";
- end;
- end;
- end;
- Tr;
- td "HTML Code";
- td;
- textarea type => 'textarea',
- class => 'text',
- rows => 3,
- name => 'paste';
- txt "<a href=\"$url\">";
- lit "\n";
- txt $info->{hostname} // "[unnamed $gamename server]";
- lit "\n";
- txt "</a>";
- end;
- end;
- end;
- end; # share options
-
+ td ($self->{site_url} . "/json/" . $gamename . "/" . ( $self->to_ipv4_str($info->{ip}) // "0.0.0.0" ) . ":" . ($info->{hostport} // 0));
+ end;
+
end; # mainbox details
$self->htmlFooter;
}
diff --git a/lib/MasterWebInterface/Util/Layout.pm b/lib/MasterWebInterface/Util/Layout.pm
index bf401c2..536aad7 100755
--- a/lib/MasterWebInterface/Util/Layout.pm
+++ b/lib/MasterWebInterface/Util/Layout.pm
@@ -18,7 +18,7 @@ sub htmlHeader
if (my $overrideStyle = $self->reqParam("style") )
{
# default to custom style if specified option doesn't exist
- $style = ( -e "$self->{root}/s/style/$overrideStyle" ) ? $overrideStyle : "basic";
+ $style = ( -e "$self->{root}/s/style/$overrideStyle" ) ? $overrideStyle : $self->{style};
}
html lang => "en";
@@ -61,19 +61,14 @@ sub htmlHeader
end;
my $overrideStyle = $self->reqParam("style");
- if ($overrideStyle) {
+ if ($overrideStyle or $self->{style_box}) {
# debug feature: force list of styles on floaty-box
div class => "mainbox",
style => "position:absolute; left: 20px; top: 20px; width:200px";
div class => "header";
h1 "Development";
- p class => "alttitle";
- txt "This site is under development. Find ";
- a href => "http://333networks.com", "333networks.com here!";
- br;
- txt "Use the list below to test different house styles.";
- end;
+ p "This box allows for testing of multiple styles. Disable it from config.";
end;
ul style => "margin: 3px 20px 10pt 40px";
diff --git a/lib/SkinFile.pm b/lib/SkinFile.pm
new file mode 100755
index 0000000..b890de2
--- /dev/null
+++ b/lib/SkinFile.pm
@@ -0,0 +1,67 @@
+package SkinFile;
+use strict;
+use warnings;
+use Fcntl 'LOCK_SH', 'SEEK_SET';
+
+sub new {
+ my($class, $root, $open) = @_;
+ my $self = bless { root => $root }, $class;
+ $self->open($open) if $open;
+ return $self;
+}
+
+sub list {
+ return map /\/([^\/]+)\/conf/?$1:(), glob "$_[0]{root}/*/conf";
+}
+
+sub open {
+ my($self, $dir, $force) = @_;
+ return if $self->{"s_$dir"} && !$force;
+ my %o;
+ open my $F, '<:utf8', "$self->{root}/$dir/conf" or die "$self->{root}/$dir/conf -> $!";
+ flock $F, LOCK_SH or die $!;
+ seek $F, 0, SEEK_SET or die $!;
+ local $_;
+ while(<$F>) {
+ chomp;
+ s/\r//g;
+ s{[\t\s]*//.+$}{};
+ next if !/^([a-z0-9]+)[\t\s]+(.+)$/;
+ $o{$1} = $2;
+ }
+ close $F;
+ $self->{"s_$dir"} = \%o;
+ $self->{opened} = $dir;
+}
+
+sub get {
+ my($self, $dir, $var) = @_;
+ $self->open($dir) if defined $var;
+ $var = $dir if !defined $var;
+ $var ? $self->{"s_$self->{opened}"}{$var} : keys %{$self->{"s_$self->{opened}"}};
+}
+
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+SkinFile - Simple object oriented interface to parsing skin configuration files
+
+=head1 USAGE
+
+ use SkinFile;
+ my $s = SkinFile->new($dir);
+ my @skins = $s->list;
+
+ $s->open($skins[0]);
+ my $name = $s->get('name');
+
+ # same as above, but in one function
+ my $name = $s->get($skins[0], 'name');
+
+