mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
Merge branch 'develop' into SessionManagement
This commit is contained in:
@@ -172,33 +172,42 @@ class DBBackup
|
||||
*/
|
||||
public function CreateCompressedBackup($sTargetFile, $sSourceConfigFile = null)
|
||||
{
|
||||
$bIsCmdbSourceInitialized = CMDBSource::GetMysqli() instanceof mysqli;
|
||||
if (!$bIsCmdbSourceInitialized)
|
||||
{
|
||||
$sErrorMsg = 'Cannot backup : CMDBSource not initialized !';
|
||||
$this->LogError($sErrorMsg);
|
||||
throw new CoreException($sErrorMsg);
|
||||
$bReadonlyBefore = SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
try {
|
||||
//safe zone for db backup => cron is stopped/ itop in readonly
|
||||
$bIsCmdbSourceInitialized = CMDBSource::GetMysqli() instanceof mysqli;
|
||||
if (!$bIsCmdbSourceInitialized) {
|
||||
$sErrorMsg = 'Cannot backup : CMDBSource not initialized !';
|
||||
$this->LogError($sErrorMsg);
|
||||
throw new CoreException($sErrorMsg);
|
||||
}
|
||||
|
||||
$this->LogInfo("Creating backup: '$sTargetFile.tar.gz'");
|
||||
|
||||
$oArchive = new ITopArchiveTar($sTargetFile.'.tar.gz');
|
||||
|
||||
$sTmpFolder = APPROOT.'data/tmp-backup-'.rand(10000, getrandmax());
|
||||
$aFiles = $this->PrepareFilesToBackup($sSourceConfigFile, $sTmpFolder);
|
||||
|
||||
$sFilesList = var_export($aFiles, true);
|
||||
$this->LogInfo("backup: adding to archive files '$sFilesList'");
|
||||
$bArchiveCreationResult = $oArchive->createModify($aFiles, '', $sTmpFolder);
|
||||
if (!$bArchiveCreationResult) {
|
||||
$sErrorMsg = 'Cannot backup : unable to create archive';
|
||||
$this->LogError($sErrorMsg);
|
||||
throw new BackupException($sErrorMsg);
|
||||
}
|
||||
|
||||
$this->LogInfo("backup: removing tmp folder '$sTmpFolder'");
|
||||
SetupUtils::rrmdir($sTmpFolder);
|
||||
} finally {
|
||||
if (! $bReadonlyBefore) {
|
||||
SetupUtils::ExitReadOnlyMode();
|
||||
} else {
|
||||
//we are in the scope of main process that needs to handle/keep readonly mode (setup for example).
|
||||
$this->LogInfo("Keep readonly mode after backup");
|
||||
}
|
||||
}
|
||||
|
||||
$this->LogInfo("Creating backup: '$sTargetFile.tar.gz'");
|
||||
|
||||
$oArchive = new ITopArchiveTar($sTargetFile.'.tar.gz');
|
||||
|
||||
$sTmpFolder = APPROOT.'data/tmp-backup-'.rand(10000, getrandmax());
|
||||
$aFiles = $this->PrepareFilesToBackup($sSourceConfigFile, $sTmpFolder);
|
||||
|
||||
$sFilesList = var_export($aFiles, true);
|
||||
$this->LogInfo("backup: adding to archive files '$sFilesList'");
|
||||
$bArchiveCreationResult = $oArchive->createModify($aFiles, '', $sTmpFolder);
|
||||
if (!$bArchiveCreationResult)
|
||||
{
|
||||
$sErrorMsg = 'Cannot backup : unable to create archive';
|
||||
$this->LogError($sErrorMsg);
|
||||
throw new BackupException($sErrorMsg);
|
||||
}
|
||||
|
||||
$this->LogInfo("backup: removing tmp folder '$sTmpFolder'");
|
||||
SetupUtils::rrmdir($sTmpFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2581,6 +2581,10 @@ class MFDocument extends \Combodo\iTop\DesignDocument
|
||||
public function GetNodes($sXPath, $oContextNode = null, $bSafe = true)
|
||||
{
|
||||
$oXPath = new DOMXPath($this);
|
||||
// For Designer audit
|
||||
$oXPath->registerNamespace("php", "http://php.net/xpath");
|
||||
$oXPath->registerPhpFunctions();
|
||||
|
||||
if ($bSafe)
|
||||
{
|
||||
$sXPath .= "[not(@_alteration) or @_alteration!='removed']";
|
||||
|
||||
@@ -1966,11 +1966,13 @@ JS
|
||||
return APPROOT.'log/setup-queries-'.strftime('%Y-%m-%d_%H_%M').'.sql';
|
||||
}
|
||||
|
||||
public static function EnterMaintenanceMode($oConfig)
|
||||
public static function EnterMaintenanceMode($oConfig): bool
|
||||
{
|
||||
$bPreviousMode = self::IsInMaintenanceMode();
|
||||
@touch(MAINTENANCE_MODE_FILE);
|
||||
self::Log("----> Entering maintenance mode");
|
||||
self::WaitCronTermination($oConfig, "maintenance");
|
||||
return $bPreviousMode;
|
||||
}
|
||||
|
||||
public static function ExitMaintenanceMode($bLog = true)
|
||||
@@ -1987,11 +1989,14 @@ JS
|
||||
return file_exists(MAINTENANCE_MODE_FILE);
|
||||
}
|
||||
|
||||
public static function EnterReadOnlyMode($oConfig)
|
||||
public static function EnterReadOnlyMode($oConfig): bool
|
||||
{
|
||||
$bPreviousMode = self::IsInReadOnlyMode();
|
||||
@touch(READONLY_MODE_FILE);
|
||||
self::Log("----> Entering read only mode");
|
||||
self::WaitCronTermination($oConfig, "read only");
|
||||
|
||||
return $bPreviousMode;
|
||||
}
|
||||
|
||||
public static function ExitReadOnlyMode($bLog = true)
|
||||
@@ -2017,8 +2022,7 @@ JS
|
||||
try
|
||||
{
|
||||
// Wait for cron to stop
|
||||
if (is_null($oConfig))
|
||||
{
|
||||
if (is_null($oConfig) || ContextTag::Check(ContextTag::TAG_CRON)) {
|
||||
return;
|
||||
}
|
||||
// Use mutex to check if cron is running
|
||||
|
||||
@@ -720,7 +720,7 @@ CSS
|
||||
foreach ($aLicenses as $oLicense)
|
||||
{
|
||||
$oPage->add('<li><b>'.$oLicense->product.'</b>, © '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:12px;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;"><pre>'.$oLicense->text.'</pre></div>');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text ibo-is-html-content" style="display:none;overflow:auto;max-height:10em;font-size:12px;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;"><pre>'.$oLicense->text.'</pre></div>');
|
||||
$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
|
||||
$oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );');
|
||||
$index++;
|
||||
|
||||
Reference in New Issue
Block a user