Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * Gets the basic site parameters
  *
  * @return  array
  */
 protected function getSiteParamsVars()
 {
     $siteurl = str_replace('/installation/', '', AUri::root());
     $ret = array('sitename' => $this->getState('sitename', $this->configModel->get('sitename', 'Restored website')), 'siteurl' => $this->getState('siteurl', $siteurl));
     require_once APATH_INSTALLATION . '/angie/helpers/setup.php';
     $ret['siteurl'] = AngieHelperSetup::cleanLiveSite($ret['siteurl']);
     $this->configModel->set('siteurl', $ret['siteurl']);
     return $ret;
 }
Пример #3
0
 /**
  * Gets the basic site parameters
  *
  * @return  array
  */
 protected function getSiteParamsVars()
 {
     // Do I have a www_root coming from UNiTE? If so, use it
     $wwwroot = $this->input->get('livesite', AUri::root());
     $wwwroot = str_replace('/installation/', '', $wwwroot);
     // Create the host from the wwwroot - This regex is not optimal, but let's use the same used by Moodle
     preg_match('|^[a-z]+://([a-zA-Z0-9-.]+)|i', $wwwroot, $matches);
     $wwwhost = $matches[1];
     $ret = array('fullname' => $this->getState('fullname', $this->configModel->get('fullname', 'Restored Moodle')), 'shortname' => $this->getState('shortname', $this->configModel->get('shortname', 'Moodle')), 'wwwroot' => $this->getState('wwwroot', $wwwroot), 'dataroot' => $this->getState('dataroot', $this->configModel->get('dataroot', '')), 'chat_host' => $this->getState('chat_host', $this->configModel->get('chat_host', $wwwhost)), 'chat_ip' => $this->getState('chat_ip', $this->configModel->get('chat_ip', isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '')));
     require_once APATH_INSTALLATION . '/angie/helpers/setup.php';
     $ret['wwwroot'] = AngieHelperSetup::cleanLiveSite($ret['wwwroot']);
     $this->configModel->set('wwwroot', $ret['wwwroot']);
     return $ret;
 }
Пример #4
0
 /**
  * Gets the basic site parameters
  *
  * @return  array
  */
 protected function getSiteParamsVars()
 {
     $db = $this->getDatabase();
     $query = $db->getQuery(true)->select($db->qn('config_value'))->from($db->qn('#__config'))->where($db->qn('config_name') . ' = ' . $db->q('sitename'));
     try {
         $sitename = $db->setQuery($query)->loadResult();
     } catch (Exception $e) {
         $sitename = 'Restored website';
     }
     $query = $db->getQuery(true)->select($db->qn('config_value'))->from($db->qn('#__config'))->where($db->qn('config_name') . ' = ' . $db->q('site_desc'));
     try {
         $sitedescr = $db->setQuery($query)->loadResult();
     } catch (Exception $e) {
         $sitedescr = 'Restored website description';
     }
     $siteurl = str_replace('/installation/', '', AUri::root());
     $ret = array('sitename' => $this->getState('sitename', $sitename), 'sitedescr' => $this->getState('sitedescr', $sitedescr), 'siteurl' => $this->getState('siteurl', $siteurl));
     require_once APATH_INSTALLATION . '/angie/helpers/setup.php';
     $ret['siteurl'] = AngieHelperSetup::cleanLiveSite($ret['siteurl']);
     return $ret;
 }
Пример #5
0
 /**
  * Method to reset class static members for testing and other various issues.
  *
  * @return  void
  */
 public static function reset()
 {
     self::$instances = array();
     self::$base = array();
     self::$root = array();
     self::$current = '';
 }
Пример #6
0
 /**
  * Writes the new config params inside the wp-config file and the database.
  *
  * @param   string  $file
  *
  * @return bool
  */
 public function writeConfig($file)
 {
     // First of all I'll save the options stored inside the db. In this way, even if
     // the configuration file write fails, the user has only to manually update the
     // config file and he's ready to go.
     $name = $this->get('dbtype');
     $options = array('database' => $this->get('dbname'), 'select' => 1, 'host' => $this->get('dbhost'), 'user' => $this->get('dbuser'), 'password' => $this->get('dbpass'), 'prefix' => $this->get('dbprefix'));
     $db = ADatabaseFactory::getInstance()->getDriver($name, $options);
     // If supplied in the request (ie restoring using UNiTE) let's use that URL
     $livesite = $this->get('livesite', '');
     if (!$livesite) {
         $livesite = AUri::root();
     }
     $url = str_replace('/installation', '', $livesite);
     // The URL must end with a slash
     $url = rtrim($url, '/') . '/';
     $query = $db->getQuery(true)->update($db->qn('#__core_config_data'))->set($db->qn('value') . ' = ' . $db->q($url))->where($db->qn('path') . ' = ' . $db->q('web/unsecure/base_url'));
     $db->setQuery($query)->execute();
     $query = $db->getQuery(true)->update($db->qn('#__core_config_data'))->set($db->qn('value') . ' = ' . $db->q($url))->where($db->qn('path') . ' = ' . $db->q('web/secure/base_url'));
     $db->setQuery($query)->execute();
     $new_config = $this->getFileContents($file);
     if (!file_put_contents($file, $new_config)) {
         return false;
     }
     return true;
 }