간단한 사이트 작업일 경우
데이타 베이스를 사용하지 않고 현재 접속자를 출력하는 방법입니다.
아래의 예제는
현재 접속 경로와 리퍼러를 출력하는 예제입니다.
<?php
//현재 접속자 상세정보 가졍오기
//Yget_filelist_in_dir 함수에 의존성을 갖는다.
//Yread_file 함수에 의존성을 갖는다.
function Yin_user($dir_session){
$time1 = 60 * 10;//활동중인 현재 접속자 기준 1분
$time2 = 60 * 20;//현재접속자의 기준 5분
if (empty($dir_session)) return Array();
if (!is_dir($dir_session)) return Array();
$dir_array = Yget_filelist_in_dir($dir_session);
$return = Array();
$i = 1;
foreach($dir_array as $val){
if (filemtime($val) < (time() - $time2)) continue;
if (filemtime($val) > (time() - $time1)) {
$text = Yread_file($val);
$return[$i]['active'] = 'Active!!';
preg_match("`s_location\|s:.+:\"(.+)\";`U", $text, $m);
$m[1] = trim($m[1]);
$return[$i]['location'] = (!empty($m[1])) ? $m[1] : '위치정보 없음';
preg_match("`s_referer\|s:.+:\"(.+)\";`U", $text, $m);
$m[1] = trim($m[1]);
$return[$i]['referer'] = (!empty($m[1])) ? $m[1] : 'Direct!!';
}
else {
$text = Yread_file($val);
$return[$i]['active'] = 'Inactive!!';
preg_match("`s_location\|s:.+:\"(.+)\";`U", $text, $m);
$m[1] = trim($m[1]);
$return[$i]['location'] = (!empty($m[1])) ? $m[1] : '위치정보 없음';
preg_match("`s_referer\|s:.+:\"(.+)\";`U", $text, $m);
$m[1] = trim($m[1]);
$return[$i]['referer'] = (!empty($m[1])) ? $m[1] : 'Direct!!';
}
$i++;
}
return $return;
}
//넘어온 디렉토리의 모든 일차 파일리스트를 배열로 반환
function Yget_filelist_in_dir($dir_path){
$dir_path = preg_replace("`/+$`", '', $dir_path);
if(!is_dir($dir_path)) return Array();
$return_file = Array();
$d = dir($dir_path) or die('해당 디렉토리(' . $dir_path . ')를 열수 없습니다.');
while (false !== ($entry = $d->read())) {
$temp_file = $dir_path . '/' . $entry;
if (is_file($temp_file) && !preg_match("`\.$`", $temp_file)) {
$return_file[] = $temp_file;
}
}
$d->close();
return $return_file;
}
//로컬파일 읽어오기
function Yread_file ($read_file_path){
if (empty($read_file_path) || !file_exists($read_file_path)) return false;
if (is_readable($read_file_path) !== true) die('해당 파일(' . $read_file_path . ')은 읽을 권한이 없는 파일입니다.');
$fr = fopen($read_file_path, "r") or die('해당 파일(' . $read_file_path . ')을 열수 없습니다.');
if (empty($fr)) return false;
$filesize = filesize($read_file_path);
if (empty($filesize)) $filesize = 1024;
$read_text = fread($fr, $filesize);
fclose($fr);
if (empty($read_text)) return false;
return $read_text;
}
//각 페이지 접속시 세션 시작 이후 페이지 로케이션을 세션으로 저장한 경우 사용할수 있습니다.
//저같은 경우
if (empty($title)) $location = $_SERVER['PHP_SELF'];
else $location = $title;
$_SESSION['s_location'] = $location;
if (!empty($_SERVER['HTTP_REFERER']) && !preg_match("`^https?://(www\.)?chancein\.com`i", $_SERVER['HTTP_REFERER'])) $_SESSION['s_referer'] = $_SERVER['HTTP_REFERER'];
unset($location);
//현재 접속자 가져오기, 세션을 저장하는 디렉토리 경로를 절대경로 or 상대경로로서 인자로 넘김, $dir_data_session
//출력
$current = Yin_user($dir_data_session);
foreach($current as $k =>$v){
echo '<b>' . $k . '.</b> [<b>' . $v['active'] . '</b>] ' . $v['location'] . '<br> [<b>referer</b>] ' . $v['referer'] . '<br><br>';
}
?>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7030 | 11년 전 | 1403 | ||
| 7029 |
|
11년 전 | 3240 | |
| 7028 |
|
11년 전 | 1137 | |
| 7027 | 11년 전 | 1005 | ||
| 7026 | 11년 전 | 2082 | ||
| 7025 |
어려워요잉
|
11년 전 | 2738 | |
| 7024 | 11년 전 | 2103 | ||
| 7023 | 11년 전 | 3131 | ||
| 7022 |
Shhhh
|
11년 전 | 1526 | |
| 7021 |
|
11년 전 | 3269 | |
| 7020 | 11년 전 | 785 | ||
| 7019 |
막돼먹은영애
|
11년 전 | 1081 | |
| 7018 | 11년 전 | 1954 | ||
| 7017 | 11년 전 | 2313 | ||
| 7016 | 11년 전 | 1021 | ||
| 7015 | 11년 전 | 2825 | ||
| 7014 | 11년 전 | 3029 | ||
| 7013 | 11년 전 | 1518 | ||
| 7012 |
|
11년 전 | 2193 | |
| 7011 | 11년 전 | 1049 | ||
| 7010 | 11년 전 | 1402 | ||
| 7009 |
|
11년 전 | 1071 | |
| 7008 | 11년 전 | 2262 | ||
| 7007 | 11년 전 | 2180 | ||
| 7006 |
|
11년 전 | 1169 | |
| 7005 | 11년 전 | 5305 | ||
| 7004 | 11년 전 | 2353 | ||
| 7003 | 11년 전 | 3064 | ||
| 7002 | 11년 전 | 1914 | ||
| 7001 | 11년 전 | 952 | ||
| 7000 | 11년 전 | 2037 | ||
| 6999 |
|
11년 전 | 2158 | |
| 6998 | 11년 전 | 1876 | ||
| 6997 |
네이비칼라
|
11년 전 | 1490 | |
| 6996 | 11년 전 | 951 | ||
| 6995 |
|
11년 전 | 1848 | |
| 6994 | 11년 전 | 2573 | ||
| 6993 |
kimsdesign
|
11년 전 | 1296 | |
| 6992 |
|
11년 전 | 2773 | |
| 6991 | 11년 전 | 1717 | ||
| 6990 | 11년 전 | 4470 | ||
| 6989 | 11년 전 | 1848 | ||
| 6988 |
네이비컬러
|
11년 전 | 2507 | |
| 6987 | 11년 전 | 3723 | ||
| 6986 |
잘살아보자
|
11년 전 | 1591 | |
| 6985 |
잘살아보자
|
11년 전 | 2467 | |
| 6984 | 11년 전 | 817 | ||
| 6983 |
천재조상훈
|
11년 전 | 1850 | |
| 6982 |
천재조상훈
|
11년 전 | 4482 | |
| 6981 |
천재조상훈
|
11년 전 | 1608 | |
| 6980 |
|
11년 전 | 1866 | |
| 6979 |
|
11년 전 | 747 | |
| 6978 |
잘살아보자
|
11년 전 | 1137 | |
| 6977 |
잘살아보자
|
11년 전 | 1465 | |
| 6976 |
잘살아보자
|
11년 전 | 1570 | |
| 6975 |
천재조상훈
|
11년 전 | 1475 | |
| 6974 |
잘살아보자
|
11년 전 | 2230 | |
| 6973 |
잘살아보자
|
11년 전 | 1153 | |
| 6972 |
잘살아보자
|
11년 전 | 3068 | |
| 6971 |
잘살아보자
|
11년 전 | 3273 | |
| 6970 |
잘살아보자
|
11년 전 | 1838 | |
| 6969 |
잘살아보자
|
11년 전 | 4760 | |
| 6968 | 11년 전 | 9893 | ||
| 6967 |
|
11년 전 | 2629 | |
| 6966 |
|
11년 전 | 1110 | |
| 6965 | 11년 전 | 3256 | ||
| 6964 | 11년 전 | 2578 | ||
| 6963 | 11년 전 | 2100 | ||
| 6962 |
star3840
|
11년 전 | 1015 | |
| 6961 | 11년 전 | 4240 | ||
| 6960 |
|
11년 전 | 713 | |
| 6959 | 11년 전 | 1236 | ||
| 6958 |
|
11년 전 | 1665 | |
| 6957 | 11년 전 | 1888 | ||
| 6956 |
잘살아보자
|
11년 전 | 1849 | |
| 6955 | 11년 전 | 4624 | ||
| 6954 | 11년 전 | 1625 | ||
| 6953 |
잘살아보자
|
11년 전 | 859 | |
| 6952 |
잘살아보자
|
11년 전 | 2042 | |
| 6951 | 11년 전 | 1609 | ||
| 6950 | 11년 전 | 2610 | ||
| 6949 |
잘살아보자
|
11년 전 | 883 | |
| 6948 | 11년 전 | 1552 | ||
| 6947 | 11년 전 | 1464 | ||
| 6946 | 11년 전 | 1603 | ||
| 6945 | 11년 전 | 1227 | ||
| 6944 | 11년 전 | 1184 | ||
| 6943 | 11년 전 | 1229 | ||
| 6942 | 11년 전 | 1569 | ||
| 6941 | 11년 전 | 1656 | ||
| 6940 | 11년 전 | 1752 | ||
| 6939 | 11년 전 | 1663 | ||
| 6938 | 11년 전 | 1940 | ||
| 6937 | 11년 전 | 1149 | ||
| 6936 | 11년 전 | 1346 | ||
| 6935 | 11년 전 | 1298 | ||
| 6934 | 11년 전 | 1465 | ||
| 6933 | 11년 전 | 1972 | ||
| 6932 | 11년 전 | 1529 | ||
| 6931 | 11년 전 | 1534 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기