A php script that will email you when Googlebot or Bingbot crawls your website
Copy and Paste any or both scripts below into your "index.php" file that is in your Joomla template folder.
Below is for Googlebot to Email you:
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false )
{
// paste your email address here
$my_email = This email address is being protected from spambots. You need JavaScript enabled to view it.';
$today = date("F j, Y, g:ia");
// notify via email
mail($my_email,'[Notification] Googlebot Visit ' . $_SERVER['SERVER_NAME'], $today . ' - Googlebot has just visited '. $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . ' your website: ' . $_SERVER['REQUEST_URI'] );
}
?>
Below is for Googlebot to Write to a File:
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false ) {
file_put_contents('Googlebot.txt', 'Googlebot was here - ' . date(DATE_RFC822));
}
?>
OR
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false )
{
$myfile = fopen("Googlebot.txt", "a+") or die("Unable to open file!");
$hasjustvisited = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . ' your website: ' . $_SERVER['REQUEST_URI'];
$todate = date('M j, Y g:ia') . " ";
$googlewashere = ' Googlebot was here - ' ;
$googlefiles = $googlewashere . $todate . $hasjustvisited;
fwrite($myfile, $googlefiles . "\n");
fclose($myfile);
}
?>
===================================================
Below is for Bingbot:
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Bingbot' ) !== false )
{
// paste your email address here
$my_email = This email address is being protected from spambots. You need JavaScript enabled to view it.';
$today = date("F j, Y, g:ia");
// notify via email
mail($my_email,'[Notification] Bingbot Visit ' . $_SERVER['SERVER_NAME'], $today . ' - Bingbot has just visited '. $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . ' your website: ' . $_SERVER['REQUEST_URI'] );
}
?>
OR
<?php
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Bingbot' ) !== false )
{
$myfile = fopen("Bingbot.txt", "a+") or die("Unable to open file!");
$hasjustvisited = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . ' your website: ' . $_SERVER['REQUEST_URI'];
$todate = date('M j, Y g:ia') . " ";
$bingwashere = ' Bingbot was here - ' ;
$bingfiles = $bingwashere . $todate . $hasjustvisited;
fwrite($myfile, $googlefiles . "\n");
fclose($myfile);
}
?>