Skip to content

Instantly share code, notes, and snippets.

@artlung
Created December 22, 2021 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artlung/db93cd01ed9c4245d6dc5132adf610e3 to your computer and use it in GitHub Desktop.
Save artlung/db93cd01ed9c4245d6dc5132adf610e3 to your computer and use it in GitHub Desktop.
In 2010 when I was applying for jobs I added a little tracker chunk of php to any page I sent to recruiters so I could get a notification if they actually clicked through. It worked pretty well. Primitive and intrusive but also pretty funny.
<?php
define('TRACK', false);
function isSpider($HTTP_USER_AGENT) {
$spiders = array(
'Baiduspider',
'msnbot',
'youdao',
'YandexBot',
'YodaoBot',
'KaloogaBot',
'googlebot',
'majestic12',
);
$is_spider = false;
$haystack = strtolower($HTTP_USER_AGENT);
foreach($spiders as $spider) {
$needle = strtolower($spider);
if (strpos($haystack, $needle) !== false) {
$is_spider = true;
}
}
return $is_spider;
}
$no_mail = array(
'24.254.168.180', // ours
'67.195.115.105', // yahoo bot
'207.46.199.50', // msn bot
'61.135.249.246', //youdao bot
'207.46.199.32', // msn bot
'68.183.146.41', // grandma's house
'61.135.249.238', // youdao bot
'123.125.66.85', // Baiduspider bot
'68.8.173.141', // matt and margots
'24.254.162.196', // mom and dads
'24.254.162.43', // mom and dads
);
if (TRACK && !in_array($_SERVER['REMOTE_ADDR'], $no_mail) && !isSpider($_SERVER['HTTP_USER_AGENT'])):
$headers = 'From: webmaster@artlung.com' . "\n" .
'Reply-To: webmaster@artlung.com' . "\n" .
'X-Mailer: PHP/' . phpversion() . "\n";
$body = 'https://artlung.com/portfolio/2010/' . "\n\n". print_r($_SERVER, true);
mail('joe@artlung.com', 'Email from https://artlung.com/portfolio/2010/ ' . $_SERVER['REMOTE_ADDR'], $body, $headers) or die("<!-- error -->");
print "<!-- E -->";
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment