help with this php code

stevelori99

Newbie
Joined
Nov 5, 2012
Messages
12
Reaction score
0
hello friend some one can tell my
what this code do

$userAgent = $_SERVER['HTTP_USER_AGENT'];


if(stripos($userAgent, 'google' ) === FALSE) {

}
 
Code is looking for string in user agent, if google come to your site , will be redirected to some other page or blocked, depends of the rest of the code.
If you plan to use it its better to look for host string, not for user agent since can be easily faked.
 
It's called cloaking, but a pretty lousy attempt at it.
 
First line gets the browser's useragent and stores it in $userAgent, i.e.
Code:
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 Safari/537.15

The second line checks to make sure the term "Google" (case-insensitive) is not in the $userAgent variable, because Google crawlers have the term "Google" in their useragents.

If the term "Google" is not in $userAgent, then the code that would be inside the curly braces would be executed.
 
Yea, it's lousy anyone can change useragent string easily.

If someone else from Google browser your site directly, the code inside the curly bracket is not executed. Perhaps the complete code also check IPs?
 
Thats called cloaking but a really poor attempt its easily faked.
 
It means that if the useragent isn't google crawler the code will execute something that should be in brackets.
 
can someone change this code to a better one
i am php programer but i don't really know how to do this better
 
Back
Top