Skip to content

Commit

Permalink
Merge pull request #44 from aXenDeveloper/feature/debuger
Browse files Browse the repository at this point in the history
Add debug server option
  • Loading branch information
aXenDeveloper authored Apr 20, 2022
2 parents f7d69a7 + 0443e5d commit 2c58679
Show file tree
Hide file tree
Showing 74 changed files with 171 additions and 78 deletions.
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ Server table showing server information about the status, name, number of player
- PHP 7.3+ - For IPS 4.5
- PHP 7.4+ - For IPS 4.6
- [Bzip2](https://www.php.net/manual/en/book.bzip2.php) - Used for A2S Compressed responses,
- ❗❗ Unlocked external ports on the website server
- ❗❗ Unlocked external ports on the website server (UDP)

## 💻 Compatible servers

- America's Army 3
- America's Army: Proving Grounds
- ARK: Survival Evolved
- Arma3
- Battlefield 2
Expand Down Expand Up @@ -100,7 +102,6 @@ Server table showing server information about the status, name, number of player
- Unturned
- Unreal Tournament 3
- Unreal Tournament 2004
- Valheim
- Ventrilo
- Warsow
- World Opponent Network
Expand All @@ -115,8 +116,17 @@ Server table showing server information about the status, name, number of player

## 🔨 Configuration

1. Go to: AdminCP -> Advanced Server List -> Servers -> **Create new**,
2. First you have to choice a game in **Game**,
### Mods

1. Go to: AdminCP -> Community -> Advanced Server List -> Mods -> **Create new**,
2. Provide a name mod in **Name**,
3. Choose a protocol mod in **Protocol**,
4. Click **save**.

### Servers

1. Go to: AdminCP -> Community -> Advanced Server List -> Servers -> **Create new**,
2. First you have to choice mod in **Mod**,
3. Provide a custom name in **Custom name** for example: _JailBreak_,
4. Provide a address IP in **IP** for example: **145.239.16.78:27015**.
❗❗ Some servers like **TeamSpeak 3** require a **Query port**!
Expand Down Expand Up @@ -145,9 +155,25 @@ b_virtualserver_client_list
b_virtualserver_channel_list
```

## 🔧 Debug tool

If server is offline you can see what's is going on by debug tool [===> Click <===](https://github.com/aXenDeveloper/ips-app-advanced-serverlist-debug).
## 🔧 Custom API

From version _2.0.0_, the table supports your own custom API. To activate your custom API follow the instructions:

1. Go to: AdminCP -> Community -> Advanced Server List -> Mods -> **Create new**,
2. Provide a name mod in **Name**,
3. Choose a **Custom API**,
4. Provide address URL in **Address URL** for example: _https://query.li/api/csgo/{ip}/{port}_,
5. Provide a fields form your Custom API.
If your API return JSON for example:
```
{
data: {
"status": 1
}
}
```
then your **field** equal **status**,
6. Click **save**.

## 🛠️ Update

Expand All @@ -168,6 +194,8 @@ If server is offline you can see what's is going on by debug tool [===> Click <=
![8](https://files.axendev.net/projects/ips/applications/serverlist/8.png)
![9](https://files.axendev.net/projects/ips/applications/serverlist/9.png)
![10](https://files.axendev.net/projects/ips/applications/serverlist/10.png)
![11](https://files.axendev.net/projects/ips/applications/serverlist/11.png)
![12](https://files.axendev.net/projects/ips/applications/serverlist/12.png)

## 🔌 Download from other sources

Expand Down
3 changes: 3 additions & 0 deletions data/lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<word key="aXenServerList_admin_table_servers_debug_text_YesNo" js="0">Enable reason?</word>
<word key="aXenServerList_admin_table_servers_debug_text_YesNo_desc" js="0">The reason will appear in the more tab for the given server and in the summary at the top of the table.</word>
<word key="aXenServerList_admin_table_servers_debug_text" js="0">Reason</word>
<word key="aXenServerList_admin_table_servers_buttons_debug" js="0">Debug Server</word>
<word key="aXenServerList_admin_table_servers_tab_urls" js="0">URLs</word>
<word key="aXenServerList_admin_table_servers_url_statistics" js="0">Statistics URL</word>
<word key="aXenServerList_admin_table_servers_url_tv" js="0">TV URL</word>
Expand All @@ -88,6 +89,7 @@
<word key="aXenServerList_admin_table_mods_protocol" js="0">Protocol</word>
<word key="aXenServerList_admin_table_mods_api" js="0">Custom API</word>
<word key="aXenServerList_admin_table_mods_api_url" js="0"><![CDATA[Custom API Field<br />Address URL]]></word>
<word key="aXenServerList_admin_table_mods_api_url_desc" js="0"><![CDATA[The URL must be able to add a variable to the URL.<br />So e.g. https://query.li/api/csgo/<span style="font-weight: bold;">{ip}</span>/<span style="font-weight: bold;">{port}</span><br /><span style="font-weight: bold;">Make sure the url contains {ip} or {ip} along with {port}.</span>]]></word>
<word key="aXenServerList_admin_table_mods_api_status" js="0"><![CDATA[Custom API Field<br />Status]]></word>
<word key="aXenServerList_admin_table_mods_api_current_players" js="0"><![CDATA[Custom API Field<br />Current Players]]></word>
<word key="aXenServerList_admin_table_mods_api_max_players" js="0"><![CDATA[Custom API Field<br />Max Players]]></word>
Expand Down Expand Up @@ -122,5 +124,6 @@
<word key="aXenServerList_widget_toggle_debug" js="0">Show servers with Debug mode</word>
<word key="aXenServerList_debug_icon" js="0">Debug mode is enabled on this server</word>
<word key="aXenServerList_popup_refresh" js="0">Servers data updated</word>
<word key="aXenServerList_popup_debug_add" js="0">Added server log</word>
</app>
</language>
65 changes: 0 additions & 65 deletions data/theme.xml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dev/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
'aXenServerList_admin_table_servers_debug_text_YesNo' => 'Enable reason?',
'aXenServerList_admin_table_servers_debug_text_YesNo_desc' => 'The reason will appear in the more tab for the given server and in the summary at the top of the table.',
'aXenServerList_admin_table_servers_debug_text' => 'Reason',
'aXenServerList_admin_table_servers_buttons_debug' => "Debug Server",
// * URLs
'aXenServerList_admin_table_servers_tab_urls' => 'URLs',
'aXenServerList_admin_table_servers_url_statistics' => 'Statistics URL',
Expand All @@ -109,6 +110,7 @@
'aXenServerList_admin_table_mods_protocol' => "Protocol",
'aXenServerList_admin_table_mods_api' => "Custom API",
'aXenServerList_admin_table_mods_api_url' => "Custom API Field<br />Address URL",
'aXenServerList_admin_table_mods_api_url_desc' => 'The URL must be able to add a variable to the URL.<br />So e.g. https://query.li/api/csgo/<span style="font-weight: bold;">{ip}</span>/<span style="font-weight: bold;">{port}</span><br /><span style="font-weight: bold;">Make sure the url contains {ip} or {ip} along with {port}.</span>',
'aXenServerList_admin_table_mods_api_status' => "Custom API Field<br />Status",
'aXenServerList_admin_table_mods_api_current_players' => "Custom API Field<br />Current Players",
'aXenServerList_admin_table_mods_api_max_players' => "Custom API Field<br />Max Players",
Expand Down Expand Up @@ -148,4 +150,5 @@
// Others
'aXenServerList_debug_icon' => 'Debug mode is enabled on this server',
'aXenServerList_popup_refresh' => 'Servers data updated',
'aXenServerList_popup_debug_add' => 'Added server log',
);
Binary file removed dev/resources/front/icons/arkse.png
Binary file not shown.
Binary file removed dev/resources/front/icons/arma3.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bf1942.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bf2.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bf3.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bf4.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bfbc2.png
Binary file not shown.
Binary file removed dev/resources/front/icons/bfh.png
Binary file not shown.
Binary file removed dev/resources/front/icons/cod.png
Binary file not shown.
Binary file removed dev/resources/front/icons/cod2.png
Binary file not shown.
Binary file removed dev/resources/front/icons/cod4.png
Binary file not shown.
Binary file removed dev/resources/front/icons/coduo.png
Binary file not shown.
Binary file removed dev/resources/front/icons/codwaw.png
Binary file not shown.
Binary file removed dev/resources/front/icons/conanexiles.png
Binary file not shown.
Binary file removed dev/resources/front/icons/contagion.png
Binary file not shown.
Binary file removed dev/resources/front/icons/cs16.png
Binary file not shown.
Binary file removed dev/resources/front/icons/cscz.png
Binary file not shown.
Binary file removed dev/resources/front/icons/csgo.png
Binary file not shown.
Binary file removed dev/resources/front/icons/css.png
Binary file not shown.
Binary file removed dev/resources/front/icons/dayz.png
Binary file not shown.
Binary file removed dev/resources/front/icons/dayzmod.png
Binary file not shown.
Binary file removed dev/resources/front/icons/discord.png
Binary file not shown.
Binary file removed dev/resources/front/icons/gmod.png
Binary file not shown.
Binary file removed dev/resources/front/icons/grav.png
Binary file not shown.
Binary file removed dev/resources/front/icons/gta5m.png
Binary file not shown.
Binary file removed dev/resources/front/icons/gtan.png
Diff not rendered.
Binary file removed dev/resources/front/icons/hl2dm.png
Diff not rendered.
Binary file removed dev/resources/front/icons/hurtworld.png
Diff not rendered.
Binary file removed dev/resources/front/icons/insurgency.png
Diff not rendered.
Binary file removed dev/resources/front/icons/jediacademy.png
Diff not rendered.
Binary file removed dev/resources/front/icons/jedioutcast.png
Diff not rendered.
Binary file removed dev/resources/front/icons/justcause2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/justcause3.png
Diff not rendered.
Binary file removed dev/resources/front/icons/killingfloor.png
Diff not rendered.
Binary file removed dev/resources/front/icons/killingfloor2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/l4d.png
Diff not rendered.
Binary file removed dev/resources/front/icons/l4d2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/minecraft.png
Diff not rendered.
Binary file removed dev/resources/front/icons/mohaa.png
Diff not rendered.
Binary file removed dev/resources/front/icons/mta.png
Diff not rendered.
Binary file removed dev/resources/front/icons/mumble.png
Diff not rendered.
Binary file removed dev/resources/front/icons/ns2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/quake2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/quake3.png
Diff not rendered.
Binary file removed dev/resources/front/icons/quakelive.png
Diff not rendered.
Binary file removed dev/resources/front/icons/redorchestra2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/rust.png
Diff not rendered.
Binary file removed dev/resources/front/icons/samp.png
Diff not rendered.
Binary file removed dev/resources/front/icons/sevendaystodie.png
Diff not rendered.
Binary file removed dev/resources/front/icons/ship.png
Diff not rendered.
Binary file removed dev/resources/front/icons/squad.png
Diff not rendered.
Binary file removed dev/resources/front/icons/starmade.png
Diff not rendered.
Binary file removed dev/resources/front/icons/teamspeak3.png
Diff not rendered.
Binary file removed dev/resources/front/icons/teeworlds.png
Diff not rendered.
Binary file removed dev/resources/front/icons/terraria.png
Diff not rendered.
Binary file removed dev/resources/front/icons/tf2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/tibia.png
Diff not rendered.
Binary file removed dev/resources/front/icons/tshock.png
Diff not rendered.
Binary file removed dev/resources/front/icons/unreal2.png
Diff not rendered.
Binary file removed dev/resources/front/icons/unturned.png
Diff not rendered.
Binary file removed dev/resources/front/icons/ut2004.png
Diff not rendered.
Binary file removed dev/resources/front/icons/ut3.png
Diff not rendered.
Binary file removed dev/resources/front/icons/valheim.png
Diff not rendered.
Binary file removed dev/resources/front/icons/ventrilo.png
Diff not rendered.
Binary file removed dev/resources/front/icons/warsow.png
Diff not rendered.
26 changes: 26 additions & 0 deletions modules/admin/servers/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ protected function refresh()
}
}

/**
* Debug
*
* @return void
*/
public function debug()
{
$id = \IPS\Request::i()->id;

/* Get data form Database */
$server = [];
try {
$server = \IPS\Application::load('axenserverlist')->getFullDataServersTask($id);
} catch (\Exception$e) {
if (\IPS\Request::i()->id) {
\IPS\Output::i()->error('page_not_found', '(aXen) Advanced Server List/103', 404, '');
}
}

// Update server status
$update = new \IPS\axenserverlist\Servers\Update;

\IPS\Log::log($update->server($server, null, true), '(aXen) Advanced Server List - Debug Server ID: ' . $id);
\IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=core&module=support&controller=systemLogs'), 'aXenServerList_popup_debug_add');
}

/**
* Execute
*
Expand Down
5 changes: 4 additions & 1 deletion setup/upg_10016/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
"aXenServerList_admin_table_servers_debug_text",
"aXenServerList_admin_table_mods_api_status",
"aXenServerList_admin_table_mods_api_name",
"aXenServerList_admin_table_mods_api_connect_link"
"aXenServerList_admin_table_mods_api_connect_link",
"aXenServerList_admin_table_servers_buttons_debug",
"aXenServerList_popup_debug_add",
"aXenServerList_admin_table_mods_api_url_desc"
],
"edited": [],
"removed": [
Expand Down
68 changes: 67 additions & 1 deletion setup/upg_10016/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,72 @@
"global\/icons\/unknown.png"
],
"edited": [],
"removed": []
"removed": [
"front\/icons\/arkse.png",
"front\/icons\/arma3.png",
"front\/icons\/bf1942.png",
"front\/icons\/bf2.png",
"front\/icons\/bf3.png",
"front\/icons\/bf4.png",
"front\/icons\/bfbc2.png",
"front\/icons\/bfh.png",
"front\/icons\/cod.png",
"front\/icons\/cod2.png",
"front\/icons\/cod4.png",
"front\/icons\/coduo.png",
"front\/icons\/codwaw.png",
"front\/icons\/conanexiles.png",
"front\/icons\/contagion.png",
"front\/icons\/cs16.png",
"front\/icons\/cscz.png",
"front\/icons\/csgo.png",
"front\/icons\/css.png",
"front\/icons\/dayz.png",
"front\/icons\/dayzmod.png",
"front\/icons\/discord.png",
"front\/icons\/gmod.png",
"front\/icons\/grav.png",
"front\/icons\/gta5m.png",
"front\/icons\/gtan.png",
"front\/icons\/hl2dm.png",
"front\/icons\/hurtworld.png",
"front\/icons\/insurgency.png",
"front\/icons\/jediacademy.png",
"front\/icons\/jedioutcast.png",
"front\/icons\/justcause2.png",
"front\/icons\/justcause3.png",
"front\/icons\/killingfloor.png",
"front\/icons\/killingfloor2.png",
"front\/icons\/l4d.png",
"front\/icons\/l4d2.png",
"front\/icons\/minecraft.png",
"front\/icons\/mohaa.png",
"front\/icons\/mta.png",
"front\/icons\/mumble.png",
"front\/icons\/ns2.png",
"front\/icons\/quake2.png",
"front\/icons\/quake3.png",
"front\/icons\/quakelive.png",
"front\/icons\/redorchestra2.png",
"front\/icons\/rust.png",
"front\/icons\/samp.png",
"front\/icons\/sevendaystodie.png",
"front\/icons\/ship.png",
"front\/icons\/squad.png",
"front\/icons\/starmade.png",
"front\/icons\/teamspeak3.png",
"front\/icons\/teeworlds.png",
"front\/icons\/terraria.png",
"front\/icons\/tf2.png",
"front\/icons\/tibia.png",
"front\/icons\/tshock.png",
"front\/icons\/unreal2.png",
"front\/icons\/unturned.png",
"front\/icons\/ut2004.png",
"front\/icons\/ut3.png",
"front\/icons\/valheim.png",
"front\/icons\/ventrilo.png",
"front\/icons\/warsow.png"
]
}
}
22 changes: 21 additions & 1 deletion sources/Servers/Servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,27 @@ protected function get__icon()
}
}

/**
* [Node] Get buttons to display in tree
* Example code explains return value
*
* @param string $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function getButtons($url, $subnode = false)
{
$buttons = parent::getButtons($url, $subnode);

$buttons['debug'] = array(
'icon' => 'bug',
'title' => 'aXenServerList_admin_table_servers_buttons_debug',
'link' => \IPS\Http\Url::internal("app=axenserverlist&module=servers&controller=servers&do=debug&id={$this->id}"),
);

return $buttons;
}

/**
* [ActiveRecord] Delete Record
*
Expand All @@ -283,5 +304,4 @@ public function delete()

return parent::delete();
}

}
15 changes: 12 additions & 3 deletions sources/Servers/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()
$this->gq->setOption('write_wait', 10);
}

public function server($server, $api = false)
public function server($server, $api = null, $debug = null)
{
if ($api) {
$url = \IPS\Application::load('axenserverlist')->linkIpWithUrl($server['ip'], $server['mod_api_url']);
Expand Down Expand Up @@ -60,6 +60,10 @@ public function server($server, $api = false)
$dataUpdate['most_players'] = $this->searchArray($data, $server['mod_api_current_players']);
}

if ($debug) {
return $data;
}

\IPS\Db::i()->update('axenserverlist_servers', $dataUpdate, ['id=?', $server['id']]);

return;
Expand All @@ -73,7 +77,7 @@ public function server($server, $api = false)
];

if ($server['query_port']) {
$server['options'] = [
$currentServer['options'] = [
'query_port' => $server['query_port'],
];
};
Expand All @@ -82,8 +86,13 @@ public function server($server, $api = false)
for ($i = 0; $i < 3; $i++) {
$this->gq->clearServers();
$this->gq->addServer($currentServer);
$results = $this->gq->process();

if ($debug) {
return $results;
}

foreach ($this->gq->process() as $id => $data) {
foreach ($results as $id => $data) {
if ($data['gq_online'] == true) {
$dataUpdate = [
'status' => 1,
Expand Down

0 comments on commit 2c58679

Please sign in to comment.