#!/bin/bash
A=~/abtan
echo "########## DIAG ABTAN $(date) ##########"
echo "== PHP CLI par defaut =="; php -v 2>/dev/null | head -1
echo "== .ovhconfig COMPTE =="; grep -i 'engine\|version' ~/.ovhconfig 2>/dev/null || echo "  (aucun)"
echo "== .ovhconfig ABTAN =="; grep -i 'engine\|version' "$A/.ovhconfig" 2>/dev/null || echo "  (aucun -> herite du compte)"
echo "== Versions stack =="
for f in "wp-content/plugins/sitepress-multilingual-cms/sitepress.php" "wp-content/plugins/js_composer/js_composer.php" "wp-content/plugins/us-core/us-core.php" "wp-content/themes/Impreza/style.css"; do
  if [ -f "$A/$f" ]; then printf "  %-52s %s\n" "$(basename $(dirname "$f"))" "$(grep -m1 -i 'Version' "$A/$f" | tr -d '\r' | sed 's/^[^0-9]*//')"; else echo "  $(basename $(dirname "$f")) : ABSENT"; fi
done
echo "== active_plugins + theme (DB) =="; php ~/_diag_active.php
echo "== mu-plugins =="; ls -1 "$A/wp-content/mu-plugins" 2>/dev/null || echo "  (aucun)"
echo "== BOOTSTRAP sous PHP 8.1 (defaut) =="
( cd "$A" && php ~/_diag_boot.php ) 2>&1 | grep -aE '===|atal|rror|match|wpbakery|undefined' | head -8
echo "== BOOTSTRAP sous PHP 7.4 =="
if [ -x /usr/local/php7.4/bin/php ]; then ( cd "$A" && /usr/local/php7.4/bin/php ~/_diag_boot.php ) 2>&1 | grep -aE '===|atal|rror|match|wpbakery|undefined' | head -8; else echo "  (binaire php7.4 introuvable)"; fi
echo "########## FIN DIAG $(date) ##########"
