<?php
define("PAGE_ID","advanced");
define("PAGE_TITLE","Nawui Configuration");
require_once("includes/main.inc.php");
include_once("html_wrap/head.inc.php");
$nawuiconf = dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"])."/nawui.conf";
function WriteConfigFile($content) {
global $nawuiconf;
// Let's make sure the file exists and is writable first.
if (is_writable($nawuiconf)) {
// Opening $filename in writing mode only.
if (!$handle = fopen($nawuiconf, 'w')) {
print "Cannot open file ($nawuiconf)";
exit;
}
// Write $content to our opened file.
$content = str_replace("\\\"", "\"", $content);
$content = str_replace("\'", "'", $content);
if (!fwrite($handle, $content)) {
print "Cannot write to file ($nawuiconf)";
exit;
}
print "<div align=\"center\"><font color=\"#009900\">Nawui Configuration was successfuly saved.</font></div>";
fclose($handle);
} else print "<div align=\"center\"><font color=\"#FF2222\">Nawui Configuration is not writable.</font></div>";
}
echo "<br>";
if ($action == "Save") {
WriteConfigFile($nawuiconf_textarea);
} else echo "<br>";
?>
<div align="center">
<table>
<tr class="dataEven">
<td>
<b><?=$nawuiconf?>: </b>
</td>
</tr>
<tr class="dataOdd">
<td>
<form name="nawuiconf_form" action="nawuiconf.php" method="POST">
<textarea name="nawuiconf_textarea" rows="25" cols="80">
<?=implode("", file("$nawuiconf"));?>
</textarea>
</td>
</tr>
<tr data="dataOdd">
<td align="right">
<input type="submit" name="action" value="Save">
<input type="submit" name="action" value="Cancel">
</form>
</td>
</tr>
</table>
</div>
<br>
<?
include_once("html_wrap/tail.inc.php");
?>