=h(pathinfo($name,PATHINFO_FILENAME))?>
=h(date('Y-m-d H:i',filemtime($v)))?> ยท =h(round($size/1048576,1))?> MB
Downloaddiff --git a/index.php b/index.php index ee9e987..d1a7860 100644 --- a/index.php +++ b/index.php @@ -2,53 +2,14 @@ $config = require __DIR__ . "/config.php"; foreach (["videos_dir", "thumbs_dir", "uploads_dir"] as $d) if (!is_dir($config[$d])) mkdir($config[$d], 0775, true); function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, "UTF-8"); } -function slugify($s){ $s = strtolower(trim($s)); $s = preg_replace('/[^a-z0-9]+/', '-', $s); return trim($s, '-') ?: 'movie'; } -function rrmdir($dir){ if(!is_dir($dir)) return; foreach(scandir($dir) as $f){ if($f==='.'||$f==='..') continue; $p="$dir/$f"; is_dir($p)?rrmdir($p):unlink($p);} rmdir($dir); } -function save_uploads($field, $dest, $allowed){ - if (empty($_FILES[$field])) return []; - $files = $_FILES[$field]; $saved = []; - $count = is_array($files['name']) ? count($files['name']) : 0; - for ($i=0; $i<$count; $i++) { - if ($files['error'][$i] === UPLOAD_ERR_NO_FILE) continue; - if ($files['error'][$i] !== UPLOAD_ERR_OK) throw new RuntimeException("Upload failed: ".$files['name'][$i]); - $ext = strtolower(pathinfo($files['name'][$i], PATHINFO_EXTENSION)); - if (!in_array($ext, $allowed, true)) throw new RuntimeException("File type not allowed: ".$files['name'][$i]); - $base = preg_replace('/[^A-Za-z0-9._-]+/', '_', basename($files['name'][$i])); - $target = $dest . '/' . sprintf('%03d_', count($saved)+1) . $base; - if (!move_uploaded_file($files['tmp_name'][$i], $target)) throw new RuntimeException("Cannot save upload"); - $saved[] = basename($target); - } - return $saved; -} -$msg = $err = null; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - try { - $title = trim($_POST['title'] ?? ''); - if ($title === '') throw new RuntimeException('Title is required.'); - $slug = date('Ymd_His') . '_' . slugify($title); - $dir = $config['uploads_dir'] . '/' . $slug; - if (!mkdir($dir, 0775, true)) throw new RuntimeException('Cannot create input directory.'); - $media = save_uploads('media', $dir, ['jpg','jpeg','png','webp','gif','mp4','mov','m4v','avi','mkv','webm']); - if (!$media) { rrmdir($dir); throw new RuntimeException('Upload at least one image or video.'); } - save_uploads('audio', $dir, ['mp3','wav','m4a','aac','ogg','flac']); - $lines = []; - foreach (['title'=>'Title','date'=>'Date','place'=>'Place','description'=>'Description'] as $k=>$label) { - $v = trim($_POST[$k] ?? ''); if ($v !== '') $lines[] = "$label: $v"; - } - file_put_contents($dir . '/data.txt', implode("\n", $lines) . "\n"); - $msg = "Created movmaker input directory: uploads/$slug"; - } catch (Throwable $e) { $err = $e->getMessage(); } -} $videos = glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: []; usort($videos, fn($a,$b)=>filemtime($b)<=>filemtime($a)); $page=max(1,(int)($_GET['page']??1)); $per=$config['items_per_page']; $total=count($videos); $pages=max(1,(int)ceil($total/$per)); $page=min($page,$pages); $slice=array_slice($videos,($page-1)*$per,$per); ?>
No videos yet. Put generated movies in videos/.
=h(date('Y-m-d H:i',filemtime($v)))?> ยท =h(round($size/1048576,1))?> MB
Download