mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
103 lines
5.1 KiB
PHP
103 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* PeerTube orphan check as HTML fragment (admin).
|
|
*
|
|
* GET /admin/actions/peertube-orphans-fragment.php
|
|
*
|
|
* Returns an HTML fragment ready for HTMX swap into #peertube-orphans-wrapper.
|
|
*/
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
// Re-use the existing JSON endpoint internally
|
|
ob_start();
|
|
require __DIR__ . '/peertube-orphans.php';
|
|
$json = ob_get_clean();
|
|
$d = json_decode($json, true);
|
|
|
|
if (!($d['configured'] ?? false)): ?>
|
|
<div id="peertube-orphans-wrapper">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>Vidéos PeerTube orphelines</summary>
|
|
<div id="peertube-orphans-stats">
|
|
<p style="margin:0;color:var(--color-warning)">⚠️ PeerTube non configuré.</p>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
<?php return; endif; ?>
|
|
|
|
<?php if (!empty($d['error'])): ?>
|
|
<div id="peertube-orphans-wrapper">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>Vidéos PeerTube orphelines</summary>
|
|
<div id="peertube-orphans-stats">
|
|
<p style="margin:0;color:var(--color-error)">✗ <?= htmlspecialchars($d['error']) ?></p>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
<?php return; endif; ?>
|
|
|
|
<div id="peertube-orphans-wrapper">
|
|
<details id="peertube-orphans-col" class="n-section" open>
|
|
<summary>Vidéos PeerTube orphelines <span class="n-meta"><?= (int)($d['total_on_channel'] ?? 0) ?> vidéos · <?= (int)($d['total_linked'] ?? 0) ?> liées</span></summary>
|
|
<div id="peertube-orphans-stats">
|
|
<?php if (($d['orphan_count'] ?? 0) > 0): ?>
|
|
<table class="n-table">
|
|
<thead><tr><th>Nom</th><th>Date</th><th width="1%"></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($d['orphans'] as $v): ?>
|
|
<tr>
|
|
<td>
|
|
<strong><?= htmlspecialchars($v['name']) ?></strong>
|
|
<span class="n-table__info" style="display:block"><?= htmlspecialchars($v['uuid']) ?></span>
|
|
</td>
|
|
<td style="white-space:nowrap"><?= htmlspecialchars(substr($v['createdAt'] ?? '', 0, 10)) ?></td>
|
|
<td style="white-space:nowrap">
|
|
<button type="button" class="btn btn--sm btn--danger" style="font-size:0.85em;padding:2px var(--space-xs)"
|
|
hx-post="/admin/actions/peertube-delete.php"
|
|
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","uuid":"<?= htmlspecialchars($v['uuid']) ?>"}'
|
|
hx-target="#peertube-orphans-wrapper"
|
|
hx-swap="outerHTML"
|
|
hx-trigger="click"
|
|
hx-indicator="#peertube-orphans-wrapper">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 256 256" aria-hidden="true"><path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"></path></svg>
|
|
Supprimer
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php else: ?>
|
|
<p style="margin:0;color:var(--accent-green)">✓ Aucune vidéo orpheline.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</details>
|
|
|
|
<?php if (($d['stale_count'] ?? 0) > 0): ?>
|
|
<details id="peertube-stale-section" class="n-section" open>
|
|
<summary>Références DB obsolètes <span class="n-meta"><?= $d['stale_count'] ?></span></summary>
|
|
<p style="margin:0 0 var(--space-sm) 0;font-size:0.85em;color:var(--text-secondary)">Ces UUID sont référencés en base de données mais n'existent plus sur la chaîne PeerTube. Les TFE liés affichent des liens morts.</p>
|
|
<table class="n-table">
|
|
<thead><tr><th>UUID</th><th>TFE(s)</th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($d['stale_entries'] as $s): ?>
|
|
<tr>
|
|
<td style="word-break:break-all;color:var(--text-secondary)"><?= htmlspecialchars($s['uuid']) ?></td>
|
|
<td>
|
|
<?php if (!empty($s['theses'])): ?>
|
|
<?= implode(', ', array_map(function($t) {
|
|
$label = $t['identifier'] ?: '#' . $t['thesis_id'];
|
|
return '<a href="/admin/contenus-edit.php?id=' . (int)$t['thesis_id'] . '" target="_blank">' . htmlspecialchars($label) . '</a>';
|
|
}, $s['theses'])) ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</details>
|
|
<?php endif; ?>
|
|
</div>
|