간단한 사이트 작업일 경우
데이타 베이스를 사용하지 않고 현재 접속자를 출력하는 방법입니다.
아래의 예제는
현재 접속 경로와 리퍼러를 출력하는 예제입니다.
<?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>';
}
?>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7730 | 10년 전 | 1309 | ||
| 7729 | 10년 전 | 1150 | ||
| 7728 |
잘살아보자
|
10년 전 | 603 | |
| 7727 |
잘살아보자
|
10년 전 | 497 | |
| 7726 |
잘살아보자
|
10년 전 | 828 | |
| 7725 |
잘살아보자
|
10년 전 | 557 | |
| 7724 |
잘살아보자
|
10년 전 | 471 | |
| 7723 |
잘살아보자
|
10년 전 | 533 | |
| 7722 |
잘살아보자
|
10년 전 | 479 | |
| 7721 |
잘살아보자
|
10년 전 | 511 | |
| 7720 |
잘살아보자
|
10년 전 | 469 | |
| 7719 |
비긴어게인
|
10년 전 | 692 | |
| 7718 |
|
10년 전 | 2539 | |
| 7717 |
잘살아보자
|
10년 전 | 651 | |
| 7716 |
잘살아보자
|
10년 전 | 404 | |
| 7715 |
잘살아보자
|
10년 전 | 432 | |
| 7714 |
잘살아보자
|
10년 전 | 500 | |
| 7713 | 10년 전 | 1787 | ||
| 7712 | 10년 전 | 1717 | ||
| 7711 | 10년 전 | 1103 | ||
| 7710 | 10년 전 | 1402 | ||
| 7709 | 10년 전 | 1521 | ||
| 7708 | 10년 전 | 1463 | ||
| 7707 | 10년 전 | 858 | ||
| 7706 |
별지기천사
|
10년 전 | 571 | |
| 7705 | 10년 전 | 1079 | ||
| 7704 |
ICONdesignstudio
|
10년 전 | 625 | |
| 7703 | 10년 전 | 595 | ||
| 7702 |
|
10년 전 | 729 | |
| 7701 | 10년 전 | 1417 | ||
| 7700 | 10년 전 | 1108 | ||
| 7699 | 10년 전 | 583 | ||
| 7698 | 10년 전 | 1145 | ||
| 7697 | 10년 전 | 5167 | ||
| 7696 | 10년 전 | 659 | ||
| 7695 | 10년 전 | 1689 | ||
| 7694 | 10년 전 | 1062 | ||
| 7693 | 10년 전 | 1559 | ||
| 7692 | 10년 전 | 1299 | ||
| 7691 | 10년 전 | 825 | ||
| 7690 | 10년 전 | 1393 | ||
| 7689 | 10년 전 | 1019 | ||
| 7688 | 10년 전 | 617 | ||
| 7687 |
파랑새1597
|
10년 전 | 598 | |
| 7686 | 10년 전 | 855 | ||
| 7685 | 10년 전 | 1345 | ||
| 7684 | 10년 전 | 802 | ||
| 7683 | 10년 전 | 1099 | ||
| 7682 | 10년 전 | 1023 | ||
| 7681 | 10년 전 | 666 | ||
| 7680 | 10년 전 | 992 | ||
| 7679 | 10년 전 | 507 | ||
| 7678 | 10년 전 | 742 | ||
| 7677 | 10년 전 | 637 | ||
| 7676 |
|
10년 전 | 948 | |
| 7675 |
|
10년 전 | 1177 | |
| 7674 | 10년 전 | 1052 | ||
| 7673 | 10년 전 | 755 | ||
| 7672 | 10년 전 | 1093 | ||
| 7671 | 10년 전 | 893 | ||
| 7670 | 10년 전 | 658 | ||
| 7669 |
mashmellow
|
10년 전 | 1234 | |
| 7668 | 10년 전 | 721 | ||
| 7667 | 10년 전 | 1013 | ||
| 7666 |
senseme
|
10년 전 | 657 | |
| 7665 | 10년 전 | 508 | ||
| 7664 | 10년 전 | 1899 | ||
| 7663 |
mixx애교
|
10년 전 | 985 | |
| 7662 | 10년 전 | 1045 | ||
| 7661 |
hkhkah
|
10년 전 | 792 | |
| 7660 | 10년 전 | 1068 | ||
| 7659 |
커네드커네드
|
10년 전 | 934 | |
| 7658 |
바람돌이팡
|
10년 전 | 679 | |
| 7657 | 10년 전 | 1168 | ||
| 7656 | 10년 전 | 1575 | ||
| 7655 | 10년 전 | 997 | ||
| 7654 |
개발짜증나
|
10년 전 | 859 | |
| 7653 |
네이비칼라
|
10년 전 | 880 | |
| 7652 |
밥먹고합시다
|
10년 전 | 815 | |
| 7651 |
플라이SINJI
|
10년 전 | 1514 | |
| 7650 |
개발짜증나
|
10년 전 | 1419 | |
| 7649 | 10년 전 | 454 | ||
| 7648 |
이미영ㅇㅇ
|
10년 전 | 866 | |
| 7647 | 10년 전 | 441 | ||
| 7646 | 10년 전 | 809 | ||
| 7645 | 10년 전 | 2325 | ||
| 7644 | 10년 전 | 825 | ||
| 7643 |
|
10년 전 | 2874 | |
| 7642 | 10년 전 | 1513 | ||
| 7641 | 10년 전 | 1140 | ||
| 7640 |
개발짜증나
|
10년 전 | 476 | |
| 7639 |
|
10년 전 | 816 | |
| 7638 |
개발짜증나
|
10년 전 | 1135 | |
| 7637 | 10년 전 | 1554 | ||
| 7636 | 10년 전 | 2916 | ||
| 7635 | 10년 전 | 1696 | ||
| 7634 | 10년 전 | 1887 | ||
| 7633 | 10년 전 | 2343 | ||
| 7632 | 10년 전 | 3951 | ||
| 7631 |
|
10년 전 | 1540 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기