Page 1 of 1
Is this IP Downloading or not (How Does Rapidshare works)
Posted: Fri Mar 02, 2007 12:19 pm
by nwp
How does Rapidshare Works
How can I know wheather This IP is downloading from my site or not
Posted: Fri Mar 02, 2007 12:27 pm
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?
Posted: Fri Mar 02, 2007 12:31 pm
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)
Posted: Fri Mar 02, 2007 12:39 pm
by impulse()
Have you got shell access to the server?
Posted: Fri Mar 02, 2007 12:43 pm
by nwp
I wanna do it in my own PC (localhost) as a roor user So i have shell access
Posted: Sat Mar 03, 2007 12:28 pm
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.
Posted: Sat Mar 03, 2007 12:32 pm
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 ??
Posted: Sat Mar 03, 2007 12:36 pm
by feyd
The script serving the download can note when it finishes.
Posted: Sat Mar 03, 2007 12:41 pm
by nwp
feyd wrote:The script serving the download can note when it finishes.
Sorry I didn't Understand How it will Know
Posted: Sat Mar 03, 2007 12:48 pm
by feyd
Do you have a script sending the file to the requesting user? If so, post it.
Posted: Sat Mar 03, 2007 12:51 pm
by nwp
No The Files (exe/zip/rar) are Directly Downloaded No Script Handles It
Posted: Sat Mar 03, 2007 12:52 pm
by feyd
Without a script handling the download there's no real way to tell.. including the Apache logs.
Posted: Sat Mar 03, 2007 12:56 pm
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
Posted: Sat Mar 03, 2007 12:59 pm
by feyd
Have you found the function
readfile()?
Posted: Sat Mar 03, 2007 10:39 pm
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));