간단한 사이트 작업일 경우
데이타 베이스를 사용하지 않고 현재 접속자를 출력하는 방법입니다.
아래의 예제는
현재 접속 경로와 리퍼러를 출력하는 예제입니다.
<?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>';
}
?>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 630 | 19년 전 | 2363 | ||
| 629 |
|
19년 전 | 2025 | |
| 628 |
|
19년 전 | 3136 | |
| 627 |
|
19년 전 | 2038 | |
| 626 |
|
19년 전 | 2071 | |
| 625 |
|
19년 전 | 1732 | |
| 624 |
|
19년 전 | 2241 | |
| 623 | 19년 전 | 2211 | ||
| 622 |
|
19년 전 | 2517 | |
| 621 |
|
19년 전 | 2926 | |
| 620 |
|
19년 전 | 2420 | |
| 619 | 19년 전 | 2489 | ||
| 618 | 19년 전 | 3520 | ||
| 617 |
|
19년 전 | 3242 | |
| 616 |
|
19년 전 | 3231 | |
| 615 |
|
19년 전 | 3056 | |
| 614 |
|
19년 전 | 2053 | |
| 613 |
|
19년 전 | 2393 | |
| 612 |
|
19년 전 | 2246 | |
| 611 |
|
19년 전 | 2093 | |
| 610 |
|
19년 전 | 2529 | |
| 609 |
|
19년 전 | 2438 | |
| 608 |
|
19년 전 | 2825 | |
| 607 | 19년 전 | 2201 | ||
| 606 | 19년 전 | 3545 | ||
| 605 | 19년 전 | 2001 | ||
| 604 | 19년 전 | 2616 | ||
| 603 | 19년 전 | 1627 | ||
| 602 |
|
19년 전 | 2848 | |
| 601 | 19년 전 | 3078 | ||
| 600 |
|
19년 전 | 2158 | |
| 599 | 19년 전 | 2010 | ||
| 598 | 19년 전 | 2493 | ||
| 597 | 19년 전 | 2400 | ||
| 596 |
|
19년 전 | 3084 | |
| 595 |
|
19년 전 | 6770 | |
| 594 | 19년 전 | 2719 | ||
| 593 | 19년 전 | 3195 | ||
| 592 |
|
19년 전 | 3098 | |
| 591 |
|
19년 전 | 1946 | |
| 590 | 19년 전 | 3372 | ||
| 589 | 19년 전 | 2222 | ||
| 588 |
|
19년 전 | 2708 | |
| 587 | 19년 전 | 2351 | ||
| 586 |
|
19년 전 | 4372 | |
| 585 | 19년 전 | 2501 | ||
| 584 | 19년 전 | 2772 | ||
| 583 |
|
19년 전 | 3537 | |
| 582 |
|
19년 전 | 3728 | |
| 581 |
|
19년 전 | 3264 | |
| 580 | 19년 전 | 2490 | ||
| 579 | 19년 전 | 3092 | ||
| 578 | 19년 전 | 3999 | ||
| 577 | 19년 전 | 3829 | ||
| 576 | 19년 전 | 1768 | ||
| 575 |
|
19년 전 | 2228 | |
| 574 |
|
19년 전 | 5408 | |
| 573 | 19년 전 | 6740 | ||
| 572 | 19년 전 | 2582 | ||
| 571 | 19년 전 | 2118 | ||
| 570 | 19년 전 | 2605 | ||
| 569 | 19년 전 | 3317 | ||
| 568 | 19년 전 | 3547 | ||
| 567 | 19년 전 | 2988 | ||
| 566 | 19년 전 | 2610 | ||
| 565 |
|
19년 전 | 4731 | |
| 564 |
|
19년 전 | 6742 | |
| 563 |
|
19년 전 | 5017 | |
| 562 |
|
19년 전 | 5964 | |
| 561 |
|
19년 전 | 2711 | |
| 560 |
|
19년 전 | 2563 | |
| 559 |
|
19년 전 | 2234 | |
| 558 |
|
19년 전 | 2310 | |
| 557 | 19년 전 | 4599 | ||
| 556 |
|
19년 전 | 4677 | |
| 555 | 19년 전 | 2517 | ||
| 554 | 19년 전 | 2185 | ||
| 553 | 19년 전 | 2532 | ||
| 552 |
|
19년 전 | 3178 | |
| 551 | 19년 전 | 2949 | ||
| 550 |
|
19년 전 | 1907 | |
| 549 |
|
19년 전 | 1972 | |
| 548 |
|
19년 전 | 3159 | |
| 547 |
|
19년 전 | 2361 | |
| 546 |
|
19년 전 | 3633 | |
| 545 |
|
19년 전 | 2569 | |
| 544 |
|
19년 전 | 1860 | |
| 543 |
|
19년 전 | 2462 | |
| 542 |
|
19년 전 | 1738 | |
| 541 |
|
19년 전 | 1417 | |
| 540 |
|
19년 전 | 1560 | |
| 539 |
|
19년 전 | 1812 | |
| 538 |
|
19년 전 | 1595 | |
| 537 |
|
19년 전 | 1802 | |
| 536 |
|
19년 전 | 1571 | |
| 535 |
|
19년 전 | 1965 | |
| 534 |
|
19년 전 | 1853 | |
| 533 |
|
19년 전 | 1460 | |
| 532 |
|
19년 전 | 1452 | |
| 531 |
|
19년 전 | 1373 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기