간단한 사이트 작업일 경우
데이타 베이스를 사용하지 않고 현재 접속자를 출력하는 방법입니다.
아래의 예제는
현재 접속 경로와 리퍼러를 출력하는 예제입니다.
<?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>';
}
?>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6730 |
|
11년 전 | 1105 | |
| 6729 | 11년 전 | 558 | ||
| 6728 |
|
11년 전 | 573 | |
| 6727 | 11년 전 | 2419 | ||
| 6726 | 11년 전 | 596 | ||
| 6725 |
네모웹에이전시
|
11년 전 | 434 | |
| 6724 |
네모웹에이전시
|
11년 전 | 882 | |
| 6723 | 11년 전 | 1012 | ||
| 6722 | 11년 전 | 960 | ||
| 6721 | 11년 전 | 640 | ||
| 6720 | 11년 전 | 1971 | ||
| 6719 | 11년 전 | 2192 | ||
| 6718 | 11년 전 | 1092 | ||
| 6717 |
|
11년 전 | 651 | |
| 6716 | 11년 전 | 2311 | ||
| 6715 | 11년 전 | 7578 | ||
| 6714 | 11년 전 | 2043 | ||
| 6713 | 11년 전 | 773 | ||
| 6712 |
geektoo
|
11년 전 | 1150 | |
| 6711 | 11년 전 | 894 | ||
| 6710 |
sirzzang
|
11년 전 | 2126 | |
| 6709 |
bewitched
|
11년 전 | 1800 | |
| 6708 |
levin
|
11년 전 | 561 | |
| 6707 | 11년 전 | 766 | ||
| 6706 | 11년 전 | 1785 | ||
| 6705 | 11년 전 | 986 | ||
| 6704 |
|
11년 전 | 752 | |
| 6703 | 11년 전 | 413 | ||
| 6702 | 11년 전 | 1093 | ||
| 6701 | 11년 전 | 803 | ||
| 6700 | 11년 전 | 1719 | ||
| 6699 | 11년 전 | 715 | ||
| 6698 |
이박사친구
|
11년 전 | 725 | |
| 6697 | 11년 전 | 1218 | ||
| 6696 | 11년 전 | 618 | ||
| 6695 |
Header
|
11년 전 | 704 | |
| 6694 | 11년 전 | 1160 | ||
| 6693 |
|
11년 전 | 1103 | |
| 6692 | 11년 전 | 1139 | ||
| 6691 | 11년 전 | 1286 | ||
| 6690 |
|
11년 전 | 711 | |
| 6689 | 11년 전 | 895 | ||
| 6688 | 11년 전 | 928 | ||
| 6687 | 11년 전 | 530 | ||
| 6686 |
RGB255
|
11년 전 | 962 | |
| 6685 |
|
11년 전 | 639 | |
| 6684 | 11년 전 | 716 | ||
| 6683 | 11년 전 | 382 | ||
| 6682 | 11년 전 | 1125 | ||
| 6681 | 11년 전 | 1407 | ||
| 6680 | 11년 전 | 434 | ||
| 6679 |
RGB255
|
11년 전 | 380 | |
| 6678 | 11년 전 | 1342 | ||
| 6677 |
|
11년 전 | 426 | |
| 6676 | 11년 전 | 1011 | ||
| 6675 |
디자이너필이
|
11년 전 | 822 | |
| 6674 | 11년 전 | 1242 | ||
| 6673 | 11년 전 | 1314 | ||
| 6672 | 11년 전 | 6023 | ||
| 6671 | 11년 전 | 1333 | ||
| 6670 |
하프의정령
|
11년 전 | 563 | |
| 6669 | 11년 전 | 412 | ||
| 6668 |
공부하고가겠슴다
|
11년 전 | 441 | |
| 6667 |
하프의정령
|
11년 전 | 543 | |
| 6666 | 11년 전 | 786 | ||
| 6665 | 11년 전 | 1409 | ||
| 6664 | 11년 전 | 914 | ||
| 6663 | 11년 전 | 1138 | ||
| 6662 | 11년 전 | 406 | ||
| 6661 |
basketball
|
11년 전 | 506 | |
| 6660 | 11년 전 | 2505 | ||
| 6659 | 11년 전 | 1603 | ||
| 6658 |
|
11년 전 | 1317 | |
| 6657 |
|
11년 전 | 3149 | |
| 6656 | 11년 전 | 560 | ||
| 6655 |
프로프리랜서
|
11년 전 | 2332 | |
| 6654 |
프로프리랜서
|
11년 전 | 1905 | |
| 6653 |
프로프리랜서
|
11년 전 | 1745 | |
| 6652 |
프로프리랜서
|
11년 전 | 1823 | |
| 6651 |
|
11년 전 | 773 | |
| 6650 | 11년 전 | 1314 | ||
| 6649 | 11년 전 | 1313 | ||
| 6648 | 11년 전 | 808 | ||
| 6647 | 11년 전 | 3155 | ||
| 6646 | 11년 전 | 459 | ||
| 6645 | 11년 전 | 963 | ||
| 6644 |
BBAYOUNG
|
11년 전 | 1365 | |
| 6643 | 12년 전 | 1785 | ||
| 6642 | 12년 전 | 635 | ||
| 6641 | 12년 전 | 1332 | ||
| 6640 | 12년 전 | 700 | ||
| 6639 | 12년 전 | 2317 | ||
| 6638 |
jasmin2
|
12년 전 | 744 | |
| 6637 |
geektoo
|
12년 전 | 440 | |
| 6636 | 12년 전 | 656 | ||
| 6635 |
프로프리랜서
|
12년 전 | 2225 | |
| 6634 |
프로프리랜서
|
12년 전 | 1738 | |
| 6633 |
프로프리랜서
|
12년 전 | 4056 | |
| 6632 |
프로프리랜서
|
12년 전 | 1345 | |
| 6631 |
프로프리랜서
|
12년 전 | 1779 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기