53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Viltube</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>Vilyaem's video sharing system.</small>
|
|
<?php
|
|
/*get a list of video files from the 'videos/' directory*/
|
|
$videoFiles = glob("videos/*.webm");
|
|
|
|
/*get a random video from the list*/
|
|
$randomVideo = $videoFiles[array_rand($videoFiles)];
|
|
|
|
/*display the random video in a video tag*/
|
|
echo '<h2>Featured video</h2>';
|
|
echo '<h3>' . basename($randomVideo) . '</h3>';
|
|
echo '<center>';
|
|
echo '<video width="640" height="480" controls>
|
|
<source src="' . $randomVideo . '" type="video/webm">
|
|
</video>';
|
|
echo '</center>';
|
|
?>
|
|
<h2>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 public domain<br>Donate Monero (XMR): 48Sxa8J6518gqp4WeGtQ4rLe6SctPrEnnCqm6v6ydjLwRPi9Uh9gvVuUsU2AEDw75meTHCNY8KfU6Txysom4Bn5qPKMJ75w</small>
|
|
</center>
|
|
</body>
|
|
</html>
|