Skip to content

Instantly share code, notes, and snippets.

@zelon88
Created December 27, 2016 06:16
Show Gist options
  • Save zelon88/efa98c5a343a0126b043f161b7d2f4cf to your computer and use it in GitHub Desktop.
Save zelon88/efa98c5a343a0126b043f161b7d2f4cf to your computer and use it in GitHub Desktop.
Log client IP on <img> interaction w/PHP.
<?php
$Time = date("F j, Y, g:i a");
$LogFile = '/path/to/logfile.txt';
$ClientIP = $_SERVER['REMOTE_ADDR'];
$txt = ('Image accessed by '.$ClientIP.' on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL , FILE_APPEND);
echo('<img src="img.jpg">');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment