diff options
| author | ilotterytea <iltsu@alright.party> | 2025-03-20 02:48:10 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-03-20 02:48:10 +0500 |
| commit | f3e0c1a833fac6982d524df172ee61f220492d42 (patch) | |
| tree | 5e5f8ba377d3039efee381ad8009b15012fbb1fe /lib/utils.php | |
| parent | 66a0a296b6608c30b14d1b8ffa7fa709e806c1ff (diff) | |
feat: random file names
Diffstat (limited to 'lib/utils.php')
| -rw-r--r-- | lib/utils.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/utils.php b/lib/utils.php index b5f8431..af8cc2f 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -1,4 +1,6 @@ <?php +include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php'; + function json_response(mixed $data, string|null $message, int $code = 200) { http_response_code($code); @@ -8,4 +10,15 @@ function json_response(mixed $data, string|null $message, int $code = 200) 'message' => $message, 'data' => $data ]); +} + +function generate_random_char_sequence(array $chars, int $length): string +{ + $o = ""; + + for ($i = 0; $i < $length; $i++) { + $o .= $chars[random_int(0, count($chars) - 1)]; + } + + return $o; }
\ No newline at end of file |
