• 13-08-2015, 15:39:33
    #1
    Merhaba, bir sitede müşteri girilen telefon markası ve modeline göre yönlensin istiyor. Daha açık anlatmak gerekirse telefon markası Samsung Note4 ise samsung galaxy not ürünleri listelesin istiyor. Listeleme etiket arama ile yapılacak.
    Şöyle bir kod oluşturdum. Fakat nerde yanlış yapıyorum anlamadım, olmuyor.

    <?php
    $iphone6 = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone6");
    $iphone4 = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone4");
    $iphone5 = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone5");
    $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
    $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
    $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
    $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
    $ios= strpos($_SERVER['HTTP_USER_AGENT'],"ios");
    $samsung= strpos($_SERVER['HTTP_USER_AGENT'],"samsung");
    $samsungnote4= strpos($_SERVER['HTTP_USER_AGENT'],"SM-N910CQ");
    
    if ($iphone6 || $ios == true) 
    { 
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%206');
    //OR
    echo "<script>window.location='http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%206'</script>";
    }
    elseif ($iphone5 || $ios == true) 
    { 
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%205');
    //OR
    echo "<script>window.location='http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%205'</script>";
    }
    elseif ($iphone4 || $ios == true) 
    { 
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%204');
    //OR
    echo "<script>window.location='http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone%204'</script>";
    }
    elseif ($samsung == true) 
    { 
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=samsung');
    //OR
    echo "<script>window.location='http://www.m.telefoncu.com.tr/index.php?route=product/search&search=samsung'</script>";
    }elseif ($samsungnote4 || $samsung == true) 
    { 
    header('Location: http://www.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20Galaxy%20Note%204');
    //OR
    echo "<script>window.location='http://www.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20Galaxy%20Note%204'</script>";
    }
    ?>
    Bu işlemi mobilcadde.com başarıyla uygulamış. Ben nasıl yapabilirim, bilen var mı?
  • 13-08-2015, 16:28:16
    #2
    mobiledetect sınıfı ile kolayca yapabilirsiniz

    http://mobiledetect.net
  • 13-08-2015, 16:34:36
    #3
    Misafir adlı üyeden alıntı: mesajı görüntüle
    mobiledetect sınıfı ile kolayca yapabilirsiniz

    http://mobiledetect.net
    Mobiledetect sınıfında yönlendirme işlemini nasıl yapabiliriz? Bu kısmını anlamadım.
  • 13-08-2015, 17:26:19
    #4
    https://github.com/serbanghita/Mobil...ile_Detect.php

    belki faydası olur
  • 14-08-2015, 10:55:59
    #5
    Peri adlı üyeden alıntı: mesajı görüntüle
    Mobiledetect sınıfında yönlendirme işlemini nasıl yapabiliriz? Bu kısmını anlamadım.
    şurda bir arkadaşa bahsetmiştim

    https://www.r10.net/php/1421845-mobil...post1070279090
  • 14-08-2015, 14:37:40
    #6
    Misafir adlı üyeden alıntı: mesajı görüntüle
    şurda bir arkadaşa bahsetmiştim

    https://www.r10.net/php/1421845-mobil...post1070279090
    Ben çerez ile yönlendirme kısmında degilim ki. Benim istedigim telefonun modelini, markasını almak.

    suadreste bir denemem var. HTTP_USER_AGENT ile alıyoruz, tamam güzel. Ama ben bunun içindeki bu gereksiz yazıları istemiyorum.

    Bu sınıfta anlamadıgım birşey var. Mobile_Detect.php diye bir sayfa var. Burada telefon kodları var. Fakat ne hikmetse bunları silsem bile telefonumun markasını modelini alıyor. O halde bunları nereden alıyor?
    Mobile_Detect içinde ayrı bir include mi var diye bakıyorum. E yok.
    Bu ne ola ki?
  • 14-08-2015, 16:54:25
    #7
    Peri adlı üyeden alıntı: mesajı görüntüle
    Ben çerez ile yönlendirme kısmında degilim ki. Benim istedigim telefonun modelini, markasını almak.

    suadreste bir denemem var. HTTP_USER_AGENT ile alıyoruz, tamam güzel. Ama ben bunun içindeki bu gereksiz yazıları istemiyorum.

    Bu sınıfta anlamadıgım birşey var. Mobile_Detect.php diye bir sayfa var. Burada telefon kodları var. Fakat ne hikmetse bunları silsem bile telefonumun markasını modelini alıyor. O halde bunları nereden alıyor?
    Mobile_Detect içinde ayrı bir include mi var diye bakıyorum. E yok.
    Bu ne ola ki?

    Mobiledetect çok kapsamlı bir sınıftır. Size tüm seçenekleri sunar.
    İstediğiniz şekilde özelleştirebilir ya da kullanabilirsiniz.
    Şuan iş yerinde olduğum için her siteye erişimim yok maalesef.
    Sadece mobilcihazın adını/modelini istiyorsanız da yine benzer şekilde yazabilirsiniz.
    True dönen fonksiyonun adını alabilirsiniz ya da tek tek if-elseif-else sorgusu yazarak halledebilirsiniz.

    NOT: akşam bunun hakkında bir fonksiyon yazarak konu altından cevaplayacağım, dediğim gibi iş yerinde olduğum için tam ilgilenemiyorum.


    include("core/classes/Mobile_Detect.php");
    $detect = new Mobile_Detect();
    if ($detect->isiPhone())
    {
        $device = 'iPhone';
    } elseif ($detect->isBlackberry())
    {
        $device = 'Blackberry';
    } elseif ($detect->isHTC())
    {
        $device = 'HTC';
    } elseif ($detect->isNexus())
    {
        $device = 'Nexus';
    } elseif ($detect->isSamsung())
    {
        $device = 'Samsung';
    } elseif ($detect->isAsus())
    {
        $device = 'Asus';
    } elseif ($detect->isSony())
    {
        $device = 'Sony';
    } elseif ($detect->isLG())
    {
        $device = 'LG';
    } else
    {
        $device = 'Other';
    }
  • 15-08-2015, 12:55:48
    #8
    Misafir adlı üyeden alıntı: mesajı görüntüle
    Mobiledetect çok kapsamlı bir sınıftır. Size tüm seçenekleri sunar.
    İstediğiniz şekilde özelleştirebilir ya da kullanabilirsiniz.
    Şuan iş yerinde olduğum için her siteye erişimim yok maalesef.
    Sadece mobilcihazın adını/modelini istiyorsanız da yine benzer şekilde yazabilirsiniz.
    True dönen fonksiyonun adını alabilirsiniz ya da tek tek if-elseif-else sorgusu yazarak halledebilirsiniz.

    NOT: akşam bunun hakkında bir fonksiyon yazarak konu altından cevaplayacağım, dediğim gibi iş yerinde olduğum için tam ilgilenemiyorum.


    include("core/classes/Mobile_Detect.php");
    $detect = new Mobile_Detect();
    if ($detect->isiPhone())
    {
        $device = 'iPhone';
    } elseif ($detect->isBlackberry())
    {
        $device = 'Blackberry';
    } elseif ($detect->isHTC())
    {
        $device = 'HTC';
    } elseif ($detect->isNexus())
    {
        $device = 'Nexus';
    } elseif ($detect->isSamsung())
    {
        $device = 'Samsung';
    } elseif ($detect->isAsus())
    {
        $device = 'Asus';
    } elseif ($detect->isSony())
    {
        $device = 'Sony';
    } elseif ($detect->isLG())
    {
        $device = 'LG';
    } else
    {
        $device = 'Other';
    }
    Merhaba, ilginiz için çok teşekkür ederim. Mesajınızı bugün gördüm. Evet bende benzer bir yol işleyerek devam ediyorum. Telefon modellerini de almam gerektiği için şöyle oluyor

    <?php
    
    include "/Mobile_Detect.php";
    $cihaz = new Mobile_Detect();
    
    if($cihaz->isMobile()==TRUE or $cihaz->isTablet()==TRUE ){
    //echo htmlentities($_SERVER['HTTP_USER_AGENT']);
    if (strpos($_SERVER['HTTP_USER_AGENT'], "SM-E500H") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20e5');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "SM-N910C") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Note%204');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=iphone');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "SM-N910CQ") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Note%204');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "SM-A300H") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20a3');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "SM-N9000Q") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20Note%204');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "SM-C101") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "Discovery") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=General%20Mobile%20Discovery');
    }elseif(strpos($_SERVER['HTTP_USER_AGENT'], "GT-I9190") !== FALSE){
    header('Location: http://www.m.telefoncu.com.tr/index.php?route=product/search&search=Samsung%20S4');
    }else{
    header('Location: http://www.m.telefoncu.com.tr');
    }}
    else{
    }
    ?>
    Şuanda sorunum iphoneları 4 5 6 diye ayırmak. Birde Nokia Lumialar var. Diğer telefonlarda istedigim gibi oluyor. Çok teşekkür ederim.