0

I have a .flv file. This file needs to be hosted on our FTP server, and I need to make a php page that displays this video. This video should be visible for only one pageload. for example:

http://somepage.com/?id=akudps2

with this URL it will load the video, one time, the next time this page is loaded the video is not visible anymore as the link expires.

there can be multiple valid links active simultaneously. So for example I could send the same video withdifferent URLs to multiple users.

MUST:

  • it should not be possible to get the real filename of the flv file from the page's source code. the viewer should not be able to download the file.
  • this should all be done without the use of a database as we dont have one on this database. it can use textfiles tough.
user2452250
  • 777
  • 2
  • 11
  • 26

1 Answers1

1

For your first segment in the question, you can create your own management via files.

Write a new line to a file every time you create a "key" for this, for example...

<?php
file_put_contents("sessions.txt", "sjhGtwtha 0", FILE_APPEND);

The '0' here for this instance, means "not used".

Then you can do something like this:

<?php
function isUsed($key) {
    $keys = file_get_contents("sessions.txt");
    foreach (explode("\n", str_ireplace("\r", "", $keys)) as $line) {
        if (substr($line, 0, strlen($key)) == $key) {
            return substr($line, strlen($key) + 1, 1) == '1';
        }
    }
    return true; // ID is invalid, never been assigned at all
}

function updateFile($key) {
    $keys = file_get_contents("sessions.txt");
    foreach (explode("\n", str_ireplace("\r", "", $keys)) as &$line) {
        if (substr($line, 0, strlen($key)) == $key)
            $line = $key . ' 1';
    }
    file_put_contents("sessions.txt", implode("\n", $keys));
}

To decide whether it was used.

As for the second part, I'm not sure that's doable. You can try to obfuscate but eventually the browser needs to know what file is going to be played, so it will always at some point, be accessible via digging in the source.

casraf
  • 21,085
  • 9
  • 56
  • 91
  • thank you! would an alternative (maybe simpler??) to writing to a file be to create a new file and just see if it exists? for example i could create a file "oadkaop" and if it exists this session is valid and deletes the file, else its not.. code obfuscation via javascript is more then enough.. people looking at this are not programmers and are quite ignorant in this matter.. :) – user2452250 Feb 10 '14 at 18:03
  • That can work too, yeah! I was just making a suggestion that immediately popped to my head. Yes, that works too. You can use the content as the flag of viewed or not, or just place it in relevant directories, – casraf Feb 10 '14 at 19:38