|
|
|
|
![]() ![]() |
Jun 17 2006, 07:45 PM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 22 Joined: 17-June 06 From: Nebuchadnezzar, dock 6, Zion Member No.: 25,271 |
Well, i had the idea of logging the downloads from my web in a html file few weeks ago, and i solved it with a lil php page included in my homepage. You could name the links with a name like "download.php?file=filename.ext" and then, in the download.php put the next code:
(well you put the html and head and body tags if u want, i only write the php here) CODE <? if (isset($_GET['file'])) $file=$_GET['file']; //so it gets the GET data from url (file=filename.ext); $ip=$_SERVER['REMOTE_ADDRESS']; $file=fopen('download_log.html','a'); $date=date('d-m-y H:i:s'); $text="<br><hr><p>".$file.", ".$ip." on date ".$date; fputs($file,$text); /* At that point, the download try is logged, so if he doesn't proceed the download, will be logged anyway */ /* if you want to be secure and avoid the ppl downloading what they dont have to do, you could add every file name to a MySQL DB and add an ID, so you were only to need to put in your links the id like "download.php?id=257", but thats a bit long to explain, so i continue with the simple explanation */ echo "You're going to download the file <b>".$file."</b>. If you want to proceed, click <a href='".$file"' target='_blank'><b>here</b></a>"; ?> Obviously you can improve that code much more, but that simple thing should work only by being at the same folder of the files to download. |
|
|
|
Jun 20 2006, 09:30 PM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 398 Joined: 9-June 06 From: Wisconsin Member No.: 24,924 |
That looks really useful I will have to write something like that for my site.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 23rd November 2008 - 12:51 AM |