diff options
| author | ilotterytea <iltsu@alright.party> | 2025-12-08 21:53:36 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-12-08 21:53:36 +0500 |
| commit | 57472eab3c7b035392c6a5aa240593ecaa7d1ccf (patch) | |
| tree | 9da30829290f225be2dab3d383549cbfda82ed19 /public/captcha.php | |
| parent | 6541d0f3888862ab049055fd418b700f73eed367 (diff) | |
upd: moved all /public/ files to the root folder
Diffstat (limited to 'public/captcha.php')
| -rw-r--r-- | public/captcha.php | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/public/captcha.php b/public/captcha.php deleted file mode 100644 index b454b7d..0000000 --- a/public/captcha.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -include_once "../src/config.php"; -include_once "../src/alert.php"; -include_once "../src/captcha.php"; -include_once "../src/utils.php"; - -session_start(); - -if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["answer"])) { - if ($_POST["answer"] == ($_SESSION["captcha_word"] ?? "")) { - $_SESSION["captcha_solved"] = true; - echo json_response([ - "status_code" => 200, - "message" => "Solved!", - "data" => null - ]); - } else { - echo json_response([ - "status_code" => 400, - "message" => "Wrong answer!", - "data" => null - ], 400); - } - exit; -} - -$file_folder = $_SERVER["DOCUMENT_ROOT"] . '/static/img/captcha'; - -if (!CAPTCHA_ENABLE || ($_SESSION["captcha_solved"] ?? false) || !is_dir($file_folder)) { - $_SESSION["captcha_solved"] = true; - echo json_response([ - "status_code" => 200, - "message" => "No need to solve captcha", - "data" => null - ]); - exit; -} - -$files = scandir($file_folder); -array_splice($files, 0, 2); - -$filename = $files[random_int(0, count($files) - 1)]; -$filename = basename($filename, ".png"); - -$_SESSION["captcha_word"] = $filename; - -$image = generate_image_captcha( - CAPTCHA_SIZE[0], - CAPTCHA_SIZE[1], - random_int(1, 3), - $filename, - $file_folder -); - -echo json_response([ - "status_code" => 200, - "message" => null, - "data" => $image -]);
\ No newline at end of file |
