...

View Full Version : PHP Coding Request- PHP Redirect with Timestamp



lifemisled
03-05-2008, 01:23 AM
I am brand new to the PHP world and a friend of mine did the majority of the legwork to get my website up and running. However, I have one final task and it's proving to be the more arduous for me because I don't know what I'm doing...

To break it down, I would like to have streaming media on my website without hosting it. I chose Flyupload as the host because it's compatible with a streaming divx player, so long as the file is in divx avi. Anyway, Flyupload links are encoded with Base64 time encryption. If the link gives a time that isn't recently, Flyupload denies direct access to that file and the link is then broken (and useless for streaming).

Someone on another forum found a way to work this out by redirecting the flyupload link using PHP to attach a current base64 timestamp to that link, to fool Flyupload into thinking it's a recent file. So long as the file stays recent, the file stays active.

My question to you guys is what is a simple PHP code I can use to produce a redirected link with a base64 encoded timestamp so I can link to media?

Before my friend left for vacation (and left me stuck with this problem), he did the following simple code just to test the idea:


<a href=http://www4.flyupload.com/dl?fid=5167274&t=<?php print base64_encode(time()); $url =$_GET['http://www4.flyupload.com/dl?fid=5167274']; ?>>Link</a>

What this did was produce a download link for a movie that stays constant because the time stamp stays current. So the proof of concept works and can be found here (http://www.lifemisled.com/Redirect.php).

I have found a site that does something similar to what I'm looking to do here (http://stage7.100webspace.net/)... Except I don't need a massive amount of media, just a few.

I am looking for the simplest solution to this problem. I know a lot of you guys are absolutely brilliant, so any help would be greatly appreciated. Also, I spend hours on end doing fruitless work, I will likely continue the trend until this one gets solved. Thank you for any and all assistance... I've been banging my head on the wall with this one.

Inigoesdr
03-05-2008, 01:28 AM
That seems to be working; what are you asking?

lifemisled
03-05-2008, 02:04 AM
The proof of concept download link is only a download link and not a stream-friendly link. If I were to use the very same link to stream media, it would fail ten minutes from now because it's not running through that PHP redirect, which attaches the current timestamp.

What I'm asking is if anyone knows how to PHP a link so that it redirects through a PHP page that will attach a timestamp before it connects to flyupload and how to link to it in a media player using the typical src=" ". Without a proper redirected link, they will all continue to die. I really don't know PHP at all, so I'm not very helpful.

If there's another way of doing it, I'm all ears. This is all I've been able to figure out so far...

Inigoesdr
03-05-2008, 02:29 AM
If you knew the id for the file(say if it were passed in the URL), and the specific server you redirect to doesn't matter, you could do something like this:


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=' . $fid . '&t=' . base64_encode(time()));
?>
You would point the user to yoursite.com/page.php?fid=5167274 and they should be redirected to the stream automatically.

lifemisled
03-05-2008, 02:42 AM
I feel like you're on to something. My friend was playing around with some very similar code before he took his flight out of here but he didn't get to finish it up. I tried using your code, exactly as you typed, same formatting as you posted, and I got the following error:


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/bobc25/public_html/fly.php on line 3

Anything I can do to make this code run without error?

...Thanks so much for the quick replies, you guys are fast...

_Aerospace_Eng_
03-05-2008, 02:44 AM
Post fly.php please. The code posted by Ini has no errors in it so it must be something in how you implemented the code.

lifemisled
03-05-2008, 03:09 AM
This is the PHP I copied and pasted...


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=986890' ' . $fid . '&t=' . base64_encode(time());
?>

Unless I missed something, I don't understand what's wrong with it. Would it be more feasible for someone to attach the PHP they know is correct and I'll upload it to the server, do it that way?

_Aerospace_Eng_
03-05-2008, 03:10 AM
You have too many quotes

dl?fid=986890' ' . $fid
Remove the first one.

lifemisled
03-05-2008, 03:13 AM
Now I've got the following error in its place:

"Parse error: syntax error, unexpected ';' in /home/bobc25/public_html/fly.php on line 3"

Thanks again for the quick replies... Much appreciated...

Using the following PHP:


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=986890 ' . $fid . '&t=' . base64_encode(time());
?>

_Aerospace_Eng_
03-05-2008, 03:20 AM
Missing a ) before the ;

<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=' . $fid . '&t=' . base64_encode(time()));
?>

Inigoesdr
03-05-2008, 03:26 AM
Missing a ) before the ;
Whoops. :p

lifemisled
03-05-2008, 04:00 AM
The PHP was parsed correctly this time and I have uploaded it. I am checking to see if the links work currently.

I appreciate all of your help and I will post back here with the results asap. Thanks again...

PS- Assuming this code works well, and I suspect it may, is there a way to reference multiple links in the same php, so I don't have to Fly1, Fly2, and so on?

lifemisled
03-05-2008, 04:06 AM
Alright, I have officially tried 5-6 different links using the PHP and it seems to be working. The real proof is how it holds up overnight but it's looking great. Thank you so much for helping me work this out because I've been going nuts trying to figure it out...

