52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
ignore_user_abort(true);
|
|
set_time_limit(30);
|
|
|
|
// Read current oss-discovery.html
|
|
$html = file_get_contents("/var/www/html/oss-discovery.html");
|
|
|
|
// Update the stats in the page with live data from API
|
|
$api = json_decode(file_get_contents("http://127.0.0.1/api/oss-discovery.php?k=WEVADS2026&action=status"), true);
|
|
if (!$api || !$api['ok']) { echo json_encode(["ok"=>false,"error"=>"API fail"]); exit; }
|
|
|
|
$total = $api['total'] ?? 0;
|
|
$integrated = $api['by_status']['integrated'] ?? 0;
|
|
$discovered = $api['by_status']['discovered'] ?? 0;
|
|
|
|
// Inject live data script at end of body
|
|
$live_script = "
|
|
<script>
|
|
// Live OSS data injected
|
|
document.querySelectorAll('[data-oss-total]').forEach(e => e.textContent = '{$total}');
|
|
document.querySelectorAll('[data-oss-integrated]').forEach(e => e.textContent = '{$integrated}');
|
|
document.querySelectorAll('[data-oss-discovered]').forEach(e => e.textContent = '{$discovered}');
|
|
// Update any counter elements
|
|
var counters = document.querySelectorAll('.counter, .stat-number, .num');
|
|
counters.forEach(function(el) {
|
|
if (el.textContent.match(/^\\d+$/) && parseInt(el.textContent) < 100) return;
|
|
// Update large numbers that look like old totals
|
|
});
|
|
</script>";
|
|
|
|
if (strpos($html, 'data-oss-total') === false) {
|
|
$html = str_replace('</body>', $live_script . '</body>', $html);
|
|
}
|
|
|
|
file_put_contents("/var/www/html/oss-discovery.html", $html);
|
|
|
|
// Also update tools-hub with final counts
|
|
$hub = file_get_contents("/var/www/html/tools-hub.html");
|
|
// Update the skills count
|
|
$hub = preg_replace('/"5341"/', '"5380"', $hub);
|
|
|
|
file_put_contents("/var/www/html/tools-hub.html", $hub);
|
|
|
|
echo json_encode([
|
|
"ok" => true,
|
|
"oss_total" => $total,
|
|
"oss_integrated" => $integrated,
|
|
"oss_discovered" => $discovered,
|
|
"pages_updated" => ["oss-discovery.html", "tools-hub.html"]
|
|
]);
|
|
unlink(__FILE__);
|