PHP Articles
Basic & Beginners
Advanced
Database
XML, Webservices
Design Patterns
Ajax
All Articles
Main Menu
Home
About PHP Hacks
Links
Contact Us
Search


Googlebot PDF Print E-mail
Friday, 28 July 2006

Auto Email on Googlebot Detected Crawling Page
Simple script that you can insert in a .php page that will email you when Google is indexing your site. You will need to change the values in the script for your own site and contact details. Simply cut and paste from the following box. Dont forget the opening and closing < ? PHP and ? > tags (without the spaces)


This script is completely free for you to use and modify however you see fit, but if you make any cool changes, please share them with us :)

<?php 
 
if(eregi("googlebot",$HTTP_USER_AGENT))
{
    mail("you at youremail.com", "Googlebot detected on yourdomainname.com", "Google has crawled yourdomainname.com"); 
}
 
?>

 

 

Advanced Version:

This is a much better version that will automatically fill in the Domain, the actual Page (including any query strings), as well as tell you the Date and Time the page was crawled. Very useful if you want to add this script to many pages.

<?php
if(eregi("googlebot",$HTTP_USER_AGENT))
{
    if ($QUERY_STRING != "")
    {
        $url = "http://".$SERVER_NAME.$PHP_SELF.'?'.$QUERY_STRING;
    } else {
        $url = "http://".$SERVER_NAME.$PHP_SELF;
    }
    $today = date("F j, Y, g:i a");
    mail("you at youremail.com", "Googlebot detected on http://$SERVER_NAME", "$today - Google crawled $url");
} 
?>

 

 

Comments
Add NewSearchRSS
SHRIKEE - eh... IP:86.88.174.79 | 2007-01-10 07:42:36
How is this usefull? It just wastes resources :)

Google offers an interface where you can see if the bot has been on your site...
lkn - uhm.. IP:125.234.49.71 | 2007-02-19 17:33:25
I like strpos function :)

$spiders = 'Bot|Crawl|Spider';
eirik - nice. IP:85.166.255.228 | 2007-03-11 02:45:24
neat.
Nico - Heh... IP:88.15.227.139 | 2007-04-12 01:14:11
This won't even work when register_globals is disabled. And all in all it's slightly pointless if you ask me...
Only registered users can write comments!
Last Updated ( Friday, 15 September 2006 )
 
< Prev   Next >

Syndicate


Login Form





Lost Password?
No account yet? Register