Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $is_maintenance = true; // Tell the core to buzz off with it's maintenance
  5.  
  6.  
  7. require_once('../include.php');
  8.  
  9.  
  10. $content = file_get_contents("php://input");
  11. $update = json_decode($content, true);
  12. if(!$update)
  13. {
  14. exit;
  15. }
  16. $message = isset($update['message']) ? $update['message'] : "";
  17. $messageId = isset($message['message_id']) ? $message['message_id'] : "";
  18. $chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
  19. $firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
  20. $lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";
  21. $username = isset($message['chat']['username']) ? $message['chat']['username'] : "";
  22. $date = isset($message['date']) ? $message['date'] : "";
  23. $text = isset($message['text']) ? $message['text'] : "";
  24. $text = trim($text);
  25. header("Content-Type: application/json");
  26.  
  27. if(strpos($text, "/start") === 0)
  28. {
  29.  
  30.  
  31. $verify = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
  32. $verify->execute(array('id' => $chatId));
  33.  
  34. if($verify->rowCount()){
  35. $response = "Hai già collegato un account, non è possibile aggiungere piu' di un account!
  36.  
  37. Se vuoi eliminarlo scrivi: /del";
  38. $parameters = array('chat_id' => $chatId, "text" => $response);
  39. $parameters["method"] = "sendMessage";
  40. echo json_encode($parameters);
  41. die;
  42. }
  43.  
  44. $response = "[".strtoupper($shortname)." STAFF BOT]
  45. Benvenuto ".$firstname."!
  46. Sei appena entrato nel BOT dello Staff di ".$shortname."!
  47. Per iscriverti al verifica password, scrivi:
  48. /auth TuoUsername TuaPassword CodiceSegreto
  49.  
  50.  
  51. (ATTENZIONE: Tieni d'occhio gli spazi, o ti darà login invalido)";
  52. $parameters = array('chat_id' => $chatId, "text" => $response);
  53. $parameters["method"] = "sendMessage";
  54. echo json_encode($parameters);
  55. }elseif(strpos($text, "/auth") === 0){
  56. $stringa = str_replace('/auth ', '', $text);
  57. $array = explode(" ",$stringa);
  58.  
  59. $username = $array[0];
  60. $pass = $array[1];
  61. $password = $sistema->hash($pass, $username);
  62. $codice = $array[2];
  63.  
  64. //
  65. $verify = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
  66. $verify->execute(array('id' => $chatId));
  67.  
  68. if($verify->rowCount()){
  69. $response = "Hai già collegato un account, non è possibile aggiungere piu' di un account!
  70.  
  71. Se vuoi eliminarlo scrivi: /del";
  72. $parameters = array('chat_id' => $chatId, "text" => $response);
  73. $parameters["method"] = "sendMessage";
  74. echo json_encode($parameters);
  75. die;
  76. }
  77.  
  78.  
  79. $verify2 = $sistema->query("SELECT * FROM telegram_accounts WHERE username = :user LIMIT 1");
  80. $verify2->execute(array('user' => $username));
  81.  
  82. if($verify2->rowCount()){
  83. $response = "C'è già collegato un account con questo username, se è il tuo account contatta un Founder!";
  84. $parameters = array('chat_id' => $chatId, "text" => $response);
  85. $parameters["method"] = "sendMessage";
  86. echo json_encode($parameters);
  87. die;
  88. }
  89.  
  90.  
  91. $check = $sistema->query("SELECT * FROM users WHERE username = :a AND password = :b LIMIT 1");
  92. $check->execute(array('a' => $username, 'b' => $password));
  93.  
  94.  
  95.  
  96. if($check->rowCount()){
  97. $user = $check->fetch(PDO::FETCH_ASSOC);
  98. }
  99.  
  100.  
  101.  
  102.  
  103. if(!isset($username) || !isset($password) || !isset($codice)){
  104. $response = "Inserisci tutti i campi richiesti!";
  105. }elseif(!$check->rowCount()){
  106. $response = "L'username e la password non corrispondono al tuo account di ".$shortname."";
  107. }elseif($user['rank'] == "1"){
  108. $response = "Utente non rankato!";
  109. }elseif($codice != $BOT_SECRET_CODE){
  110. $response = "Codice Segreto errato, sicuro di far parte dello Staff?";
  111. }else{
  112.  
  113. $insert = $sistema->query("INSERT INTO `telegram_accounts` (user_id, username, password, telegram_id) VALUES (:user, :name, :pass, :telid)");
  114. $insert->execute(array('user' => $user['id'], 'name' => $username, 'pass' => $password, 'telid' => $chatId));
  115.  
  116. $response = "Benvenuto ".$user['username']." nel Security Code di ".$shortname."!
  117. Ogni volta che entrerai nel client ti arriverà un messaggio, da questo BOT, con un codice da dover inserire nel client!";
  118.  
  119. }
  120.  
  121. $parameters = array('chat_id' => $chatId, "text" => $response);
  122. $parameters["method"] = "sendMessage";
  123. echo json_encode($parameters);
  124. }elseif(strpos($text, "/del") === 0){
  125.  
  126. $check = $sistema->query("SELECT * FROM telegram_accounts WHERE telegram_id = :id LIMIT 1");
  127. $check->execute(array('id' => $chatId));
  128.  
  129. if($check->rowCount()){
  130. $del = $sistema->query("DELETE FROM telegram_accounts WHERE telegram_id = :del");
  131. $del->execute(array(':del' => $chatId));
  132.  
  133. $response = "Hai eliminato il collegamento all'account correttamente!";
  134. }else{
  135. $response = "Non hai nessun account collegato, se sei Staff devi aggiungere un account per poter loggare nel Client!";
  136. }
  137.  
  138. $parameters = array('chat_id' => $chatId, "text" => $response);
  139. $parameters["method"] = "sendMessage";
  140. echo json_encode($parameters);
  141. }else{
  142. $response = "Comando non valido!";
  143. $parameters = array('chat_id' => $chatId, "text" => $response);
  144. $parameters["method"] = "sendMessage";
  145. echo json_encode($parameters);
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement