<?php
$dir=rtrim($argv[1]??'','/');$s=file_get_contents($dir.'/wp-config.php');
function gc($s,$k){return preg_match('/define\(\s*[\x27\x22]'.$k.'[\x27\x22]\s*,\s*[\x27\x22]([^\x27\x22]*)/',$s,$m)?$m[1]:'';}
$pfx=preg_match('/\$table_prefix\s*=\s*[\x27\x22]([^\x27\x22]+)/',$s,$m)?$m[1]:'wp_';
$h=gc($s,'DB_HOST');$p=0;if(strpos($h,':')!==false){list($h,$p)=explode(':',$h,2);}
$m=@new mysqli($h,gc($s,'DB_USER'),gc($s,'DB_PASSWORD'),gc($s,'DB_NAME'),$p?:3306);
$r=$m->query("SELECT option_value FROM {$pfx}options WHERE option_name='home'");
echo ($r&&$r->num_rows?$r->fetch_row()[0]:'?')."\n";
