테스트 사이트 - 개발 중인 베타 버전입니다

모바일 접속자수 체크 채택완료

감기약 11년 전 조회 8,120
모바일 접속자수를 체크할려면 어떻게 해야할까요?
편리님 도와주세요~~~ ^^
댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
11년 전
그누보드5의 경우
/bbs 폴더내 visit_insert_inc.php 내에
visit 테이블에 insert 하는 내용을 보시면 $user_agent  = escape_trim($_SERVER['HTTP_USER_AGENT']);
값을 테이블 저장시킵니다.
그리고 관리자 페이지 에서 브라우저별 접속자 집계화면을 보여줄때 아래와 같은 get_brow()함수를 호출해서
9가지로 나누어서만 표시해줍니다.
이 함수를 세분화 해서 모바일 AGENT로 정의한 아래 내용을 아래 함수에 추가해주고 
모바일이라고 정의하면 관리자페이지에서 모바일 접속 수를 자세히 보실수 있습니다.
define('G5_MOBILE_AGENT',   'phone|samsung|lgtel|mobile|[^A]skt|nokia|blackberry|android|sony');
예를 들자면 get_brow()함수를 구체적으로 세분화 해서
Mozilla 로 잡히는 부분을 제외시키고 디비에 저장된 agent를 분석해서 룰을 추가해주셔야됩니다.
else if(preg_match("/samsung/", $agent))            { $s = "Mobile"; }
이렇게 함수에 추가해주면 samsung agent로 들어오는 접속통계를 Mobile 브라우저로 표시되도록 할 수 있습니다.
function get_brow($agent)
{
    $agent = strtolower($agent);
    //echo $agent; echo " ";
    if (preg_match("/msie ([1-9][0-9]\.[0-9]+)/", $agent, $m)) { $s = 'MSIE '.$m[1]; }
    else if(preg_match("/firefox/", $agent))            { $s = "FireFox"; }
    else if(preg_match("/chrome/", $agent))             { $s = "Chrome"; }
    else if(preg_match("/x11/", $agent))                { $s = "Netscape"; }
    else if(preg_match("/opera/", $agent))              { $s = "Opera"; }
    else if(preg_match("/gec/", $agent))                { $s = "Gecko"; }
    else if(preg_match("/bot|slurp/", $agent))          { $s = "Robot"; }
    else if(preg_match("/internet explorer/", $agent))  { $s = "IE"; }
    else if(preg_match("/mozilla/", $agent))            { $s = "Mozilla"; }
    else { $s = "기타"; }
    return $s;
}
추가로 get_os() 함수를 아래와 같이 수정하시면 운영체제 부분에서 모바일과 모바일이 아닌 접속자수로
쉽게 구분도 가능합니다.
</div>
<div>
<div>
</div>
<div>function get_os($agent)</div>
<div>{</div>
<div>    $agent = strtolower($agent);</div>
<div>
</div>
<div>    //echo $agent; echo "
";</div>
<div>
</div>
<div>    if (preg_match("/".G5_MOBILE_AGENT."/", $agent))                 { $s = "Mobile"; }</div>
<div>    else if (preg_match("/windows 98/", $agent))                 { $s = "98"; }</div>
<div>    else if(preg_match("/windows 95/", $agent))             { $s = "95"; }</div>
<div>    else if(preg_match("/windows nt 4\.[0-9]*/", $agent))   { $s = "NT"; }</div>
<div>    else if(preg_match("/windows nt 5\.0/", $agent))        { $s = "2000"; }</div>
<div>    else if(preg_match("/windows nt 5\.1/", $agent))        { $s = "XP"; }</div>
<div>    else if(preg_match("/windows nt 5\.2/", $agent))        { $s = "2003"; }</div>
<div>    else if(preg_match("/windows nt 6\.0/", $agent))        { $s = "Vista"; }</div>
<div>    else if(preg_match("/windows nt 6\.1/", $agent))        { $s = "Windows7"; }</div>
<div>    else if(preg_match("/windows nt 6\.2/", $agent))        { $s = "Windows8"; }</div>
<div>    else if(preg_match("/windows 9x/", $agent))             { $s = "ME"; }</div>
<div>    else if(preg_match("/windows ce/", $agent))             { $s = "CE"; }</div>
<div>    else if(preg_match("/mac/", $agent))                    { $s = "MAC"; }</div>
<div>    else if(preg_match("/linux/", $agent))                  { $s = "Linux"; }</div>
<div>    else if(preg_match("/sunos/", $agent))                  { $s = "sunOS"; }</div>
<div>    else if(preg_match("/irix/", $agent))                   { $s = "IRIX"; }</div>
<div>    else if(preg_match("/bot|slurp/", $agent))              { $s = "Robot"; }</div>
<div>    else if(preg_match("/internet explorer/", $agent))      { $s = "IE"; }</div>
<div>    else if(preg_match("/mozilla/", $agent))                { $s = "Mozilla"; }</div>
<div>    else { $s = "기타"; }</div>
<div>
</div>
<div>    return $s;</div>
<div>}</div></div>
<div>
로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

감기약
11년 전
너무 감사합니다.
적용해보고 말씀 결과물 알려드리겠습니다

댓글을 작성하려면 로그인이 필요합니다.

11년 전
그누보드에는 기본적으로보바일과 웹 브라우저의 접속자를 기록하는게 없지 않나요 ?
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인