Add admin run and show switches

This commit is contained in:
hbrain 2026-05-26 13:33:37 +02:00
parent a49600a5d9
commit fcae25d28a
4 changed files with 58 additions and 5 deletions

View file

@ -3,6 +3,15 @@ date_default_timezone_set('Europe/Copenhagen');
$config = require __DIR__ . "/config.php";
function x($s){ return htmlspecialchars((string)$s, ENT_XML1 | ENT_QUOTES, "UTF-8"); }
function nice_title($s){ return trim(ucwords(str_replace(['_','-'], ' ', $s))); }
function hidden_video_outputs($config){
$hidden = [];
foreach (glob($config['uploads_dir'].'/*', GLOB_ONLYDIR) ?: [] as $dir) {
if (!is_file($dir . '/.mvlog-hidden')) continue;
$state = is_file($dir . '/.movmaker-state.json') ? json_decode((string)file_get_contents($dir . '/.movmaker-state.json'), true) : [];
if (is_array($state) && !empty($state['output'])) $hidden[basename((string)$state['output'])] = true;
}
return $hidden;
}
function video_metadata($path){
$base = pathinfo($path, PATHINFO_FILENAME);
$meta = ['title'=>nice_title($base),'date'=>date('Y-m-d',filemtime($path)),'location'=>'','description'=>''];
@ -22,7 +31,8 @@ function video_metadata($path){
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'https';
$host = $_SERVER['HTTP_HOST'] ?? 'bubulescu.org';
$baseUrl = $scheme . '://' . $host . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$videos = glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [];
$hiddenOutputs = hidden_video_outputs($config);
$videos = array_values(array_filter(glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [], fn($v)=>empty($hiddenOutputs[basename($v)])));
usort($videos, fn($a,$b)=>filemtime($b)<=>filemtime($a));
$videos = array_slice($videos,0,20);
header('Content-Type: application/rss+xml; charset=UTF-8');