Repository navigation
Expand file tree
/
Copy pathdelayed_posts.php
More file actions
85 lines (61 loc) · 2.45 KB
/
Copy pathdelayed_posts.php
File metadata and controls
85 lines (61 loc) · 2.45 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
include 'data.ini.php';
include "global.php";
$link = mysqli_connect($hostName, $userName, $password, $databaseName) or die ("Error connect to database");
$curtime = time();
// Select all positions to send
$str2select = "SELECT * FROM `delayed_posts` WHERE `sendtime` <= '$curtime'";
$result = mysqli_query($link, $str2select);
while($row = @mysqli_fetch_object($result)){
if($row->stop == 1) continue;
$response = array(
'chat_id' => $row->chatid,
'text' => "*Не дай боту заскучать* ".hex2bin('F09F93AB')."
Верный спутник SMM-продвижения по прежнему здесь. Без обеда и выходных, он принимает заказы. Подписчики, Лайки и просмотры!
1. Напишите команду /start
2. Выберите услугу
3. Укажите параметры
*Раз, два, три - и ваш заказ на получение лайков, просмотров и подписчиков запущен*".hex2bin('F09F988D'),
'parse_mode' => 'Markdown');
sendit($response, 'sendMessage');
// Update the record
$sendtime = time() + 86400*14;
$str2upd = "UPDATE `delayed_posts` SET `sendtime`='$sendtime' WHERE `rowid`='$row->rowid'";
mysqli_query($link, $str2upd);
} // end WHILE MySQL
exit('ok'); //Обязательно возвращаем "ok", чтобы телеграмм не подумал, что запрос не дошёл
function sendit($response, $restype){
$ch = curl_init('https://api.telegram.org/bot' . TOKEN . '/'.$restype);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $response);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_exec($ch);
curl_close($ch);
}
function send($id, $message, $keyboard) {
//Удаление клавы
if($keyboard == "DEL"){
$keyboard = array(
'remove_keyboard' => true
);
}
if($keyboard){
//Отправка клавиатуры
$encodedMarkup = json_encode($keyboard);
$data = array(
'chat_id' => $id,
'text' => $message,
'reply_markup' => $encodedMarkup
);
}else{
//Отправка сообщения
$data = array(
'chat_id' => $id,
'text' => $message
);
}
$out = sendit($data, 'sendMessage');
return $out;
}
?>