diff --git a/source/packages/com_mokosuitebackup/src/Engine/MokoRestore.php b/source/packages/com_mokosuitebackup/src/Engine/MokoRestore.php index 7134943b..044b9314 100644 --- a/source/packages/com_mokosuitebackup/src/Engine/MokoRestore.php +++ b/source/packages/com_mokosuitebackup/src/Engine/MokoRestore.php @@ -272,6 +272,8 @@ function actionExtract(array $data): array 'user' => 'db_user', 'dbprefix' => 'db_prefix', 'sitename' => 'sitename', + 'smtphost' => 'smtp_host', + 'smtpuser' => 'smtp_user', ]; foreach ($fieldMap as $phpField => $configKey) { @@ -388,6 +390,9 @@ function actionConfig(array $data): array $prefix = $data['db_prefix'] ?? 'moko_'; $sitename = $data['sitename'] ?? 'Joomla Site'; $livesite = $data['live_site'] ?? ''; + $smtpHost = $data['smtp_host'] ?? ''; + $smtpUser = $data['smtp_user'] ?? ''; + $smtpPass = $data['smtp_pass'] ?? ''; $tmpPath = RESTORE_DIR . '/tmp'; $logPath = RESTORE_DIR . '/administrator/logs'; @@ -413,6 +418,17 @@ function actionConfig(array $data): array $replacements['/\$live_site\s*=\s*\'[^\']*\'/'] = "\$live_site = '{$livesite}'"; } + // Replace SMTP credentials (only if provided — leave existing values if blank) + if ($smtpHost !== '') { + $replacements['/\$smtphost\s*=\s*\'[^\']*\'/'] = "\$smtphost = '{$smtpHost}'"; + } + if ($smtpUser !== '') { + $replacements['/\$smtpuser\s*=\s*\'[^\']*\'/'] = "\$smtpuser = '" . addcslashes($smtpUser, "'\\") . "'"; + } + if ($smtpPass !== '') { + $replacements['/\$smtppass\s*=\s*\'[^\']*\'/'] = "\$smtppass = '" . addcslashes($smtpPass, "'\\") . "'"; + } + foreach ($replacements as $pattern => $replacement) { $config = preg_replace($pattern, $replacement, $config); } @@ -835,15 +851,33 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N

Site Configuration

-

Update or create configuration.php with the correct settings for this server.

-
-
- - -
Leave blank to auto-detect. Set this if using a reverse proxy or custom domain.
+

Configure your site settings. Credentials were removed from the backup for security — enter the correct values for this server.

+ +
+
+ 🌐 General +
+
+
+ + +
Leave blank to auto-detect. Set this if using a reverse proxy or custom domain.
+
+ +
+
+ Mail / SMTP — leave blank if using PHP mail() +
+
+
+
+
+
+
+
- A new Joomla secret will be generated automatically for security. + 🔒 A new Joomla secret key will be generated automatically. This invalidates active sessions (users will need to log in again) but does not affect passwords or user accounts.
@@ -1055,13 +1089,16 @@ async function runExtract() { setStatus('extractStatus', r.message, 'success'); log(r.message); - // Pre-fill DB config from extracted configuration.php + // Pre-fill config from extracted configuration.php + // (sanitized fields will be absent — those form fields stay empty) if (r.config) { if (r.config.db_host) document.getElementById('dbHost').value = r.config.db_host; if (r.config.db_name) document.getElementById('dbName').value = r.config.db_name; if (r.config.db_user) document.getElementById('dbUser').value = r.config.db_user; if (r.config.db_prefix) document.getElementById('dbPrefix').value = r.config.db_prefix; if (r.config.sitename) document.getElementById('siteName').value = r.config.sitename; + if (r.config.smtp_host) document.getElementById('smtpHost').value = r.config.smtp_host; + if (r.config.smtp_user) document.getElementById('smtpUser').value = r.config.smtp_user; } if (!r.has_db) { @@ -1128,6 +1165,9 @@ async function runConfig() { const params = Object.assign({}, dbConfig, { sitename: document.getElementById('siteName').value, live_site: document.getElementById('liveSite').value, + smtp_host: document.getElementById('smtpHost').value, + smtp_user: document.getElementById('smtpUser').value, + smtp_pass: document.getElementById('smtpPass').value, }); const r = await post('config', params);