#!/bin/bash
# audit-site.sh : audit en LECTURE SEULE du site view-avocats.fr (ne modifie, ne supprime, ne crée rien).
# N'affiche jamais de mot de passe ni de clé d'API.
cd ~ || exit 1
W=""
for d in www public_html .; do [ -f "$d/index.html" ] || [ -f "$d/index.php" ] && { W="$d"; break; }; done
[ -z "$W" ] && W="www"
cd "$W" 2>/dev/null || { echo "Racine du site introuvable"; exit 1; }
echo "=== 1. RACINE: $(pwd)"; php -v 2>/dev/null | head -1
echo; echo "=== 2. FICHIERS A LA RACINE"; ls -la | head -60
echo; echo "=== 3. PAGES STATIQUES (dossier/index.html)"; find . -maxdepth 2 -name index.html -not -path './wp-*' | sort
echo; echo "=== 4. .htaccess (www, redirections, expertise)"
if [ -f .htaccess ]; then wc -l .htaccess; grep -n -i -E 'www|expertise|nos-missions|domaines|Redirect|RewriteRule \^' .htaccess | head -40; else echo ".htaccess absent"; fi
echo; echo "=== 5. BENJAMIN / VANOVERSCHELDE dans les fichiers du site (hors WordPress core et caches)"
grep -rIil -E 'benjamin|vanoverschelde' . --include='*.html' --include='*.php' --include='*.xml' --include='*.txt' --include='*.json' --include='*.md' --include='*.js' --include='*.css' \
  --exclude-dir=wp-includes --exclude-dir=wp-admin --exclude-dir=cache --exclude-dir=plugins --exclude-dir=themes --exclude-dir=node_modules 2>/dev/null | head -40
echo "(fichiers dont le NOM contient benjamin / vanover :)"
find . \( -iname '*benjamin*' -o -iname '*vanover*' \) -not -path './wp-includes/*' 2>/dev/null | head -20
echo; echo "=== 6. PDF et plaquettes dans uploads"; find wp-content/uploads -iname '*.pdf' 2>/dev/null | head -20
echo; echo "=== 7. LOGO (webp / png)"; ls -la wp-content/uploads/2023/11/LogoCabView-1.* 2>&1 | head
echo; echo "=== 8. FORMULAIRE traitement.php"
if [ -f traitement.php ]; then ls -la traitement.php; echo "mots-cles presents (nombre d'occurrences):"; grep -o -i -E 'site_web|recaptcha|turnstile|hcaptcha|mail\(|PHPMailer|smtp|sleep|REMOTE_ADDR|strlen|filter_var' traitement.php | tr 'A-Z' 'a-z' | sort | uniq -c; else echo "traitement.php ABSENT a la racine"; fi
echo; echo "=== 9. SCRIPTS AVIS / ACTUALITES"
ls -la avis-google.php avis-google.cache.json maj-actualites.php maj-actualites.stamp 2>&1 | head
[ -f avis-google.php ] && echo "cle API encore a coller: $(grep -c 'COLLER_ICI_LA_CLE_API' avis-google.php) (1 = pas encore renseignee, 0 = renseignee)"
echo "index.html inscriptible par PHP: $( [ -w index.html ] && echo oui || echo non )"; ls -ld . index.html
echo; echo "=== 10. ROBOTS ET SITEMAPS"; [ -f robots.txt ] && cat robots.txt || echo "robots.txt physique absent (WordPress en genere un virtuel)"; ls -la sitemap*.xml 2>&1 | head
echo; echo "=== 11. MENTIONS www DANS LES PAGES STATIQUES (doit etre vide)"; grep -rIl 'www.view-avocats.fr' --include='index.html' . 2>/dev/null | head
echo; echo "FIN DE L'AUDIT"
