diff --git a/index.php b/index.php index eaa5e34..df2fed3 100644 --- a/index.php +++ b/index.php @@ -90,6 +90,6 @@ $page=max(1,(int)($_GET['page']??1)); $per=$config['items_per_page']; $total=cou

No videos yet.

-

+

diff --git a/new.php b/new.php index e2e5e6e..6b400cc 100644 --- a/new.php +++ b/new.php @@ -11,12 +11,24 @@ function safe_input_dir($base, $name){ $name = basename((string)$name); $path = function read_data($dir){ $data = ['title'=>'','date'=>'','place'=>'','description'=>'','captions'=>[]]; $file = $dir . '/data.txt'; if (!is_file($file)) return $data; - foreach (file($file, FILE_IGNORE_NEW_LINES) as $line) { - $line = trim($line); + $lines = file($file, FILE_IGNORE_NEW_LINES); + for ($i = 0; $i < count($lines); $i++) { + $line = trim($lines[$i]); if ($line === '' || str_starts_with($line, '#') || !str_contains($line, ':')) continue; [$key, $value] = array_map('trim', explode(':', $line, 2)); $low = strtolower($key); - if (in_array($low, ['title','name'], true)) $data['title'] = $value; + if ($value === '|' && in_array($low, ['description','desc','synopsis'], true)) { + $block = []; + while ($i + 1 < count($lines)) { + $next = $lines[$i + 1]; + if (trim($next) !== '' && $next[0] !== ' ' && $next[0] !== "\t") break; + $i++; + if (str_starts_with($next, ' ')) $next = substr($next, 2); + elseif (str_starts_with($next, ' ') || str_starts_with($next, "\t")) $next = substr($next, 1); + $block[] = rtrim($next); + } + $data['description'] = trim(implode("\n", $block)); + } elseif (in_array($low, ['title','name'], true)) $data['title'] = $value; 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; @@ -34,7 +46,11 @@ function write_data($dir, $post){ if ($title !== '') $lines[] = 'Title: ' . $title; if ($place !== '') $lines[] = 'Location: ' . $place; if ($date !== '') $lines[] = 'Date: ' . $date; - if ($description !== '') $lines[] = 'Description: ' . str_replace(["\r", "\n"], ' ', $description); + if ($description !== '') { + $lines[] = 'Description: |'; + $description = str_replace(["\r\n", "\r"], "\n", $description); + foreach (explode("\n", $description) as $descLine) $lines[] = ' ' . rtrim($descLine); + } $captionFiles = $post['caption_files'] ?? []; $captions = $post['captions'] ?? []; if (is_array($captionFiles) && is_array($captions)) { @@ -113,8 +129,8 @@ try { write_data($dir, $_POST); save_uploads('media', $dir, $allowedMedia); save_uploads('audio', $dir, $allowedAudio); - $msg = 'Updated input directory: in-dir/' . basename($dir); - $_GET['edit'] = basename($dir); + header('Location: new.php?tab=edit&msg=' . rawurlencode('Updated input directory: in-dir/' . basename($dir))); + exit; } elseif ($action === 'delete_file') { $dir = safe_input_dir($config['uploads_dir'], $_POST['dir'] ?? ''); $file = basename((string)($_POST['file'] ?? ''));