import os
import re

tables = set()

for root, dirs, files in os.walk('.'):
    for file in files:
        if file.endswith('.php'):
            with open(os.path.join(root, file), 'r', encoding='utf-8', errors='ignore') as f:
                content = f.read()
                matches_from = re.findall(r'FROM\s+([a-zA-Z0-9_]+)', content, re.IGNORECASE)
                matches_into = re.findall(r'INTO\s+([a-zA-Z0-9_]+)', content, re.IGNORECASE)
                matches_update = re.findall(r'UPDATE\s+([a-zA-Z0-9_]+)', content, re.IGNORECASE)
                
                tables.update(matches_from)
                tables.update(matches_into)
                tables.update(matches_update)

print(sorted(list(tables)))
