<?php
mysqli_report(MYSQLI_REPORT_OFF);
$site='abtan';
$c=@file_get_contents(getenv('HOME')."/$site/wp-config.php");
if($c===false){echo "  wp-config KO\n";exit;}
$g=function($k)use($c){return preg_match("/define\(\s*['\"]".$k."['\"]\s*,\s*['\"]([^'\"]*)/",$c,$m)?$m[1]:'';};
$p=preg_match('/\$table_prefix\s*=\s*[\'"]([^\'"]+)[\'"]/',$c,$m)?$m[1]:'wp_';
$hp=explode(':',$g('DB_HOST'));
$db=@mysqli_connect($hp[0],$g('DB_USER'),$g('DB_PASSWORD'),$g('DB_NAME'),isset($hp[1])?(int)$hp[1]:3306);
if(!$db){echo "  DB KO\n";exit;}
$r=mysqli_query($db,"SELECT option_value FROM {$p}options WHERE option_name='active_plugins'");
$row=$r?mysqli_fetch_row($r):null;
if(!$row){echo "  active_plugins ABSENT\n";}
else{
  $a=@unserialize($row[0]);
  if(!is_array($a)){echo "  active_plugins ILLISIBLE: ".substr($row[0],0,100)."\n";}
  else{
    echo "  active_plugins count=".count($a)."\n";
    $base=getenv('HOME')."/$site/wp-content/plugins/";
    foreach($a as $pl){ echo "   - $pl".(file_exists($base.$pl)?'':'  <<< FICHIER MANQUANT!!')."\n"; }
  }
}
$r=mysqli_query($db,"SELECT option_name,option_value FROM {$p}options WHERE option_name IN ('template','stylesheet')");
while($r&&($x=mysqli_fetch_row($r)))echo "  ".$x[0]."=".$x[1]."\n";
mysqli_close($db);
