long2ip issue
Colatino opened this issue · 3 comments
Priority
Low
Area
Admin
What OS are you seeing the problem on?
Windows
Browser
Chrome
What happened?
A bug happened!
While trying to edit players on the Admin panel there was the following error:
Exception class: TypeError()
long2ip(): Argument #1 ($ip) must be of type int, string given
File: D:\Andre\OT13\UniServerZ\www\system\functions.php
Line: 66
Backtrace:
#0 D:\Andre\OT13\UniServerZ\www\system\functions.php(66): long2ip()
#1 D:\Andre\OT13\UniServerZ\www\admin\pages\players.php(700): longToIp()
#2 D:\Andre\OT13\UniServerZ\www\admin\index.php(62): include('...')
#3 {main}
I fixed it by changing this line to this:
value="<?= (strlen($player->getLastIP()) > 11) ? inet_ntop($player->getLastIP()) : longToIp(intval($player->getLastIP())); ?>"
I'm running MyAAC on Uniform server and PHP 8.1.6
Code of Conduct
- I agree to follow this project's Code of Conduct
I didn't clone the repo, I got it from another website and it's probably an older version. In the current version the longtoip
function is present but on line 82 and it is the same as my version and it still calls for PHP's long2ip
, that is the real cause of the trouble.
Maybe updating the repo would solve the issue and maybe using PHP 7.4 would solve the problem but requirements say 7.4 or later.
I think maybe my "solution" make it more compatible.
I didn't clone the repo, I got it from another website and it's probably an older version. In the current version the
longtoip
function is present but on line 82 and it is the same as my version and it still calls for PHP'slong2ip
, that is the real cause of the trouble.Maybe updating the repo would solve the issue and maybe using PHP 7.4 would solve the problem but requirements say 7.4 or later.
I think maybe my "solution" make it more compatible.
Yes. I saw your fix in player.php
the function longToIp() explodes an $ip string in long2ip() function.
I think the validation could be in function longToIp($ip)
to check if string or int before cast.