방문자 목록 표시 코드 개선 [code by ChatGPT]
그누보드 관리자 페이지의 방문자 분석 페이지를 보는데, os, 와 브라우저 정보가 제대로 표시되지 않습니다.
os 정보와 브라우저 파싱함수인 get_os(), get_brow() 함수가 오래전에 만들어져서 최신 user-agent 를 제대로 처리하지 못하네요.
방문자 정보를 제대로 표시하기 위해서 visit.lib.php 코드중 일부를 개선해보았습니다.
/lib/visit.lib.php[code] function get_brow($agent) { $agent = strtolower($agent); if (preg_match("/msie ([1-9][0-9]\.[0-9]+)/", $agent, $m)) { $s = 'IE '.$m[1]; } else if (preg_match("/trident\/.*rv:([1-9][0-9]\.[0-9]+)/", $agent, $m)) { $s = 'IE '.$m[1]; } // For IE 11 else if (preg_match("/edge\/([0-9\.]+)/", $agent, $m)) { $s = 'Edge '.$m[1]; } else if (preg_match("/edg\/([0-9\.]+)/", $agent, $m)) { $s = 'Edge(Chromium) '.$m[1]; } // For Chromium-based Edge else if (preg_match("/firefox\/([0-9\.]+)/", $agent, $m)) { $s = 'Firefox '.$m[1]; } else if (preg_match("/chrome\/([0-9\.]+)/", $agent, $m)) { $s = 'Chrome '.$m[1]; } else if (preg_match("/safari\/([0-9\.]+)/", $agent, $m)) { $s = 'Safari '.$m[1]; } else if (preg_match("/opera\/([0-9\.]+)/", $agent, $m)) { $s = 'Opera '.$m[1]; } else if (preg_match("/opr\/([0-9\.]+)/", $agent, $m)) { $s = 'Opera(Chromium) '.$m[1]; } // For Chromium-based Opera else if (preg_match("/bot|slurp|crawler|spider/", $agent)) { $s = 'Robot'; } else { $s = '기타'; } return $s; } function get_os($agent) { $agent = strtolower($agent); if (preg_match("/windows nt 10\.0/", $agent)) { $s = "Windows 10"; } else if (preg_match("/windows nt ([0-9]\.[0-9])/", $agent, $matches)) { $s = "Windows NT ".$matches[1]; } else if (preg_match("/windows nt/", $agent)) { $s = "Windows NT"; } else if (preg_match("/windows ([0-9]+)/", $agent, $matches)) { $s = "Windows ".$matches[1]; } else if (preg_match("/windows/", $agent)) { $s = "Windows"; } else if (preg_match("/android ([0-9\.]+)/", $agent, $matches)) { $s = "Android ".$matches[1]; } else if (preg_match("/android/", $agent)) { $s = "Android"; } else if (preg_match("/iphone os ([0-9_]+)/", $agent, $matches)) { $s = "iOS ".str_replace("_", ".", $matches[1]); } else if (preg_match("/iphone/", $agent)) { $s = "iOS"; } else if (preg_match("/ipad/", $agent)) { $s = "iPadOS"; } else if (preg_match("/mac os x ([0-9_]+)/", $agent, $matches)) { $s = "macOS ".str_replace("_", ".", $matches[1]); } else if (preg_match("/macintosh|mac os x/", $agent)) { $s = "macOS"; } else { $s = "기타"; } return $s; } [/code]
프롬프트는
https://sir.kr/so_ai/27
에서 확인 하실수 있습니다.
댓글 7개
2년 전
감사 합니다.
2년 전
감사합니다. ^^
2년 전
감사합니다.
marty72
2년 전
감사합니다 ^^
2년 전
감사합니다.
민트다이어리
2년 전
감사합니다. ^^
2년 전
감사합니다
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4402 | ||
| 2454 |
|
1년 전 | 1124 | |
| 2453 | 1년 전 | 1057 | ||
| 2452 | 1년 전 | 1623 | ||
| 2451 | 1년 전 | 1155 | ||
| 2450 | 1년 전 | 958 | ||
| 2449 | 1년 전 | 1338 | ||
| 2448 | 1년 전 | 884 | ||
| 2447 | 1년 전 | 1339 | ||
| 2446 | 1년 전 | 1416 | ||
| 2445 | 1년 전 | 1129 | ||
| 2444 | 1년 전 | 1284 | ||
| 2443 | 1년 전 | 1678 | ||
| 2442 | 1년 전 | 1488 | ||
| 2441 | 1년 전 | 1071 | ||
| 2440 | 1년 전 | 1179 | ||
| 2439 | 1년 전 | 4621 | ||
| 2438 | 1년 전 | 1078 | ||
| 2437 | 1년 전 | 1118 | ||
| 2436 | 1년 전 | 928 | ||
| 2435 | 1년 전 | 1562 | ||
| 2434 | 1년 전 | 1455 | ||
| 2433 | 1년 전 | 1019 | ||
| 2432 |
|
1년 전 | 613267 | |
| 2431 |
|
1년 전 | 1095 | |
| 2430 |
|
1년 전 | 1708 | |
| 2429 | 1년 전 | 1313 | ||
| 2428 | 1년 전 | 1273 | ||
| 2427 | 1년 전 | 1150 | ||
| 2426 | 1년 전 | 1112 | ||
| 2425 |
뽕엄능브라
|
1년 전 | 1235 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기