From 0550ff7dcf5162f446188de264fe26f3b302117c Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Wed, 15 Jan 2020 10:33:47 +0100 Subject: [PATCH] Added ping error --- src/psm/Util/Server/Updater/StatusUpdater.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 24d37cd8..8dfa421f 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -175,7 +175,9 @@ class StatusUpdater if ($max_runs == null || $max_runs > 1) { $max_runs = 1; } - $txt = exec("ping -c " . $max_runs . " " . $this->server['ip']); + $result = null; + // Execute ping + $txt = exec("ping -c " . $max_runs . " " . $this->server['ip'] . " 2>&1", $output); // Non-greedy match on filler $re1 = '.*?'; // Uninteresting: float @@ -184,16 +186,16 @@ class StatusUpdater $re3 = '.*?'; // Float 1 $re4 = '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])'; - - if ($c = preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) { + if (preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) { $result = $matches[1][0]; - } else { - $result = null; } if (!is_null($result)) { + $this->header = $output[0]; $status = true; } else { + $this->header = "-"; + $this->error = $output[0]; $status = false; } //Divide by a thousand to convert to milliseconds