Is this IP Downloading or not (How Does Rapidshare works)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Is this IP Downloading or not (How Does Rapidshare works)

Post by nwp »

How does Rapidshare Works
How can I know wheather This IP is downloading from my site or not
Last edited by nwp on Sat Mar 03, 2007 12:33 pm, edited 2 times in total.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

What do you mean by downloading?

And by this IP do you mean a specific IP or the IP of the forums or what?
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

Begby wrote:What do you mean by downloading?
And by this IP do you mean a specific IP or the IP of the forums or what?
By this IP I mean My Visitor's IP . I wanna Know Is This Visitor currently downloading or not(Like rapidshared.org)
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Have you got shell access to the server?
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

I wanna do it in my own PC (localhost) as a roor user So i have shell access
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

You Can't Do It Just With PHP OnlyApache Writes Log Messages On apache/logs/access.log When User/Visitors asks For A Files To Download.
Suppose Your Visitor Is Asking for a File Names Photo_Album.zip on your root Folder(http://localhost/Photo_Album.zip) with Filesize 4774381 Bites A Log Messege Like This
access.log wrote:127.0.0.1 - - [03/Mar/2007:23:46:33 +0530] "GET /Photo_Album.zip HTTP/1.1" 200 4774381
will get written By Apache Itself.
You Can Use fopen() , fread To Read The Log File also Use Can Use Shell Scripting To Read The Log File. And The Visitor's IP Is also written There.
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

Thanks Man My Problem Got an answer at last.
My Problem Is Almost Solved.
But How Can I Know Is The Visitor Still Downloading It Or Not ??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The script serving the download can note when it finishes.
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

feyd wrote:The script serving the download can note when it finishes.
Sorry I didn't Understand How it will Know
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you have a script sending the file to the requesting user? If so, post it.
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

No The Files (exe/zip/rar) are Directly Downloaded No Script Handles It
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Without a script handling the download there's no real way to tell.. including the Apache logs.
nwp
Forum Contributor
Posts: 105
Joined: Sun Feb 04, 2007 12:25 pm

Post by nwp »

Ok So If I use a Script to handls it
How Would It Handle downloads.
How the script Will get Written Whats The Algorithm .
Please Explain
Last edited by nwp on Sat Mar 03, 2007 12:59 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you found the function readfile()?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

This Is How You can do something like rapidshare
-----------------------------------------------------------------
1.The User Requests For A File To download.php (POST/SESSION)
2.IF Request is not valid (invalid session or any error like 404 or 500) Send a Header

Code: Select all

header("Content-Type: text/html");
And Then Write Your php Code
IF Request Is Valid Send a Header

Code: Select all

header ("Content-Type: application/force-download; name=\"$filename\"");
As I use Opera Browser I Prefer

Code: Select all

header('Content-Type: application/octet-stream');
and then stream the files Using readfile().
3.But Just Before Starting Download Do Step 5 and if Passed log the visitor's IP Download Time and etc....
to a DB or csv Or log. then Start Downloading if Not passed Request Is not Valid
4.Remove that line from log after finishing the download (after compleating readfile())
5..And Now When the User Requests For another file Check from the log wheather that Visitors IP is Logged Or Not If Logged The request Not Valid return to Step1 else valid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Safe Way Is to Keep The Files On a FTP Server (With Username and Password) and Pull The Files With readfile().
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
But Remember :

Code: Select all

readfile("ftp://" . "User_name" . ":" . "password" . "@domain.com/file.zip");
May not Work Properly So You should use

Code: Select all

readfile(ftp_get($conn, $local_file, $server_file, FTP_BINARY));
Post Reply