Added ability to read from a server's properties file, and added server port numbers to the index display

This commit is contained in:
2022-10-14 10:59:28 -04:00
parent 5c35389ae3
commit 2297768b57
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php
namespace BitGoblin\MCST\Minecraft;
class ServerConfig {
protected array $config;
public function __construct($propertiesFile) {
$this->config = array(); // initialize array
// parse config file
$fh = fopen($propertiesFile, 'r+');
while (!feof($fh)) {
$line = fgets($fh);
$eqpos = strpos($line, '=');
$parameterName = substr($line, 0, $eqpos);
$parameterValue = substr($line, ($eqpos + 1));
// assign parameter values to the config array
$this->config[$parameterName] = $parameterValue;
}
}
public function get(string $param) {
return $this->config[$param];
}
}