diff --git a/system/libs/pot/OTS.php b/system/libs/pot/OTS.php index f739c709..fb93afea 100644 --- a/system/libs/pot/OTS.php +++ b/system/libs/pot/OTS.php @@ -415,9 +415,11 @@ class POT * @tutorial POT/Server_status.pkg * @deprecated 0.1.4 Use OTS_ServerInfo->status(). */ - public static function serverStatus($server, $port) + public static function serverStatus($server, $port, $timeout = 2.0) { $status = new OTS_ServerInfo($server, $port); + $status->setTimeout($timeout); + return $status->status(); } diff --git a/system/libs/pot/OTS_ServerInfo.php b/system/libs/pot/OTS_ServerInfo.php index e39f9fe7..76ebcaf7 100644 --- a/system/libs/pot/OTS_ServerInfo.php +++ b/system/libs/pot/OTS_ServerInfo.php @@ -26,14 +26,19 @@ class OTS_ServerInfo * * @var string */ - private $server; + private string $server; /** * Connection port. * * @var int */ - private $port; + private int $port; + + /** + * Status timeout + */ + private float $timeout = 2.0; /** * Creates handler for new server. @@ -57,7 +62,7 @@ class OTS_ServerInfo private function send(OTS_Buffer $packet) { // connects to server - $socket = @fsockopen($this->server, $this->port, $error, $message, setting('core.status_timeout')); + $socket = @fsockopen($this->server, $this->port, $error, $message, $this->timeout); // if connected then checking statistics if($socket) @@ -224,6 +229,10 @@ class OTS_ServerInfo throw new OutOfBoundsException(); } } + + public function setTimeout($timeout) { + $this->timeout = $timeout; + } } /**#@-*/ diff --git a/system/status.php b/system/status.php index 835f204d..8e8225dd 100644 --- a/system/status.php +++ b/system/status.php @@ -114,6 +114,8 @@ function updateStatus() { // get server status and save it to database $serverInfo = new OTS_ServerInfo($status_ip, $status_port); + $serverInfo->setTimeout(setting('core.status_timeout')); + $serverStatus = $serverInfo->status(); if(!$serverStatus) {