Add includes/functions.php

This commit is contained in:
2026-06-15 09:36:18 +02:00
parent edde051845
commit 23dd1b312e
+32
View File
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
function sanitize(string $value): string
{
return htmlspecialchars(
trim($value),
ENT_QUOTES,
'UTF-8'
);
}
function usernameToFolder(
string $username
): string {
return preg_replace(
'/[^a-zA-Z0-9_-]/',
'',
strtolower($username)
);
}
function userPath(
string $username
): string {
return USERS_PATH .
'/' .
usernameToFolder($username);
}