do not provide backup tools if backup dir is not set

This commit is contained in:
Uwe Steinmann 2019-07-30 07:08:10 +02:00
parent ce420a78eb
commit 5997717099

View File

@ -74,110 +74,114 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
// archive creation ////////////////////////////////////////////////////////////
$this->contentHeading(getMLText("archive_creation"));
print "<p>".getMLText("archive_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form action=\"../op/op.CreateFolderArchive.php\" name=\"form2\">";
$this->printFolderChooserHtml("form2",M_READWRITE);
print "<label class=\"checkbox\"><input type=\"checkbox\" name=\"human_readable\" value=\"1\">".getMLText("human_readable")."</label>";
print "<input type='submit' class='btn' name='' value='".getMLText("archive_creation")."'/>";
print "</form>\n";
if($this->params['hasbackupdir']) {
$this->contentHeading(getMLText("archive_creation"));
print "<p>".getMLText("archive_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form action=\"../op/op.CreateFolderArchive.php\" name=\"form2\">";
$this->printFolderChooserHtml("form2",M_READWRITE);
print "<label class=\"checkbox\"><input type=\"checkbox\" name=\"human_readable\" value=\"1\">".getMLText("human_readable")."</label>";
print "<input type='submit' class='btn' name='' value='".getMLText("archive_creation")."'/>";
print "</form>\n";
// list backup files
// list backup files
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".tar.gz")==FALSE) continue;
$entries[] = $e;
}
closedir($handle);
sort($entries);
$entries = array_reverse($entries);
if($entries) {
$this->contentSubHeading(getMLText("backup_list"));
print "<table class=\"table-condensed\">\n";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("folder")."</th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach ($entries as $entry){
$folderid=substr($entry,strpos($entry,"_")+1);
$folder=$dms->getFolder((int)$folderid);
print "<tr>\n";
print "<td><a href=\"../op/op.Download.php?arkname=".$entry."\">".$entry."</a></td>\n";
if (is_object($folder)) print "<td>".htmlspecialchars($folder->getName())."</td>\n";
else print "<td>".getMLText("unknown_id")."</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveArchive.php?arkname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("backup_remove")."</a>";
print "</td>\n";
print "</tr>\n";
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".tar.gz")==FALSE) continue;
$entries[] = $e;
}
print "</table>\n";
}
closedir($handle);
$this->contentContainerEnd();
sort($entries);
$entries = array_reverse($entries);
// dump creation ///////////////////////////////////////////////////////////////
if($entries) {
$this->contentSubHeading(getMLText("backup_list"));
print "<table class=\"table-condensed\">\n";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("folder")."</th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
$this->contentHeading(getMLText("dump_creation"));
print "<p>".getMLText("dump_creation_warning")."</p>\n";
$this->contentContainerStart();
foreach ($entries as $entry){
print "<form action=\"../op/op.CreateDump.php\" name=\"form4\">";
print "<input type='submit' class='btn' name='' value='".getMLText("dump_creation")."'/>";
print "</form>\n";
// list backup files
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".sql.gz")==FALSE) continue;
$entries[] = $e;
}
closedir($handle);
sort($entries);
$entries = array_reverse($entries);
if($entries) {
$this->contentSubHeading(getMLText("dump_list"));
print "<table class=\"table-condensed\">\n";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach ($entries as $entry){
print "<tr>\n";
print "<td>";
print "<a href=\"../op/op.Download.php?dumpname=".$entry."\">".$entry."</a>";
print "</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveDump.php?dumpname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("dump_remove")."</a>";
print "</td>\n";
print "</tr>\n";
$folderid=substr($entry,strpos($entry,"_")+1);
$folder=$dms->getFolder((int)$folderid);
print "<tr>\n";
print "<td><a href=\"../op/op.Download.php?arkname=".$entry."\">".$entry."</a></td>\n";
if (is_object($folder)) print "<td>".htmlspecialchars($folder->getName())."</td>\n";
else print "<td>".getMLText("unknown_id")."</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveArchive.php?arkname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("backup_remove")."</a>";
print "</td>\n";
print "</tr>\n";
}
print "</table>\n";
}
print "</table>\n";
}
$this->contentContainerEnd();
$this->contentContainerEnd();
// dump creation ///////////////////////////////////////////////////////////////
$this->contentHeading(getMLText("dump_creation"));
print "<p>".getMLText("dump_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form action=\"../op/op.CreateDump.php\" name=\"form4\">";
print "<input type='submit' class='btn' name='' value='".getMLText("dump_creation")."'/>";
print "</form>\n";
// list backup files
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".sql.gz")==FALSE) continue;
$entries[] = $e;
}
closedir($handle);
sort($entries);
$entries = array_reverse($entries);
if($entries) {
$this->contentSubHeading(getMLText("dump_list"));
print "<table class=\"table-condensed\">\n";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach ($entries as $entry){
print "<tr>\n";
print "<td>";
print "<a href=\"../op/op.Download.php?dumpname=".$entry."\">".$entry."</a>";
print "</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveDump.php?dumpname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("dump_remove")."</a>";
print "</td>\n";
print "</tr>\n";
}
print "</table>\n";
}
$this->contentContainerEnd();
} else {
$this->warningMsg(getMLText('no_backup_dir'));
}
// files deletion //////////////////////////////////////////////////////////////
/*