$rootPath = "c:\Users\user\Downloads\sshia.org\sshia.org\sshia"
$fixed = 0

Get-ChildItem -Path $rootPath -Recurse -Filter "*.php" | Where-Object {
    $_.FullName -notlike "*\vendor\*"
} | ForEach-Object {
    $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
    if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
        [System.IO.File]::WriteAllBytes($_.FullName, $bytes[3..($bytes.Length - 1)])
        Write-Host "BOM removed: $($_.FullName.Replace($rootPath, ''))"
        $fixed++
    }
}

Write-Host ""
Write-Host "Done. $fixed file(s) had BOM removed."
