/ Published in: PHP
Add an image to the email, must be linked not embedded ie in thunderbird mail moz-do-not-send attribute must be set true.
any requests for this gif image will be redirected through display which will log the request and serve up the stored t.gif image.
the log file name will be as the requested gif file in this case loggingname.txt in the /log directory
any requests for this gif image will be redirected through display which will log the request and serve up the stored t.gif image.
the log file name will be as the requested gif file in this case loggingname.txt in the /log directory
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
create a /track and a /track/log directory under webroot find a 1x1 transparent gif image and upload to the /track directory as t.gif add .htaccess file to the track directory -.htaccess-------- <filesMatch "\.(gif|txt)$"> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </ifModule> </filesMatch> IndexIgnore * RewriteEngine on RewriteRule .(gif)$ display.php [NC] -end .htaccess--------- Create display.php in the /track directory ---display.php----- <?php //ini_set('display_startup_errors',1); //ini_set('display_errors',1); //error_reporting(-1); function writeAccess($filename) { //time for log if( ($time = $_SERVER['REQUEST_TIME']) == '') { } $remote_addr = ' unknown'; $remoteHost = ' unknown'; } else { $remote_addr = $_SERVER['REMOTE_ADDR']; //$remoteHost='no'; } //$_SERVER["HTTP_USER_AGENT"] $remoteAgent=' No User Agent'; } else { $remoteAgent=$_SERVER['HTTP_USER_AGENT']; } // Format the date and time //remove extension then spaces $filename = $_SERVER["DOCUMENT_ROOT"] . '/track/log/'. $filename .'.txt'; // Append to the log file } } //get name of request file filter out any spaces and %20 and sanitize //log writeAccess($filename); //$data = file_get_contents($_SERVER["DOCUMENT_ROOT"] . '/track/t.gif'); //echo $data; Add <img src="http://website.co.uk/track/loggingname.gif"> to the email, this must not be embedded ie in thunderbird mail moz-do-not-send attribute must be set true. any requests for this gif image will be redirected through display.php which will log the request and serve up the stored t.gif image.