foreach ($neededUpgradeFiles as $version) { $file = INSTALL_PATH . '/sql/upgrade/' . $version . '.sql'; if (!file_exists($file)) { $logger->logError('Error while loading sql upgrade file.'); die('<action result="fail" error="33" />' . "\n"); } if (!($sqlContent .= file_get_contents($file))) { $logger->logError('Error while loading sql upgrade file.'); die('<action result="fail" error="33" />' . "\n"); } $sqlContent .= "\n"; } $sqlContent = str_replace(array($filePrefix, $engineType), array(_DB_PREFIX_, $mysqlEngine), $sqlContent); $sqlContent = preg_split("/;\\s*[\r\n]+/", $sqlContent); error_reporting($oldLevel); $confFile = new AddConfToFile(SETTINGS_FILE, 'w'); if ($confFile->error) { $logger->logError($confFile->error); die('<action result="fail" error="' . $confFile->error . '" />' . "\n"); } foreach ($datas as $data) { $confFile->writeInFile($data[0], $data[1]); } if ($confFile->error != false) { $logger->logError($confFile->error); die('<action result="fail" error="' . $confFile->error . '" />' . "\n"); } //sql file execution global $requests, $warningExist; $requests = ''; $warningExist = false;
if (!file_exists($file)) { die('<action result="fail" error="33" />' . "\n"); } if (!($sqlContent .= file_get_contents($file))) { die('<action result="fail" error="33" />' . "\n"); } $sqlContent .= "\n"; } $sqlContent = str_replace($filePrefix, _DB_PREFIX_, $sqlContent); $sqlContent = preg_split("/;\\s*[\r\n]+/", $sqlContent); //refresh conf file include INSTALL_PATH . '/classes/AddConfToFile.php'; $oldLevel = error_reporting(E_ALL); $datas = array(array('_DB_SERVER_', _DB_SERVER_), array('_DB_TYPE_', _DB_TYPE_), array('_DB_NAME_', _DB_NAME_), array('_DB_USER_', _DB_USER_), array('_DB_PASSWD_', _DB_PASSWD_), array('_DB_PREFIX_', _DB_PREFIX_), array('__PS_BASE_URI__', __PS_BASE_URI__), array('_THEME_NAME_', _THEME_NAME_), array('_COOKIE_KEY_', _COOKIE_KEY_), array('_COOKIE_IV_', _COOKIE_IV_), array('_PS_CREATION_DATE_', defined("_PS_CREATION_DATE_") ? _PS_CREATION_DATE_ : date('Y-m-d')), array('_PS_VERSION_', INSTALL_VERSION)); error_reporting($oldLevel); $confFile = new AddConfToFile(SETTINGS_FILE, 'w'); if ($confFile->error) { die('<action result="fail" error="' . $confFile->error . '" />' . "\n"); } foreach ($datas as $data) { $confFile->writeInFile($data[0], $data[1]); } $confFile->writeEndTagPhp(); if ($confFile->error != false) { die('<action result="fail" error="' . $confFile->error . '" />' . "\n"); } //sql file execution global $requests, $warningExist; $requests = ''; $warningExist = false; Configuration::loadConfiguration();
public function writeNewSettings() { // note : duplicated line $mysqlEngine = defined('_MYSQL_ENGINE_') ? _MYSQL_ENGINE_ : 'MyISAM'; $oldLevel = error_reporting(E_ALL); //refresh conf file require_once _PS_ROOT_DIR_ . '/modules/autoupgrade/classes/AddConfToFile.php'; copy(SETTINGS_FILE, str_replace('.php', '.old.php', SETTINGS_FILE)); $confFile = new AddConfToFile(SETTINGS_FILE, 'w'); if ($confFile->error) { $this->next = 'error'; $this->next_desc = $this->l('Error when opening settings.inc.php file in write mode'); $this->nextQuickInfo[] = $confFile->error; $this->nextErrors[] = $this->l('Error when opening settings.inc.php file in write mode') . ': ' . $confFile->error; return false; } $datas = array(array('_DB_SERVER_', _DB_SERVER_), array('_DB_NAME_', _DB_NAME_), array('_DB_USER_', _DB_USER_), array('_DB_PASSWD_', _DB_PASSWD_), array('_DB_PREFIX_', _DB_PREFIX_), array('_MYSQL_ENGINE_', $mysqlEngine), array('_PS_CACHING_SYSTEM_', (defined('_PS_CACHING_SYSTEM_') and _PS_CACHING_SYSTEM_ != 'CacheMemcache') ? _PS_CACHING_SYSTEM_ : 'CacheMemcache'), array('_PS_CACHE_ENABLED_', defined('_PS_CACHE_ENABLED_') ? _PS_CACHE_ENABLED_ : '0'), array('_MEDIA_SERVER_1_', defined('_MEDIA_SERVER_1_') ? _MEDIA_SERVER_1_ : ''), array('_MEDIA_SERVER_2_', defined('_MEDIA_SERVER_2_') ? _MEDIA_SERVER_2_ : ''), array('_MEDIA_SERVER_3_', defined('_MEDIA_SERVER_3_') ? _MEDIA_SERVER_3_ : ''), array('_COOKIE_KEY_', _COOKIE_KEY_), array('_COOKIE_IV_', _COOKIE_IV_), array('_PS_CREATION_DATE_', defined("_PS_CREATION_DATE_") ? _PS_CREATION_DATE_ : date('Y-m-d')), array('_PS_VERSION_', INSTALL_VERSION)); if (defined('_RIJNDAEL_KEY_')) { $datas[] = array('_RIJNDAEL_KEY_', _RIJNDAEL_KEY_); } if (defined('_RIJNDAEL_IV_')) { $datas[] = array('_RIJNDAEL_IV_', _RIJNDAEL_IV_); } if (!defined('_PS_CACHE_ENABLED_')) { define('_PS_CACHE_ENABLED_', '0'); } if (!defined('_MYSQL_ENGINE_')) { define('_MYSQL_ENGINE_', 'MyISAM'); } // if install version is before 1.5 if (version_compare(INSTALL_VERSION, '1.5.0.0', '<=')) { $datas[] = array('_DB_TYPE_', _DB_TYPE_); $datas[] = array('__PS_BASE_URI__', __PS_BASE_URI__); $datas[] = array('_THEME_NAME_', _THEME_NAME_); } else { $datas[] = array('_PS_DIRECTORY_', __PS_BASE_URI__); } foreach ($datas as $data) { $confFile->writeInFile($data[0], $data[1]); } if ($confFile->error != false) { $this->next = 'error'; $this->next_desc = $this->l('Error when generating new settings.inc.php file.'); $this->nextQuickInfo[] = $confFile->error; $this->nextErrors[] = $this->l('Error when generating new settings.inc.php file.') . ' ' . $confFile->error; return false; } else { $this->nextQuickInfo[] = $this->l('settings file updated'); } error_reporting($oldLevel); }