From 43e84760980e6845871897681652b7e5ff8e5ef8 Mon Sep 17 00:00:00 2001 From: hbrain Date: Mon, 15 Jun 2026 04:46:26 +0200 Subject: [PATCH] Allow permalink pages without showing on index --- index.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index a234328..1ebebe9 100644 --- a/index.php +++ b/index.php @@ -84,6 +84,24 @@ function shown_video_paths($config){ return $videos; } +function permalink_video_paths($config, $articleId){ + $articleId = strtolower(trim((string)$articleId)); + if (!preg_match('/^[0-9]{14}[a-f0-9]{16}$/', $articleId)) return []; + foreach (glob($config['uploads_dir'].'/*', GLOB_ONLYDIR) ?: [] as $dir) { + if (!is_file($dir . '/.mvlog-permalink')) continue; + if (read_article_id($dir) !== $articleId) continue; + $stateFile = $dir . '/.movmaker-state.json'; + if (!is_file($stateFile)) return []; + $state = json_decode((string)file_get_contents($stateFile), true); + if (!is_array($state)) return []; + $name = basename((string)($state['output'] ?? '')); + if ($name === '' || preg_match('/_preview\.(mp4|webm|mov|m4v)$/i', $name)) return []; + $path = $config['videos_dir'] . '/' . $name; + return is_file($path) ? [$path] : []; + } + return []; +} + function public_url_path($path){ $path = str_replace('\\', '/', trim((string)$path)); if ($path === '') return ''; @@ -309,9 +327,8 @@ if ($articleId !== '') { if (!article_permalink_enabled($config, $articleId)) { render_404_page(); } - $videos = array_values(array_filter($allVideos, function($v) use ($articleId, $config) { - return video_article_id($config, basename($v)) === $articleId; - })); + // Permalink pages are allowed when Permalink is ON, even if Show is OFF. + $videos = permalink_video_paths($config, $articleId); $rawKeyword = ''; $keywordType = 'general'; $keywordValue = '';