HTTP_USER_AGENT is a global variable used to obtain information about the user's browser. We can use the value obtained by HTTP_USER_AGENT to determine whether the user is a mobile browser or a computer accessing the network. HTTP_USER_AGENT is a global variable used to obtain information about the user's browser. We can use the value obtained by HTTP_USER_AGENT to determine whether the user is a mobile browser or a computer accessing the network.
Script ec (2); script
The Code is as follows: |
|
$ UAgent = $ _ SERVER ['HTTP _ USER_AGENT ']; $ OsPat = "mozilla | mshortate | winwap | openwave | Windows NT | Windows 3.1 | 95 | Blackcomb | 98 | ME | X Window | ubuntu | Longhorn | AIX | Linux | AmigaOS | BEOS | HP-UX | OpenBSD | FreeBSD | NetBSD | OS/2 | OSF1 | SUN "; If (preg_match ("/($ osPat)/I", $ uAgent) // a browser that simulates WAP mobile Internet access; openwave | The following is a pc operating system { Echo "computer access "; } Else { Echo "mobile access "; } Echo' '. $ UAgent; |
Now we are fully writing the instance into a file.
The Code is as follows: |
|
$ Ua = strtolower ($ _ SERVER ['HTTP _ USER_AGENT ']);
$ Uachar = "/(nokia | sony | ericsson | mot | samsung | sgh | lg | philips | panasonic | alcatel | lenovo | cldc | midp | mobile | wap)/I "; If ($ ua = ''| preg_match ($ uachar, $ ua ))&&! Strpos (strtolower ($ _ SERVER ['request _ URI ']), 'wap ')) { $ Loaction = 'wap /'; If (! Empty ($ Loaction )) { Ecs_header ("Location: $ Loactionn "); Exit; } } /** * The Custom header function is used to filter potential security risks. * * @ Param string content * * @ Return void **/ Function ecs_header ($ string, $ replace = true, $ http_response_code = 0) { If (strpos ($ string, '../upgrade/index. php') = 0) { Echo'
|