Skip to content

Commit

Permalink
PHP motd array/string fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ldilley committed Sep 11, 2021
1 parent 4d0c780 commit 3c72b37
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions PHP/minestat.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,21 @@ private function strip_motd($is_json = false)
$this->stripped_motd = preg_replace("/§./", "", $this->motd);
else
{
$this->stripped_motd = $this->motd['text'];
$json_data = $this->motd['extra'];
if(!empty($json_data))
if(isset($this->motd['text']))
$this->stripped_motd = $this->motd['text'];
else
$this->stripped_motd = $this->motd;
if(isset($this->motd['extra']))
{
foreach($json_data as &$nested_hash)
$this->stripped_motd .= $nested_hash['text'];
$json_data = $this->motd['extra'];
if(!empty($json_data))
{
foreach($json_data as &$nested_hash)
$this->stripped_motd .= $nested_hash['text'];
}
}
$this->motd = json_encode($this->motd);
if(is_array($this->motd))
$this->motd = json_encode($this->motd);
$this->stripped_motd = preg_replace("/§./", "", $this->stripped_motd);
}
}
Expand Down

0 comments on commit 3c72b37

Please sign in to comment.