public function onBeforeMain() { if ($this->input->get('layout') != 'init') { return true; } // Assign the results of the various checks $this->reqSettings = $this->getModel()->getRequired(); $this->reqMet = $this->getModel()->isRequiredMet(); $this->recommendedSettings = $this->getModel()->getRecommended(); $this->extraInfo = $this->getModel()->getExtraInfo(); $this->joomlaVersion = ASession::getInstance()->get('jversion'); // Am I restoring to a different site? $this->restoringToDifferentHost = false; if (isset($this->extraInfo['host'])) { $uri = AUri::getInstance(); $this->restoringToDifferentHost = $this->extraInfo['host']['current'] != $uri->getHost(); } // Am I restoring to a different PHP version? $this->restoringToDifferentPHP = false; if (isset($this->extraInfo['php_version'])) { $parts = explode('.', $this->extraInfo['php_version']['current']); $sourceVersion = $parts[0] . '.' . $parts[1]; $parts = explode('.', PHP_VERSION); $targetVersion = $parts[0] . '.' . $parts[1]; $this->restoringToDifferentPHP = $sourceVersion != $targetVersion; } // If I am restoring to a different host blank out the database // connection information to prevent unpleasant situations, like a user // "accidentally" overwriting his original site's database... if ($this->restoringToDifferentHost && !ASession::getInstance()->get('main.resetdbinfo', false)) { $this->getModel()->resetDatabaseConnectionInformation(); } return true; }
public function onBeforeMain() { if ($this->input->get('layout') != 'init') { return true; } /** @var AngieModelBaseMain $model */ $model = $this->getModel(); /** @var ASession $session */ $session = $this->container->session; // Assign the results of the various checks $this->reqSettings = $model->getRequired(); $this->reqMet = $model->isRequiredMet(); $this->recommendedSettings = $model->getRecommended(); $this->extraInfo = $model->getExtraInfo(); $this->joomlaVersion = $session->get('jversion'); $this->version = $session->get('version'); // Am I restoring to a different site? $this->restoringToDifferentHost = false; if (isset($this->extraInfo['host'])) { $uri = AUri::getInstance(); $this->restoringToDifferentHost = $this->extraInfo['host']['current'] != $uri->getHost(); } // If I am restoring to a different host blank out the database // connection information to prevent unpleasant situations, like a user // "accidentally" overwriting his original site's database... if ($this->restoringToDifferentHost && !$session->get('main.resetdbinfo', false)) { $model->resetDatabaseConnectionInformation(); } return true; }
/** * Get the state variables pertaining to the FTP connection * * @staticvar \stdClass $statevars * * @return \stdClass A stdClass object with the variables */ public function getStateVariables() { static $statevars = null; if (is_null($statevars)) { $statevars = new stdClass(); $vars = array('hostname', 'port', 'username', 'password', 'directory'); foreach ($vars as $v) { $value = $this->getState($v, null, 'raw'); $statevars->{$v} = $value; switch ($v) { case 'hostname': if (empty($statevars->{$v})) { $uri = AUri::getInstance(); $statevars->{$v} = $uri->getHost(); } break; case 'port': $statevars->{$v} = (int) $statevars->{$v}; if ($statevars->{$v} <= 0 || $statevars->{$v} >= 65536) { $statevars->{$v} = 21; } break; } } } return $statevars; }
public function onBeforeMain() { try { $stuff = $this->getModel()->getListingAndCrumbs(); $uri = clone AUri::getInstance(); $queryParts = $uri->getQuery(true); unset($queryParts['directory']); $uri->setQuery($queryParts); $this->ftppath = $stuff['path']; $this->crumbs = $stuff['crumbs']; $this->directories = $stuff['directories']; $this->badFTP = false; $this->ftpError = ''; $this->baseURL = $uri->toString(); } catch (Exception $exc) { $this->badFTP = true; $this->ftpError = $exc->getMessage(); } return true; }
/** * Renames the directory containing the old host name to the new one * * @param string $directory Absolute path to the slave directory with the old hostname * @param string $host Force the host to a specific domain. This is used when we're restoring using UNiTE * * @return string */ public function updateSlaveDirectory($directory, $host = 'SERVER') { // No need to continue if the directory is not valid if (!is_dir($directory)) { return $directory; } // First of all, let's get the old hostname /** @var AngieModelDrupal8Main $mainModel */ $mainModel = AModel::getAnInstance('Main', 'AngieModel', array(), $this->container); $extraInfo = $mainModel->getExtraInfo(); // No host information? Well, let's stop here if (!isset($extraInfo['host']) || !$extraInfo['host']) { return $directory; } $uri = AUri::getInstance($host); $oldHost = $extraInfo['host']['current']; $newHost = $uri->getHost(); // If the old host name is not inside the folder name, there's no point in continuing if (strpos($directory, $oldHost) === false) { return $directory; } // Can't fetch the new host? Let's stop here if (!$newHost) { return $directory; } $newDirectory = str_replace($oldHost, $newHost, $directory); if (!rename($directory, $newDirectory)) { return $directory; } // Ok, I have successfully renamed the folder, now I have to update the Configuration model // since it stores all the values using the folder name $oldNamespace = basename($directory); $newNamespace = basename($newDirectory); /** @var AngieModelDrupal8Configuration $configModel */ $configModel = $this->configModel; $configVars = $configModel->getConfigvars(); if (isset($configVars[$oldNamespace])) { // Let's migrate all the values. Old values are still set, but we can live with that foreach ($configVars[$oldNamespace] as $key => $value) { $configModel->set($key, $value, $newNamespace); } } // Finally register the association between the old namespace with the new one // it will be useful if we have a multi database installation, see AngieModelDrupal7Configuration::getDatabase() $configModel->set('hostMapping', array($newNamespace => $oldNamespace), 'default'); return $newDirectory; }