TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,022
  • Total Topics: 21,332
  • Online today: 725
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 209
  • Total: 209

Need help on how to use this code in a php article !

Started by knat, August 12, 2007, 12:27:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knat

Hey all

Can anybody help me on how to use this code in a php article. I can get it to work no problem but i dont know how to add linebreaks, so i could use some help  :)

Here is the code:

$premiumaccount = 12345;     // Insert your premium ID here
$fileid = 12345678;          // Insert the file ID here
$filename = "yourfile.zip";  // The filename of the file
$killcode = 123456;          // The killcode of the file. Can be found out via "Export+MD5" in your premium zone.
$validuntil = time() + 300;  // Valid for 300 seconds from now on
$md5hex = md5($premiumaccount.",".$fileid.",".$killcode.",".$validuntil);

print 
"Secured link is http://rapidshare.com/files/$fileid/t$validuntil-$md5hex/$filename";


I use this code several times in a row to display multiple links but all the links are printed out on the same line and they are not clickable.. so thats the problems i have... if you wonder what this code is i can tell you that it is a new service offered by Rapidshare where you can allow your users to download files even if they dont have a rapidshare account. You pay for their downloads. But to prevent users from steal your links and post them on other sites you can use this script to create links that are only valid for 300 seconds (or whatever amount of seconds that you choose).

So can anybody help me with the two problems.. addin linebreaks between the links, and making the links clickable ?  :)

Maybe they would be clickable if they wasnt on the same line ??

jacortina

#1
Try 'echo'ing it and including the proper html:

echo 'Secured link is <a href="http://rapidshare.com/files/', $fileid, '/t', $validuntil, '-', $md5hex, '/', $filename, '">Link</a><br />';

[the "br /"  will insert the line break]

When you send something to a client browser, you're almost always going to want it to be proper HTML.

knat

Thanks it seems that what you show me is working fine.. but i just found out that the links dont work at all.. even thou the script generates a new link each time i refresh the page, Rapidshare keeps telling me this: This is a secured direct download. The download link has been modified.

Maybe my servers time() is the problem ??

the also have the script example shown in Perl

#!/usr/bin/perl

use strict;
use warnings;
use Digest::MD5("md5_hex");

my $premiumaccount = 12345;    # Insert your premium ID here
my $fileid = 12345678;         # Insert the file ID here
my $filename = "yourfile.zip"; # The filename of the file
my $killcode = 123456;         # The killcode of the file. Can be found out via "Export+MD5" in your premium zone.
my $validuntil = time + 300;   # Valid for 300 seconds from now on
my $md5hex = md5_hex("$premiumaccount,$fileid,$killcode,$validuntil");

print "Secured link is http://rapidshare.com/files/$fileid/t$validuntil-$md5hex/$filename";


Edit: i try to change the seconds to 30000 to see if it was maybe the time that was wrong but it changed nothing !

knat

I will try to contact rapidshare support and ask them what the problem is.. thanks for helping me out with the problems i have.. i understand that my new problem is not TP related and should be solved otherwise.. Thanks alot, this is not the first time you come to my rescue ;-)

knat

So this is the reply i get from Rapidshare

QuoteHello,

You should make longer durability then 300 sec. When do you start the link? We
have GMT+1. Please check your clock.


Best regards,

RapidShare AG - Support Team

So dos anybody know how to check what the time is on a server ??

And what i dont understand is that time() is (according to my invastigations) = 1. january 1970

I also have a problem with the date in my paidsubscriptions mod because of the time()

Anybody know how to find out how the time() is behaving on a server ??

This is TP related since it is something i would love to get to work in a php article.. and i think others would like this to so they can provide direct downloads to their users in a cheap way  :)

Edit: BTW if any of you coders have a rapidshare premium account you can test this code because all accounts come with 10Gb free traffic for the users to try out !

jacortina

Try to put the code below (on its own) in a phpbox block (shown to Admin only) and see what output it generates:

$localtime = localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);

knat

I already tried output the time and i found that my servers time is the same time as Rapidshares server.

I just can not get the links to work... if i make the valid second less than zero i get "link is no longer valid" if i make it above zero (300 is default) then i get "link has been modified"..

So no matter what i do it dont work, and rapidshare support say they dont know why and they cant help me with such a complex thing... pretty strange because this is what the write below the code on their example page:

QuoteAttention: This method must not be used in JavaScript (for example). We generate a MD5-hash based on some secret values including a time stamp. Since a hacker does not know the secret data, he can not create "hacked" download links, which are valid for 3 years for example. The main secret is the killcode of your file, but also the premium login should not be published. In case you need help implementing the method, you can contact our support.

and this is what thay write to me:

QuoteHello,

We are sorry but we can not support you in this case. The scripting support is
to complex and we don`t offer it.

Maybe you should search some help in internet or maybe some of your friends
can help you.

Thank you for understanding.


Best regards,

RapidShare AG - Support Team

your code output this result


Array ( [0] => 51 [1] => 18 [2] => 7 [3] => 17 [4] => 7 [5] => 107 [6] => 5 [7] => 228 [8] => 1 ) 
Array ( [
tm_sec] => 51 [tm_min] => 18 [tm_hour] => 7 [tm_mday] => 17 [tm_mon] => 7 [tm_year] => 107 [tm_wday] => 5 [tm_yday] => 228 [tm_isdst] => 1 )


If i give you a new rapidshare account, would you want to try this out yourself ?? Every new rapidshare account comes with 10 Gb of free direct downloads for new users to try out so you could help me investigate how to make this work..  ::)

This website is proudly hosted on Crocweb Cloud Website Hosting.