I have multiple HTML video tags with source URLs as follows in my PHP file :
<video class="d-block video-js vjs-default-skin col-video" width="100%" controls:false;>
<source src="<?php echo $videoPath; ?>" type='video/mp4'>
</video>
As loaded by the client, the source attribute looks like this on a web-browser :
<source src="./Username/videos/001_video.mp4" type='video/mp4'>
{...}
<source src="./Username/videos/002_video.mp4" type='video/mp4'>
{...}
My problem is that I don't want the client to be able to view other user's video by changing the URL on the source attribute of the video tags.
This seems to be called "user restricted content/ressources" (not sure as I am a C/C++ dev.).
I'm not using any framework, pure PHP, on L.A.M.P. (Apache2) web server.
I know this was made 10 years ago and that there are a lot of newer solutions by using frameworks or other languages like NodeJS, but I have no possibility of changing the architecture of the website, for the moment (but it will be reviewed in the future).
This either can be done server-side on Apache configuration (if it can ?), or either on HTML/PHP web-side.
What I saw on the web before asking is a solution like this one (https://www.sitepoint.com/community/t/hide-video-url/225822/7), that I tried :
<source src="video.php?show_the_video=VIDEO_ID/NAME_ENCRYPTED" type='video/mp4'>
And have, in video.php, something like this :
if (($_SERVER['REQUEST_METHOD'] === "GET") && ( isset($_GET['show_the_video']) )) {
$uncryptedPath = decrypt($_GET['show_the_video']);
$ctype = 'video/mp4';
header('Content-Type: ' . $ctype);
$file_path_name = $uncryptedPath;
$handle = fopen($file_path_name, "rb");
$contents = fread($handle, filesize($file_path_name));
fclose($handle);
echo $contents;
} else {
echo "";
}
But it seems not to work quite well for me (maybe as I have a lot a lot of video tags on the same page). It worked partially but was so slow to load the page... It is not acceptable for me. It took forever to load the page with about 20 video tags.
Can anybody help me by routing me or proposing solutions ?