Googlebot Useragent

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Googlebot Useragent

    How can i show googlebot as "googlebot" and NOT as Mozilla/5.0 or Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) at my guests online list??

    Im having little trouble with extracting that word out from useragent!!!

    thanx in advance
    sigpiceeeeerrr....

    #2
    Try something like this, i havnt tested it but i think it should work

    Code:
    $_mob_browser=$_SERVER['HTTP_USER_AGENT'];
    
    if(preg_match('/(google|bot)/i',strtolower($_mob_browser)))
    {
    $position = strpos($_mob_browser,"bot");
    $_mob_browser = substr($_mob_browser, $position-20, $position+3);
    $_browser = explode (" ", $_mob_browser);
    $_browser  = array_reverse($_bot_name);
    } 
    else 
    {
    $_browser = explode (" ", $_mob_browser);
    }
    
    echo $_browser[0];
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      no, something is wrong... but i dont understand what...

      it still shows others useragent corectly, but not the googlebot...

      i change my useragent as googlebot is using and it shows blank 4 useragent, but also it gives me this error on the end of page

      Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/domain/public_html/x/onlgst.php on line 29


      this is whts on line 29 and i got no clue to resolve it
      Code:
      $_mob_browser=$_SERVER['HTTP_USER_AGENT'];
      
      if(preg_match('/(google|bot)/i',strtolower($_mob_browser)))
      {
      $position = strpos($_mob_browser,"bot");
      $_mob_browser = substr($_mob_browser, $position-20, $position+3);
      $_browser = explode (" ", $_mob_browser);
      $_browser  = array_reverse($_bot_name);   <----line 29
      } 
      else 
      {
      $_browser = explode (" ", $_mob_browser);
      }
      sigpiceeeeerrr....

      Comment


        #4
        sorry it was a small mistake

        Code:
        $_mob_browser=$_SERVER[&#39;HTTP_USER_AGENT&#39;];
        
        if(preg_match(&#39;/(google|bot)/i&#39;,strtolower($_mob_browser)))
        {
        $position = strpos($_mob_browser,"bot");
        $_mob_browser = substr($_mob_browser, $position-20, $position+3);
        $_browser = explode (" ", $_mob_browser);
        $_browser  = array_reverse($_browser); 
        } 
        else 
        {
        $_browser = explode (" ", $_mob_browser);
        }
        
        echo $_browser[0];
        i think now its ok
        Advertise your mobile site for FREE with AdTwirl

        Comment


          #5
          <div class='quotetop'>QUOTE (GumSlone @ Dec 23 2008, 07:42 PM) <{POST_SNAPBACK}></div>
          sorry it was a small mistake

          Code:
          $_mob_browser=$_SERVER[&#39;HTTP_USER_AGENT&#39;];
          
          if(preg_match(&#39;/(google|bot)/i&#39;,strtolower($_mob_browser)))
          {
          $position = strpos($_mob_browser,"bot");
          $_mob_browser = substr($_mob_browser, $position-20, $position+3);
          $_browser = explode (" ", $_mob_browser);
          $_browser  = array_reverse($_browser); 
          } 
          else 
          {
          $_browser = explode (" ", $_mob_browser);
          }
          
          echo $_browser[0];
          i think now its ok[/b]
          yes it was a small mistake, but my BIG stupidness...
          should see it
          lol

          anyway BIG THANX it works perfectly
          thou i had 2 change
          Code:
          $_mob_browser = substr($_mob_browser, $position-20, $position+3);
          to
          Code:
          $_mob_browser = substr($_mob_browser, $position-30, $position+2);
          to get just "Googlebot" because that 1st one shows "+http"

          now i wonder will it work that way with others bots...

          but that i&#39;ll see when "they" comes... lol

          THANX
          sigpiceeeeerrr....

          Comment


            #6
            Here i have improved everything a little bit:


            Code:
            function get_mob_browser($_mob_browser)
            {
            if(preg_match(&#39;/(google|bot)/i&#39;,strtolower($_mob_browser)))
            {
            $position = strpos(strtolower($_mob_browser),"bot");
            $_mob_browser = substr($_mob_browser, $position-30, $position+2);
            $_browser = explode (" ", $_mob_browser);
            $_browser  = array_reverse($_browser); 
            } 
            else 
            {
            
            $_position=strpos(strtolower($_mob_browser),"nokia");
            if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
            $_browser = explode ("/", $_mob_browser);
            }
            
            return $_browser[0];
            }
            Usage:
            Code:
            echo get_mob_browser($_SERVER[&#39;HTTP_USER_AGENT&#39;]);
            Advertise your mobile site for FREE with AdTwirl

            Comment


              #7
              <div class='quotetop'>QUOTE (GumSlone @ Dec 23 2008, 11:57 PM) <{POST_SNAPBACK}></div>
              Here i have improved everything a little bit:


              Code:
              function get_mob_browser($_mob_browser)
              {
              if(preg_match(&#39;/(google|bot)/i&#39;,strtolower($_mob_browser)))
              {
              $position = strpos(strtolower($_mob_browser),"bot");
              $_mob_browser = substr($_mob_browser, $position-30, $position+2);
              $_browser = explode (" ", $_mob_browser);
              $_browser  = array_reverse($_browser); 
              } 
              else 
              {
              
              $_position=strpos(strtolower($_mob_browser),"nokia");
              if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
              $_browser = explode ("/", $_mob_browser);
              }
              
              return $_browser[0];
              }
              Usage:
              Code:
              echo get_mob_browser($_SERVER[&#39;HTTP_USER_AGENT&#39;]);
              [/b]
              okay whats missing here is to show a model of mobile phone instead of Opera Mini when user is browsing with Opera mini lol

              back when i run a lava script i used this

              Code:
                  $useragent = $HTTP_USER_AGENT;
                  $useragent2 = explode (&#39;; &#39;, $useragent);
                  $operabrowser = substr(trim($useragent2[1]),0,10);
              if ($operabrowser == "Opera Mini")
                    {
                     $ubr = $HTTP_X_OPERAMINI_PHONE_UA;
                    }else{
                          $brws = explode(" ",$HTTP_USER_AGENT);
                          $ubr = $brws[0];  
                         }
              yeah its a newbie coding and it needs globals ON lol and its a bit messed up, BUT it shows phn models instead of opera mini

              Now GumSlone you should add this to that function of yours, you know how to shrink it lol
              sigpiceeeeerrr....

              Comment


                #8
                Here is which will work with opera mini:


                Code:
                function get_mob_browser($_mob_browser)
                {
                
                if(preg_match(&#39;/(google|bot)/i&#39;,strtolower($_mob_browser)))
                {
                $position = strpos(strtolower($_mob_browser),"bot");
                $_mob_browser = substr($_mob_browser, $position-30, $position+2);
                $_browser = explode (" ", $_mob_browser);
                $_browser  = array_reverse($_browser); 
                }
                else if (isset($_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;])) 
                {
                $_mob_browser = $_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;];
                $_position=strpos(strtolower($_mob_browser),"nokia");
                if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
                $_browser = explode ("/", $_mob_browser);
                }
                else 
                {
                $_position=strpos(strtolower($_mob_browser),"nokia");
                if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
                $_browser = explode ("/", $_mob_browser);
                }
                
                return $_browser[0];
                }
                
                echo get_mob_browser($_SERVER[&#39;HTTP_USER_AGENT&#39;]);
                Advertise your mobile site for FREE with AdTwirl

                Comment


                  #9
                  works fine with opera mini!
                  but not with symbian web browser.... it still shows Mozilla...
                  cannot test it with symbian opera 8.65 cuz im not using it...but i think it will work, cuz i tested it long time ago and it works....

                  anyway Merry X-mas to all
                  sigpiceeeeerrr....

                  Comment


                    #10
                    <div class='quotetop'>QUOTE (alesh @ Dec 24 2008, 12:45 PM) <{POST_SNAPBACK}></div>
                    works fine with opera mini!
                    but not with symbian web browser.... it still shows Mozilla...
                    cannot test it with symbian opera 8.65 cuz im not using it...but i think it will work, cuz i tested it long time ago and it works....

                    anyway Merry X-mas to all[/b]
                    it works with the browser on n95 i get NokiaN95 istead Mozilla, please post here the useragent of your browser
                    Advertise your mobile site for FREE with AdTwirl

                    Comment


                      #11
                      <div class='quotetop'>QUOTE </div>
                      okay whats missing here is to show a model of mobile phone instead of Opera Mini when user is browsing with Opera mini lol

                      back when i run a lava script i used this[/b]
                      try diz
                      Code:
                      //--------------//
                      function getrealuseragent()
                      {
                      if (isset($_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;])) {$browsus = htmlspecialchars(stripslashes($_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;]));}
                      elseif(isset($_SERVER[&#39;HTTP_USER_AGENT&#39;])) {$browsus=htmlspecialchars(stripslashes($_SERVER[&#39;HTTP_USER_AGENT&#39;]));} 
                      else {$browsus=&#39;Not_detected&#39;;}
                      //$browsus=clean($browsus);
                      return $browsus;
                      }
                      //--------------//

                      Comment


                        #12
                        <div class='quotetop'>QUOTE (Ansh @ Dec 25 2008, 04:01 PM) <{POST_SNAPBACK}></div>
                        try diz
                        Code:
                        //--------------//
                        function getrealuseragent()
                        {
                        if (isset($_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;])) {$browsus = htmlspecialchars(stripslashes($_SERVER[&#39;HTTP_X_OPERAMINI_PHONE_UA&#39;]));}
                        elseif(isset($_SERVER[&#39;HTTP_USER_AGENT&#39;])) {$browsus=htmlspecialchars(stripslashes($_SERVER[&#39;HTTP_USER_AGENT&#39;]));} 
                        else {$browsus=&#39;Not_detected&#39;;}
                        //$browsus=clean($browsus);
                        return $browsus;
                        }
                        //--------------//
                        [/b]
                        Actually i have already posted the fuction to make it work with opera, take a look few post before
                        Advertise your mobile site for FREE with AdTwirl

                        Comment


                          #13
                          To detect spiders put those in in an array check it with strpos of user agent. If both match echo spiders nicks else echo user agent.

                          Comment


                            #14
                            And for the googlebot think only

                            Code:
                            function ip()
                            {
                            if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR"];}
                            else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}
                            if(strpos($ip,",")){
                            $exp_ip=explode(",",$ip);
                            $ip=$exp_ip[0];
                            }
                            $ip = ip2long($ip);
                            return $ip;
                            }
                            
                            if((ip() >= 1123631104) && (ip() <= 1123639295))
                            {
                            echo "GoogleBot";
                            
                            }
                            else 
                            {
                            $ua =  explode(" ",$_SERVER["HTTP_USER_AGENT"]);
                            echo $ua[0];
                            }

                            Comment


                              #15
                              <div class='quotetop'>QUOTE (GumSlone @ Dec 25 2008, 08:04 PM) <{POST_SNAPBACK}></div>
                              it works with the browser on n95 i get NokiaN95 istead Mozilla, please post here the useragent of your browser[/b]
                              not working wid nokia e61i browser its shows Mozilla . Or you can say it dont work with Nokia E series browsers .

                              Browser : Mozilla/5.0 (SymbianOS/9.1; U; en-us) AppleWebKit/413 (KHTML, like Gecko) Safari/413 es61i

                              Comment

                              Working...
                              X