Wanted mobile detector code

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

    Wanted mobile detector code

    WapMasters i want mobile detector code so that site should run only on mobile not on pc. Plzzzzz help

    #2
    Originally posted by zong11 View Post
    WapMasters i want mobile detector code so that site should run only on mobile not on pc. Plzzzzz help
    Detect Mobile Browsers - Mobile User Agent Detection
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      how to use this code?????

      Comment


        #4
        Originally posted by zong11 View Post
        how to use this code?????
        PHP Code:
        require_once('mobile_device_detect.php');
        $mobile mobile_device_detect();
        if(
        $mobile == true)
        {
        echo 
        'Mobile phone user.';
        }
        else
        {
        echo 
        'PC user.';

        Advertise your mobile site for FREE with AdTwirl

        Comment


          #5
          PHP Code:
          <?php
          //////GYSMS.com Browser Detection

          $mobile_browser '0';

          if(
          preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wa p|phone)/i',
          strtolower($_SERVER['HTTP_USER_AGENT']))){
          $mobile_browser++;
          }

          if((
          strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or
          ((isset(
          $_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){
          $mobile_browser++;
          }

          $mobile_ua strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
          $mobile_agents = array(
          'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird' ,'blac',
          'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
          'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
          'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
          'newt','noki','oper','palm','pana','pant','phil',' play','port','prox',
          'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
          'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
          'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
          'wapr','webc','winw','winw','xda','xda-');

          if(
          in_array($mobile_ua,$mobile_agents)){
          $mobile_browser++;
          }
          if (
          strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) {
          $mobile_browser++;
          }
          if (
          strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) {
          $mobile_browser=0;
          }


          if(
          $mobile_browser>0){

          header("Location: http://www.yourmobilesite.com");
          }
          else{
          header("Location: http://www.yoursite.com/notphone.php");

          }

          ?>
          Added after 2 minutes:

          i am using on all my sites and working very well..
          check demo at adcell.mobi from ur mob and pc
          Last edited by irfiii; 03.12.11, 15:45.
          Free Web Hosting @HostersPoint.com
          php Hosting with Web Builder

          Buy - Sell ADs
          ADMOLA ADs Network
          Monetize Your Site Traffic

          Comment


            #6
            Originally posted by irfiii View Post
            Added after 2 minutes:

            i am using on all my sites and working very well..
            check demo at adcell.mobi from ur mob and pc
            the function by Andy Moore is more advanced, i would recommend you to use it instead of this code.
            Advertise your mobile site for FREE with AdTwirl

            Comment


              #7
              ohhh Really?
              thanks for suggestion.. i will change it today
              Free Web Hosting @HostersPoint.com
              php Hosting with Web Builder

              Buy - Sell ADs
              ADMOLA ADs Network
              Monetize Your Site Traffic

              Comment


                #8
                Originally posted by irfiii View Post
                PHP Code:
                <?php
                //////GYSMS.com Browser Detection

                $mobile_browser '0';

                if(
                preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wa p|phone)/i',
                strtolower($_SERVER['HTTP_USER_AGENT']))){
                $mobile_browser++;
                }

                if((
                strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or
                ((isset(
                $_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){
                $mobile_browser++;
                }

                $mobile_ua strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
                $mobile_agents = array(
                'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird' ,'blac',
                'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
                'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
                'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
                'newt','noki','oper','palm','pana','pant','phil',' play','port','prox',
                'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
                'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
                'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
                'wapr','webc','winw','winw','xda','xda-');

                if(
                in_array($mobile_ua,$mobile_agents)){
                $mobile_browser++;
                }
                if (
                strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) {
                $mobile_browser++;
                }
                if (
                strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) {
                $mobile_browser=0;
                }


                if(
                $mobile_browser>0){

                header("Location: http://www.yourmobilesite.com");
                }
                else{
                header("Location: http://www.yoursite.com/notphone.php");

                }

                ?>
                Added after 2 minutes:

                i am using on all my sites and working very well..
                check demo at adcell.mobi from ur mob and pc
                Anyway if you using it or not, in this part needs to be a space between OperaMini:

                PHP Code:
                if (strpos(strtolower($_SERVER['ALL_HTTP']),'Opera Mini')>0) { 
                $mobile_browser++; 

                And this i think is wrong because its alone in a string at position 0 in $_SERVER['HTTP_ACCEPT'].

                PHP Code:
                //...
                strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0)
                //... 
                But i got an idea on mobile redirect.
                <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                Comment


                  #9
                  may be wrong but it work fine on opera for me..
                  Free Web Hosting @HostersPoint.com
                  php Hosting with Web Builder

                  Buy - Sell ADs
                  ADMOLA ADs Network
                  Monetize Your Site Traffic

                  Comment


                    #10
                    You were right, i have just read the code btb and didn't test it first. My mistake. Sorry.
                    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                    Comment


                      #11
                      Thanks masters

                      Thanks masters for sharing codes but how to use that codes anyone plz help????

                      Comment


                        #12
                        where do we apply this code?

                        Comment


                          #13
                          Its very good,I always use it :D

                          Comment


                            #14
                            Originally posted by brentg View Post
                            where do we apply this code?
                            anyone help please

                            Comment


                              #15
                              Originally posted by brentg View Post
                              anyone help please
                              In the script.
                              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                              Comment

                              Working...
                              X