Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: An_dz on October 06, 2019, 12:38:34 PM

Title: IPv6 inet_aton database error on Subs.php
Post by: An_dz on October 06, 2019, 12:38:34 PM
In our forums SMF is giving the following error (nearly 100% of the times) when accessing it with an IPv6 address. No problems with IPv4.

QuoteIncorrect string value: '''' for function inet_aton
File: /home/sforum/public_html/Sources/Subs.php

The bug is happening on this part of the code:
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_online
SET log_time = {int:log_time}, ip = IFNULL(INET_ATON({string:ip}), 0), url = {string:url}
WHERE session = {string:session}',
array(
'log_time' => time(),
'ip' => $user_info['ip'],
'url' => $serialized,
'session' => $session_id,
)
);


I've tried a complete replacement of the Sources and Themes folders with unchanged files from 2.0.15 together with a clean installed.list file to disable all mods and the problem persisted. We've been doing patches since 2.0.7.

I'm puzzled on what's the problem as this part of the code is unchanged from SMF source and a complete reset of the source files still raised the bug.

The database is MySQL 5.7.27 and PHP is 7.2.7.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: shadav on October 06, 2019, 12:50:59 PM
not sure if it's the problem but 2.0.15 isn't made to work with php 7.2 .... try lowering it to 7.1 and see if there's any issues.... i'm sure it's something else but just thought i'd mention it :)
i mean it does kind of work i had it running on 7.2 but if you check your error log you'll see a bunch of depressiated errors
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: Arantor on October 06, 2019, 12:58:14 PM
Think the issue is more that 2.0 has no support for IPv6.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: An_dz on October 06, 2019, 01:06:50 PM
The PHP version was not the problem as I expected, but you never know.

Quote from: Arantor on October 06, 2019, 12:58:14 PM
Think the issue is more that 2.0 has no support for IPv6.
Yet I have no problems here, but I do on our forums.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: Shambles on October 06, 2019, 01:28:26 PM
Could give this mod a whirl

https://custom.simplemachines.org/mods/index.php?mod=3051
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: Arantor on October 06, 2019, 02:04:58 PM
Quote from: An_dz on October 06, 2019, 01:06:50 PM
The PHP version was not the problem as I expected, but you never know.

Quote from: Arantor on October 06, 2019, 12:58:14 PM
Think the issue is more that 2.0 has no support for IPv6.
Yet I have no problems here, but I do on our forums.

This forum doesn't support IPv6 either but I'll bet the handling is a bit different by way of the networking stack on the servers here.

Also do you have a reverse proxy (e.g. CloudFlare) involved? The proxied IP might not be subject to the same "nuke it" rule the normal IP would be.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: An_dz on October 06, 2019, 02:23:44 PM
Quote from: Arantor on October 06, 2019, 02:04:58 PM
Quote from: An_dz on October 06, 2019, 01:06:50 PM
Quote from: Arantor on October 06, 2019, 12:58:14 PM
Think the issue is more that 2.0 has no support for IPv6.
Yet I have no problems here, but I do on our forums.

This forum doesn't support IPv6 either but I'll bet the handling is a bit different by way of the networking stack on the servers here.

Also do you have a reverse proxy (e.g. CloudFlare) involved? The proxied IP might not be subject to the same "nuke it" rule the normal IP would be.
No reverse proxy. But that's probably the problem, though I don't think I can change that nor can I convince the server admin to do so.

Quote from: Shambles on October 06, 2019, 01:28:26 PM
Could give this mod a whirl

https://custom.simplemachines.org/mods/index.php?mod=3051
It's failing to install but it looks like it's just a single line.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: Kindred on October 09, 2019, 07:23:48 AM
So manually update that failed line and finish installing the mod.
Title: Re: IPv6 inet_aton database error on Subs.php
Post by: An_dz on October 09, 2019, 05:58:28 PM
Yes, I did try doing it but it ended up being a can of worms. Many other errors popped and I don't have the time to work on it.