간단한 사이트 작업일 경우
데이타 베이스를 사용하지 않고 현재 접속자를 출력하는 방법입니다.
아래의 예제는
현재 접속 경로와 리퍼러를 출력하는 예제입니다.
<?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>';
}
?>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7430 |
|
10년 전 | 4922 | |
| 7429 | 10년 전 | 1750 | ||
| 7428 |
멋진남자임
|
11년 전 | 1126 | |
| 7427 |
sdflksdj2
|
11년 전 | 788 | |
| 7426 | 11년 전 | 1328 | ||
| 7425 | 11년 전 | 1355 | ||
| 7424 | 11년 전 | 1021 | ||
| 7423 |
SeungYeon
|
11년 전 | 539 | |
| 7422 | 11년 전 | 778 | ||
| 7421 |
sdflksdj2
|
11년 전 | 656 | |
| 7420 | 11년 전 | 945 | ||
| 7419 |
|
11년 전 | 1362 | |
| 7418 |
멋진남자임
|
11년 전 | 1377 | |
| 7417 | 11년 전 | 573 | ||
| 7416 |
senseme
|
11년 전 | 1191 | |
| 7415 | 11년 전 | 938 | ||
| 7414 | 11년 전 | 688 | ||
| 7413 | 11년 전 | 4820 | ||
| 7412 | 11년 전 | 4388 | ||
| 7411 |
holla
|
11년 전 | 870 | |
| 7410 | 11년 전 | 4215 | ||
| 7409 | 11년 전 | 3902 | ||
| 7408 | 11년 전 | 4250 | ||
| 7407 | 11년 전 | 5032 | ||
| 7406 | 11년 전 | 4701 | ||
| 7405 | 11년 전 | 4263 | ||
| 7404 | 11년 전 | 727 | ||
| 7403 | 11년 전 | 5643 | ||
| 7402 | 11년 전 | 1470 | ||
| 7401 |
|
11년 전 | 949 | |
| 7400 | 11년 전 | 2953 | ||
| 7399 |
멋진남자임
|
11년 전 | 882 | |
| 7398 |
파랑새1597
|
11년 전 | 2631 | |
| 7397 | 11년 전 | 2232 | ||
| 7396 |
basketball
|
11년 전 | 1329 | |
| 7395 | 11년 전 | 1572 | ||
| 7394 | 11년 전 | 895 | ||
| 7393 | 11년 전 | 2041 | ||
| 7392 | 11년 전 | 819 | ||
| 7391 |
잘살아보자
|
11년 전 | 5327 | |
| 7390 |
잘살아보자
|
11년 전 | 2191 | |
| 7389 |
잘살아보자
|
11년 전 | 3301 | |
| 7388 |
파랑새1597
|
11년 전 | 898 | |
| 7387 | 11년 전 | 1074 | ||
| 7386 |
프리랜서퍼블리셔
|
11년 전 | 949 | |
| 7385 | 11년 전 | 1553 | ||
| 7384 |
울라라라우
|
11년 전 | 874 | |
| 7383 | 11년 전 | 1519 | ||
| 7382 |
잘살아보자
|
11년 전 | 4200 | |
| 7381 |
잘살아보자
|
11년 전 | 1964 | |
| 7380 |
잘살아보자
|
11년 전 | 1918 | |
| 7379 |
잘살아보자
|
11년 전 | 5877 | |
| 7378 |
senseme
|
11년 전 | 1852 | |
| 7377 |
잘살아보자
|
11년 전 | 2710 | |
| 7376 | 11년 전 | 2364 | ||
| 7375 |
잘살아보자
|
11년 전 | 1023 | |
| 7374 |
잘살아보자
|
11년 전 | 3119 | |
| 7373 |
잘살아보자
|
11년 전 | 2452 | |
| 7372 |
잘살아보자
|
11년 전 | 5817 | |
| 7371 |
잘살아보자
|
11년 전 | 3441 | |
| 7370 |
잘살아보자
|
11년 전 | 1885 | |
| 7369 |
잘살아보자
|
11년 전 | 2146 | |
| 7368 |
ksdhtm56
|
11년 전 | 525 | |
| 7367 | 11년 전 | 1391 | ||
| 7366 | 11년 전 | 905 | ||
| 7365 | 11년 전 | 3509 | ||
| 7364 |
잘살아보자
|
11년 전 | 1359 | |
| 7363 |
잘살아보자
|
11년 전 | 1327 | |
| 7362 |
잘살아보자
|
11년 전 | 1469 | |
| 7361 | 11년 전 | 3568 | ||
| 7360 | 11년 전 | 3532 | ||
| 7359 | 11년 전 | 3359 | ||
| 7358 |
멋진남자임
|
11년 전 | 998 | |
| 7357 | 11년 전 | 3381 | ||
| 7356 | 11년 전 | 2581 | ||
| 7355 | 11년 전 | 3154 | ||
| 7354 |
파랑새1597
|
11년 전 | 623 | |
| 7353 |
잘살아보자
|
11년 전 | 2395 | |
| 7352 |
잘살아보자
|
11년 전 | 2385 | |
| 7351 |
잘살아보자
|
11년 전 | 2460 | |
| 7350 |
잘살아보자
|
11년 전 | 1438 | |
| 7349 |
잘살아보자
|
11년 전 | 1928 | |
| 7348 |
잘살아보자
|
11년 전 | 1246 | |
| 7347 |
잘살아보자
|
11년 전 | 1055 | |
| 7346 |
멋진남자임
|
11년 전 | 1627 | |
| 7345 | 11년 전 | 956 | ||
| 7344 | 11년 전 | 3837 | ||
| 7343 | 11년 전 | 3607 | ||
| 7342 | 11년 전 | 1235 | ||
| 7341 | 11년 전 | 2487 | ||
| 7340 |
|
11년 전 | 901 | |
| 7339 | 11년 전 | 1713 | ||
| 7338 | 11년 전 | 3319 | ||
| 7337 | 11년 전 | 3615 | ||
| 7336 | 11년 전 | 4541 | ||
| 7335 | 11년 전 | 936 | ||
| 7334 | 11년 전 | 1500 | ||
| 7333 | 11년 전 | 2905 | ||
| 7332 |
|
11년 전 | 1079 | |
| 7331 |
KeePin뽁이
|
11년 전 | 1070 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기