PHP Access Source (WAP access, PC Web Access)

Source: Internet
Author: User

For a better user experience, this topic is supported by default WAP and Web two access styles, WAP Access will not contain any script, style is also re-compose, do not support more pages, only support home page, detail page, comment box, login and other content will be updated to WAP content. If you want to test, you can use the phone to access http://qianduanblog.com try, is not the effect and computer access is not the same?

The following is a function for accessing the type of access (from the Internet):

After testing, the following judgment is wrong.

  1. /***************************************************
  2. * * return type of access (WAP web)
  3. * * December 2, 2012 22:21:20
  4. ***************************************************/
  5. function yundanran_get_access_type()
  6. {
  7. $is _wap=false;
  8. //If there is http_x_wap_profile, it must be a mobile device .
  9. if (isset($_server[' Http_x_wap_profile ']))
  10. {
  11. $is _wap=true;
  12. }
  13. Else
  14. {
  15. //If via information contains WAP, it must be a mobile device, some service associations block this information
  16. if(isset($_server[' Http_via ']))
  17. {
  18. //cannot be found for flase, otherwise true
  19. $is _wap=stristr($_server[' Http_via '],"WAP") ? true : false;
  20. }
  21. Else
  22. {
  23. //Protocol law, because there may be inaccuracies, put to the final Judgment
  24. if (isset($_server[' http_accept ']))
  25. {
  26. //If only WML is supported and HTML is not supported it must be a mobile device .
  27. //If WML and HTML are supported but WML is a mobile device before HTML
  28. if
  29. (
  30. (strpos ([ ' http_accept ' ], ' VND.WAP.WML ' ) !== Span class= "KWD" >false)
  31. && ( strpos ($_server[], ' text/html ' ) === false
  32. ¦¦ (strpos($_server[' http_accept '], ' vnd.wap.wml ') < strpos($_server[' http_accept '], ' text/html ' )))
  33. )
  34. {
  35. $is _wap=true;
  36. }
  37. }
  38. }
  39. }
  40. return $is _wap?' WAP ':' web ';
  41. }
  42. The correct method of judging will be written in the near future:

    ╮(╯▽╰)╭, a stupid method, judged by UA, comes from a large front end:

    1. /***************************************************
    2. * * return type of access (WAP web)
    3. * * December 2, 2012 22:21:20
    4. * * December 3, 2012 22:30:00
    5. ***************************************************/
    6. function yundanran_get_access_type()
    7. {
    8. $is _wap=false;
    9. $user _agent = $_server[' http_user_agent '];
    10. $mobile _agents = Array
    11. (
    12. "240x320","Acer","Acoon","acs-","Abacho","Ahong", "Airness",
    13. "Alcatel","Amoi","Android","anywhereyougo.com","applewebkit/525",
    14. "applewebkit/532","Asus","audio","Au-mic","Avantogo",
    15. "Becker","BenQ","Bilbo","Bird","BlackBerry","Blazer"," Bleu ",
    16. "cdm-","Compal","Coolpad","Danger","Dbtel","Dopod" ,"Elaine",
    17. "Eric","Etouch","Fly","Fly_","fly-","Go.web"," Goodaccess ",
    18. "Gradiente","Grundig","Haier","Hedy","Hitachi","HTC" ,
    19. "Huawei" , "Hutchison" Span class= "pun" >, "Inno" , "ipad" , "iPAQ" , "ipod" , "Jbrowser" Span class= "pun",
    20. "KDDI" , "KGT" , "KWC" , "Lenovo" ,< span class= "str" > "LG" , "LG2" , "LG3" , "LG4" , "LG5"
    21. "Lg7","Lg8","Lg9","lg-","lge-","Lge9","Longcos", "Maemo",
    22. "Mercator","Meridian","Micromax","MIDP","Mini","Mitsu" ,
    23. "MMM","MMP","mobi","mot-","moto","nec-","NetFront" ,"Newgen",
    24. "Nexian","Nf-browser","Nintendo","Nitro","Nokia","Nook" ,
    25. "Novarra","Obigo","Palm","Panasonic","Pantech","Philips",
    26. "Phone","pg-","PlayStation","pocket","pt-","qc-", "Qtek",
    27. "Rover","Sagem","sama","Samu","Sanyo","Samsung","sch-" ,
    28. "Scooter","sec-","Sendo","sgh-","sharp","Siemens", "sie-",
    29. "SoftBank","Sony","Spice","Sprint","SPV","Symbian"," Tablet ",
    30. "Talkabout","tcl-","Teleca","Telit","Tianyu","tim-" ,"Toshiba",
    31. "TSM","Up.browser","Utec","Utstar","Verykool","Virgin", "vk-",
    32. "Voda","Voxtel","VX","WAP","Wellco","Wig Browser", "Wii",
    33. "Windows CE","wireless","XDA","Xde","ZTE"
    34. );
    35. $is _wap = false;
    36. foreach ($mobile _agents as $device)
    37. {
    38. if (stristr($user _agent, $device))
    39. {
    40. $is _wap = true;
    41. break;
    42. }
    43. }
    44. return $is _wap?' WAP ':' web ';
    45. }
    46. Reprinted from Http://qianduanblog.com/post/php-get-access-source.html

PHP Access Source (WAP access, PC Web Access)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.