Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
940 B
2
Indexable
Never
  $agent = $_SERVER['HTTP_USER_AGENT'];
 if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}
$date = date("Y-m-d H-i-s", time());
function sendMessage($chatID, $messaggio, $token) {
  
    $url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chatID;
    $url = $url . "&text=" . urlencode($messaggio);
    $ch = curl_init();
    $optArray = array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true
    );
    curl_setopt_array($ch, $optArray);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$data = $date." | ". $ip ." | ". $agent . "\n";
$file = "../../log.txt";
file_put_contents($file, $data, FILE_APPEND);
sendMessage("5091771045" ,$data,"5040258455:AAGCF01VlPX7t1aq880G1h8YJlLk7s49CQg");