mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
- Changes to the setup program: Backup now works for real
- A few cosmetic changes... SVN:trunk[2252]
This commit is contained in:
@@ -141,31 +141,31 @@ try
|
||||
ini_set('display_errors', true);
|
||||
ini_set('display_startup_errors', true);
|
||||
|
||||
$sConfigFile = utils::GetConfigFilePath();
|
||||
if (file_exists($sConfigFile) && !is_writable($sConfigFile))
|
||||
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
|
||||
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
|
||||
|
||||
$sClass = utils::ReadParam('step_class', '');
|
||||
$sState = utils::ReadParam('step_state', '');
|
||||
$sActionCode = utils::ReadParam('code', '');
|
||||
$aParams = utils::ReadParam('params', array(), false, 'raw_data');
|
||||
$oPage = new ajax_page('');
|
||||
$oDummyController = new WizardController('');
|
||||
if (is_subclass_of($sClass, 'WizardStep'))
|
||||
{
|
||||
$oPage->error("<b>Error:</b> the configuration file '".$sConfigFile."' already exists and cannot be overwritten.");
|
||||
$oPage->p("The wizard cannot modify the configuration file for you. If you want to upgrade ".ITOP_APPLICATION.", make sure that the file '<b>".realpath($sConfigFile)."</b>' can be modified by the web server.");
|
||||
$oPage->output();
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
|
||||
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
|
||||
|
||||
$sClass = utils::ReadParam('step_class', '');
|
||||
$sState = utils::ReadParam('step_state', '');
|
||||
$sActionCode = utils::ReadParam('code', '');
|
||||
$aParams = utils::ReadParam('params', array(), false, 'raw_data');
|
||||
$oPage = new ajax_page('');
|
||||
$oDummyController = new WizardController('');
|
||||
if (is_subclass_of($sClass, 'WizardStep'))
|
||||
$oStep = new $sClass($oDummyController, $sState);
|
||||
$sConfigFile = utils::GetConfigFilePath();
|
||||
if (file_exists($sConfigFile) && !is_writable($sConfigFile) && $oStep->RequiresWritableConfig())
|
||||
{
|
||||
$oPage->error("<b>Error:</b> the configuration file '".$sConfigFile."' already exists and cannot be overwritten.");
|
||||
$oPage->p("The wizard cannot modify the configuration file for you. If you want to upgrade ".ITOP_APPLICATION.", make sure that the file '<b>".realpath($sConfigFile)."</b>' can be modified by the web server.");
|
||||
$oPage->output();
|
||||
}
|
||||
else
|
||||
{
|
||||
$oStep = new $sClass($oDummyController, $sState);
|
||||
$oStep->AsyncAction($oPage, $sActionCode, $aParams);
|
||||
}
|
||||
$oPage->output();
|
||||
}
|
||||
$oPage->output();
|
||||
break;
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
@@ -127,7 +127,7 @@ class ApplicationInstaller
|
||||
$aCopies = $aPreinstall['copies'];
|
||||
|
||||
$sReport = self::DoCopy($aCopies);
|
||||
$sReport = "copy disabled...";
|
||||
$sReport = "Copying...";
|
||||
|
||||
$aResult = array(
|
||||
'status' => self::OK,
|
||||
@@ -136,7 +136,7 @@ class ApplicationInstaller
|
||||
if (isset($aPreinstall['backup']))
|
||||
{
|
||||
$aResult['next-step'] = 'backup';
|
||||
$aResult['next-step-label'] = 'Backuping the database';
|
||||
$aResult['next-step-label'] = 'Performing a backup of the database';
|
||||
$aResult['percentage-completed'] = 20;
|
||||
}
|
||||
else
|
||||
@@ -224,7 +224,7 @@ class ApplicationInstaller
|
||||
'status' => self::OK,
|
||||
'message' => '',
|
||||
'next-step' => 'after-db-create',
|
||||
'next-step-label' => 'Creating Profiles',
|
||||
'next-step-label' => 'Creating profiles',
|
||||
'percentage-completed' => 60,
|
||||
);
|
||||
break;
|
||||
@@ -260,7 +260,7 @@ class ApplicationInstaller
|
||||
'status' => self::OK,
|
||||
'message' => '',
|
||||
'next-step' => 'sample-data',
|
||||
'next-step-label' => 'Loading Sample Data',
|
||||
'next-step-label' => 'Loading sample data',
|
||||
'percentage-completed' => 80,
|
||||
);
|
||||
|
||||
@@ -268,7 +268,7 @@ class ApplicationInstaller
|
||||
if (!$bLoadData)
|
||||
{
|
||||
$aResult['next-step'] = 'create-config';
|
||||
$aResult['next-step-label'] = 'Creating the Configuration File';
|
||||
$aResult['next-step-label'] = 'Creating the configuration File';
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -291,7 +291,7 @@ class ApplicationInstaller
|
||||
'status' => self::INFO,
|
||||
'message' => 'All data loaded',
|
||||
'next-step' => 'create-config',
|
||||
'next-step-label' => 'Creating the Configuration File',
|
||||
'next-step-label' => 'Creating the configuration File',
|
||||
'percentage-completed' => 99,
|
||||
);
|
||||
break;
|
||||
@@ -401,7 +401,13 @@ class ApplicationInstaller
|
||||
}
|
||||
|
||||
$sSourcePath = APPROOT.$sSourceDir;
|
||||
$aDirsToScan = array($sSourcePath);
|
||||
$sExtensionsPath = APPROOT.$sExtensionDir;
|
||||
if (is_dir($sExtensionsPath))
|
||||
{
|
||||
// if the extensions dir exists, scan it for additional modules as well
|
||||
$aDirsToScan[] = $sExtensionsPath;
|
||||
}
|
||||
$sTargetPath = APPROOT.$sTargetDir;
|
||||
if (!is_dir($sSourcePath))
|
||||
{
|
||||
@@ -421,7 +427,7 @@ class ApplicationInstaller
|
||||
}
|
||||
}
|
||||
|
||||
$oFactory = new ModelFactory(array($sSourcePath, $sExtensionsPath));
|
||||
$oFactory = new ModelFactory($aDirsToScan);
|
||||
$aModules = $oFactory->FindModules();
|
||||
|
||||
foreach($aModules as $foo => $oModule)
|
||||
|
||||
@@ -617,10 +617,10 @@ class SetupUtils
|
||||
$oPage->add('<table>');
|
||||
if ($bAllowDBCreation)
|
||||
{
|
||||
$oPage->add('<tr><td><input type="radio" id="existing_db" name="create_db" value="no"/><label for="existing_db"> Use the existing database:</label></td>');
|
||||
$oPage->add('<td id="db_name_container"><input id="db_name" name="db_name" size="15" maxlen="32" value="'.htmlentities($sDBName, ENT_QUOTES, 'UTF-8').'"/><span style="width:20px;" id="v_db_name"></span></td></tr>');
|
||||
$oPage->add('<tr><td><input type="radio" id="create_db" name="create_db" value="yes"/><label for="create_db"> Create a new database:</label></td>');
|
||||
$oPage->add('<td><input id="db_new_name" type="text" name="db_new_name" value="'.htmlentities($sNewDBName, ENT_QUOTES, 'UTF-8').'" size="15" maxlength="32"/><span style="width:20px;" id="v_db_new_name"></span></td></tr>');
|
||||
$oPage->add('<tr><td><input type="radio" id="existing_db" name="create_db" value="no"/><label for="existing_db"> Use the existing database:</label></td>');
|
||||
$oPage->add('<td id="db_name_container"><input id="db_name" name="db_name" size="15" maxlen="32" value="'.htmlentities($sDBName, ENT_QUOTES, 'UTF-8').'"/><span style="width:20px;" id="v_db_name"></span></td></tr>');
|
||||
$oPage->add('<tr><td>Use a prefix for the tables:</td><td><input id="db_prefix" type="text" name="db_prefix" value="'.htmlentities($sDBPrefix, ENT_QUOTES, 'UTF-8').'" size="15" maxlength="32"/><span style="width:20px;" id="v_db_prefix"></span></td></tr>');
|
||||
}
|
||||
else
|
||||
|
||||
@@ -465,14 +465,7 @@ EOF
|
||||
|
||||
$sInstalledVersion = $aInstalledInfo['product_version'];
|
||||
$sInstalledDataModelVersion = $aInstalledInfo['datamodel_version'];
|
||||
|
||||
if ($sInstalledDataModelVersion == '$ITOP_VERSION$.$WCREV$')
|
||||
{
|
||||
// Special case for upgrading some development versions (temporary)
|
||||
$sLatestDMDir = SetupUtils::GetLatestDataModelDir();
|
||||
$sInstalledDataModelVersion = SetupUtils::GetDataModelVersion($sLatestDMDir);
|
||||
}
|
||||
|
||||
|
||||
$oPage->add("<h2>Information about the upgrade from version $sInstalledVersion to ".ITOP_VERSION.'.'.ITOP_REVISION."</h2>");
|
||||
|
||||
if ($sInstalledVersion == (ITOP_VERSION.'.'.ITOP_REVISION))
|
||||
@@ -481,13 +474,25 @@ EOF
|
||||
$bDisplayLicense = false;
|
||||
}
|
||||
$this->oWizard->SetParameter('license', $bDisplayLicense); // Remember for later
|
||||
|
||||
echo "sInstalledDataModelVersion: $sInstalledDataModelVersion";
|
||||
|
||||
if ($sInstalledDataModelVersion == '$ITOP_VERSION$.$WCREV$')
|
||||
{
|
||||
// Special case for upgrading some development versions (temporary)
|
||||
$sCompatibleDMDir = SetupUtils::GetLatestDataModelDir();
|
||||
$sInstalledDataModelVersion = SetupUtils::GetDataModelVersion($sLatestDMDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sCompatibleDMDir = SetupUtils::GetCompatibleDataModelDir($sInstalledDataModelVersion);
|
||||
}
|
||||
|
||||
if ($sCompatibleDMDir === false)
|
||||
{
|
||||
// No compatible version exists... cannot upgrade. Either it is too old, or too new (downgrade !)
|
||||
$this->bCanMoveForward = false;
|
||||
$oPage->p("The current version of ".ITOP_APPLICATION." (".ITOP_VERSION.'.'.ITOP_REVISION.") does not sem to be compatible with the installed version ($sInstalledVersion).");
|
||||
$oPage->p("The current version of ".ITOP_APPLICATION." (".ITOP_VERSION.'.'.ITOP_REVISION.") does not seem to be compatible with the installed version ($sInstalledVersion).");
|
||||
$oPage->p("The upgrade cannot continue, sorry.");
|
||||
}
|
||||
else
|
||||
@@ -668,7 +673,7 @@ class WizStepLicense extends WizardStep
|
||||
foreach($aLicenses as $index => $oLicense)
|
||||
{
|
||||
$oPage->add('<li><b>'.$oLicense->product.'</b>, licensed by '.$oLicense->author.' 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:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'<div>');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'</div>');
|
||||
$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
|
||||
$oPage->add_ready_script('$("#toggle_'.$index.'").click( function() { $("#license_'.$index.'").toggle(); } );');
|
||||
}
|
||||
@@ -748,7 +753,7 @@ class WizStepDBParams extends WizardStep
|
||||
$oPage->add('<table>');
|
||||
SetupUtils::DisplayDBParameters($oPage, true, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sNewDBName);
|
||||
$oPage->add('</table>');
|
||||
$sCreateDB = $this->oWizard->GetParameter('create_db', 'no');
|
||||
$sCreateDB = $this->oWizard->GetParameter('create_db', 'yes');
|
||||
if ($sCreateDB == 'no')
|
||||
{
|
||||
$oPage->add_ready_script('$("#existing_db").attr("checked", "checked");');
|
||||
@@ -1845,7 +1850,7 @@ EOF
|
||||
|
||||
if ($sBackupDestination != '')
|
||||
{
|
||||
$aInstallParams['backup'] = array (
|
||||
$aInstallParams['preinstall']['backup'] = array (
|
||||
'destination' => $sBackupDestination,
|
||||
'configuration_file' => $sPreviousConfigurationFile,
|
||||
);
|
||||
@@ -1973,13 +1978,30 @@ class WizStepDone extends WizardStep
|
||||
$oPage->add("<h2>Congratulations for installing iTop</h2>");
|
||||
$oPage->ok("The installation completed successfully.");
|
||||
}
|
||||
|
||||
if ($this->oWizard->GetParameter('db_backup', false))
|
||||
{
|
||||
$sBackupDestination = $this->oWizard->GetParameter('db_backup_path', '');
|
||||
if (file_exists($sBackupDestination))
|
||||
{
|
||||
// To mitigate security risks: pass only the filename without the extension, the download will add the extensino itself
|
||||
$sTruncatedFilePath = preg_replace('/\.zip$/', '', $sBackupDestination);
|
||||
$oPage->p('Your backup is ready');
|
||||
$oPage->p('<a style="background:transparent;" href="'.utils::GetAbsoluteUrlAppRoot().'setup/ajax.dataloader.php?operation=async_action&step_class=WizStepDone¶ms[backup]='.urlencode($sTruncatedFilePath).'" target="_blank"><img src="../images/tar.png" style="border:0;vertical-align:middle;"> Download '.basename($sBackupDestination).'</a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$oPage->p('<img src="../images/error.png"/> Warning: Backup creation failed !');
|
||||
}
|
||||
}
|
||||
|
||||
// Form goes here.. No back button since the job is done !
|
||||
$oPage->add('<table style="width:600px;border:0;padding:0;"><tr>');
|
||||
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Free: Register your iTop version.\" href=\"http://www.combodo.com/register?product=iTop&version=".urlencode(ITOP_VERSION." revision ".ITOP_REVISION)."\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-register.gif\"/></td></a>");
|
||||
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Support from Combodo\" href=\"http://www.combodo.com/itopsupport\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-support.gif\"/></td></a>");
|
||||
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Training from Combodo\" href=\"http://www.combodo.com/itoptraining\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-training.gif\"/></td></a>");
|
||||
$oPage->add('</tr></table>');
|
||||
$sForm = '<form method="post" action="'.$this->oWizard->GetParameter('application_url').'/pages/UI.php">';
|
||||
$sForm = '<form method="post" action="'.$this->oWizard->GetParameter('application_url').'pages/UI.php">';
|
||||
$sForm .= '<input type="hidden" name="auth_user" value="'.htmlentities($this->oWizard->GetParameter('admin_user'), ENT_QUOTES, 'UTF-8').'">';
|
||||
$sForm .= '<input type="hidden" name="auth_pwd" value="'.htmlentities($this->oWizard->GetParameter('admin_pwd'), ENT_QUOTES, 'UTF-8').'">';
|
||||
$sForm .= "<p style=\"text-align:center;width:100%\"><button id=\"enter_itop\" type=\"submit\">Enter iTop</button></p>";
|
||||
@@ -2007,4 +2029,18 @@ class WizStepDone extends WizardStep
|
||||
return false; //This step executes once the config was written and secured
|
||||
}
|
||||
|
||||
public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
|
||||
{
|
||||
$oParameters = new PHPParameters();
|
||||
// For security reasons: add the extension now so that this action can be used to read *only* .zip files from the disk...
|
||||
$sBackupFile = $aParameters['backup'].'.zip';
|
||||
if (file_exists($sBackupFile))
|
||||
{
|
||||
// Make sure there is NO output at all before our content, otherwise the document will be corrupted
|
||||
$sPreviousContent = ob_get_clean();
|
||||
$oPage->SetContentType('application/zip');
|
||||
$oPage->SetContentDisposition('attachment', basename($sBackupFile));
|
||||
$oPage->add(file_get_contents($sBackupFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user