PHP & Others

핸드폰별로 페이지 자동이동 소스

페이지 정보

본문

아래의 소스(ASP,PHP,jSP)들은 접속하는 핸드폰별로
해당통신사가 지원하는 언어(wml,m-html,hdml..)에 맞게
자동으로 페이지를 이동하는 소스입니다.

ASP

default.asp 예제
<%
accept = Request.ServerVariables("HTTP_ACCEPT")
agent = Request.ServerVariables("HTTP_USER_AGENT")
subno = Request.ServerVariables("HTTP_X_UP_SUBNO")
row = Request.ServerVariables("ALL_RAW")

if InStr(agent,"SK") >= 1 Then
'011인 경우
response.Redirect "http://www.babosoft.com/mobile/wml/index.asp"
elseif InStr(subno,"itouch") >= 1 or InStr(subno,"ezweb") >= 1 Then
'017,019인 경우
response.Redirect "http://www.babosoft.com/mobile/hdml/index.asp"
elseif InStr(agent,"MSMB") >= 1 Then
'016,018인 경우
response.Redirect "http://www.babosoft.com/mobile/mhtml/index.asp"
elseif InStr(agent,"UP.Browser/3.1") >= 1 Then
'UP브라우저3.1 for hdml인 경우
response.Redirect "http://www.babosoft.com/mobile/hdml/index.asp"
elseif InStr(agent,"UP.Browser/3.2") >= 1 Then
'UP브라우저3.2 for hdml인 경우
response.Redirect "http://www.babosoft.com/mobile/hdml/index.asp"
elseif InStr(agent,"UP.Browser/4.0") >= 1 Then
'UP브라우저4인 경우
response.Redirect "http://www.babosoft.com/mobile/wml/index.asp"
elseif InStr(agent,"Mozilla") >= 1 Then
'일반 브라우저인 경우
response.Redirect "http://www.babosoft.com/mobile/mhtml/index.asp"
end if
%>

PHP
default.php 예제
<?PHP
$phone1 = strchr($HTTP_ACCEPT,"SK");
$phone2 = strchr($HTTP_X_UP_SUBNO,"itouch");
$phone3 = strchr($HTTP_X_UP_SUBNO,"ezweb");
$phone4 = strchr($HTTP_USER_AGENT,"MSMB");
$pos = strchr($HTTP_USER_AGENT,"Mozilla");
$pos1 = strchr($HTTP_USER_AGENT,"UP.Browser/3.1");
$pos3 = strchr($HTTP_USER_AGENT,"UP.Browser/3.2");
$pos2 = strchr($HTTP_USER_AGENT,"UP.Browser/4.0");

if (strlen($phone1) >=2) {
//011인 경우
$redirect = "http://www.babosoft.com/mobile/wml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($phone2) >=5) {
//017인 경우
$redirect = "http://www.babosoft.com/mobile/hdml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($phone3) >=4) {
//019인 경우
$redirect = "http://www.babosoft.com/mobile/hdml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($phone4) >=4) {
//016,018,MBPHONE인 경우
$redirect = "http://www.babosoft.com/mobile/mhtml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($pos2) >=5) {
//up4.0
$redirect = "http://www.babosoft.com/mobile/wml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($pos1) >=5) {
//up3.1
$redirect = "http://www.babosoft.com/mobile/hdml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($pos3) >=5) {
//up3.2
$redirect = "http://www.babosoft.com/mobile/hdml/index.asp";
header("Location: ".$redirect); }
elseif (strlen($pos) >=5) {
//IE or Netscape
$redirect = "http://www.babosoft.com/mobile/html/index.asp";
header("Location: ".$redirect); }
?>


JSP

default.jsp 예제
<%@ page import="java.util.*" %>
<%
String agent = request.getHeader("user-agent");
String accept = request.getHeader("accept");

if(agent.indexOf("SK") >= 0){
'011
response.sendRedirect( "http://www.babosoft.com/mobile/wml/index.asp");
}else if(accept.indexOf("image/vnd.wap.wbmp") >= 0){
'017,019
response.sendRedirect( "http://www.babosoft.com/mobile/hdml/index.asp");
}else if(agent.indexOf("MSMB") >= 0){
'016,018
response.sendRedirect( "http://www.babosoft.com/mobile/mhtml/index.asp");
}else if(agent.indexOf("UP.Browser/3.1") >= 0){
'UP3.1 for hdml
response.sendRedirect(" http://www.babosoft.com/mobile/hdml/index.asp");
}else if(agent.indexOf("UP.Browser/3.2") >= 0){
'UP3.2 for hdml
response.sendRedirect( "http://www.babosoft.com/mobile/hdml/index.asp");
}else if(agent.indexOf("UP.Browser/4.0") >= 0){
'UP4
response.sendRedirect( "http://www.babosoft.com/mobile/wml/index.asp");
}else if(agent.indexOf("Mozilla") >= 0){
'ie or Netscape
response.sendRedirect( "http://www.babosoft.com/mobile/mhtml/index.asp");
}
%>

출처 : http://www.babosoft.com

관련자료

등록된 댓글이 없습니다.
Today's proverb
어떤 일을 할 수 없다고 생각하고 있는 동안은 사실은 그것을 하기 싫다고 다짐하고 있는 것이다. (스피노자)