To close this mess up, if there's anyway to add multiple links in the same PHP, it would save me a TON of time.

Thank you for all the quick hits and knowledgeable answers. This place goes above and beyond what I anticipated when I first posted my query. Thank you guys so much.

_Aerospace_Eng_
03-05-2008, 04:22 AM
Not sure what you mean. Once you call the header it goes to the next site and stops parsing your php. Be more clear on what it is that you are trying to do.

lifemisled
03-05-2008, 04:35 AM
I am looking to post about 10-20 videos residing on Flyupload severs. Now that we've got a working redirect, I'm trying to figure out if it's possible to code the PHP so that I can reference all 10-20 links in the same PHP so that I don't have to use an individual PHP for every movie I want to stream. If it's not possible I'll get to work on a bunch of PHP's but I was hoping there was a simpler way...

I hope this makes a bit more sense... If it doesn't I'll be happy to try to clarify some more.

Inigoesdr
03-05-2008, 04:54 AM
Yeah, if you use the code that I posted originally, or the code Aero posted all you have to do is pass the fid in the url of fly.php. ie. fly.php?fid=12345

lifemisled
03-05-2008, 05:07 AM
I'm sorry if I appear to be thick but I'm not sure what you mean. I understand using the fid to link to a file but how do I add multiple files to the same fly.php we're working with. Linking them is the easy part, I'm just not sure how to insert multiple urls. I tried a couple of things, neither of which worked:


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=2930844, http://www4.flyupload.com/dl?fid=5530844 ' . $fid . '&t=' . base64_encode(time()));
?>

I tried that with and without the space after the comma.

I also tried:


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=2930844 ' . $fid . '&t=' . base64_encode(time()));
header('Location: http://www4.flyupload.com/dl?fid=5530844 ' . $fid . '&t=' . base64_encode(time()));
?>

No matter, the second link gets ignored but the first works. Is there a functional way?

...Sorry about the delayed response, I was refreshing the first page looking for a response not realizing there was a second page... Thanks again for quick responses.

lifemisled
03-05-2008, 05:52 AM
I really hope there's a way to do this because I just set up all the video pages on my blog as if they're referencing an fid on the fly.php, there are about 20 videos setup. If I need to create a different php for each video, I've got a bit of tedium ahead of me.

Any ideas before I go jumping into 20 phps?

Inigoesdr
03-05-2008, 06:34 AM
If you have this for your fly.php page:

<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=' . $fid . '&t=' . base64_encode(time()));
?>
You would link them like this:

<a href="http://www.yoursite.com/fly.php?fid=2930844">First</a>
<a href="http://www.yoursite.com/fly.php?fid=5530844">Second</a>

lifemisled
03-05-2008, 06:47 AM
Like I've said, I don't know much about this stuff but the php you referenced assumes that all files reside on the same www4. server and this isn't the case. Unless I'm wrong? I have the full urls of the files I need to stream but I have no way to reference them in the php, with respect to the servers at the very least...

So basically this works no problem:


