Jump to content
xisto Community
Sign in to follow this  
NeOniX

Logging Dowload Files From Your Server Onto A Html File

Recommended Posts

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)

<?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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.