diff --git a/src/lgsl_admin.php b/src/lgsl_admin.php
index 387c5c2..ea47563 100644
--- a/src/lgsl_admin.php
+++ b/src/lgsl_admin.php
@@ -57,7 +57,7 @@
$_POST['form_s_port'] [$form_key],
$_POST['form_zone'] [$form_key],
$_POST['form_disabled'][$form_key],
- $_POST['form_comment'] [$form_key]) = explode(":", "{$form_line}:::::::");
+ $_POST['form_comment'] [$form_key]) = explode(":", "{$form_line}", 8);
}
}
@@ -328,7 +328,7 @@
[ S Port ] |
[ Zone ] |
[ {$lgsl_config['text']['dsb']} ] |
- [ Comment ] |
+ [ Comment | Additional Data ] |
";
$result = $db->get_all();
diff --git a/src/lgsl_class.php b/src/lgsl_class.php
index 9c4ddcd..df4209c 100644
--- a/src/lgsl_class.php
+++ b/src/lgsl_class.php
@@ -990,7 +990,7 @@ public function getTimestamp($type = Timestamp::SERVER) {
}
public function getTimestampFormatted($type = Timestamp::SERVER) {
$time = $this->getTimestamp($type);
- global $lgsl_config;
+ global $lgsl_config;
if ($time > 0) {
return Date($lgsl_config['text']['tzn'], $time);
}
@@ -1002,6 +1002,28 @@ public function setTimestamp($type, $time) {
public function getTimestamps() {
return $this->_server['cache_time']->toString();
}
+ public function getAdditionalData(): array {
+ $json = json_decode(str_replace(""", '"', $this->_other['comment']), true);
+ try {
+ if (json_last_error() > 0) {
+ throw new \Exception('JSON decode error code '. json_last_error() . " for server {$this->getId()}");
+ }
+ return $json;
+ } catch (\Exception $e) {
+ return [0 => $json, 1 => $e->getMessage()];
+ }
+ }
+ public function setAdditionalData($data) : null {
+ $json = json_encode($this->_other['comment']);
+ try {
+ if (json_last_error() > 0) {
+ throw new \Exception();
+ }
+ $this->_other['comment'] = $json;
+ } catch (\Exception $e) {
+ $this->_other['comment'] = $data;
+ }
+ }
public function checkTimestamps($request = "") {
global $lgsl_config;
$needed = "";
diff --git a/src/lgsl_protocol.php b/src/lgsl_protocol.php
index a3be43e..c1467a2 100644
--- a/src/lgsl_protocol.php
+++ b/src/lgsl_protocol.php
@@ -100,6 +100,7 @@ class Protocol {
const OPENTTD = "openttd";
const PAINKILLER = "painkiller";
const PALWORLD = "palworld";
+ const PALWORLDDIRECT = "palworlddirect";
const PLAINSIGHT = "plainsight";
const PREY = "prey";
const QUAKEWORLD = "quakeworld";
@@ -179,6 +180,7 @@ static public function lgslConnectionType($type) {
self::ECO => self::HTTP,
self::FIVEM => self::HTTP,
self::PALWORLD => self::HTTP,
+ self::PALWORLDDIRECT=> self::HTTP,
self::RAGEMP => self::HTTP,
self::SCUM => self::HTTP,
self::TERRARIA => self::HTTP,
@@ -274,6 +276,7 @@ static public function lgslList($type = null) {
self::OPENTTD => ["Query22", "Open Transport Tycoon Deluxe"],
self::PAINKILLER => ["Query08", "PainKiller"],
self::PALWORLD => ["Query51", "Palworld"],
+ self::PALWORLDDIRECT=> ["Query55", "Palworld Direct"],
self::PLAINSIGHT => ["Query32", "Plain Sight"],
self::PREY => ["Query10", "Prey"],
self::QUAKEWORLD => ["Query07", "Quake World"],
@@ -2883,6 +2886,25 @@ public function process() {
return $this::SUCCESS;
}
}
+ class Query55 extends QueryJSON { // Palworld Direct
+ public function process() {
+ $cred = $this->_server->getAdditionalData();
+ if (empty($cred['login']) || empty($cred['password'])) {
+ $this->_data['e']['_error'] = "No login or password presented";
+ return $this::WITH_ERROR;
+ }
+ $auth = base64_encode("{$cred['login']}:{$cred['password']}");
+ $this->_fp->setOpt(CURLOPT_HTTPHEADER, ['Accept: application/json', "Authorization: Basic {$auth}"]);
+ $buffer = $this->fetch("http://{$this->_server->getIp()}:{$this->_server->getQueryPort()}/v1/api/settings");
+ if (!$buffer) return $this::NO_RESPOND;
+ $this->_data['s']['name'] = $buffer['ServerName'];
+ $this->_data['s']['password'] = 0;
+ $this->_data['s']['players'] = 0;
+ $this->_data['s']['playersmax'] = $buffer['ServerPlayerMaxNum'];
+ $this->_data['e']['description'] = isset($buffer['ServerDescription']) ? $buffer['ServerDescription'] : "";
+ return $this::SUCCESS;
+ }
+ }
class QueryTest extends Query {
public function process() {
@@ -3057,7 +3079,7 @@ public function readRaw($length = 4096) {
} else {
return $msg;
}
- }
+ }
return $result;
} else {
return fread($this->_stream, $length);
@@ -3086,6 +3108,9 @@ public function write($data) {
public function &getStream() {
return $this->_stream;
}
+ public function setOpt($name, $value) {
+ curl_setopt($this->_stream, $name, $value);
+ }
public function close() {
if (!$this->_stream) return;
if ($this->_isHttp()) {