');
$sProduct = utils::ReadParam('applicationName', '', false, 'raw_data');
$sVersion = utils::ReadParam('applicationVersion', '', false, 'raw_data');
$sInstanceUUID = utils::ReadParam('uuidFile', '', false, 'raw_data');
$sDatabaseUUID = utils::ReadParam('uuidBdd', '', false, 'raw_data');
$aExtensions = utils::ReadParam('extensions', array(), false, 'raw_data');
// Basic consistency validation
if ($sProduct != ITOP_APPLICATION) {
throw new Exception("Inconsistent product '$sProduct', expecting '".ITOP_APPLICATION."'");
}
if ($sVersion != ITOP_VERSION) {
throw new Exception("Inconsistent version '$sVersion', expecting ".ITOP_VERSION."'");
}
$sFileUUID = (string)trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n");
if ($sInstanceUUID != $sFileUUID) {
throw new Exception("Inconsistent file UUID '$sInstanceUUID', expecting ".$sFileUUID."'");
}
$sDBUUID = (string)trim(DBProperty::GetProperty('database_uuid', ''), '{}');
if ($sDatabaseUUID != $sDBUUID) {
throw new Exception("Inconsistent database UUID '$sDatabaseUUID', expecting ".$sDBUUID."'");
}
// Uncompression of extensions in data/downloaded-extensions
// only newly downloaded extensions reside in this folder
$i = 0;
$sPath = APPROOT.'data/downloaded-extensions/';
if (!is_dir($sPath)) {
if (!mkdir($sPath)) {
throw new Exception("ERROR: Unable to create the directory '$sPath'. Cannot download any extension. Check the access rights on '".dirname('data/downloaded-extensions/')."'");
}
} else {
// Make sure that the directory is empty
SetupUtils::tidydir($sPath);
}
foreach ($aExtensions as $sBase64Archive) {
$sArchive = base64_decode($sBase64Archive);
$sZipArchiveFile = $sPath."/extension-{$i}.zip";
file_put_contents($sZipArchiveFile, $sArchive);
// Expand the content of extension-x.zip into APPROOT.'data/downloaded-extensions/'
// where the installation will load the extension automatically
$oZip = new ZipArchive();
if (!$oZip->open($sZipArchiveFile)) {
throw new Exception('Unable to open "'.$sZipArchiveFile.'" for extraction. Make sure that the directory "'.'data/downloaded-extensions/'.'" is writable for the web server.');
}
for ($idx = 0; $idx < $oZip->numFiles; $idx++) {
$sCompressedFile = $oZip->getNameIndex($idx);
$oZip->extractTo($sPath, $sCompressedFile);
}
@$oZip->close();
@unlink($sZipArchiveFile); // Get rid of the temporary file
$i++;
}
// Now scan the extensions and display a report of the extensions brought by the hub
$sNextPage = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'land.php', array('operation' => 'install'));
$oPage->add_ready_script("window.location.href='$sNextPage'");
}
function DoInstall(WebPage $oPage)
{
$sUID = hash('sha256', rand());
file_put_contents(APPROOT.'data/hub/compile_authent', $sUID);
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/css/hub.css');
$oPage->add('
');
// Now scan the extensions and display a report of the extensions brought by the hub
// Now scan the extensions and display a report of the extensions brought by the hub
$sPath = APPROOT.'data/downloaded-extensions/';
$aExtraDirs = array();
if (is_dir($sPath)) {
$aExtraDirs[] = $sPath; // Also read the extra downloaded-modules directory
}
$oExtensionsMap = new iTopExtensionsMap('production', true, $aExtraDirs);
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE) {
if (count($oExtension->aMissingDependencies) > 0) {
$oPage->add('