Add includes/functions.php
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user