mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 14:58:43 +02:00
Backup tools disabled when the demo mode is active
SVN:trunk[3406]
This commit is contained in:
@@ -46,15 +46,22 @@ try
|
||||
$oPage->no_cache();
|
||||
$oPage->SetContentType('text/html');
|
||||
|
||||
try
|
||||
if (utils::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
set_time_limit(0);
|
||||
$oBB = new BackupExec(APPROOT.'data/backups/manual/', 0 /*iRetentionCount*/);
|
||||
$sRes = $oBB->Process(time() + 36000); // 10 hours to complete should be sufficient!
|
||||
$oPage->add("<div data-error-stimulus=\"Error\">Sorry, iTop is in <b>demonstration mode</b>: the feature is disabled.</div>");
|
||||
}
|
||||
catch (Exception $e)
|
||||
else
|
||||
{
|
||||
$oPage->p('Error: '.$e->getMessage());
|
||||
try
|
||||
{
|
||||
set_time_limit(0);
|
||||
$oBB = new BackupExec(APPROOT.'data/backups/manual/', 0 /*iRetentionCount*/);
|
||||
$sRes = $oBB->Process(time() + 36000); // 10 hours to complete should be sufficient!
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$oPage->p('Error: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
$oPage->output();
|
||||
break;
|
||||
@@ -104,39 +111,46 @@ EOF
|
||||
$oPage->no_cache();
|
||||
$oPage->SetContentType('text/html');
|
||||
|
||||
$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
|
||||
$oRestoreMutex = new iTopMutex('restore.'.$sEnvironment);
|
||||
$oRestoreMutex->Lock();
|
||||
try
|
||||
if (utils::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
// Get the file and destroy the token (single usage)
|
||||
$sToken = utils::ReadParam('token', '', false, 'raw_data');
|
||||
$sTokenFile = APPROOT.'/data/restore.'.$sToken.'.tok';
|
||||
$sFile = file_get_contents($sTokenFile);
|
||||
unlink($sTokenFile);
|
||||
|
||||
$sMySQLBinDir = utils::ReadParam('mysql_bindir', '', false, 'raw_data');
|
||||
$sDBHost = utils::ReadParam('db_host', '', false, 'raw_data');
|
||||
$sDBUser = utils::ReadParam('db_user', '', false, 'raw_data');
|
||||
$sDBPwd = utils::ReadParam('db_pwd', '', false, 'raw_data');
|
||||
$sDBName = utils::ReadParam('db_name', '', false, 'raw_data');
|
||||
$sDBSubName = utils::ReadParam('db_subname', '', false, 'raw_data');
|
||||
|
||||
$oDBRS = new DBRestore($sDBHost, $sDBUser, $sDBPwd, $sDBName, $sDBSubName);
|
||||
$oDBRS->SetMySQLBinDir($sMySQLBinDir);
|
||||
|
||||
$sBackupDir = APPROOT.'data/backups/';
|
||||
$sBackupFile = $sBackupDir.$sFile;
|
||||
$sRes = $oDBRS->RestoreFromZip($sBackupFile, $sEnvironment);
|
||||
|
||||
$oRestoreMutex->Unlock();
|
||||
$oPage->add("<div data-error-stimulus=\"Error\">Sorry, iTop is in <b>demonstration mode</b>: the feature is disabled.</div>");
|
||||
}
|
||||
catch (Exception $e)
|
||||
else
|
||||
{
|
||||
$oRestoreMutex->Unlock();
|
||||
$oPage->p('Error: '.$e->getMessage());
|
||||
$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
|
||||
$oRestoreMutex = new iTopMutex('restore.'.$sEnvironment);
|
||||
$oRestoreMutex->Lock();
|
||||
try
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
// Get the file and destroy the token (single usage)
|
||||
$sToken = utils::ReadParam('token', '', false, 'raw_data');
|
||||
$sTokenFile = APPROOT.'/data/restore.'.$sToken.'.tok';
|
||||
$sFile = file_get_contents($sTokenFile);
|
||||
unlink($sTokenFile);
|
||||
|
||||
$sMySQLBinDir = utils::ReadParam('mysql_bindir', '', false, 'raw_data');
|
||||
$sDBHost = utils::ReadParam('db_host', '', false, 'raw_data');
|
||||
$sDBUser = utils::ReadParam('db_user', '', false, 'raw_data');
|
||||
$sDBPwd = utils::ReadParam('db_pwd', '', false, 'raw_data');
|
||||
$sDBName = utils::ReadParam('db_name', '', false, 'raw_data');
|
||||
$sDBSubName = utils::ReadParam('db_subname', '', false, 'raw_data');
|
||||
|
||||
$oDBRS = new DBRestore($sDBHost, $sDBUser, $sDBPwd, $sDBName, $sDBSubName);
|
||||
$oDBRS->SetMySQLBinDir($sMySQLBinDir);
|
||||
|
||||
$sBackupDir = APPROOT.'data/backups/';
|
||||
$sBackupFile = $sBackupDir.$sFile;
|
||||
$sRes = $oDBRS->RestoreFromZip($sBackupFile, $sEnvironment);
|
||||
|
||||
$oRestoreMutex->Unlock();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$oRestoreMutex->Unlock();
|
||||
$oPage->p('Error: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
$oPage->output();
|
||||
break;
|
||||
@@ -146,6 +160,10 @@ EOF
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
|
||||
|
||||
if (utils::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
throw new Exception('iTop is in demonstration mode: the feature is disabled');
|
||||
}
|
||||
$sFile = utils::ReadParam('file', '', false, 'raw_data');
|
||||
$oBackup = new DBBackupScheduled();
|
||||
$sBackupDir = APPROOT.'data/backups/';
|
||||
|
||||
@@ -184,6 +184,10 @@ if ($bSimulate)
|
||||
{
|
||||
$oP->p("Simulate: would create file '$sZipArchiveFile'");
|
||||
}
|
||||
elseif (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oP->p("Sorry, iTop is in demonstration mode: the feature is disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
$oBackup->CreateZip($sZipArchiveFile);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
SetupWebPage::AddModule(
|
||||
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
|
||||
'itop-backup/2.1.0',
|
||||
'itop-backup/2.1.1',
|
||||
array(
|
||||
// Identification
|
||||
//
|
||||
|
||||
@@ -50,6 +50,11 @@ try
|
||||
{
|
||||
$oP->add("<h1>".Dict::S('bkp-status-title')."</h1>");
|
||||
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oP->add("<div class=\"header_message message_info\">iTop is in <b>demonstration mode</b>: the feature is disabled.</div>");
|
||||
}
|
||||
|
||||
$sImgOk = '<img src="../images/validation_ok.png"> ';
|
||||
$sImgError = '<img src="../images/validation_error.png"> ';
|
||||
|
||||
@@ -181,8 +186,15 @@ try
|
||||
{
|
||||
$sFileName = basename($sBackupFile);
|
||||
$sFilePath = 'auto/'.$sFileName;
|
||||
$sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
|
||||
$sName = "<a href=\"$sAjax\">".$sFileName.'</a>';
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$sName = $sFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
|
||||
$sName = "<a href=\"$sAjax\">".$sFileName.'</a>';
|
||||
}
|
||||
$sSize = SetupUtils::HumanReadableSize(filesize($sBackupFile));
|
||||
$sConfirmRestore = addslashes(Dict::Format('bkp-confirm-restore', $sFileName));
|
||||
$sFileEscaped = addslashes($sFilePath);
|
||||
@@ -222,8 +234,15 @@ try
|
||||
{
|
||||
$sFileName = basename($sBackupFile);
|
||||
$sFilePath = 'manual/'.$sFileName;
|
||||
$sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
|
||||
$sName = "<a href=\"$sAjax\">".$sFileName.'</a>';
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$sName = $sFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
|
||||
$sName = "<a href=\"$sAjax\">".$sFileName.'</a>';
|
||||
}
|
||||
$sSize = SetupUtils::HumanReadableSize(filesize($sBackupFile));
|
||||
$sConfirmRestore = addslashes(Dict::Format('bkp-confirm-restore', $sFileName));
|
||||
$sFileEscaped = addslashes($sFilePath);
|
||||
@@ -376,6 +395,11 @@ function LaunchRestoreNow(sBackupFile, sConfirmationMessage)
|
||||
}
|
||||
EOF
|
||||
);
|
||||
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oP->add_ready_script("$('button').attr('disabled', 'disabled').attr('title', 'Disabled in demonstration mode')");
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user