I got the following function while googling for bot behaviour. while i am using this code, i get error for eregi()
expression. i am not an expert of regualar expression. since ereri( )
has been depreciated, i am getting the same error.
function check_if_spider()
{
// Add as many spiders you want in this array
$spiders = array('Googlebot', 'Yammybot', 'Openbot', 'Yahoo', 'Slurp', 'msnbot', 'ia_archiver', 'Lycos', 'Scooter', 'AltaVista', 'Teoma', 'Gigabot', 'Googlebot-Mobile');
// Loop through each spider and check if it appears in
// the User Agent
foreach ($spiders as $spider)
{
if (eregi($spider, $_SERVER['HTTP_USER_AGENT']))
{
return TRUE;
}
}
return FALSE;
}
how can i modify the code to make it workin? google search says it should be converted to preg_match();
being a newbee, i am at failure, although i tried at my end..can somebody guide me?