Check if browser open

Is there a was of checking if the script is being run from a browser or if its been spidered/crawled. I tried something like this but it didnt work

if(!empty($_SERVER['HTTP_USER_AGENT'])) 
{
 // Do something if browser
}
else
{
 // Do something if spider cronjob
}

What didn’t work? What happened that wasn’t supposed to? Why do you assume spiders don’t send a user agent value?

Hi

What I am looking for is.

For argument sake when you ereg a url as follows

$htmlString=file_get_contents($row['recip_url']);
if(!ereg($site_url,$htmlString)) {
// Do something
}

and the contents you are looking for are dynamic from a database I want to know if the script can distinguish between a user (Which will assign a max link per page, say of 25) and a spider (Which will then drag all the links from the database). Is this possible

Sponsor our Newsletter | Privacy Policy | Terms of Service