1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help with this php code

Discussion in 'Cloaking and Content Generators' started by stevelori99, Nov 28, 2012.

  1. stevelori99

    stevelori99 Newbie

    Joined:
    Nov 5, 2012
    Messages:
    12
    Likes Received:
    0
    hello friend some one can tell my
    what this code do

    $userAgent = $_SERVER['HTTP_USER_AGENT'];


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

    }
     
  2. TZ2011

    TZ2011 Senior Member

    Joined:
    Jun 26, 2011
    Messages:
    832
    Likes Received:
    863
    Occupation:
    Cleaning servers
    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.
     
  3. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    It's called cloaking, but a pretty lousy attempt at it.
     
  4. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    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.
     
  5. audioguy

    audioguy Power Member

    Joined:
    Jun 12, 2010
    Messages:
    609
    Likes Received:
    224
    Location:
    Anywhere in the world building WP sites.
    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?
     
  6. Jenny30

    Jenny30 Regular Member

    Joined:
    Feb 2, 2012
    Messages:
    478
    Likes Received:
    32
    Thats called cloaking but a really poor attempt its easily faked.
     
  7. ecko911

    ecko911 Newbie

    Joined:
    Apr 15, 2009
    Messages:
    22
    Likes Received:
    1
    It means that if the useragent isn't google crawler the code will execute something that should be in brackets.
     
  8. stevelori99

    stevelori99 Newbie

    Joined:
    Nov 5, 2012
    Messages:
    12
    Likes Received:
    0
    can someone change this code to a better one
    i am php programer but i don't really know how to do this better
     
  9. lambofgods

    lambofgods Junior Member

    Joined:
    Oct 12, 2012
    Messages:
    171
    Likes Received:
    35
    Occupation:
    Studyin!
    Location:
    Bangalore
    its called CLOAKING!!