Apply fixes from StyleCI (#13201)

This commit is contained in:
Jellyfrog
2021-09-08 03:33:54 +02:00
committed by GitHub
parent f3b92ce313
commit 232b9a414c
3 changed files with 10 additions and 10 deletions

View File

@@ -184,11 +184,11 @@ class TwoFactor
}
}
$hash = hash_hmac('sha1', pack('N*', 0) . pack('N*', $counter), $kbin, true);
$offset = ord($hash[19]) & 0xf;
$truncated = (((ord($hash[$offset + 0]) & 0x7f) << 24) |
((ord($hash[$offset + 1]) & 0xff) << 16) |
((ord($hash[$offset + 2]) & 0xff) << 8) |
(ord($hash[$offset + 3]) & 0xff)) % pow(10, self::OTP_SIZE);
$offset = ord($hash[19]) & 0xF;
$truncated = (((ord($hash[$offset + 0]) & 0x7F) << 24) |
((ord($hash[$offset + 1]) & 0xFF) << 16) |
((ord($hash[$offset + 2]) & 0xFF) << 8) |
(ord($hash[$offset + 3]) & 0xFF)) % pow(10, self::OTP_SIZE);
return str_pad($truncated, self::OTP_SIZE, '0', STR_PAD_LEFT);
}

View File

@@ -100,7 +100,7 @@ class IPv6 extends IP
foreach ($net_bytes as $index => $byte) {
$shift = min($cidr - 16 * ($index - 1), 16);
if ($shift > 0) {
$mask = ~(0xffff >> $shift) & 0xffff;
$mask = ~(0xFFFF >> $shift) & 0xFFFF;
$net_bytes[$index] = $byte & $mask;
} else {
$net_bytes[$index] = 0;
@@ -134,7 +134,7 @@ class IPv6 extends IP
for ($index = 1; $index <= 8; $index++) {
$shift = $cidr - 16 * ($index - 1);
if ($shift > 0) {
$mask = ~(0xffff >> $shift) & 0xffff;
$mask = ~(0xFFFF >> $shift) & 0xFFFF;
if (($net_bytes[$index] & $mask) != ($ip_bytes[$index] & $mask)) {
return false;
}

View File

@@ -675,7 +675,7 @@ function match_network($nets, $ip, $first = false)
$ip_arr = explode('/', $net);
$net_long = ip2long($ip_arr[0]);
$x = ip2long($ip_arr[1]);
$mask = long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 - $ip_arr[1]);
$mask = long2ip($x) == $ip_arr[1] ? $x : 0xFFFFFFFF << (32 - $ip_arr[1]);
$ip_long = ip2long($ip);
if ($rev) {
if (($ip_long & $mask) == ($net_long & $mask)) {
@@ -1090,8 +1090,8 @@ function guidv4($data)
// From: Jack http://stackoverflow.com/users/1338292/ja%CD%A2ck
assert(strlen($data) == 16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
$data[6] = chr(ord($data[6]) & 0x0F | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3F | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}