<?php
$fid = intval($_GET['fid']);
header('Location: http://www4.flyupload.com/dl?fid=986890' ' . $fid . '&t= . base64_encode(time());
?>

I simply reference it using the command mentioned earlier "www.mysite.com/fly.php?fid=986890" and it plays/downloads without issue. If the php requires a full server url, is there a way to code it including the server?

I'm really hoping to do this without doing a 20 php's but I'll do what I have to in order to close this mess, it'll just take a lot longer than I was hoping it would, especially considering I did the client side work already.

Inigoesdr
03-05-2008, 07:11 AM
Like I've said, I don't know much about this stuff but the php you referenced assumes that all files reside on the same www4. server and this isn't the case. Unless I'm wrong?
Yeah, that's what I said before. If they are mirroring their content across all servers then it would work, and if they aren't you can use something like this:

<?php
$fid = intval($_GET['fid']);
$server = !empty($_GET['s']) ? intval($_GET['s']) : '';
header('Location: http://www' . $server . '.flyupload.com/dl?fid=' . $fid . '&t=' . base64_encode(time()));
?>
And simply add &s=4 to the end of the URL, where 4 is the server.

lifemisled
03-05-2008, 07:33 AM
It's either late or I'm simply not understanding this. I don't mean to drag this out, I feel like I should just be PMing you at this point. I want to be as clear as possible so that I can get the most from this experience.

So far I've only understood how to implement the one file with a reference in my embed code for the player on the site using the "/fly.php?fid=xxxxx" command. If I want to reference all of the files I want to stream from the same fly.php, I'm trying to figure out how it should look and I'm not understanding it.

For the sake of an example, to clarify for me, say we have two files. One file is http://www3.flyupload.com/dl?fid=00000 and the other is http://www18.flyupload.com/dl?fid=111111. How would the fly.php look to accommodate both files in the same page?

I keep looking at the codes and I'm sure they make sense, I don't think I'm understanding how to add those two links (or in my case the 20 links) to the same fly.php. If I have a php with an example of two in there, I'll recognize the pattern and the rest will be cake...

Sorry I've proven to be such a difficult solution. I don't get it, that's why I'm here.

Inigoesdr
03-05-2008, 09:17 AM
For the sake of an example, to clarify for me, say we have two files. One file is http://www3.flyupload.com/dl?fid=00000 and the other is http://www18.flyupload.com/dl?fid=111111. How would the fly.php look to accommodate both files in the same page?

You would link them like this, assuming you're using the code from the last post I made:

<a href="http://yourpage.com/fly.php?s=3&fid=00000">one</a>
<a href="http://yourpage.com/fly.php?s=18&fid=11111">two</a>

lifemisled
03-05-2008, 07:16 PM
I just woke up, so I'll be testing your post out right now. From the looks of it alone, it looks to be the solution I've been dying for. Thanks so much for all your help here and I'll report back shortly.

lifemisled
03-05-2008, 07:37 PM
That appears to have worked a charm. I seriously cannot thank you enough for all the suggestions and ideas that led to the end result. Everything seems to be in perfect working order and this should officially end hours of beating my head on the wall. Thank you. A lot.

imissstage6
03-15-2008, 06:51 AM
yeah you should probably remove the intval($_GET['fid']) part. when i wrote it i didnt realise it breaks with large integers.

[edit] also if you wanna be really clever implememt sockets to find the server ie www3 savethat to a db then when its requested again use the cached server name in the db rather than have the socket connect to flyupload everytime someone watches the vid. Who are you by the way myvideolinks? sfmstudios?


iMissStage6

mkdirect
04-22-2008, 02:23 AM
flyupload no longer uses base64 to encode the timestamp.

this is the different encoded timestamp within 3min time.


rfZQZD2uOOAvCvfNzhh1nQ..
rfZQZD2uOOASN4jodo7OIA..
rfZQZD2uOODnurJWfe99aQ..
rfZQZD2uOOD1aTh5nvZ5zw..
rfZQZD2uOOC-oWHFgtK9kA..
rfZQZD2uOOBUmzVgExlhvQ..
rfZQZD2uOOAVF0oKU8vCKQ..
rfZQZD2uOODuUQSDIo2eOg..
eZFAMkSjaktu0_ftmpI7gw..
eZFAMkSjaksAc7-u1mJoWw..
eZFAMkSjakupT4BEOgrTHg..
eZFAMkSjaku4SW6xvlGnfQ..
eZFAMkSjaktwivfYaUxyGg..
eZFAMkSjaku6cBFfHyRxHg..
eZFAMkSjakvrZM1fsA91_Q..
eZFAMkSjaktzukJdou8m0w..
eZFAMkSjaktRB1YW22Zekg..
KhKPk_wn0G_-R8aVVUNMyg..
KhKPk_wn0G9452-hzpG0qg..
KhKPk_wn0G_HZssEqzhxvg..
KhKPk_wn0G9ROxcI5FZdCQ..
KhKPk_wn0G_XJf2YOZWrtw..
KhKPk_wn0G-oXIOyets7Cw..
KhKPk_wn0G_WKxNXwMZ3Xg..
KhKPk_wn0G8wrf7nqw6wrg..
KhKPk_wn0G_jIKeSMZ1gUQ..
KhKPk_wn0G-2CQ0pbjrqiw..

Can anyone see their new encoding method?

Inigoesdr
04-22-2008, 05:21 AM
That's kind of vague. There's a repeating pattern, so something is static at least temporarily(oxymoron). Probably a mix of the file id and timestamp.

prometeus
04-25-2008, 10:53 PM
Hi Guys! I noticed you helped the other guy and were great at getting this working perfectly, great job!

Unfortunately they changed the timestamp method :(

The links before were like this:
http://www2.flyupload.com/dl?fid=2586954&t=MTIwOTE1NjI3Nw==

The links are now like this:
http://www2.flyupload.com/dl?fid=2586954&x=Bt87APz1cQMsjk9HcUOEbQ..

The below code was working perfectly using fly.php?fid=2586954&s=2
With the following php:
<?php
$fid = intval($_GET['fid']);
$server = !empty($_GET['s']) ? intval($_GET['s']) : '';
header('Location: http://www' . $server . '.flyupload.com/dl?fid=' . $fid . '&t=' . base64_encode(time()));
?>

The new timestamp lasts for 15 minutes before it is no good anymore based on my tests.

I'm sure one of the great coders here can fix this in no time :) Thank you in advance. Your help and excellent coding abilities are much appreciated.

prometeus
04-27-2008, 05:36 PM
So is this a no go or what guys?

Can you code it to work?

Inigoesdr
04-28-2008, 12:53 AM
Probably not. They have changed their methods to work a little smarter. Besides, they provide a service, and this is just to bypass their ads/etc. I probably shouldn't have helped before, but the answer was simple. It doesn't work anymore, so it doesn't matter.

prometeus
04-29-2008, 05:42 PM
This is not simply to bypass their ads. It's to allow streaming of their files which is a service that they do not provide to it's users.

Inigoesdr
04-29-2008, 06:08 PM
This is not simply to bypass their ads. It's to allow streaming of their files which is a service that they do not provide to it's users.
That doesn't make it any better. This thread is done.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum