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

IP위에 접속경로를 보여주고 싶은데요.

namtann엣네이트닷컴
· 13년 전 · 1993 · 1
이미지 3.jpg
배추빌더에 스킨을 추가했는데요.

>IP위에 접속경로를 보여주고 싶은데요.(자바스크립트로다가...)

>최근접속 순으로 소팅하고 싶은데요.

지도부탁드립니다.


<?
/* 출처:freeimage.kr 이곳이고요 그누보드사이트 로빈아빠님의 자료를 조금 수정한 것입니다. */
$sub_menu = "200810";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");
$g4[title] = "IP별 방문통계";
include_once("./admin.head.php");

$colspan = 7;
?>

<table width=100% cellpadding=0 cellspacing=1>
<tr>
<td colspan='<?=$colspan?>' align="left">

<?
if (!$sdate) $sdate=date("Y-m-d");

$dir="$g4[path]/data/visit/$sdate";
$afile=array();
if (is_dir($dir)) {
if ($dh = @opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (substr($file,0,3)!="ip.") continue;
$ip=str_replace(".txt","",substr($file,3));
$filename="$dir/$file";
$visit=file_get_contents($filename);
$afile[$ip]=$visit;
}
closedir($dh);
}
}
arsort($afile);

$i=0;
$list=array();
foreach($afile as $ip=>$visit) {
$filename="$dir/ip.$ip.txt";
$mtime=filemtime($filename);
$list[$i][ip]=$ip;
$list[$i][visit]=$visit;
$list[$i][filename]=$filename;
$list[$i][mtime]=$mtime;
$list[$i][date]=date("Y-m-d H:i:s",$mtime);

$row=sql_fetch("select * from $g4[visit_table] where vi_ip='$ip' limit 1");
//방문자가 누구인가 파악
if (!$row) $list[$i][who] = '-';
//else if (preg_match("/bot|slurp/i", $row[vi_agent])) $list[$i][who] = '웹로봇';
else if (strstr($g4[ip],"211.172.253.19")) $list[$i][who] = '다음로봇'; //다음
else if (strstr($g4[ip],"222.231.40.")) $list[$i][who] = '다음로봇'; //다음
else if (strstr($g4[ip],"121.254.193.")) $list[$i][who] = '다음로봇'; //다음 121.254.193.211
else if (strstr($g4[ip],"116.125.142.")) $list[$i][who] = '네이트로봇'; //네이트 116.125.142.201
else if(preg_match("/windows nt 6\.0/i", $row[vi_agent])) $list[$i][who] = "Vis";
else if(preg_match("/windows nt 6\.1/i", $row[vi_agent])) $list[$i][who] = "Win7";
else if(preg_match("/windows nt 5\.1/i", $row[vi_agent])) $list[$i][who] = "XP";
else if(preg_match("/windows/i", $row[vi_agent])) $list[$i][who] = "Win";
//else if(preg_match("/mozilla/i", $row[vi_agent])) $list[$i][who] = "Moz";
//else $list[$i][who] = "Etc";

if (strstr($row[vi_agent],"MSIE 9.0;")) $list[$i][who].=" IE 9";
else if (strstr($row[vi_agent],"MSIE 8.0;")) $list[$i][who].=" IE 8";
else if (strstr($row[vi_agent],"MSIE 7.0;")) $list[$i][who].=" IE 7";
else if (strstr($row[vi_agent],"MSIE 6.0;")) $list[$i][who].=" IE 6";

$row2=sql_fetch("select * from $g4[login_table] where lo_ip='$ip' limit 1");
if ($row2[mb_id]) $list[$i][mb_id]=$row2[mb_id];

if ($list[$i][mb_id]) $row3=sql_fetch("select * from $g4[member_table] where mb_id = '{$list[$i][mb_id]}' limit 1");
else {
$row3[out]='*';
$row3=sql_fetch("select * from $g4[member_table] where mb_login_ip = '$ip' limit 1");
}

$list[$i][mb_id]=$row3[mb_id]?$row3[out].$row3[mb_id]:"-";
$list[$i][mb_nick]=$row3[mb_nick]?$row3[mb_nick]:"-";
$i++;
}

echo "<form method=get><input name='sdate' value='$sdate' size=11>";

?>

<a href="javascript:win_calendar('sdate', document.getElementById('sdate').value, '-');"><img src='<?=$g4[admin_path]?>/img/calendar.gif' border=0 align=absmiddle title='달력 - 날짜를 선택하세요'></a>&nbsp;&nbsp;&nbsp;<input type=image src='<?=$g4[admin_path]?>/img/btn_search.gif' align=absmiddle>&nbsp;&nbsp;&nbsp;&nbsp;( ./ data / visit / 일자별 폴더로 저장되니 기간이 오래된 것은 지우세요.)</form></td></tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='bgcol1 bold col1 ht center'>
<td width="50">순위</td>
<td width="150">아이피</td>
<td width="70">카운트</td>
<td width="130">최근접속</td>
<td width="70">접속 OS</td>
<td width="100">아이디</td>
<td width="100"><font color="red">닉네임</font></td>
</tr>


<?
foreach($list as $i=>$row) {
$no_list = $i+1;

echo "
<tr class='bgcol1 bold col1 ht center'>
<td width=50>$no_list</td>
<td width=150>$row[ip]</td>
<td width=70>$row[visit]</td>
<td width=130>".substr($row[date],5)."</td>
<td width=70>$row[who]</td>
<td width=100>$row[mb_id]</td>
<td width=100>$row[mb_nick]</td>
</tr>";
}
?>

<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
</table>

<?
include_once("./admin.tail.php");
?>

댓글 작성

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

로그인하기

댓글 1개

위에 보여주신 소스는 접속자 정보가 들어있는 테이블에서 불러와서 보여주는 역할을 합니다.

접속경로가 db에 있지 않기 때문에 위 소스 수정만으로는 해결안됩니다.



$g4[visit_table]가 가르키는 테이블에 접속경로 필드를 추가하시고, 그 필드에는

$_SERVER['REQUEST_URI'] 를 이용하여 현재 접속중인 경로를 입력하시면 됩니다.

그리고, 마지막으로 위 소스에서 해당 필드를 호출하여 표시하시면 됩니다.



p.s : 위 기능이 꼭 필요한것이 아이라면 접속자 정보테이블은 이용하지 마시고 구글 어날리틱스를 이용하시는 걸 추천합니다. 시간이 지나면 접속자 정보 테이블이 용량을 매우 많이 차지하게 됩니다.

그리고 구글 어날리틱스도 요즘은 실시간 접속현황 제공합니다. (베타)

게시글 목록

번호 제목
284508
284499
284492
284490
284484
284481
284478
284476
284474
284472
284470
284458
284457
284454
284453
284447
284446
284444
284441
284440