1

Depending on the "id" in the video source I want to load different video files via php. For example if the source in the video tag is "/get.php?id= 1" load, http://example.com/movie1.mp4 and "/get.php?id= 2" load, http://example.com/movie2.mp4 and so on. Basically I want the php file to act as a "link" to the video files, how would you do this?

<html> 
<body> 
<video width="400" controls>
<source src="/get.php?id=1" type="video/mp4">
</video>
</body> 
</html>

The get.php file so far:

<?php
$id = ($_GET["id"]);
if ($id = 1) {
//load movie1.
}
?>
Maninderpreet Singh
  • 2,569
  • 2
  • 17
  • 31
S. Doe
  • 67
  • 6
  • Is linking to the video directly from the html file not an option? Does it have to go through get.php? – PSZ_Code Mar 19 '16 at 12:15
  • Yeah it needs to go through get.php, I'm also adding a string to the url (like: get.php?id=1&k=5115) and the server validates the string and then it should load the video file. The string updates every time someone access it, only a temporary link, to add some sort of security. – S. Doe Mar 19 '16 at 12:25
  • And how is the video id chosen in the html file, also by a get_parameter? – PSZ_Code Mar 19 '16 at 12:41
  • The Video id is chosen by a string query in the url. Currently setup like http://domain.com/watch/?id=1. The query is then with help of javascript added to the video source so it becomes "get.php/?id=1". – S. Doe Mar 19 '16 at 14:44
  • and you append an extra string as security. What do you do with it? Is it ok if it is processed on the html page? – PSZ_Code Mar 19 '16 at 14:50
  • Check this page under "Temporary resource urls" thats pretty much what im after. The get.php page basically checks if the added string matches the one saved and then allows the video to be played. Then it resets the string so the url cant be used again. http://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved – S. Doe Mar 19 '16 at 14:59
  • Is it ok if this processing is done on the html page itself? – PSZ_Code Mar 19 '16 at 15:04
  • What part of the processing? The only part i want to avoid is to have the "real" video url on the html page – S. Doe Mar 19 '16 at 15:12
  • I deleted my answer because I though you wanted to do something else. I do not think it is possible to obfuscate the urls to your video – PSZ_Code Mar 19 '16 at 15:52
  • Okay. Did you have a look at the link I commented? Its exactly what i want to do, just not sure how to do it – S. Doe Mar 19 '16 at 15:55
  • How about this: If someone clicks the video watch page, they arrive on a php-page "create-token.php", this saves a token to the databases and redirects to a page with ?sid=..... parameter. There you check if the token was stored and if so, load the video and delete the token as I posted earlier. If not, do not load the video. This way the video can only be watched when following the link ( I think) – PSZ_Code Mar 20 '16 at 13:17

0 Answers0