forked from team/site
1
0
Fork 0

use str_starts_with() now that we are on php8

This commit is contained in:
Ben Harris 2022-09-29 12:04:12 -04:00
parent 52c178e460
commit 021bc3041c
1 changed files with 5 additions and 8 deletions

View File

@ -16,18 +16,14 @@ function getUserIpAddr() {
return $ip;
}
function add_ban_info($name, $email) {
function add_ban_info($name, $email): void
{
$user_ip = getUserIpAddr();
$user_info = "$name - $email - $user_ip";
file_put_contents("/var/signups_banned", $user_info.PHP_EOL, FILE_APPEND);
}
function starts_with($string, $prefix)
{
return mb_substr($string, 0, mb_strlen($prefix)) === $prefix;
}
function is_ssh_pubkey($string)
function is_ssh_pubkey($string): bool
{
// list from sshd(8)
$valid_pubkeys = [
@ -42,7 +38,8 @@ function is_ssh_pubkey($string)
];
foreach ($valid_pubkeys as $pub)
if (starts_with($string, $pub)) return true;
if (str_starts_with($string, $pub)) return true;
return false;
}