/// List of known of ip from Linkedin. Source = https://www.distilnetworks.com/bot-directory/bot/linkedin-bot/
$ips = ['108.174.2.205', '108.174.2.203', '108.174.2.206', '108.174.2.204', '108.174.5.115', '108.174.5.115', '108.174.5.117', '108.174.5.116', '216.52.242.13', '216.52.242.14', '108.174.2.200'];
/**
* User agent validation. It just tests if the user agent contains the word linkedin in lowered case.
* @return bool
*/
function validateUserAgent($keyword)
{
$regularExpression = '/(?i)linkedin/m';
preg_match_all($regularExpression, $keyword, $matches, PREG_SET_ORDER, 0);
return (count($matches) > 0);
}
$remoteHost = $_SERVER['REMOTE_HOST'];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (in_array($remoteHost, $ips) || validateUserAgent($userAgent)) {
/// Is linkedin bot.
echo '<img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=14214&fmt=gif" />';
}
#insight #linkedin #ta #tag