2014-12-01, 07:10 PM
Hi!
Short description:
When searching for an IP-Range in ModCP there will never be any "user results", only posts.
Long description:
Today I stumbled upon a bug with the IP-Search feature in the ModCP. Whenever I enter an IP-Range as the search parameter (e.g. 123.123.123.*), the search will never return any users. Even if there is a user with regIp or lastIp 123.123.123.123 that can be found by only searching for 123.123.123.123
The problem lies within the code of modcp.php close to line ~3700:
The if's with the "strcmp" will never return true, because they basically do (for my example from above):
which can't ever evaluate to true.
MyBB Version:
I'm using the newest version of MyBB, which is currently 1.8.3.
The bug was introduced to 1.8 when the IPv6 support was added last year, but I guess nobody noticed it because that feature isn't used very often.
Possible fix:
The bug can be fixed by switching ">=" with "<=" and vice versa everywhere in the code snippet above. Alternatively switch the 0 and 1 indexes around in the $ip_range[] arrays. Or changing the order of the parameters for the strcmp methods.
I chose to go with the first solution and the search now works correctly for my forum, resulting in matching users found by regIp and lastIp when searching by IP-Range.
Short description:
When searching for an IP-Range in ModCP there will never be any "user results", only posts.
Long description:
Today I stumbled upon a bug with the IP-Search feature in the ModCP. Whenever I enter an IP-Range as the search parameter (e.g. 123.123.123.*), the search will never return any users. Even if there is a user with regIp or lastIp 123.123.123.123 that can be found by only searching for 123.123.123.123
The problem lies within the code of modcp.php close to line ~3700:
if(is_array($ip_range))
{
if(strcmp($ip_range[0], $ipaddress['regip']) >= 0 && strcmp($ip_range[1], $ipaddress['regip']) <= 0)
{
eval("\$subject = \"".$templates->get("modcp_ipsearch_result_regip")."\";");
$ip = my_inet_ntop($db->unescape_binary($ipaddress['regip']));
}
elseif(strcmp($ip_range[0], $ipaddress['lastip']) >= 0 && strcmp($ip_range[1], $ipaddress['lastip']) <= 0)
{
eval("\$subject = \"".$templates->get("modcp_ipsearch_result_lastip")."\";");
$ip = my_inet_ntop($db->unescape_binary($ipaddress['lastip']));
}
}
The if's with the "strcmp" will never return true, because they basically do (for my example from above):
if(123.123.123.0 >= 123.123.123.123 && 123.123.123.255 <= 123.123.123.123)
which can't ever evaluate to true.
MyBB Version:
I'm using the newest version of MyBB, which is currently 1.8.3.
The bug was introduced to 1.8 when the IPv6 support was added last year, but I guess nobody noticed it because that feature isn't used very often.
Possible fix:
The bug can be fixed by switching ">=" with "<=" and vice versa everywhere in the code snippet above. Alternatively switch the 0 and 1 indexes around in the $ip_range[] arrays. Or changing the order of the parameters for the strcmp methods.
I chose to go with the first solution and the search now works correctly for my forum, resulting in matching users found by regIp and lastIp when searching by IP-Range.