public function __construct() { global $config; $filename = $config['sq_config_path'] . $config['sq_playback_file']; try { if (!is_readable($filename)) { throw new Exception('File not found'); } $luaconf = file_get_contents($filename); //Clean file $luaconf = str_replace(array("\r\n", "\n", "\r"), "", $luaconf); //reformat lua config with newlines $luaconf = str_replace(array("{", ","), array("{\n", ",\n"), $luaconf); $parser = new ConfigParser($luaconf); $c = $parser->toArray(); $this->playerName = $c['settings']['playerInit']['name']; $this->serverInfos['uuid'] = $c['settings']['serverUuid']; if (array_key_exists('mac', $c['settings']['serverInit'])) { $this->serverInfos['mac'] = $c['settings']['serverInit']['mac']; } $this->serverInfos['ip'] = $c['settings']['serverInit']['ip']; $this->serverInfos['name'] = $c['settings']['serverName']; } catch (Exception $e) { //Can't parse lua config, reset it @unlink($filename); $this->serverInfos['uuid'] = "Unknown"; $this->serverInfos['ip'] = "None"; $this->serverInfos['name'] = "None"; } //Write setupdone into lua config to tell squeezeplay setup is done and don't bother with that $filename = $config['sq_config_path'] . $config['sq_welcome_file']; $fp = fopen($filename, 'w'); fwrite($fp, 'settings = {setupDone=true,}'); fclose($fp); }