44 lines
1.8 KiB
PHP
44 lines
1.8 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$out = ["wiki_hits"=>[], "endpoints_pdf"=>[], "historic_pdf_mentions"=>[]];
|
|
|
|
// 1. Deep search obsidian vault
|
|
$search_terms = ["pdf premium", "pdf graphique", "pdf chart", "chart.js pdf", "pdf artefact", "reportlab chart", "matplotlib pdf", "weasyprint chart"];
|
|
foreach (glob("/opt/obsidian-vault/**/*.md") as $f) {
|
|
$c = @file_get_contents($f);
|
|
if (!$c) continue;
|
|
foreach ($search_terms as $term) {
|
|
if (stripos($c, $term) !== false) {
|
|
$out["wiki_hits"][] = [
|
|
"file" => str_replace("/opt/obsidian-vault/", "", $f),
|
|
"term" => $term,
|
|
"size" => strlen($c),
|
|
"mtime" => date("Y-m-d", filemtime($f)),
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
// 2. All PDF-related endpoints
|
|
foreach (glob("/var/www/html/api/*pdf*.php") as $f) {
|
|
$out["endpoints_pdf"][] = ["name"=>basename($f), "size"=>filesize($f), "mtime"=>date("Y-m-d H:i", filemtime($f))];
|
|
}
|
|
foreach (glob("/var/www/html/api/*doc*.php") as $f) {
|
|
$out["endpoints_pdf"][] = ["name"=>basename($f), "size"=>filesize($f), "mtime"=>date("Y-m-d H:i", filemtime($f))];
|
|
}
|
|
|
|
// 3. Existing generated PDFs recent
|
|
$gen_pdfs = [];
|
|
foreach (glob("/var/www/html/generated/*.pdf") as $f) {
|
|
$gen_pdfs[] = ["name"=>basename($f), "size_kb"=>round(filesize($f)/1024, 1), "mtime"=>date("Y-m-d H:i", filemtime($f))];
|
|
}
|
|
usort($gen_pdfs, function($a,$b){return strcmp($b["mtime"], $a["mtime"]);});
|
|
$out["recent_pdfs"] = array_slice($gen_pdfs, 0, 5);
|
|
|
|
// 4. Look for any ambre-tool-pdf-premium.php current state
|
|
$pdf_prem = "/var/www/html/api/ambre-tool-pdf-premium.php";
|
|
$out["pdf_premium_exists"] = file_exists($pdf_prem);
|
|
$out["pdf_premium_size"] = file_exists($pdf_prem) ? filesize($pdf_prem) : 0;
|
|
|
|
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|