Jump to content

Recommended Posts

Is it possible to keep track of users that have clicked on the link?

<?php

echo "<a href=\"http://site.com/downloads/$_GET[f]\" target=\"_blank\">Click Here to start downloading</a>";

echo "Please do NOT close this page until your file starts downloading!";
echo "\n";
$url = "refresh:5; url=http://youarelazytoclick.com";
header($url)
?>

I want to heve logs of user IP, date and $_GET,

For example like this one:

03.13.2015 9:57am  41.36.xxx.xxx  awp.rar
03.13.2015 10:00am  223.207.xxx.xxx  file.rar
03.13.2015 11:44am  202.142.xxx.xxx  example.rar
03.13.2015 12:05pm  82.122.xxx.xxx  winter_v1.rar
03.13.2015 12:07pm  176.26.xxx.xxx  ausscatter.rar
03.13.2015 12:12pm  109.95.xxx.xxx nailgun.rar
03.13.2015 12:33pm  46.63.xxx.xxx  lol.rar
03.13.2015 12:51pm  71.104.xxx.xxx  kingdom.zip
03.13.2015 1:10pm  92.16.xxx.xxx  thunderstorm.rar

Setup:

 

Users will click on site1.com/download/download.zip

 

will be redirected to site2.com/waitfile.php?f=site1.com/download/download.zip (.htaccess) where information will be displayed (I want logs of this page)

 

In waitfile.php will be a CLICK HERE button and users will be redirected to site3.com/download/download.zip where download will start.

 

 

Link to comment
https://forums.phpfreaks.com/topic/295209-logs-of-users-that-clicked-on-link/
Share on other sites

Server access logs generally are in a file. But whatever.

 

Make waitfile.php write to a log itself. Build a string with the information you want, like

$line = date("m.d.Y h:ia ") . $_SERVER["REMOTE_ADDR"] . $filename;
then write to the file with file_put_contents with the append flag. Make sure you don't take the $filename blindly from $_GET - you should make sure it looks valid (like http://site1.com/download/) before writing it to a file. Edited by requinix

Here is the code I found

define('LOG_FILE','wait.log');

define('LOG_DOWNLOADS',true);




$fname = basename($_GET['f']);




if (!LOG_DOWNLOADS) die();


$f = @fopen(LOG_FILE, 'a+');
if ($f) {
  @fputs($f, date("m.d.Y g:ia")."  ".$_SERVER['REMOTE_ADDR']."  ".$fname."\n");
  @fclose($f);
}

and the output

 

03.13.2015 8:28pm 79.106.xxx.xxx download.zip
Is it possible to log downloads after link has been clicked, or add another colum if CLICK HERE has been clicked, for ex:
03.13.2015 8:28pm 79.106.xxx.xxx download.zip clicked

or

03.13.2015 8:28pm 79.106.xxx.xxx download.zip skipped

Make that link go through a PHP script as well. waitfile.php can handle it too. I figure you can have the same URL as before but with an added value in the query string indicating it's the "click here" link, and you log those requests a little differently.

Make that link go through a PHP script as well. waitfile.php can handle it too. I figure you can have the same URL as before but with an added value in the query string indicating it's the "click here" link, and you log those requests a little differently.

And, how do i do that?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.