mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Fix php8 uncaught fatal error: Unsupported operand types string * int
This commit is contained in:
parent
a69bf2c6dd
commit
6b01e6afae
1 changed files with 9 additions and 5 deletions
|
@ -52,11 +52,15 @@ function mask2cidr($mask)
|
|||
*/
|
||||
function cidr2mask($cidr)
|
||||
{
|
||||
$ta = substr ($cidr, strpos ($cidr, '/') + 1) * 1;
|
||||
$netmask = str_split (str_pad (str_pad ('', $ta, '1'), 32, '0'), 8);
|
||||
foreach ($netmask as &$element)
|
||||
$element = bindec ($element);
|
||||
return join ('.', $netmask);
|
||||
$ipParts = explode('/', $cidr);
|
||||
$ip = $ipParts[0];
|
||||
$prefixLength = $ipParts[1];
|
||||
|
||||
$ipLong = ip2long($ip);
|
||||
$netmaskLong = bindec(str_pad(str_repeat('1', $prefixLength), 32, '0'));
|
||||
$netmask = long2ip($netmaskLong);
|
||||
|
||||
return $netmask;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue