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 = " "; if (strpos($html, 'data-oss-total') === false) { $html = str_replace('', $live_script . '', $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__);