-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_add.php
More file actions
35 lines (26 loc) · 817 Bytes
/
bot_add.php
File metadata and controls
35 lines (26 loc) · 817 Bytes
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
<?php
if (empty($_REQUEST['bot_name'])) {
exit('bot name is empty');
}
if (empty($_REQUEST['token'])) {
exit('token is empty');
}
include_once('base_loader.php');
if (!$config['debug']) {
exit('debug mode off');
}
$botName = $_REQUEST['bot_name'];
$token = $_REQUEST['token'];
$statementSearch = $db->getConnect()->prepare('SELECT 1 FROM `bots` WHERE `bot_name` = ?');
$statementSearch->execute(array($botName));
if ($statementSearch->rowCount()) {
exit('bot already exists');
}
$tokenCrypt = Encryption::encrypt($token, $config['secret_key']);
$statement = $db->getConnect()->prepare('INSERT INTO `bots` (`bot_name`, `token`, `last_update_id`) VALUES (?, ?, "")');
$statement->execute(array($botName, $tokenCrypt));
if ($statement->rowCount()) {
exit('ok');
} else {
exit('fail');
}