ip 기록

This commit is contained in:
2026-02-17 22:31:08 +09:00
parent e51bc6f711
commit 5b13f8bd30
3 changed files with 3 additions and 21 deletions
+1 -1
View File
@@ -1047,7 +1047,7 @@ function increaseRefresh($type = "", $cnt = 1)
$logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql'); $logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql');
$ip = $_SERVER['REMOTE_ADDR'] ?? 'local'; $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'local';
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
$logDB->insert('api_log', [ $logDB->insert('api_log', [
+1 -1
View File
@@ -73,7 +73,7 @@ class APIHelper
$logPath = "{$rootPath}/d_log/{$realYearMonth}_api_log.db"; $logPath = "{$rootPath}/d_log/{$realYearMonth}_api_log.db";
} }
$logDB = FileDB::db($logPath, __DIR__ . '/../../f_install/sql/api_log.sql'); $logDB = FileDB::db($logPath, __DIR__ . '/../../f_install/sql/api_log.sql');
$ip = $_SERVER['REMOTE_ADDR'] ?? 'local'; $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'local';
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
//NOTE: array_merge([], {})의 상황이 가능함. //NOTE: array_merge([], {})의 상황이 가능함.
+1 -19
View File
@@ -947,31 +947,13 @@ class Util
return $flattened; return $flattened;
} }
/**
* Returns the IP address of the client.
*
* @param boolean $trust_proxy_headers Whether or not to trust the
* proxy headers HTTP_CLIENT_IP
* and HTTP_X_FORWARDED_FOR. ONLY
* use if your server is behind a
* proxy that sets these values
* @return string
*/
public static function get_client_ip($trust_proxy_headers = false) public static function get_client_ip($trust_proxy_headers = false)
{ {
if (!$trust_proxy_headers) { if (!$trust_proxy_headers) {
return $_SERVER['REMOTE_ADDR']; return $_SERVER['REMOTE_ADDR'];
} }
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'local';
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
} }
/** /**