From 937cef38db4d7fc79c16ec53e83da47ef20e8339 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 14 Feb 2024 07:28:55 +0000 Subject: [PATCH] [db] show original client IP in postgres status --- core/dbengine.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/dbengine.php b/core/dbengine.php index 53a28136..e71c18b5 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -82,11 +82,8 @@ class PostgreSQL extends DBEngine public function init(PDO $db): void { - if (array_key_exists('REMOTE_ADDR', $_SERVER)) { - $db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); - } else { - $db->exec("SET application_name TO 'shimmie [local]';"); - } + $addr = array_key_exists('REMOTE_ADDR', $_SERVER) ? get_real_ip() : 'local'; + $db->exec("SET application_name TO 'shimmie [$addr]';"); if (defined("DATABASE_TIMEOUT")) { $this->set_timeout($db, DATABASE_TIMEOUT); }