Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $is_maintenance = true; // Tell the core to buzz off with it's maintenance
- require_once('../include.php');
- $content = file_get_contents("php://input");
- $update = json_decode($content, true);
- if(!$update)
- {
- exit;
- }
- $message = isset($update['message']) ? $update['message'] : "";
- $messageId = isset($message['message_id']) ? $message['message_id'] : "";
- $chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
- $firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
- $lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";
- $username = isset($message['chat']['username']) ? $message['chat']['username'] : "";
- $date = isset($message['date']) ? $message['date'] : "";
- $text = isset($message['text']) ? $message['text'] : "";
- $text = trim($text);
- header("Content-Type: application/json");
- if(strpos($text, "/start") === 0)
- {
- $verify = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
- $verify->execute(array('id' => $chatId));
- if($verify->rowCount()){
- $response = "Hai già collegato un account, non è possibile aggiungere piu' di un account!
- Se vuoi eliminarlo scrivi: /del";
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- die;
- }
- $response = "[".strtoupper($shortname)." STAFF BOT]
- Benvenuto ".$firstname."!
- Sei appena entrato nel BOT dello Staff di ".$shortname."!
- Per iscriverti al verifica password, scrivi:
- /auth TuoUsername TuaPassword CodiceSegreto
- (ATTENZIONE: Tieni d'occhio gli spazi, o ti darà login invalido)";
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- }elseif(strpos($text, "/auth") === 0){
- $stringa = str_replace('/auth ', '', $text);
- $array = explode(" ",$stringa);
- $username = $array[0];
- $pass = $array[1];
- $password = $sistema->hash($pass, $username);
- $codice = $array[2];
- //
- $verify = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
- $verify->execute(array('id' => $chatId));
- if($verify->rowCount()){
- $response = "Hai già collegato un account, non è possibile aggiungere piu' di un account!
- Se vuoi eliminarlo scrivi: /del";
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- die;
- }
- $verify2 = $sistema->query("SELECT * FROM telegram_accounts WHERE username = :user LIMIT 1");
- $verify2->execute(array('user' => $username));
- if($verify2->rowCount()){
- $response = "C'è già collegato un account con questo username, se è il tuo account contatta un Founder!";
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- die;
- }
- $check = $sistema->query("SELECT * FROM users WHERE username = :a AND password = :b LIMIT 1");
- $check->execute(array('a' => $username, 'b' => $password));
- if($check->rowCount()){
- $user = $check->fetch(PDO::FETCH_ASSOC);
- }
- if(!isset($username) || !isset($password) || !isset($codice)){
- $response = "Inserisci tutti i campi richiesti!";
- }elseif(!$check->rowCount()){
- $response = "L'username e la password non corrispondono al tuo account di ".$shortname."";
- }elseif($user['rank'] == "1"){
- $response = "Utente non rankato!";
- }elseif($codice != $BOT_SECRET_CODE){
- $response = "Codice Segreto errato, sicuro di far parte dello Staff?";
- }else{
- $insert = $sistema->query("INSERT INTO `telegram_accounts` (user_id, username, password, telegram_id) VALUES (:user, :name, :pass, :telid)");
- $insert->execute(array('user' => $user['id'], 'name' => $username, 'pass' => $password, 'telid' => $chatId));
- $response = "Benvenuto ".$user['username']." nel Security Code di ".$shortname."!
- Ogni volta che entrerai nel client ti arriverà un messaggio, da questo BOT, con un codice da dover inserire nel client!";
- }
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- }elseif(strpos($text, "/del") === 0){
- $check = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
- $check->execute(array('id' => $chatId));
- if($check->rowCount()){
- $del = $sistema->query("DELETE FROM telegram_accounts WHERE telegram_id = :del");
- $del->execute(array(':del' => $chatId));
- $response = "Hai eliminato il collegamento all'account correttamente!";
- }else{
- $response = "Non hai nessun account collegato, se sei Staff devi aggiungere un account per poter loggare nel Client!";
- }
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- }else{
- $response = "Comando non valido!";
- $parameters = array('chat_id' => $chatId, "text" => $response);
- $parameters["method"] = "sendMessage";
- echo json_encode($parameters);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement