$files = @( "public_html\login\login.php", "public_html\tests\test_db.php", "public_html\account\wallet\index.php", "public_html\account\profile\index.php", "public_html\cron\archive_matches.php", "public_html\account\settings\update_settings.php", "public_html\account\settings\index.php", "public_html\account\settings\delete_account.php", "public_html\account\settings\change_password_verify.php", "public_html\account\settings\change_password_request.php", "public_html\account\settings\change_email_verify.php", "public_html\account\settings\change_email_request.php", "public_html\api\updateUser.php", "public_html\api\test_db_connection.php", "public_html\administration\includes\config.php", "public_html\api\deleteUser.php", "public_html\api\getUser.php", "public_html\api\getMatches.php", "public_html\api\loadUsers.php", "public_html\login\verify.php", "public_html\login\register.php", "public_html\login\recover_account.php", "private_html\login\login.php", "private_html\tests\test_db.php", "private_html\account\wallet\index.php", "private_html\account\profile\index.php", "private_html\cron\archive_matches.php", "private_html\account\settings\update_settings.php", "private_html\account\settings\index.php", "private_html\account\settings\delete_account.php", "private_html\account\settings\change_password_verify.php", "private_html\account\settings\change_password_request.php", "private_html\account\settings\change_email_verify.php", "private_html\account\settings\change_email_request.php", "private_html\api\updateUser.php", "private_html\api\test_db_connection.php", "private_html\administration\includes\config.php", "private_html\api\deleteUser.php", "private_html\api\getUser.php", "private_html\api\getMatches.php", "private_html\api\loadUsers.php", "private_html\login\verify.php", "private_html\login\register.php", "private_html\login\recover_account.php" ) $targetLine = '$pdo->exec("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci");' $results = @() foreach ($file in $files) { if (Test-Path $file) { $content = Get-Content $file -Raw if ($content.Contains($targetLine)) { $results += [PSCustomObject]@{File=$file; Status="Skipped (Already present)"} } elseif ($content -match '\$pdo\s*=\s*new\s+PDO\s*\([\s\S]*?\);') { $newContent = $content -replace '(\$pdo\s*=\s*new\s+PDO\s*\([\s\S]*?\);)', "`$1`r`n$targetLine" Set-Content $file $newContent $results += [PSCustomObject]@{File=$file; Status="Modified"} } else { $results += [PSCustomObject]@{File=$file; Status="Skipped (PDO instantiation not found)"} } } else { $results += [PSCustomObject]@{File=$file; Status="Error (File not found)"} } } $results | Format-Table -AutoSize