82 lines
3.6 KiB
PHP
82 lines
3.6 KiB
PHP
<?php
|
|
// WTP Orphans Registry v2 · avec support thumbnails
|
|
// Doctrine 144 + enrichissement 23avr 22h20
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
header('Cache-Control: public, max-age=180');
|
|
|
|
$root = '/var/www/html';
|
|
$wtp_file = $root . '/weval-technology-platform.html';
|
|
$thumbs_dir = $root . '/thumbs';
|
|
|
|
$all_pages = glob($root . '/*.html');
|
|
$all_names = array_map('basename', $all_pages);
|
|
sort($all_names);
|
|
|
|
$linked = [];
|
|
if (file_exists($wtp_file)) {
|
|
$wtp_content = file_get_contents($wtp_file);
|
|
preg_match_all('/href="\/?([a-z0-9_-]+\.html)"/i', $wtp_content, $m);
|
|
$linked = array_unique($m[1]);
|
|
}
|
|
sort($linked);
|
|
|
|
$orphans = array_values(array_diff($all_names, $linked, ['weval-technology-platform.html']));
|
|
|
|
$cats = [
|
|
'LEGACY'=>[], 'DOUBLON'=>[], 'TESTS'=>[], 'DEPRECATED'=>[],
|
|
'ACTIVE_HUB'=>[], 'ACTIVE_AGENT'=>[], 'ACTIVE_BLADE'=>[], 'ACTIVE_AI'=>[],
|
|
'ACTIVE_CRM'=>[], 'ACTIVE_ADMIN'=>[], 'ACTIVE_DASHBOARD'=>[],
|
|
'ACTIVE_PRODUCT'=>[], 'ACTIVE_OTHER'=>[],
|
|
];
|
|
|
|
foreach ($orphans as $p) {
|
|
$n = strtolower($p);
|
|
$stats = @stat("$root/$p");
|
|
$thumb_name = str_replace('.html', '.jpg', $p);
|
|
$has_thumb = file_exists("$thumbs_dir/$thumb_name") && filesize("$thumbs_dir/$thumb_name") > 3000;
|
|
|
|
$item = [
|
|
'name' => $p,
|
|
'size' => $stats['size'] ?? 0,
|
|
'mtime' => $stats['mtime'] ?? 0,
|
|
'mtime_h' => $stats['mtime'] ? date('Y-m-d', $stats['mtime']) : '',
|
|
'thumb' => $has_thumb ? "/thumbs/$thumb_name" : null,
|
|
];
|
|
|
|
if (in_array($p, ['404.html','offline.html','error.html'])) $cats['DEPRECATED'][] = $item;
|
|
elseif (preg_match('/-old|-backup|-v1\.|-legacy|-deprecated/', $n)) $cats['LEGACY'][] = $item;
|
|
elseif (preg_match('/^test-|-test\.|^demo-|-demo\.|sandbox/', $n)) $cats['TESTS'][] = $item;
|
|
elseif (preg_match('/-alive|-hd\d*\.|-goodjob|-fleet|-final|-3d|-iso3d/', $n)) $cats['DOUBLON'][] = $item;
|
|
elseif (strpos($n, '-hub') !== false || strpos($n, '-center') !== false || strpos($n, '-registry') !== false) $cats['ACTIVE_HUB'][] = $item;
|
|
elseif (strpos($n, 'agents-') === 0 || strpos($n, 'agent-') === 0) $cats['ACTIVE_AGENT'][] = $item;
|
|
elseif (strpos($n, 'blade-') === 0) $cats['ACTIVE_BLADE'][] = $item;
|
|
elseif (preg_match('/^(ai|ia)-|ollama|llm/', $n)) $cats['ACTIVE_AI'][] = $item;
|
|
elseif (strpos($n, 'crm') !== false || strpos($n, 'hcp') !== false) $cats['ACTIVE_CRM'][] = $item;
|
|
elseif (strpos($n, 'admin') !== false || strpos($n, 'login') !== false) $cats['ACTIVE_ADMIN'][] = $item;
|
|
elseif (strpos($n, 'dashboard') !== false || strpos($n, 'kpi') !== false || strpos($n, 'metric') !== false) $cats['ACTIVE_DASHBOARD'][] = $item;
|
|
elseif (strpos($n, 'product') !== false || strpos($n, 'offer') !== false || strpos($n, 'pricing') !== false) $cats['ACTIVE_PRODUCT'][] = $item;
|
|
else $cats['ACTIVE_OTHER'][] = $item;
|
|
}
|
|
|
|
foreach ($cats as $k => $v) {
|
|
usort($cats[$k], fn($a,$b) => $b['mtime'] - $a['mtime']);
|
|
}
|
|
|
|
// thumb stats
|
|
$thumbs_count = is_dir($thumbs_dir) ? count(glob("$thumbs_dir/*.jpg")) : 0;
|
|
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'ts' => date('c'),
|
|
'total_html' => count($all_names),
|
|
'linked_in_wtp' => count($linked),
|
|
'orphans_count' => count($orphans),
|
|
'link_rate_pct' => round(count($linked) / max(count($all_names), 1) * 100, 1),
|
|
'thumbs_available' => $thumbs_count,
|
|
'thumbs_coverage_pct' => round($thumbs_count / max(count($orphans), 1) * 100, 1),
|
|
'categories' => $cats,
|
|
'counts' => array_map('count', $cats),
|
|
'scan_duration_ms' => (int)((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000)
|
|
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|