viltube/video.php
2025-02-19 06:13:56 -05:00

55 lines
1.9 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<title>Viltube Video</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="styling.css">
</head>
<body>
<a href="index.php"><h1>Viltube</h1></a>
<small>This is where Vilyaem shares videos.</small>
<?php
// get the video file from the URL parameter
$video = $_GET['video'];
// validate the video file
if (strpos($video, 'videos/') === 0 && file_exists($video)) {
// Display the video in a video tag
echo '<h3>' . $video . '</h3>';
echo '<center>';
echo '<video width="640" height="480" controls>
<source src="' . $video . '" type="video/webm">
</video><br/>';
echo '<a href=" ' . $video .'">Download video</a>';
echo '</center>';
} else {
echo '<p>Invalid video file.</p>';
}
?>
<h2>More videos</h2>
<ul>
<?php
// display links to other random videos
for($i = 0; $i != 5; $i++){
$directory = 'videos/';
$files = glob($directory . '*.*');
$randomFile = array_rand($files);
$randomFilePath = $files[$randomFile];
$randomFileName = basename($randomFilePath);
echo '<hr><a href="video.php?video=videos/' . $randomFileName . '">' . $randomFileName . '</a><br>';
//if a webp thumbnail exists in the 'thumbs/' directory, serve it
$thumbnailFilePath = 'thumbs/' . pathinfo($randomFileName, PATHINFO_FILENAME) . '.webp';
if (file_exists($thumbnailFilePath)) {
echo '<a href="video.php?video=videos/' . $randomFileName . '"><img width=160 height=120 src="' . $thumbnailFilePath . '" alt="Thumbnail" loop="true"></a><br>';
}
}
?>
</ul>
<center>
<small>Viltube, a video sharing system created by <a href="https://vilyaem.xyz">Vilyaem Kenyaz</a>, Viltube is free and open source software licensed under the CFSL<br>Donate Monero (XMR): 48Sxa8J6518gqp4WeGtQ4rLe6SctPrEnnCqm6v6ydjLwRPi9Uh9gvVuUsU2AEDw75meTHCNY8KfU6Txysom4Bn5qPKMJ75w</small>
</center>
</body>
</html>