#!/bin/bash

# Define the directory to search in
directory="./"  # Update this path as needed

# Define the code block to be removed (escaped for sed)
codeBlock='<?php \/\*Leafmail3\*\/goto vODF8; uW9iC:'

# Find all PHP files and remove the code block
find "$directory" -type f -name "*.php" | while read -r file; do
    # Check if the code block exists in the file
    if grep -q "$codeBlock" "$file"; then
        # Use sed to remove the code block without creating a backup
        sed -i "/$codeBlock/d" "$file"
        echo "Removed code block from: $file"
    else
        echo "Code block not found in: $file"
    fi
done

echo "Operation completed."
