#1
  1. King of da Wackos
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    Jan 2003
    Location
    Planet Zeekois
    Posts
    680
    Rep Power
    17

    Googlebot php script = .txt log?


    Is it possible to use a php script to put content in a .txt file? This script E-mails you the Googlebot info and I would like to turn it into making a .txt log file if it's possible. It wouldn't be very fun geting bombed with a ton of Google bot E-mails a day.

    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@youremail.com", "Googlebot detected on http://$SERVER_NAME", "$today - Google crawled $url");
    }
  2. #2
  3. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jan 2003
    Location
    Springfield, Missouri
    Posts
    39
    Rep Power
    17
    Here's a quick example...

    First, create a file named googlebot.txt in your web dir, chmod it to 0777.

    Secondly, add the following code to each one of the pages you want to track, or put this in a include file and include on pages you want to track...

    <?
    if(eregi("googlebot",$HTTP_USER_AGENT)) {
    if ($QUERY_STRING != "") {
    $visit_url = "http://".$SERVER_NAME.$PHP_SELF.'?'.$QUERY_STRING;
    } else {
    $visit_url = "http://".$SERVER_NAME.$PHP_SELF;
    }
    $visit_dt = date("F j, Y g:i a");
    }

    $line=$visit_dt . " - " . $visit_url . "\r\n";

    $file = fopen("googlebot.txt","a+");
    fputs($file, $line);
    fclose($file);
    ?>

    Lastly, create a file called googlebot-retrieve.php or whatever you want to name it, and put this code in that file...

    <?
    $file = fopen("googlebot.txt","r");
    $text = fread($file, filesize("googlebot.txt"));
    fclose($file);

    mail("you@yourdomain.com", "Googlebot visit results", "$text");

    $file = fopen("googlebot.txt","w");
    fclose($file);

    echo"Results sent";
    ?>

    Each time googlebot accesses one of the pages you have included the code above, it will write a new line to the googlebot.txt file. Whenever you want to retrieve your results (in da morning when you wake up or whenever) just browse to http://www.yourdomain.com/googlebot-retrieve.php

    This will also clear the text file, starting from fresh again. Let me know if you have any questions.
  4. #3
  5. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Dec 2002
    Location
    Spain
    Posts
    328
    Rep Power
    17
    Originally posted by "jwarren93"


    First, create a file named googlebot.txt in your web dir, chmod it to 0777.
    jwarren could you pls explain what you mean with "chmod it to 0777"

    thanks in advance
  6. #4
  7. No Profile Picture
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jan 2003
    Posts
    475
    Rep Power
    17
    I believe he meant chmod it to 777. 777=everyone can read write and execute to it. But if you can chmod to 0777, then please tell me.

    -Josh
  8. #5
  9. No Profile Picture
    Contributing User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jan 2003
    Location
    Springfield, Missouri
    Posts
    39
    Rep Power
    17
    At console in linux, i use chmod 0777, however, if you are just using an ftp program, you would want to set it to 777.

    Darrin -
    Hahaha, nah, I'm a business owner, but it's not McDonalds however. Just thought it was a silly avatar. Will do a real life pic one of these days. Also just wanted to say thanks for a great forum.
  10. #6
  11. No Profile Picture
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jan 2003
    Posts
    475
    Rep Power
    17
    Darn, i thought i might have been in a forum, getting site pointers, with Ronald McDonald... That woulda kicked ***!

    -Josh
  12. #7
  13. King of da Wackos
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    Jan 2003
    Location
    Planet Zeekois
    Posts
    680
    Rep Power
    17
    If any one want's the IP address, change it to this.

    $line=$visit_dt . " - " . $visit_url . " - " . $REMOTE_ADDR . "\r\n";
  14. #8
  15. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Dec 2002
    Location
    Spain
    Posts
    328
    Rep Power
    17
    Originally posted by "jwarren93"

    At console in linux, i use chmod 0777, however, if you are just using an ftp program, you would want to set it to 777.
    jwarren: on my apache it doesn´t work. The googlebot.txt file changes only his access time, but without any visit-notice inside. What could be the problem? Do I have to change something in the config.inc.php file?
  16. #9
  17. King of da Wackos
    SEO Chat Adventurer (500 - 999 posts)

    Join Date
    Jan 2003
    Location
    Planet Zeekois
    Posts
    680
    Rep Power
    17
    Do you just get ' - - '? If so that's normal.

    That is what it looks like when you set it up (I added the IP address part.)
    Only the ones that show the URL are the Googlebot, and yes, it's been active today!!

    http://www.vgchat.com/google.txt
  18. #10
  19. SEO Freak
    SEO Chat Good Citizen (1000 - 1499 posts)

    Join Date
    Feb 2003
    Location
    Hannover, Germany
    Posts
    1,410
    Rep Power
    24
    FYI, Here is something pretty useful. needs php pages but you could always Iframe on in.

    http://www.webrankinfo.com/english/googlestats/index.php

    I think this is exactly what the doctor ordered :-)
    It is also btw. with a bit of phpmyadmin know-how possible to add other search engine crawl ips as well.
    What is a website without traffic?
    ABAKUS Internet Marketing

Similar Threads

  1. External Links & PHP Redirect Script: Is this OK?
    By chakotha in forum Google Optimization
    Replies: 5
    Last Post: Dec 4th, 2012, 04:33 AM
  2. Has anyone found a script to track Googlebot through a website?
    By WhiteGyr in forum Google Optimization
    Replies: 19
    Last Post: Jan 23rd, 2005, 08:23 AM
  3. Cool script: Emails you when googlebot hits your domain (*)
    By Angus in forum Web Design, Coding and Programming
    Replies: 87
    Last Post: Jul 12th, 2003, 12:14 AM
  4. Googlebot e-mail monitor (PHP)
    By brendabee in forum Google Optimization
    Replies: 6
    Last Post: Apr 18th, 2003, 04:37 AM
  5. Using a php script to automate reciprocal links...
    By dhecker in forum Google Optimization
    Replies: 10
    Last Post: Apr 16th, 2003, 08:46 PM

IMN logo majestic logo threadwatch logo seochat tools logo