isp 위치확인 소스
페이지 정보
작성자 최고관리자 댓글 0건 조회 83회 작성일 25-10-25 14:01본문

function get_ipinfo($ip)
{
if ($ip == "") return false;
$sql = "SELECT * FROM typing_ipinfo WHERE ii_ip = '".$ip."'";
$row = sql_fetch($sql);
if ($row) {
$data = json_decode($row['ii_info'], true);
} else {
// 외부 API 호출
$url = 'https://ipinfo.io/'.$ip.'/json?token=';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode != 200 || !$response) {
return false;
}
$data = json_decode($response, true);
$escaped_response = addslashes($response);
$sql = "INSERT INTO typing_ipinfo
SET ii_ip = '".$ip."', ii_info = '".$escaped_response."', ii_datetime = '".G5_TIME_YMDHIS."'";
sql_query($sql, false);
}
if (!isset($data['region']) || !isset($data['city']) || !isset($data['loc'])) {
return "위치 정보 없음";
}
$region = htmlspecialchars($data['region'], ENT_QUOTES, 'UTF-8');
$city = htmlspecialchars($data['city'], ENT_QUOTES, 'UTF-8');
$loc = htmlspecialchars($data['loc'], ENT_QUOTES, 'UTF-8');
$str = $region . " " . $city . " ";
$str .= "<a href='https://maps.google.com/?q={$loc}&ll={$loc}&z=8' target='_blank'>(map)</a>";
return $str;
}
댓글목록
등록된 댓글이 없습니다.


