-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.php
51 lines (34 loc) · 1.19 KB
/
ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// Токен телеграм бота
$tg_bot_token = "5818256025:AAGBeCdFKMDLCJCDQ6-aUXFRmO09bumeRSg";
// ID Чата
$chat_id = "-666113692";
$text = '';
foreach ($_POST as $key => $val) {
$text .= $key . ": " . $val . "\n";
}
$text .= "\n" . $_SERVER['REMOTE_ADDR'];
$text .= "\n" . date('d.m.y H:i:s');
$param = [
"chat_id" => $chat_id,
"text" => $text
];
$url = "https://api.telegram.org/bot" . $tg_bot_token . "/sendMessage?" . http_build_query($param);
var_dump($text);
file_get_contents($url);
foreach ( $_FILES as $file ) {
$url = "https://api.telegram.org/bot" . $tg_bot_token . "/sendDocument";
move_uploaded_file($file['tmp_name'], $file['name']);
$document = new \CURLFile($file['name']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ["chat_id" => $chat_id, "document" => $document]);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:multipart/form-data"]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$out = curl_exec($ch);
curl_close($ch);
unlink($file['name']);
}
die('1');