I dumped this in my phpinclude template. Does it look like it will properly e-mail me if Googlebot is encountered, then not e-mail me again for two hours even if it is still there?
PHP Code:
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') != false)
{
$result = mysql_query("SELECT lastvisit + INTERVAL 2 HOUR > NOW() AS withintwohours FROM nonstandard_visitors WHERE useragent = 'Googlebot'");
$s = mysql_fetch_row($result);
if ($s[0] == '1')
{
mail($technicalemail, 'Googlebot is at the site!', 'Googlebot is at the site at ' . strftime('%X') . '.
There will be no more e-mails until at least two hours have passed.');
$result = mysql_query("UPDATE nonstandard_visitors SET lastvisit = NOW() WHERE useragent = 'Googlebot'");
}
}
The schema for nonstandard_visitors is:
Code:
mysql> describe nonstandard_visitors;
+-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| useragent | varchar(255) | | | | |
| lastvisit | timestamp(14) | YES | | NULL | |
+-----------+---------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)