不要
This commit is contained in:
16
util.php
16
util.php
@@ -178,12 +178,11 @@ function assert_unless_success(Result $assertion, Throwable|string|null $descrip
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AUTH_ENABLED) {
|
function getcookie(string $name): string|null {
|
||||||
function getcookie(string $name): string|null {
|
|
||||||
return $_COOKIE[$name] ?? null;
|
return $_COOKIE[$name] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function namecolor(\stdClass $userData): string {
|
function namecolor(\stdClass $userData): string {
|
||||||
$ban = "#888888";
|
$ban = "#888888";
|
||||||
$male = "#97ACEF";
|
$male = "#97ACEF";
|
||||||
$female = "#F185C9";
|
$female = "#F185C9";
|
||||||
@@ -200,9 +199,9 @@ if (AUTH_ENABLED) {
|
|||||||
$suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん');
|
$suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん');
|
||||||
|
|
||||||
return $color.$suffix;
|
return $color.$suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_csrf_token(?bool $force = false): string {
|
function make_csrf_token(?bool $force = false): string {
|
||||||
if (null !== getcookie('csrf_token') && !$force) return getcookie('csrf_token');
|
if (null !== getcookie('csrf_token') && !$force) return getcookie('csrf_token');
|
||||||
$token = bin2hex(random_bytes(32));
|
$token = bin2hex(random_bytes(32));
|
||||||
setcookie('csrf_token', $token, [
|
setcookie('csrf_token', $token, [
|
||||||
@@ -214,11 +213,10 @@ if (AUTH_ENABLED) {
|
|||||||
'samesite' => 'Strict'
|
'samesite' => 'Strict'
|
||||||
]);
|
]);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify_csrf_token(string $token): bool {
|
function verify_csrf_token(string $token): bool {
|
||||||
return null !== getcookie('csrf_token') && hash_equals(getcookie('csrf_token'), $token);
|
return null !== getcookie('csrf_token') && hash_equals(getcookie('csrf_token'), $token);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function count_special_chars(string $str): int {
|
function count_special_chars(string $str): int {
|
||||||
|
|||||||
Reference in New Issue
Block a user