55 lines
2.1 KiB
PHP
55 lines
2.1 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$out = [];
|
|
|
|
// 1. Search wikis about "pdf premium" or "pdf graphique"
|
|
$wiki_hits = [];
|
|
foreach (glob("/opt/obsidian-vault/**/*.md") as $f) {
|
|
$content = @file_get_contents($f);
|
|
if (!$content) continue;
|
|
if (stripos($content, "pdf premium") !== false ||
|
|
stripos($content, "weasyprint") !== false ||
|
|
stripos($content, "pdf graphique") !== false ||
|
|
stripos($content, "reportlab") !== false ||
|
|
stripos($content, "pdf chart") !== false ||
|
|
stripos($content, "pdfmake") !== false) {
|
|
$wiki_hits[] = [
|
|
"file" => str_replace("/opt/obsidian-vault/", "", $f),
|
|
"size" => filesize($f),
|
|
];
|
|
}
|
|
}
|
|
$out["wiki_hits_pdf"] = array_slice($wiki_hits, 0, 15);
|
|
|
|
// 2. Existing PDF endpoints
|
|
$out["pdf_endpoints"] = [];
|
|
foreach (glob("/var/www/html/api/*pdf*.php") as $f) {
|
|
$out["pdf_endpoints"][] = [
|
|
"name" => basename($f),
|
|
"size" => filesize($f),
|
|
"mtime" => date("Y-m-d H:i", filemtime($f)),
|
|
];
|
|
}
|
|
|
|
// 3. PDF generation binaries available
|
|
$out["pdf_tools"] = [
|
|
"wkhtmltopdf" => trim(@shell_exec("which wkhtmltopdf") ?: "NO"),
|
|
"weasyprint" => trim(@shell_exec("which weasyprint") ?: "NO"),
|
|
"pandoc" => trim(@shell_exec("which pandoc") ?: "NO"),
|
|
"chromium" => trim(@shell_exec("which chromium chromium-browser google-chrome 2>&1 | head -1") ?: "NO"),
|
|
"reportlab" => trim(@shell_exec("python3 -c 'import reportlab; print(reportlab.__version__)' 2>&1") ?: "NO"),
|
|
"matplotlib" => trim(@shell_exec("python3 -c 'import matplotlib; print(matplotlib.__version__)' 2>&1") ?: "NO"),
|
|
"plotly" => trim(@shell_exec("python3 -c 'import plotly; print(plotly.__version__)' 2>&1") ?: "NO"),
|
|
];
|
|
|
|
// 4. Earlier wiki sessions about PDF
|
|
$recent_sessions = [];
|
|
foreach (glob("/opt/obsidian-vault/sessions/*.md") as $f) {
|
|
$base = basename($f);
|
|
$recent_sessions[] = ["name"=>$base, "mtime"=>date("Y-m-d", filemtime($f))];
|
|
}
|
|
usort($recent_sessions, function($a,$b){return strcmp($b["mtime"], $a["mtime"]);});
|
|
$out["recent_sessions"] = array_slice($recent_sessions, 0, 10);
|
|
|
|
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|