/** * Initialises the steps array */ public function initialiseSteps() { $this->steps = $this->defaultSteps; $data = $this->input->getData(); $this->steps['database'] = AModel::getAnInstance('Database', 'AngieModel')->getDatabaseNames(); // Do I have off-site directories? $offsitedirs = AModel::getAnInstance('Offsitedirs', 'AngieModel')->getDirs(); if ($offsitedirs) { // Rearrange steps order to inject off-site dirs restore after the db step $savedSteps = $this->steps; $this->steps = array(); $this->steps['main'] = $savedSteps['main']; $this->steps['database'] = $savedSteps['database']; $this->steps['offsitedirs'] = $offsitedirs; $this->steps['setup'] = $savedSteps['setup']; $this->steps['finalise'] = $savedSteps['finalise']; } // Do I have a site setup step? $fileNameMain = APATH_INSTALLATION . '/angie/controllers/setup.php'; $fileNameAlt = APATH_INSTALLATION . '/angie/platform/controllers/setup.php'; if (!@file_exists($fileNameAlt) && !@file_exists($fileNameMain)) { unset($this->steps['setup']); } $this->input->setData($data); }
public function readAliases() { $sites = APATH_SITE . '/sites/sites.php'; if (!file_exists($sites)) { return array(); } $contents = file_get_contents($sites); $tokenizer = new AUtilsPhptokenizer($contents); $skip = 0; $error = false; $tokens = array(); // Database info while (!$error) { try { // Let's try to extract all the occurrences until we get an error. Since it's just a PHP array, // you could write it in a million of different ways $info = $tokenizer->searchToken('T_VARIABLE', '$sites', $skip); $skip = $info['endLine'] + 1; $tokens[] = $info['data']; } catch (RuntimeException $e) { $error = true; } } if (!$tokens) { return array(); } // Let's use Configuration model function to extract the data we need /** @var AngieModelDrupal8Configuration $configModel */ $configModel = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container); $aliases = $configModel->extractVariables($tokens, 'sites'); return $aliases; }
public function __construct($config = array()) { // Call the parent constructor parent::__construct($config); // Get the Joomla! version from the configuration or the session if (array_key_exists('jversion', $config)) { $jVersion = $config['jversion']; } else { $jVersion = ASession::getInstance()->get('jversion', '2.5.0'); } // Load the configuration variables from the session or the default configuration shipped with ANGIE $this->configvars = ASession::getInstance()->get('configuration.variables'); if (empty($this->configvars)) { // Get default configuration based on the Joomla! version if (version_compare($jVersion, '2.5.0', 'ge') && version_compare($jVersion, '3.0.0', 'lt')) { $v = '25'; } else { $v = '30'; } $className = 'J' . $v . 'Config'; $filename = APATH_INSTALLATION . '/platform/models/jconfig/j' . $v . '.php'; $this->configvars = $this->loadFromFile($filename, $className); if (!empty($this->configvars)) { $this->saveToSession(); } } }
/** * Gets the basic site parameters * * @return array */ protected function getSiteParamsVars() { $siteurl = str_replace('/installation/', '', AUri::root()); $homeurl = str_replace('/installation/', '', AUri::root()); $ret = array('blogname' => $this->getState('blogname', $this->configModel->get('blogname', 'Restored website')), 'blogdescription' => $this->getState('blogdescription', $this->configModel->get('blogdescription', 'Restored website')), 'dbcharset' => $this->getState('dbcharset', $this->configModel->get('dbcharset', 'utf_8')), 'dbcollation' => $this->getState('dbcollation', $this->configModel->get('dbcollation', '')), 'homeurl' => $this->getState('homeurl', $homeurl), 'siteurl' => $this->getState('siteurl', $siteurl)); require_once APATH_INSTALLATION . '/angie/helpers/setup.php'; $ret['homeurl'] = AngieHelperSetup::cleanLiveSite($ret['homeurl']); $ret['siteurl'] = AngieHelperSetup::cleanLiveSite($ret['siteurl']); $this->configModel->set('siteurl', $ret['siteurl']); $this->configModel->set('homeurl', $ret['homeurl']); // Special handling: if we were told to downgrade data from utf8mb4 to utf8 and the dbcharset or dbcollation // contains utf8mb4 we have to downgrade that too to utf8. /** @var AngieModelDatabase $dbModel */ $dbModel = AModel::getTmpInstance('Database', 'AngieModel'); $allDbIni = $dbModel->getDatabasesIni(); $dbNames = $dbModel->getDatabaseNames(); $firstDb = array_shift($dbNames); $dbIni = $allDbIni[$firstDb]; $dbOptions = array('driver' => $dbIni['dbtype'], 'database' => $dbIni['dbname'], 'select' => 0, 'host' => $dbIni['dbhost'], 'user' => $dbIni['dbuser'], 'password' => $dbIni['dbpass'], 'prefix' => $dbIni['prefix']); $db = ADatabaseDriver::getInstance($dbOptions); $downgradeUtf8 = $dbIni['utf8tables'] && (!$dbIni['utf8mb4'] || $dbIni['utf8mb4'] && !$db->supportsUtf8mb4()); if ($downgradeUtf8) { $ret['dbcharset'] = str_replace('utf8mb4', 'utf8', $ret['dbcharset']); $ret['dbcollation'] = str_replace('utf8mb4', 'utf8', $ret['dbcollation']); $this->configModel->set('dbcharset', $ret['dbcharset']); $this->configModel->set('dbcollation', $ret['dbcollation']); } return $ret; }
public function onBeforeMain() { ADocument::getInstance()->addScriptDeclaration(<<<ENDSRIPT var akeebaAjax = null; \$(document).ready(function(){ akeebaAjax = new akeebaAjaxConnector('index.php'); akeebaAjax.callJSON({ 'view' : 'runscripts', 'format' : 'raw' }); }); ENDSRIPT ); $model = $this->getModel(); $this->showconfig = $model->getState('showconfig', 0); if ($this->showconfig) { $this->configuration = AModel::getAnInstance('Configuration', 'AngieModel')->getFileContents(); } if (ASession::getInstance()->get('tfa_warning', false)) { $this->extra_warning = '<div class="alert alert-block alert-error">'; $this->extra_warning .= '<h4 class="alert-heading">' . AText::_('FINALISE_TFA_DISABLED_TITLE') . '</h4>'; $this->extra_warning .= '<p>' . AText::_('FINALISE_TFA_DISABLED_BODY') . '</p>'; $this->extra_warning .= '</div>'; } return true; }
/** * Returns the database connection variables for the default database. * * @return null|stdClass */ protected function getDbConnectionVars() { /** @var AngieModelDatabase $model */ $model = AModel::getAnInstance('Database', 'AngieModel', array(), $this->container); $keys = $model->getDatabaseNames(); $firstDbKey = array_shift($keys); return $model->getDatabaseInfo($firstDbKey); }
public function onBeforeMain() { $model = $this->getModel(); $this->showconfig = $model->getState('showconfig', 0); if ($this->showconfig) { $this->configuration = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container)->getFileContents(); } return true; }
public function onBeforeMain() { $stepsModel = AModel::getAnInstance('Steps', 'AngieModel'); $dbModel = AModel::getAnInstance('Database', 'AngieModel'); $this->substep = $stepsModel->getActiveSubstep(); $this->number_of_substeps = $stepsModel->getNumberOfSubsteps(); $this->db = $dbModel->getDatabaseInfo($this->substep); return true; }
/** * Initialises the steps array */ public function initialiseSteps() { $this->steps = $this->defaultSteps; $data = $this->input->getData(); /** @var AngieModelDatabase $dbModel */ $dbModel = AModel::getAnInstance('Database', 'AngieModel', array(), $this->container); $this->steps['database'] = $dbModel->getDatabaseNames(); // Do I have off-site directories? /** @var AngieModelBaseOffsitedirs $offsiteModel */ $offsiteModel = AModel::getAnInstance('Offsitedirs', 'AngieModel', array(), $this->container); $offsitedirs = $offsiteModel->getDirs(); if ($offsitedirs) { // Rearrange steps order to inject off-site dirs restore after the db step $savedSteps = $this->steps; $this->steps = array(); $this->steps['main'] = $savedSteps['main']; $this->steps['database'] = $savedSteps['database']; $this->steps['offsitedirs'] = $offsitedirs; $this->steps['setup'] = $savedSteps['setup']; $this->steps['finalise'] = $savedSteps['finalise']; } // Do I have a site setup step? $fileNameMain = APATH_INSTALLATION . '/angie/controllers/setup.php'; $fileNameAlt = ''; $altFiles = array(APATH_INSTALLATION . '/angie/platform/controllers/setup.php', APATH_INSTALLATION . '/platform/controllers/setup.php', APATH_INSTALLATION . '/platform/controllers/' . strtolower(ANGIE_INSTALLER_NAME) . 'setup.php'); foreach ($altFiles as $altFile) { if (file_exists($altFile)) { $fileNameAlt = $altFile; break; } } if (!@file_exists($fileNameAlt)) { $fileNameAlt = APATH_INSTALLATION . '/platform/controllers/setup.php'; } if (!@file_exists($fileNameAlt) && !@file_exists($fileNameMain)) { unset($this->steps['setup']); } $fileNameMain = APATH_INSTALLATION . '/angie/platform/steps.php'; $fileNameAlt = APATH_INSTALLATION . '/platform/steps.php'; if (@file_exists($fileNameMain)) { @(include_once $fileNameMain); } elseif (@file_exists($fileNameAlt)) { @(include_once $fileNameAlt); } if (class_exists('PlatformSteps')) { $platformSteps = new PlatformSteps(); if (method_exists($platformSteps, 'additionalSteps')) { $steps = $platformSteps->additionalSteps($this->steps); if (is_array($steps) && !empty($steps)) { $this->steps = $steps; } } } // @todo Load additional steps $this->input->setData($data); }
public function onBeforeMain() { $stepsModel = AModel::getAnInstance('Steps', 'AngieModel'); $offsiteModel = AModel::getAnInstance('Offsitedirs', 'AngieModel'); $substeps = $offsiteModel->getDirs(true, true); $cursubstep = $stepsModel->getActiveSubstep(); $this->substep = $substeps[$cursubstep]; $this->number_of_substeps = $stepsModel->getNumberOfSubsteps(); return true; }
public function onBeforeMain() { /** @var AngieModelSteps $stepsModel */ $stepsModel = AModel::getAnInstance('Steps', 'AngieModel', array(), $this->container); /** @var AngieModelDatabase $dbModel */ $dbModel = AModel::getAnInstance('Database', 'AngieModel', array(), $this->container); $this->substep = $stepsModel->getActiveSubstep(); $this->number_of_substeps = $stepsModel->getNumberOfSubsteps(); $this->db = $dbModel->getDatabaseInfo($this->substep); return true; }
public function onBeforeMain() { /** @var AngieModelSteps $stepsModel */ $stepsModel = AModel::getAnInstance('Steps', 'AngieModel', array(), $this->container); /** @var AngieModelOffsitedirs $offsiteModel */ $offsiteModel = AModel::getAnInstance('Offsitedirs', 'AngieModel', array(), $this->container); $substeps = $offsiteModel->getDirs(true, true); $cursubstep = $stepsModel->getActiveSubstep(); $this->substep = $substeps[$cursubstep]; $this->number_of_substeps = $stepsModel->getNumberOfSubsteps(); return true; }
public function step() { $key = $this->input->get('key', null); $model = AModel::getAnInstance('Database', 'AngieModel'); $data = $model->getDatabaseInfo($key); try { $restoreEngine = ADatabaseRestore::getInstance($key, $data); $result = $restoreEngine->stepRestoration(); } catch (Exception $exc) { $result = array('percent' => 0, 'restored' => 0, 'total' => 0, 'eta' => 0, 'error' => $exc->getMessage(), 'done' => 1); } echo json_encode($result); }
/** * Is this a multisite installation? */ public function ismultisite() { /** @var AngieModelDrupal7Configuration $configModel */ $configModel = AModel::getAnInstance('Configuration', 'AngieModel'); $folders = $configModel->getSettingsFolders(); // If I have more than a folder containing the settings.php file it means that this is // a multisite installation if (count($folders) > 1) { echo json_encode(true); } else { echo json_encode(false); } }
public function replaceneeded() { /** @var AngieModelWordpressConfiguration $config */ $config = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container); $result = true; // These values are stored inside the session, after the setup step $old_url = $config->get('oldurl'); $new_url = $config->get('homeurl'); // If we are restoring to the same URL we don't need to replace any data if ($old_url == $new_url) { $result = false; } echo json_encode($result); }
public function main() { /** @var AngieModelMauticConfiguration $config */ $config = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container); // These values are stored inside the session, after the setup step $old_url = $config->get('old_live_site'); $new_url = $config->get('live_site'); // If we are restoring to the same URL we don't need to replace any data if ($old_url == $new_url) { $this->setRedirect('index.php?view=finalise'); return; } parent::main(); }
/** * Adds additional steps for this installer * * @param array $steps * * @return mixed */ public function additionalSteps(array $steps) { /** @var AngieModelDatabase $model */ $model = AModel::getAnInstance('Database', 'AngieModel', array()); $keys = $model->getDatabaseNames(); $firstDbKey = array_shift($keys); $connectionVars = $model->getDatabaseInfo($firstDbKey); // If I have a sqlite database I have to skip database restoration. It's just a simple file to drop if ($connectionVars->dbtype == 'sqlite') { if (isset($steps['database'])) { unset($steps['database']); } } return $steps; }
/** * Try to read the configuration */ public function getconfig() { // Load the default configuration and save it to the session $data = $this->input->getData(); /** @var AngieModelMagento2Configuration $model */ $model = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container); $this->input->setData($data); $this->container->session->saveData(); $vars = $model->loadFromFile(); foreach ($vars as $k => $v) { $model->set($k, $v); } $this->container->session->saveData(); echo json_encode(true); }
public function onBeforeMain() { $this->container->application->getDocument()->addScriptDeclaration(<<<ENDSRIPT var akeebaAjax = null; \$(document).ready(function(){ akeebaAjax = new akeebaAjaxConnector('index.php'); }); ENDSRIPT ); $model = $this->getModel(); $this->showconfig = $model->getState('showconfig', 0); if ($this->showconfig) { $this->configuration = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container)->getFileContents(); } return true; }
/** * Initialises the steps array */ public function initialiseSteps() { $this->steps = $this->defaultSteps; $data = $this->input->getData(); $this->steps['database'] = AModel::getAnInstance('Database', 'AngieModel')->getDatabaseNames(); // Do I have off-site directories? $offsitedirs = AModel::getAnInstance('Offsitedirs', 'AngieModel')->getDirs(); if ($offsitedirs) { // Rearrange steps order to inject off-site dirs restore after the db step $savedSteps = $this->steps; $this->steps = array(); $this->steps['main'] = $savedSteps['main']; $this->steps['database'] = $savedSteps['database']; $this->steps['offsitedirs'] = $offsitedirs; $this->steps['setup'] = $savedSteps['setup']; $this->steps['finalise'] = $savedSteps['finalise']; } // Do I have a site setup step? $fileNameMain = APATH_INSTALLATION . '/angie/controllers/setup.php'; $fileNameAlt = APATH_INSTALLATION . '/angie/platform/controllers/setup.php'; if (!@file_exists($fileNameAlt)) { $fileNameAlt = APATH_INSTALLATION . '/platform/controllers/setup.php'; } if (!@file_exists($fileNameAlt) && !@file_exists($fileNameMain)) { unset($this->steps['setup']); } $fileNameMain = APATH_INSTALLATION . '/angie/platform/steps.php'; $fileNameAlt = APATH_INSTALLATION . '/platform/steps.php'; if (@file_exists($fileNameMain)) { @(include_once $fileNameMain); } elseif (@file_exists($fileNameAlt)) { @(include_once $fileNameAlt); } if (class_exists('PlatformSteps')) { $platformSteps = new PlatformSteps(); if (method_exists($platformSteps, 'additionalSteps')) { $steps = $platformSteps->additionalSteps($this->steps); if (is_array($steps) && !empty($steps)) { $this->steps = $steps; } } } // @todo Load additional steps $this->input->setData($data); }
/** * Try to read app/etc/local.xml */ public function getconfig() { // Load the default configuration and save it to the session $data = $this->input->getData(); $model = AModel::getAnInstance('Configuration', 'AngieModel', array(), $this->container); $this->input->setData($data); $this->container->session->saveData(); // Try to load the configuration from the site's configuration.php $filename = APATH_SITE . '/app/etc/local.xml'; if (file_exists($filename)) { $vars = $model->loadFromFile($filename); foreach ($vars as $k => $v) { $model->set($k, $v); } $this->container->session->saveData(); echo json_encode(true); } else { echo json_encode(false); } }
/** * This method allows to update the slave directories with the new hostname. It's never invoked inside ANGIE, * it's only used by UNiTE */ public function updateslavedirectories() { /** @var AngieModelDrupal7Configuration $configModel */ $configModel = AModel::getAnInstance('Configuration', 'AngieModel'); /** @var AngieModelDrupal7Setup $setupModel */ $setupModel = AModel::getAnInstance('Setup', 'AngieModel'); $host = $this->input->getString('host', 'SERVER'); // Do I have a multi-site environment? If so I have to display the setup page several times $directories = $configModel->getSettingsFolders(); // We have to update foreach ($directories as $directory) { // Skip the default directory if ($directory == 'default') { continue; } // Wait, before adding such directory to the stack, I have to update them with the new domain name // ie from oldsite.local.slave to newsite.com.slave $setupModel->updateSlaveDirectory(APATH_ROOT . '/sites/' . $directory, $host); } echo json_encode(true); }
/** * Try to read configuration.php */ public function getconfig() { // Load the default configuration and save it to the session $data = $this->input->getData(); /** @var AngieModelConfiguration $model */ $model = AModel::getAnInstance('Configuration', 'AngieModel'); $this->input->setData($data); ASession::getInstance()->saveData(); // Try to load the configuration from the site's configuration.php $filename = APATH_SITE . '/configuration.php'; if (file_exists($filename)) { $vars = $model->loadFromFile($filename); foreach ($vars as $k => $v) { $model->set($k, $v); } ASession::getInstance()->saveData(); echo json_encode(true); } else { echo json_encode(false); } //AApplication::getInstance()->close(); }
/** * Adds additional steps for this installer * * @param array $steps * * @return mixed */ public function additionalSteps(array $steps) { // Let's double check that we really have the sites folder if (!is_dir(APATH_ROOT . '/sites')) { return $steps; } /** @var AngieModelDrupal7Configuration $configModel */ $configModel = AModel::getAnInstance('Configuration', 'AngieModel'); /** @var AngieModelDrupal7Setup $setupModel */ $setupModel = AModel::getAnInstance('Setup', 'AngieModel'); // Do I have a multi-site environment? If so I have to display the setup page several times $extraSetup = array(); $directories = $configModel->getSettingsFolders(); // We have to update foreach ($directories as $directory) { // Skip the default directory if ($directory == 'default') { continue; } // Wait, before adding such directory to the stack, I have to update them with the new domain name // ie from oldsite.local.slave to newsite.com.slave $directory = $setupModel->updateSlaveDirectory(APATH_ROOT . '/sites/' . $directory); $extraSetup[] = basename($directory); } if ($extraSetup) { // I have to manually add the default "setup" $steps['setup'][] = 'default'; // Now I can add the extra steps $steps['setup'] = array_merge($steps['setup'], $extraSetup); } // Do I have an alias file? If so let's add the step so the user can change it if (file_exists(APATH_ROOT . '/sites/sites.php')) { $finalise = array_pop($steps); $steps['updatealias'] = null; $steps['finalise'] = $finalise; } return $steps; }
<?php /** * @package angi4j * @copyright Copyright (C) 2009-2016 Nicholas K. Dionysopoulos. All rights reserved. * @author Nicholas K. Dionysopoulos - http://www.dionysopoulos.me * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL v3 or later */ defined('_AKEEBA') or die; $data = $this->input->getData(); /** @var AngieModelSteps $stepsModel */ $stepsModel = AModel::getAnInstance('Steps', 'AngieModel', array(), $this->container); $this->input->setData($data); $crumbs = $stepsModel->getBreadCrumbs(); $i = 0; ?> <?php if (isset($helpurl) && !empty($helpurl) || isset($videourl) && !empty($videourl)) { ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <?php if (isset($helpurl) && !empty($helpurl)) { ?> <?php echo AText::_('GENERIC_LBL_WHATTODONEXT'); ?> <a href="<?php echo $helpurl; ?>
/** * Resets the database connection information of all databases */ public function resetDatabaseConnectionInformation() { $model = AModel::getAnInstance('Database', 'AngieModel'); $databasesIni = $model->getDatabasesIni(); $temp = array(); foreach ($databasesIni as $key => $data) { $data['dbhost'] = ''; $data['dbuser'] = ''; $data['dbpass'] = ''; $data['dbname'] = ''; $model->setDatabaseInfo($key, $data); } $model->saveDatabasesIni(); ASession::getInstance()->set('main.resetdbinfo', true); }
/** * Method to add a model to the view. We support a multiple model single * view system by which models are referenced by classname. * * @param AModel $model The model to add to the view. * @param boolean $default Is this the default model? * * @return object The added model. */ public function setModel($model, $default = false) { $name = strtolower($model->getName()); $this->_models[$name] = $model; if ($default) { $this->_defaultModel = $name; } return $model; }
/** * @covers Paradox\AModel::__call */ public function test__call() { $this->model->loadPod($this->pod); $this->assertNull($this->model->getId(), 'The new pod should have no id'); }
/** * @return bool */ protected function beforeValidate() { if ($this->sid_expiration && !is_numeric($this->sid_expiration)) { $this->sid_expiration = strtotime($this->sid_expiration); } return parent::beforeValidate(); }
public static function superusers($selected = null) { $options = array(); $params = AModel::getAnInstance('Setup', 'AngieModel')->getStateVariables(); if (isset($params)) { $superusers = $params->superusers; foreach ($superusers as $sa) { $options[] = self::option($sa->id, $sa->username); } } return self::genericlist($options, 'superuserid', array('onchange' => 'setupSuperUserChange()'), 'value', 'text', $selected); }