예제 #1
0
 function restoreProcess()
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'helpers' . DS . 'restore.php';
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $lang = JFactory::getLanguage();
     $lang->load('com_installer');
     $link = 'index.php?option=com_rsform&task=backup.restore';
     if (!extension_loaded('zlib')) {
         JError::raiseWarning(500, JText::_('WARNINSTALLZLIB'));
         return $this->setRedirect($link);
     }
     $userfile = JRequest::getVar('userfile', null, 'files');
     if ($userfile['error']) {
         JError::raiseWarning(500, JText::_($userfile['error'] == 4 ? 'ERRORNOFILE' : 'WARNINSTALLUPLOADERROR'));
         return $this->setRedirect($link);
     }
     $baseDir = JPATH_SITE . DS . 'media';
     $moved = JFile::upload($userfile['tmp_name'], $baseDir . DS . $userfile['name']);
     if (!$moved) {
         JError::raiseWarning(500, JText::_('FAILED TO MOVE UPLOADED FILE TO'));
         return $this->setRedirect($link);
     }
     $options = array();
     $options['filename'] = $baseDir . DS . $userfile['name'];
     $options['overwrite'] = JRequest::getInt('overwrite');
     $restore = new RSFormProRestore($options);
     if (!$restore->process()) {
         JError::raiseWarning(500, JText::_('Unable to extract archive'));
         return $this->setRedirect($link);
     }
     if (!$restore->restore()) {
         return $this->setRedirect($link);
     }
     $this->setRedirect($link, JText::_('RSFP_RESTORE_OK'));
 }
예제 #2
0
 protected function restoreLegacy($userfile)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/restore/legacy.php';
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $overwrite = $this->getOverwrite();
     if (!extension_loaded('zlib')) {
         throw new Exception('The installer cannot continue until Zlib is installed.');
     }
     if (!JFile::upload($userfile['tmp_name'], JPATH_SITE . '/media/' . $userfile['name'])) {
         throw new Exception('Failed to move uploaded file to <b>/media</b> directory.');
     }
     $options = array('filename' => JPATH_SITE . '/media/' . $userfile['name'], 'overwrite' => $overwrite);
     $restore = new RSFormProRestore($options);
     if (!$restore->process()) {
         throw new Exception('Unable to extract archive.');
     }
     if (!$restore->restore()) {
         throw new Exception($restore->getErrors());
     }
 }