
<?php

include "config.php";
include "telegram.php";

if(
    !isset($_SESSION['consent']) ||
    $_SESSION['consent'] !== true
){
    exit;
}

$event =
$_GET['type'] ??
$_POST['event'] ??
'Unknown Event';

$ip =
$_SERVER['REMOTE_ADDR'] ?? 'Unknown';

$userAgent =
$_SERVER['HTTP_USER_AGENT'] ?? 'Unknown';

$time =
date("Y-m-d H:i:s");

function getBrowser($agent){

    if(
        stripos($agent,'Edge') !== false
    ){
        return 'Edge';
    }

    if(
        stripos($agent,'Chrome') !== false
    ){
        return 'Chrome';
    }

    if(
        stripos($agent,'Firefox') !== false
    ){
        return 'Firefox';
    }

    if(
        stripos($agent,'Safari') !== false
    ){
        return 'Safari';
    }

    return 'Unknown';
}

$browser =
getBrowser($userAgent);

$device =
preg_match('/mobile/i',$userAgent)
? 'Mobile'
: 'Desktop';

$message = "

SECURE PORTAL EVENT

Event:
{$event}

IP Address:
{$ip}

Device:
{$device}

Browser:
{$browser}

Timestamp:
{$time}

Consent:
APPROVED

";

sendTelegramMessage($message);


