shopnc跳轉WAP端的實現方法

shop/templates/default/layout/home_layout.php

在第二行寫入

<?php


$agent = check_wap();
if( $agent )
{
    header('Location: http://blog.csdn.net/wang8559422/wap');
    exit;
}


// check if wap 
function check_wap(){
    // 先檢查是否爲wap代理,準確度高
    if(stristr($_SERVER['HTTP_VIA'],"wap")){
        return true;
    }
    // 檢查瀏覽器是否接受 WML.
    elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){
        return true;
   }
   //檢查USER_AGENT
   elseif(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){
        return true;             
    }
    else{
        return false;    
   }
}


?>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章