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
Update or create configuration.php with the correct settings for this server.
- -Configure your site settings. Credentials were removed from the backup for security — enter the correct values for this server.
+ +