From a6446be4bee19a616cde6da9b0c47bdeaf845624 Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 4 Nov 2024 20:03:23 +0100 Subject: [PATCH] fixes #2265 no longer truncate IP at 15 chars --- include/functions.inc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index 794037bb0..0eae796e3 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -463,14 +463,11 @@ UPDATE '.USER_INFOS_TABLE.' } $ip = $_SERVER['REMOTE_ADDR']; - // In case of "too long" ipv6 address, we take only the 15 first chars. - // - // It would be "cleaner" to increase length of history.IP to 50 chars, but - // the alter table is very long on such a big table. We should plan this - // for a future version, once history table is kept "smaller". - if (strpos($ip,':') !== false and strlen($ip) > 15) + // IPv6 should not be longer than 39 chars, and that is the maximum length of + // the column in the database, but in case it would be longer, let's truncate it. + if (strlen($ip) > 39) { - $ip = substr($ip, 0, 15); + $ip = substr($ip, 0, 39); } // If plugin developers add their own sections, Piwigo will automatically add it in the history.section enum column