'.gettext("No file name specified").'' . '|');
} elseif (is_dir($_POST['file'])) {
print('|4|' . '
' . gettext("Loading a directory is not supported") .'
' . '|');
} elseif (!is_file($_POST['file'])) {
print('|3|' . '' . gettext("File does not exist or is not a regular file") . '
' . '|');
} else {
$data = file_get_contents(urldecode($_POST['file']));
if ($data === false) {
print('|1|' . '' . gettext("Failed to read file") . '
' . '|');
} else {
$data = base64_encode($data);
print("|0|{$_POST['file']}|{$data}|");
}
}
exit;
case 'save':
if (strlen($_POST['file']) < 1) {
print('|' . ''.gettext("No file name specified").'
' . '|');
} else {
conf_mount_rw();
$_POST['data'] = str_replace("\r", "", base64_decode($_POST['data']));
$ret = file_put_contents($_POST['file'], $_POST['data']);
conf_mount_ro();
if ($_POST['file'] == "/conf/config.xml" || $_POST['file'] == "/cf/conf/config.xml") {
if (file_exists("/tmp/config.cache")) {
unlink("/tmp/config.cache");
}
disable_security_checks();
}
if ($ret === false) {
print('|' . '' . gettext("Failed to write file") . '
' . '|');
} elseif ($ret != strlen($_POST['data'])) {
print('|' . '' . gettext("Error while writing file") . '
' . '|');
} else {
print('|' . '' . gettext("File saved successfully") . '
' . '|');
}
}
exit;
}
exit;
}
require("head.inc");
?>
=gettext("Save / Load a file from the filesystem")?>