13 Replies - 445 Views - Last Post: 17 October 2019 - 04:46 PM Rate Topic: -----

#1 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Help with hash md5 for fake video path/url

Posted 16 October 2019 - 10:34 AM

I am trying to modify a video web script and have been looking at a hash Md5 solution where the hashed md5 solution would replace the url/path with a fake url/path that would disappear when the user session is over, and the next time that video is played a new fake url/path will be displayed. If I have that correct, I believe that would help if a logged-in User shared the url/path/link (or someone attempted to hot link the url/path), it would be fail once the User logged-out.

I attempted to test this. I've added this code to .htaccess file:

RewriteCond %{REQUEST_URI} .(mp4)$ [NC] 
RewriteRule ^ validate.php?request_url=%{REQUEST_URI} [L]



and then placed this php file, named validate.php in the root directory:

<?php $v = $_GET['video'] ?? null;
if(file_exists($v)) { unlink($v); header('Content-type: application/mp4'); header('Content-Disposition: inline; filename=video.mp4');
readfile("./mytestvideo.mp4");
} else http_response_code(404);



and then proceeded with a video transaction, which resulted in preventing the video from playing.
And when I commented out the .htaccess lines, the video plays as normal, and still see the unmasked url/path to the video,
instead of this type of url/path:

http://......com?validate.php?video=40f677a45113eb829e345d278b8d1d31

as I was hoping for.

I'm sure I must have something incomplete.

Any guidance that you'd like to share will be much appreciated.

This post has been edited by chrisjchrisj: 16 October 2019 - 10:35 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Help with hash md5 for fake video path/url

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15497
  • View blog
  • Posts: 62,060
  • Joined: 12-June 08

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 10:41 AM

Have you considered a rarely collision causing alternative like 'GUIDs'?
https://www.php.net/...create-guid.php
Was This Post Helpful? 0
  • +
  • -

#3 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 10:48 AM

Thanks for your reply and suggestion.
Can you give me an explanation, it is beyond my skill comprehension, how I might apply it to my situation, example maybe?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15497
  • View blog
  • Posts: 62,060
  • Joined: 12-June 08

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 10:52 AM

Why make a fake path with MD5 on what ever you are attempting when you can generate your path with a GUID. It's unique on generate, rarely collides, and would fit the bill. Generate them until the cows come home and you'll not hit a duplicate, and coupled with 'expiring' links by session then bada bing, bada boom.
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3070
  • View blog
  • Posts: 11,779
  • Joined: 03-December 12

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 10:54 AM

A file retrieval process is probably what you want.

The initial file you go to does the checks, if they pass it displays the video.

So, letís say a url is shared, if the person isnít logged in, it doesnít pass the checks and doesnít retrieve the video.
Was This Post Helpful? 0
  • +
  • -

#6 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:01 AM

Thanks for the replies.
The file retrieval sounds simpler.
Can you please provide a code example or some type of additional guidance on what that might look like?
Any assistance is appreciated
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15497
  • View blog
  • Posts: 62,060
  • Joined: 12-June 08

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:03 AM

Careful walking that line of asking someone to do the work for you before you even thought it out or attempted it.
Was This Post Helpful? 0
  • +
  • -

#8 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:06 AM

Thanks for the replies.
The file retrieval sounds simpler.
But, if a logged-in user copies the url and logs in later he can see that video again.
That doesn't seem like it would work for this pay to play scenario. So, maybe the url needs to be replaced each time.

Regarding GUID, can you please provide any code example that might pertain to my situation, as something I can see, guidance/direction?

any additional assistance is appreciated

This post has been edited by chrisjchrisj: 16 October 2019 - 11:07 AM

Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15497
  • View blog
  • Posts: 62,060
  • Joined: 12-June 08

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:09 AM

I'm not going to do your work for you before you even attempted it. That's not how this forum rolls. With a hundred posts, and eight months of dragging this project around, I would have hoped you realized that. :hmmm:
Was This Post Helpful? 0
  • +
  • -

#10 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:11 AM

Thanks for your reply.
Just looking for help getting started, not looking for anyone to do my work for me...
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15497
  • View blog
  • Posts: 62,060
  • Joined: 12-June 08

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 11:14 AM

Come on.. asking folk, before you even attempt it, to walk you through an example of how it is done is still getting someone to do it for you. :eh:

For anyone future helping - here's links to what the OP has already been helped with.
https://www.sitepoin...a-url/341056/20
https://www.webdevel...essed-via-url/6
Was This Post Helpful? 0
  • +
  • -

#12 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2494
  • View blog
  • Posts: 7,551
  • Joined: 15-January 14

Re: Help with hash md5 for fake video path/url

Posted 16 October 2019 - 04:49 PM

Are you saying that one of the requirements is that a logged-in user should only be allowed to download the video once?

So what happens with your original code, if you go to that validate.php page it shows a 404 instead of the video? Something else? Are you using your browser's developer tools to look at the request and response?
Was This Post Helpful? 0
  • +
  • -

#13 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 04-February 19

Re: Help with hash md5 for fake video path/url

Posted 17 October 2019 - 11:15 AM

View PostArtificialSoldier, on 16 October 2019 - 04:49 PM, said:

Are you saying that one of the requirements is that a logged-in user should only be allowed to download the video once?

So what happens with your original code, if you go to that validate.php page it shows a 404 instead of the video? Something else? Are you using your browser's developer tools to look at the request and response?


Much thanks for your message.
yes, you can play & replay, but once you log out you'd have to log-in again and pay to view again (unless you copy the url/path).

Also, regarding "what happens..." when the .htaccess code and validate.php are added, nothing changes, the file plays as normal and the video path/url is viewable in F12 view still.

Any suggestions are appreciated.
Was This Post Helpful? 0
  • +
  • -

#14 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2494
  • View blog
  • Posts: 7,551
  • Joined: 15-January 14

Re: Help with hash md5 for fake video path/url

Posted 17 October 2019 - 04:46 PM

Quote

you can play & replay

Not unless they save the video or the browser caches it, you delete the validation after the first time it's downloaded. If the browser doesn't cache it then trying to download it again won't work.

The file plays as normal? What about this:

Quote

and then proceeded with a video transaction, which resulted in preventing the video from playing.

Does everything work, or not? If not, what specifically happens? Saying it's not playing isn't enough.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1