#!/bin/bash
# Vérification intégrité core WordPress - alerte uniquement sur fichiers altérés (backdoor)
WP_PATH_BASE="/homez.432/citronze/www/hosting"
ALERT_FOUND=0

for d in "$WP_PATH_BASE"/*/; do
  site=$(basename "$d")
  if [ -f "$d/wp-config.php" ]; then
    result=$(~/bin/wp core verify-checksums --path="$d" 2>&1 | grep "doesn't match checksum")
    if [ -n "$result" ]; then
      ALERT_FOUND=1
      echo "=== ALERTE SITE: $site ==="
      echo "$result"
      echo ""
    fi
  fi
done

if [ "$ALERT_FOUND" -eq 0 ]; then
  echo "OK - Aucun fichier core altéré detecté sur le fleet ($(date))"
else
  echo "!!! FICHIERS CORE ALTERES DETECTES - INVESTIGATION REQUISE !!!"
fi
