echo "\nConfig written\n"; $success = true; } else { echo "\nConfig not written (invalid)\n"; } echo "</pre>"; if ($success) { echo '<input type="button" value="OK" onClick="window.location.href=window.location.href">'; } else { echo '<input type="button" value="Back" onClick="history.go(-1)">'; } die; } $code = Configurator::loadCode($filename); $config = Configurator::parseConfig($code); echo Configurator::generateForm($config); class Configurator { public static function loadCode($filename) { if (!file_exists($filename)) { $filename .= '.template'; } if (!file_exists($filename)) { throw new \Exception("Could not read: {$filename}"); } return file_get_contents($filename); } public static function writeCode($filename, $code) { file_put_contents($filename, $code);