function to detect mobile brand

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

    function to detect mobile brand

    Here is a function which detects mobile brand,
    other wapmasters are welcome to improve this function and post here their works.

    PHP Code:
    function brand_detect($user_agent)
    {
     
    $brands = array(
                 array(
                     
    'id' => '100',
                     
    'brand' => 'Nokia',
                     
    'check' => array('nokia')
                 ),
                 array(
                     
    'id' => '200',
                     
    'brand' => 'SonyEricsson',
                     
    'check' => array('sonyericsson')
                 ),
                 array(
                     
    'id' => '300',
                     
    'brand' => 'Samsung',
                     
    'check' => array('samsung','sec-','sam-','sgh-')
                 ),
                 array(
                     
    'id' => '400',
                     
    'brand' => 'LG',
                     
    'check' => array('lg/','lg-')
                 ),
                 array(
                     
    'id' => '500',
                     
    'brand' => 'Motorola',
                     
    'check' => array('mot-','moto')
                 ),
                 array(
                     
    'id' => '600',
                     
    'brand' => 'RIM BlackBerry',
                     
    'check' => array('blackberry')
                 ),
                 array(
                     
    'id' => '700',
                     
    'brand' => 'HTC',
                     
    'check' => array('htc')
                 ),
                 array(
                     
    'id' => '800',
                     
    'brand' => 'Apple',
                     
    'check' => array('ipod','iphone','ipad')
                 ),
                 array(
                     
    'id' => '900',
                     
    'brand' => 'Sagem',
                     
    'check' => array('sagem')
                 ),
                 array(
                     
    'id' => '1010',
                     
    'brand' => 'Bird',
                     
    'check' => array('bird')
                 ),
                 array(
                     
    'id' => '1020',
                     
    'brand' => 'Zen',
                     
    'check' => array('z77')
                 ),
                 array(
                     
    'id' => '1030',
                     
    'brand' => 'Haier',
                     
    'check' => array('htil')
                 ),
                 array(
                     
    'id' => '1040',
                     
    'brand' => 'Micromax',
                     
    'check' => array('micromax')
                 ),
                 array(
                     
    'id' => '1050',
                     
    'brand' => 'Spice',
                     
    'check' => array('spice')
                 ),
                 array(
                     
    'id' => '1060',
                     
    'brand' => 'ZTE',
                     
    'check' => array('zte-')
                 ),
                 array(
                     
    'id' => '1070',
                     
    'brand' => 'Huawei',
                     
    'check' => array('huawei')
                 ),
                 array(
                     
    'id' => '1080',
                     
    'brand' => 'Fly',
                     
    'check' => array('fly-')
                 ),
                 array(
                     
    'id' => '1090',
                     
    'brand' => 'Nexian',
                     
    'check' => array('nexian')
                 ),
                 array(
                     
    'id' => '9090',
                     
    'brand' => 'RT',
                     
    'check' => array('rt')
                 )
                 
    /*array(
                     'id' => '800',
                     'brand' => 'Apple Ipod Touch',
                     'check' => array('ipod')
                 ),
                 array(
                     'id' => '810',
                     'brand' => 'Apple Iphone',
                     'check' => array('iphone')
                 ),
                 array(
                     'id' => '820',
                     'brand' => 'Apple Ipad',
                     'check' => array('ipad')
                 )*/

     
    );
        foreach(
    $brands as $brand)
        {
            foreach(
    $brand['check'] as $check)
            {
                if(
    stristr($user_agent,$check))
                {
                    
    $found true;
                    break;
                }
            }
            if(
    $found) break;
        }
        return 
    $brand;

    usage:
    PHP Code:
    $ua 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3';

    print_r(brand_detect($ua)); 
    output:
    Code:
    Array ( [id] => 800 [brand] => Apple [check] => Array ( [0] => ipod [1] => iphone [2] => ipad ) )
    Advertise your mobile site for FREE with AdTwirl


    #2
    LTE bubble touch lol not in the list but i will add it
    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      i think u post exactly something like this b4


      ....................................
      http://photomag.lk/
      ....................................

      Comment


        #4
        Thanks, I will try this..but @gumslone why you`re not replying to my messages?
        ยป PornZeriEs.com - | New! Hottest Porn Movies

        Comment


          #5
          function updated
          Advertise your mobile site for FREE with AdTwirl

          Comment


            #6
            Originally posted by subzero View Post
            LTE bubble touch lol not in the list but i will add it
            Is that a soap or chewingum?
            mysterio.al - programming is a functional art

            Comment

            Working...
            X