$action = $_REQUEST['action_do'];
$modName = $_REQUEST['modName'];
$backURL = $_REQUEST['backURL'];
$cfgTool = $_REQUEST['cfgTool'];
if ($cfgTool == '') { $cfgTool = 'configtool'; }
if ($modName == "") {
exit;
}
$modDir = '/raid/data/module/'.$modName;
$configTool = $modDir.'/system/'.$cfgTool;
$tmpfile = '/tmp/tmpcfg_'.$modName.'.tar.gz';
if ($action == 'Download')
{
$cmd = $configTool.' getconfig "'.$modName.'" "'.$tmpFile.'" &>/dev/null && echo OK';
$status = trim (shell_exec ($cmd));
if ($status == 'OK') {
$fileName = 'N5200-config-'.$modName.'.tar.gz';
$fileSize = filesize ($tmpfile);
header ('Pragma: public');
header ('Expires: 0');
header ('Last-Modified: '.gmdate('D, d M Y H:i ').' GMT');
header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header ('Cache-Control: private', false);
header ('Content-Type: application/octet-stream');
header ('Content-Length: '.$fileSize);
header ('Content-Disposition: attachment; filename="'.$fileName.'";');
header ('Content-Transfer-Encoding: binary');
readfile ($tmpfile);
} else {
print 'Error creating config save: '.$status;
print 'cmd: '.$cmd;
}
}
elseif ($action == 'Upload')
{
include_once ("/img/www/inc/msgbox.inc.php");
$tmpfile = '/tmp/tmpcfg_'.$modName.'.tar.gz';
move_uploaded_file ($_FILES['cfgfile']['tmp_name'], $tmpfile);
$cmd = $configTool.' putconfig "'.$modName.'" "'.$tmpfile.'" &>/tmp/conftool.out && echo OK';
$status = trim (shell_exec ($cmd));
$title = 'Upload configuration for module '.$modName;
if ($status != "OK")
{
$errors = shell_exec('cat /tmp/conftool.out');
$a = new msgBox ("ERROR: cannot install configuration files!
".$errors, "OKOnly", $title);
}
else
{
$a = new msgBox ('Success: uploaded configuration for module '.$modName.'', 'OKOnly', $title);
}
$a->makeLinks (array ($backURL));
$a->showMsg ();
}
shell_exec ("rm -f $tmpfile");
exit;
?>