From 13281a33075129c0fddb47c212ccbcc10de57778 Mon Sep 17 00:00:00 2001 From: usushshwhshs Date: Mon, 13 Jan 2025 22:36:35 +0300 Subject: [PATCH] Create amora --- .github/amora | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/amora diff --git a/.github/amora b/.github/amora new file mode 100644 index 0000000..fcbf4ba --- /dev/null +++ b/.github/amora @@ -0,0 +1,40 @@ + $value) { + $data_check_arr[] = $key . '=' . $value; + } + sort($data_check_arr); + $data_check_string = implode("\n", $data_check_arr); + $secret_key = hash('sha256', BOT_TOKEN, true); + $hash = hash_hmac('sha256', $data_check_string, $secret_key); + if (strcmp($hash, $check_hash) !== 0) { + throw new Exception('Data is NOT from Telegram'); + } + if ((time() - $auth_data['auth_date']) > 86400) { + throw new Exception('Data is outdated'); + } + return $auth_data; +} + +function saveTelegramUserData($auth_data) { + $auth_data_json = json_encode($auth_data); + setcookie('tg_user', $auth_data_json); +} + + +try { + $auth_data = checkTelegramAuthorization($_GET); + saveTelegramUserData($auth_data); +} catch (Exception $e) { + die ($e->getMessage()); +} + +header('Location: login_example.php'); + +?>