/** * Retrieves an object for the specified engine. It reads the engine.ini in order to do that. * It will also call the _addEngineInclude to make sure the included file persists during * the backup session. * * @param string $engine The engine type (lister, dumper, packer) * @param string $item The engine class file name (e.g. deafault, jpa, etc) */ function &_getAnEngine($engine, $item) { // Load engine definitions JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating {$engine} engine of type {$item}"); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to read engine setup data for {$engine}"); // Find and parse all ini files in the given directory $ini_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'engine' . DS . $engine; jimport('joomla.filesystem.folder'); $ini_files = JFolder::files($ini_path, '\\.ini$'); $engineArray = array(); if (count($ini_files)) { foreach ($ini_files as $sourceINI) { $myData = JoomlapackHelperUtils::parse_ini_file($ini_path . DS . $sourceINI, true); foreach ($myData as $key => $value) { $engineArray[$key] = $value; } } } if (isset($engineArray[$item])) { $engineDescriptor = $engineArray[$item]; $dotted = 'engine.' . $engine . '.' . $engineDescriptor['include']; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to include engine file {$dotted}"); $this->_addEngineInclude($dotted); jpimport($dotted); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Instanciating " . $engineDescriptor['class']); $instance = new $engineDescriptor['class'](); // If we are getting an archiver class, also populate the _archiveExtension field if ($engine == 'packer') { $this->archiveExtension = $engineDescriptor['extension']; } return $instance; } else { $this->setError(JText::sprintf('CUBE_PROVISIONING_ENGINENOTFOUND', $engine . '.' . $item)); return false; } }
/** * Initializes the array of filters. Reads the data of the filter.ini in the * classes/filter directory. */ function init() { // Load the filter.ini jpimport('helpers.utils', true); // Find and parse all ini files in the given directory $ini_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'filter'; jimport('joomla.filesystem.folder'); $ini_files = JFolder::files($ini_path, '\\.ini$'); $filterArray = array(); if (count($ini_files)) { foreach ($ini_files as $sourceINI) { $myData = JoomlapackHelperUtils::parse_ini_file($ini_path . DS . $sourceINI, true); foreach ($myData as $key => $value) { $filterArray[$key] = $value; } } } // Walk through INI file entries and add them to the filter list foreach ($filterArray as $filter) { $this->addFilter('filter.' . $filter['include'], $filter['class']); } }
function _getEngineList($engine) { jpimport('helpers.utils', true); // Load engine definitions $ini_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'engine' . DS . $engine; jimport('joomla.filesystem.folder'); $ini_files = JFolder::files($ini_path, '\\.ini$'); $engineArray = array(); if (count($ini_files)) { foreach ($ini_files as $sourceINI) { $myData = JoomlapackHelperUtils::parse_ini_file($ini_path . DS . $sourceINI, true); foreach ($myData as $key => $value) { $engineArray[$key] = $value; } } } // Create selection list array $options = array(); foreach ($engineArray as $sectionKey => $engineItem) { // Use translation keys for engine names $description = JText::_($engineItem['translationkey']); $options[] = JHTML::_('select.option', $sectionKey, $description); } return $options; }
/** * Retrieves an object for the specified engine. It reads the engine.ini in order to do that. * It will also call the _addEngineInclude to make sure the included file persists during * the backup session. * * @param string $engine The engine type (lister, dumper, packer) * @param string $item The engine class file name (e.g. deafault, jpa, etc) */ function &_getAnEngine($engine, $item) { // Load engine definitions JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating {$engine} engine of type {$item}"); $sourceINI = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'engine' . DS . $engine . DS . 'engine.ini'; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to read engine setup data from {$sourceINI}"); $engineArray = JoomlapackHelperUtils::parse_ini_file($sourceINI, true); if (isset($engineArray[$item])) { $engineDescriptor = $engineArray[$item]; $dotted = 'engine.' . $engine . '.' . $engineDescriptor['include']; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to include engine file {$dotted}"); $this->_addEngineInclude($dotted); jpimport($dotted); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Instanciating " . $engineDescriptor['class']); $instance = new $engineDescriptor['class'](); // If we are getting an archiver class, also populate the _archiveExtension field if ($engine == 'packer') { $this->archiveExtension = $engineDescriptor['extension']; } return $instance; } else { $this->setError(JText::sprintf('CUBE_PROVISIONING_ENGINENOTFOUND', $engine . '.' . $item)); return false; } }
/** * Initializes the array of filters. Reads the data of the filter.ini in the * classes/filter directory. */ function init() { // Load the filter.ini jpimport('helpers.utils', true); $sourceINI = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'filter' . DS . 'filter.ini'; $filterArray = JoomlapackHelperUtils::parse_ini_file($sourceINI, true); // Walk through INI file entries and add them to the filter list foreach ($filterArray as $filter) { $this->addFilter('filter.' . $filter['include'], $filter['class']); } }
function _getEngineList($engine) { jpimport('helpers.utils', true); // Load engine definitions $sourceINI = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'engine' . DS . $engine . DS . 'engine.ini'; $engineArray = JoomlapackHelperUtils::parse_ini_file($sourceINI, true); // Create selection list array $options = array(); foreach ($engineArray as $sectionKey => $engineItem) { if (JPSPECIALEDITION || !$engineItem['special'] && !JPSPECIALEDITION) { // Use translation keys for engine names $description = JText::_($engineItem['translationkey']); $options[] = JHTML::_('select.option', $sectionKey, $description); } } return $options; }
/** * We are ready to start the restoration. Generates a password protected datarestore.php * and places it on the site's root. Then presents the user with the information page. */ function ready() { $filename = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'scripts' . DS . 'datarestore.jpa'; $ret =& $this->_extract($filename); if ($ret === false) { $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=buadmin', JText::_('STATS_ERROR_RESTOREREADJPA'), 'error'); parent::display(); return; } // Read databases.ini from the disk and make it into an array $configuration =& JoomlapackModelRegistry::getInstance(); jpimport('helpers.utils', true); $originalDBINI = JoomlapackHelperUtils::parse_ini_file($configuration->getTemporaryDirectory() . DS . 'databases.ini', true); $databaseArray = array(); $counter = 0; foreach ($originalDBINI as $dbDef) { $counter++; $newEntry = array('host' => $dbDef['dbhost'], 'username' => $dbDef['dbuser'], 'password' => $dbDef['dbpass'], 'database' => $dbDef['dbname'], 'prefix' => $dbDef['prefix'], 'dumpFile' => $configuration->getTemporaryDirectory() . DS . $dbDef['sqlfile']); $databaseArray['db' . $counter] = $newEntry; } // Ask for a fresh password $bumodel =& $this->getModel('buadmin'); $password = $bumodel->getRandomPassword(); // Append password information and encrypted array to data jpimport('misc.cryptography'); $serialized = serialize($databaseArray); $encryption = new cryptography(); $encryption->set_key($password); $encrypted = $encryption->encrypt($serialized); $md5 = md5($password); $append = "<?php\ndefine('passwordHash', '{$md5}');\ndefine('encrypted', '{$encrypted}');\n?>\n"; $ret['data'] = $append . $ret['data']; // Write datarestore.php $filename = JPATH_SITE . DS . 'datarestore.php'; if (!JFile::write($filename, $ret['data'])) { $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=buadmin', JText::_('STATS_ERROR_RESTOREDEPLOY'), 'error'); parent::display(); return; } // Set the linktarget $URIbase = JURI::base(); $adminPos = strrpos($URIbase, '/administrator'); $URIbase = substr($URIbase, 0, $adminPos); $linktarget = $URIbase . '/datarestore.php'; JRequest::setVar('linktarget', $linktarget); parent::display(); }