serve files from PHP
Posted by arcangel95 (arcangel95), 21 April 2006before nothing sorry for my english, i ll do my best.
I ve this problem, i m working on an e-learning page, in some point i`ve to serve the current loged user of some content, (pdf, flash movies, etc)...
Thats the problem, I need that the path of this resources remains hidden, so a user cant share this with noone else...
I've found tons of scrpts that can be used to download a .pdf or something like that, but I can't download de flash files becouse they have relatives paths to other files.
I need this flash files be accesed (no downloaded) but without showing the complete path of the file in the browser...
I hope someone could help me .... thanks from Argentina..
Posted by admin (Graham Ellis), 21 April 2006Hello, welcome.
I don't think you're going to be able to hide the links within the page, but you could use a PHP script to serve out the flash and only have it served if the user has a cookie set. That way, even if a user gives the URL to a friend, the friend won;t be able to download it.
It's late at night here in England. If that idea looks good and you would like me to write some more about it and perhaps an example, please let me know.
Posted by arcangel95 (arcangel95), 21 April 2006Hi, thanks for the reply.
The problem is that I dont want the flash to be downloaded, i need it to be accessed like a web resource, because inside it, it has relative paths to another files...
If I put the complete path in the browser it works fine... becouse it doesnt download, (but I show the complete path)
If you have another idea I would be very greatfull cause im a bit desperate by now..
Posted by admin (Graham Ellis), 22 April 2006I'm not a flash expert ... so I may be wrong, but I understand that your flash is going to run dynamically in the browser and so it has to be downloaded. If you write flash then try to run flash without downloading it, it's rather like buying fuel for your car but not putting it in the tank and hoping it will work.
If it has paths to pull in other files, isn't it designed to pull them in anyway just like relative images and style sheets are pulling in to normal HTML? If you have file: type URLs, you will need to change those to http: types.
And from a security / protection viewpoint, the PHP wrapper I suggested in my previous post can be used to check via cookies or hidden fields / logins / referer strings etc to prevent the file(s) being served if they're not requested in the correct context.
Posted by arcangel95 (arcangel95), 22 April 2006I dont know if this flash are well designed, (I didnt made them) cause they are componed like this:
* An html file with various links pointing to a php file wich launch various .flv (flash video) depending on the link
I think this is for not to download the complete videos, only the one you want to see.
Im not an expert in this fields, Im a beginner....
But this problem is driving me crazy
I think I cant point to this .html directly whit header('location: '... )
because in the URL it will appear the URL in wich I have all my contents and people will could access directly to them
If I serve this .html file with a .php script whit
this html cant file the relative paths to images or the flash movies, I think this is because this file is download with fread($file).... Its not accessed like a web page resource from Apache,
Iv found a lot of examples with fread or something like that for downloading .pdfs, but I think thats not useful to me
The question would be.... how i serve a page (an html page) from a Php.... without using Header(location....
with something like fread
but.... the Html file dont loosses the references to images etc...
Iv you have a clue I woud be very gratefull...
Posted by admin (Graham Ellis), 24 April 2006You have three options that I can see
- you can write some code to rewrite the paths within the .pdf (don't know how easy that would be)
- you can download from the directory that is supposed to contain the flash file that makes the relative calls in the first place, via a PHP script of a different name
- you could replace the top level file be a piece of PHP, set your .htaccess file to know that it's PHP, and proceed that way
The second and third options will give you the ability to check the user's environment before you send him the flash - allowing you to send out a different ("where did you get this") movie if you feel that it's a download attempt.
Posted by arcangel95 (arcangel95), 26 April 2006I think Iv found the solution althougt Iv not implemented it fully yet, Its something like this
Ill have an unique PHP for access to files and it will be something like this
I build this URL and call it with header(location...
what happend next is that the file.PHP executes and inside it it will show the content of any file with fread or something like that.
this way, althought I dont understand well why but the file.php executes shows the content and all the links on the page replace for something like the above URL (I think i would be Apache)
the only dificult thing is that the PHP file has to recover from somewhere (a global maybe) the file that is going to be read...
Iv found an implementation of something like this, but more complex in the moodle proyect
It was hard to understand how it works and why, so if someone can help me to understand I would be gratefull... but I think here is the solution
Posted by admin (Graham Ellis), 26 April 2006If you're saying that you're importing the relative files within the original Flash document then, yes, that seems viable. I'm not a flash expert so I don't know what other extra issues you may find.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho