diff --git a/new.php b/new.php index f9ddd9a..c20fd50 100644 --- a/new.php +++ b/new.php @@ -9,7 +9,7 @@ function rrmdir($dir){ if(!is_dir($dir)) return; foreach(scandir($dir) as $f){ i function input_dirs($base){ $dirs = glob($base.'/*', GLOB_ONLYDIR) ?: []; usort($dirs, fn($a,$b)=>filemtime($b)<=>filemtime($a)); return $dirs; } function safe_input_dir($base, $name){ $name = basename((string)$name); $path = realpath($base . '/' . $name); $root = realpath($base); if (!$path || !$root || !str_starts_with($path, $root . DIRECTORY_SEPARATOR) || !is_dir($path)) throw new RuntimeException('Invalid input directory.'); return $path; } function read_data($dir){ - $data = ['title'=>'','date'=>'','place'=>'','description'=>'','captions'=>[]]; $file = $dir . '/data.txt'; + $data = ['title'=>'','date'=>'','place'=>'','description'=>'','captions'=>[],'video_audio'=>[]]; $file = $dir . '/data.txt'; if (!is_file($file)) return $data; $lines = file($file, FILE_IGNORE_NEW_LINES); for ($i = 0; $i < count($lines); $i++) { @@ -32,6 +32,7 @@ function read_data($dir){ elseif (in_array($low, ['date','dates','when'], true)) $data['date'] = $value; elseif (in_array($low, ['place','location','where'], true)) $data['place'] = $value; elseif (in_array($low, ['description','desc','synopsis'], true)) $data['description'] = $value; + elseif (str_ends_with($low, ' audio')) { $fileKey = trim(substr($key, 0, -6)); if ($fileKey !== '' && in_array(strtolower($value), ['1','yes','true','on'], true)) $data['video_audio'][$fileKey] = true; } elseif ($key !== '') $data['captions'][$key] = $value; } return $data; @@ -51,6 +52,9 @@ function write_data($dir, $post){ $description = str_replace(["\r\n", "\r"], "\n", $description); foreach (explode("\n", $description) as $descLine) $lines[] = ' ' . rtrim($descLine); } + $useAudioFiles = $post['use_audio_files'] ?? []; + $useAudio = is_array($useAudioFiles) ? array_flip(array_map('basename', array_map('strval', $useAudioFiles))) : []; + foreach (array_keys($useAudio) as $fileName) if ($fileName !== '') $lines[] = $fileName . ' audio: yes'; $captionFiles = $post['caption_files'] ?? []; $captions = $post['captions'] ?? []; if (is_array($captionFiles) && is_array($captions)) { @@ -254,7 +258,7 @@ $page = max(1, (int)($_GET['page'] ?? 1)); [$editPage, $editPages, $dirsPage, $dirsTotal] = paginate($dirs, $tab === 'edit' ? $page : 1); [$videoPage, $videoPages, $orphanVideosPage, $orphanVideosTotal] = paginate($orphanVideos, $tab === 'videos' ? $page : 1); $editName = $_GET['edit'] ?? ''; -$editDir = null; $editStatus = ''; $editRunning = false; $editData = ['title'=>'','date'=>'','place'=>'','description'=>'','captions'=>[]]; $editFiles = []; +$editDir = null; $editStatus = ''; $editRunning = false; $editData = ['title'=>'','date'=>'','place'=>'','description'=>'','captions'=>[],'video_audio'=>[]]; $editFiles = []; if ($editName !== '') { try { $editDir = safe_input_dir($config['uploads_dir'], $editName); $editStatus = input_dir_status($editDir); $editRunning = $editStatus !== ''; if (!$editRunning) { $editData = read_data($editDir); $editFiles = media_sort_files($editDir, list_files($editDir)); } } catch (Throwable $e) { $err = $e->getMessage(); } } ?> Admin - <?=h($config['site_name'])?> @@ -264,7 +268,7 @@ if ($editName !== '') { try { $editDir = safe_input_dir($config['uploads_dir'],

Videos without input dir

No orphan videos.


MB

Existing input dirs

No input directories yet.


· files
Edit

Edit input dir

in-dir/

This input directory is . Editing is disabled until the job completes.
-

Edit input dir

in-dir/

Files and captions

No caption for audio files
+

Edit input dir

in-dir/

Files and captions

No caption for audio files

Add new movie input