/** * Attempts import of plugins from previous installation path. * List of plugins is determined by looking into config section in the loaded * config file. (more precisely $GLOBALS['_MAX']['CONF']['plugins']) * * Copies plugin related artifacts using OX_UpgradePluginImport->import(..) function. * Also copies data objects. * * '$path' param is considered the source path. MAX path is * considered the target path. * * @param $path an absolute path to previous OpenX installation * @return boolean false if import failed, true otherwise */ public static function importPlugins($path) { $success = true; // Prevent directory traversal and other nasty tricks: $path = str_replace("\\", '/', $path); $path = rtrim(str_replace("", '', $path), '/'); if (!stristr($path, '../')) { $oPluginImporter = new OX_UpgradePluginImport(); $oPluginImporter->basePath = $path; if ($oPluginImporter->verifyAll($GLOBALS['_MAX']['CONF']['plugins'], false)) { // For each plugin that's claimed to be installed... (ex|im)port it into the new codebase foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $plugin => $enabled) { $oPluginImporter->import($plugin); } // Plugins may also have placed files in the MAX_PATH . /var/plugins folder, // but these files aren't declared in the XML, for now, copy all files in there up $DO_DIR = opendir($path . '/var/plugins/DataObjects/'); while ($file = readdir($DO_DIR)) { if (!is_file($path . '/var/plugins/DataObjects/' . $file)) { continue; } @copy($path . '/var/plugins/DataObjects/' . $file, MAX_PATH . '/var/plugins/DataObjects/' . $file); } } else { $success = false; } } return $success; }
$oUpgrader->putAdmin($aAdminInfo); // Save admim account preference for timezone $oUpgrader->putTimezoneAccountPreference($_POST['aPrefs']); } $importErrors = false; // Import any plugins present from the previous install if (isset($_POST['previousPath']) && $_POST['previousPath'] != MAX_PATH) { // Prevent directory traversal and other nasty tricks: $path = rtrim(str_replace("", '', $_POST['previousPath']), '\\/'); if (!stristr($path, '../') && !stristr($path, '..\\')) { $oPluginImporter = new OX_UpgradePluginImport(); $oPluginImporter->basePath = $path; if ($oPluginImporter->verifyAll($GLOBALS['_MAX']['CONF']['plugins'], false)) { // For each plugin that's claimed to be installed... (ex|im)port it into the new codebase foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $plugin => $enabled) { $oPluginImporter->import($plugin); } // Plugins may also have placed files in the MAX_PATH . /var/plugins folder, // but these files aren't declared in the XML, for now, copy all files in there up $DO_DIR = opendir($path . '/var/plugins/DataObjects/'); while ($file = readdir($DO_DIR)) { if (!is_file($path . '/var/plugins/DataObjects/' . $file)) { continue; } @copy($path . '/var/plugins/DataObjects/' . $file, MAX_PATH . '/var/plugins/DataObjects/' . $file); } } else { $importErrors = true; } } }