현재 접속자를 보니 참 아름다운 봇 입니다. 모두 다 로봇만 있다는. ㅠㅠ...
현재 접속자가 갑자기 급증해서 원인을 알아보려고 만든 팁 입니다.
g4_login 테이블에 필드를 추가 합니다.
ALTER TABLE `g4_login` ADD `lo_referer` TEXT NOT NULL ,
ADD `lo_agent` VARCHAR( 255 ) NOT NULL ;
ADD `lo_agent` VARCHAR( 255 ) NOT NULL ;
tail.sub.php
tail.sub.php에 g4_login 필드 넣는 코드를 추가 합니다 (불당팩 기준입니다).
// 사이트를 방문하게 되면 처음 한번 insert가 되고, 이후에는 계속 update가 이루어 집니다. 따라서 무조건 update를 먼저하게 하는게 속도를 더 빠르게 합니다.
$tmp_sql = " update $g4[login_table] set mb_id = '$member[mb_id]', lo_datetime = '$g4[time_ymdhis]', lo_location = '$lo_location', lo_url = '$lo_url', lo_referer='$referer', lo_agent='$user_agent' where lo_ip = '$remote_addr' ";
sql_query($tmp_sql, FALSE);
$tmp_sql = " update $g4[login_table] set mb_id = '$member[mb_id]', lo_datetime = '$g4[time_ymdhis]', lo_location = '$lo_location', lo_url = '$lo_url', lo_referer='$referer', lo_agent='$user_agent' where lo_ip = '$remote_addr' ";
sql_query($tmp_sql, FALSE);
// update가 안되는 경우에는 insert를 합니다.
if (!mysql_affected_rows())
{
$tmp_sql = " insert into $g4[login_table] ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '$remote_addr', '$member[mb_id]', '$g4[time_ymdhis]', '$lo_location', '$lo_url', '$referer', '$user_agent' ) ";
sql_query($tmp_sql, FALSE);
if (!mysql_affected_rows())
{
$tmp_sql = " insert into $g4[login_table] ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '$remote_addr', '$member[mb_id]', '$g4[time_ymdhis]', '$lo_location', '$lo_url', '$referer', '$user_agent' ) ";
sql_query($tmp_sql, FALSE);
// 시간이 지난 접속은 삭제한다
sql_query(" delete from $g4[login_table] where lo_datetime < '".date("Y-m-d H:i:s", $g4[server_time] - (60 * $config[cf_login_minutes]))."' ");
sql_query(" delete from $g4[login_table] where lo_datetime < '".date("Y-m-d H:i:s", $g4[server_time] - (60 * $config[cf_login_minutes]))."' ");
skin/current/basic/current_connect.skin.php를 수정 합니다.
위치를 보면 아실 겁니다.
// bot을 구분 합니다.
$bot = "";
if (preg_match('/Googlebot/', $list[$i][lo_agent]))
$bot = "Google-bot";
else if (preg_match('/bingbot/', $list[$i][lo_agent]))
$bot = "bingbot";
else if (preg_match('/Yeti/', $list[$i][lo_agent]))
$bot = "Naver-bot";
$bot = "";
if (preg_match('/Googlebot/', $list[$i][lo_agent]))
$bot = "Google-bot";
else if (preg_match('/bingbot/', $list[$i][lo_agent]))
$bot = "bingbot";
else if (preg_match('/Yeti/', $list[$i][lo_agent]))
$bot = "Naver-bot";
// 최고관리자에게만 허용
// 이 조건문은 가능한 변경하지 마십시오.
if ($bot)
echo "<td colspan=2> {$bot}</td>";
else if ($is_admin == "super" && $list[$i][lo_url])
echo "<td colspan=2> <a href='{$list[$i][lo_url]}'>{$location}</a></td>";
else
echo "<td colspan=2> {$location}</td>";
// 이 조건문은 가능한 변경하지 마십시오.
if ($bot)
echo "<td colspan=2> {$bot}</td>";
else if ($is_admin == "super" && $list[$i][lo_url])
echo "<td colspan=2> <a href='{$list[$i][lo_url]}'>{$location}</a></td>";
else
echo "<td colspan=2> {$location}</td>";
- opencode.co.kr -