From 599771709914a191761d3e3c77ed4323c4cf45df Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 30 Jul 2019 07:08:10 +0200 Subject: [PATCH] do not provide backup tools if backup dir is not set --- views/bootstrap/class.BackupTools.php | 194 +++++++++++++------------- 1 file changed, 99 insertions(+), 95 deletions(-) diff --git a/views/bootstrap/class.BackupTools.php b/views/bootstrap/class.BackupTools.php index f9b28b892..6ec1754bc 100644 --- a/views/bootstrap/class.BackupTools.php +++ b/views/bootstrap/class.BackupTools.php @@ -74,110 +74,114 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style { // archive creation //////////////////////////////////////////////////////////// - $this->contentHeading(getMLText("archive_creation")); - print "

".getMLText("archive_creation_warning")."

\n"; - $this->contentContainerStart(); - print "
"; - $this->printFolderChooserHtml("form2",M_READWRITE); - print ""; - print ""; - print "
\n"; + if($this->params['hasbackupdir']) { + $this->contentHeading(getMLText("archive_creation")); + print "

".getMLText("archive_creation_warning")."

\n"; + $this->contentContainerStart(); + print "
"; + $this->printFolderChooserHtml("form2",M_READWRITE); + print ""; + print ""; + print "
\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 "\n"; - print "\n\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n\n\n"; - - foreach ($entries as $entry){ - - $folderid=substr($entry,strpos($entry,"_")+1); - $folder=$dms->getFolder((int)$folderid); - - print "\n"; - print "\n"; - if (is_object($folder)) print "\n"; - else print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\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 "
".getMLText("folder")."".getMLText("creation_date")."".getMLText("file_size")."
".$entry."".htmlspecialchars($folder->getName())."".getMLText("unknown_id")."".getLongReadableDate(filectime($backupdir.$entry))."".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry)).""; - print " ".getMLText("backup_remove").""; - print "
\n"; - } + closedir($handle); - $this->contentContainerEnd(); + sort($entries); + $entries = array_reverse($entries); - // dump creation /////////////////////////////////////////////////////////////// + if($entries) { + $this->contentSubHeading(getMLText("backup_list")); + print "\n"; + print "\n\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; - $this->contentHeading(getMLText("dump_creation")); - print "

".getMLText("dump_creation_warning")."

\n"; - $this->contentContainerStart(); + foreach ($entries as $entry){ - print ""; - print ""; - print "\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 "
".getMLText("folder")."".getMLText("creation_date")."".getMLText("file_size")."
\n"; - print "\n\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n\n\n"; - - foreach ($entries as $entry){ - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + $folderid=substr($entry,strpos($entry,"_")+1); + $folder=$dms->getFolder((int)$folderid); + + print "\n"; + print "\n"; + if (is_object($folder)) print "\n"; + else print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + } + print "
".getMLText("creation_date")."".getMLText("file_size")."
"; - print "".$entry.""; - print "".getLongReadableDate(filectime($backupdir.$entry))."".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry)).""; - print " ".getMLText("dump_remove").""; - print "
".$entry."".htmlspecialchars($folder->getName())."".getMLText("unknown_id")."".getLongReadableDate(filectime($backupdir.$entry))."".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry)).""; + print " ".getMLText("backup_remove").""; + print "
\n"; } - print "\n"; - } - $this->contentContainerEnd(); + $this->contentContainerEnd(); + + // dump creation /////////////////////////////////////////////////////////////// + + $this->contentHeading(getMLText("dump_creation")); + print "

".getMLText("dump_creation_warning")."

\n"; + $this->contentContainerStart(); + + print "
"; + print ""; + print "
\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 "\n"; + print "\n\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + + foreach ($entries as $entry){ + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + } + print "
".getMLText("creation_date")."".getMLText("file_size")."
"; + print "".$entry.""; + print "".getLongReadableDate(filectime($backupdir.$entry))."".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry)).""; + print " ".getMLText("dump_remove").""; + print "
\n"; + } + + $this->contentContainerEnd(); + } else { + $this->warningMsg(getMLText('no_backup_dir')); + } // files deletion ////////////////////////////////////////////////////////////// /*