Solved

Php Googlebot detect (adsense)

Posted on 2013-01-08
2
559 Views
Last Modified: 2013-01-09
Hi E's, Every time I open a page in my site I send information to my database. The problem is I have Google Ad-sense in my page, and sometimes when I open a page Google check Ad-sense, and that opening page (Google check) will write also to my database, and is that situation I want avoid, I just want information from human customer, not from google.
For example today the IP address of Googlebot is "66.249.73.45", and sometimes they change that IP.

What I need is something like this:
if(NOT Googlebot){
mysql_query("insert into table.........
}

Open in new window

Note: I don't want block googlebot at all, I just don't want them in my database.

How I detect googlebot?

The best regards, JC
0
Comment
Question by:Pedro Chagas
2 Comments
 
LVL 4

Accepted Solution

by:
Rahul Gupta earned 350 total points
ID: 38757830
0
 
LVL 10

Assisted Solution

by:d4durvesh
d4durvesh earned 150 total points
ID: 38758913
Hi you can do following,

if(!NOT strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot"))
{
    mysql_query("insert into table.........
}

Open in new window

Thank You!
Naik Durvesh.
Source:
http://stackoverflow.com/questions/677419/how-to-detect-search-engine-bots-with-php
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Logic behind "best rated" calculation 11 30
Split wordpress loop 35 56
Row insertion failed. Array 5 45
Link failure 16 31
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question