use str_starts_with() now that we are on php8
This commit is contained in:
parent
52c178e460
commit
021bc3041c
|
@ -16,18 +16,14 @@ function getUserIpAddr() {
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_ban_info($name, $email) {
|
function add_ban_info($name, $email): void
|
||||||
|
{
|
||||||
$user_ip = getUserIpAddr();
|
$user_ip = getUserIpAddr();
|
||||||
$user_info = "$name - $email - $user_ip";
|
$user_info = "$name - $email - $user_ip";
|
||||||
file_put_contents("/var/signups_banned", $user_info.PHP_EOL, FILE_APPEND);
|
file_put_contents("/var/signups_banned", $user_info.PHP_EOL, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
function starts_with($string, $prefix)
|
function is_ssh_pubkey($string): bool
|
||||||
{
|
|
||||||
return mb_substr($string, 0, mb_strlen($prefix)) === $prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_ssh_pubkey($string)
|
|
||||||
{
|
{
|
||||||
// list from sshd(8)
|
// list from sshd(8)
|
||||||
$valid_pubkeys = [
|
$valid_pubkeys = [
|
||||||
|
@ -42,7 +38,8 @@ function is_ssh_pubkey($string)
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($valid_pubkeys as $pub)
|
foreach ($valid_pubkeys as $pub)
|
||||||
if (starts_with($string, $pub)) return true;
|
if (str_starts_with($string, $pub)) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue