Answer the question
In order to leave comments, you need to log in
Sending a form in telegram what's wrong?
I sent data to telegram, everything worked, and suddenly
the code stopped working once:
<?php
$aipi = $_SERVER['REMOTE_ADDR'];
$token = "1420262397:AAFJZEK-q3_ba3cYcqbUo9R2cz1wUCEiNcg";
$chat_id = "-253031623";
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = @$_SERVER['REMOTE_ADDR'];
$result = array('country'=>'', 'city'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)) $ip = $client;
elseif(filter_var($forward, FILTER_VALIDATE_IP)) $ip = $forward;
else $ip = $remote;
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null)
{
$result = $ip_data->geoplugin_countryCode;
}
$arr = array(
'Кто то перешёл на сайт! IP: ' => $aipi,
'Страна: ' => $result,
);
foreach($arr as $key => $value) {
$txt .= "<b>".$key."</b> ".$value."%0A";
};
$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
if ($sendToTelegram) {
header('Location: testuser.php');
} else {
echo "Error";
}
?>
Answer the question
In order to leave comments, you need to log in
We need to declare a variable first. And then look further.
$txt = '';
foreach($arr as $key => $value) {
$txt .= "<b>".$key."</b> ".$value."%0A";
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question