-
Notifications
You must be signed in to change notification settings - Fork 2
/
getting_master_key.php
140 lines (135 loc) · 5.79 KB
/
getting_master_key.php
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* Created by PhpStorm.
* User: alavi
* Date: 2/22/17
* Time: 3:31 PM
*/
function gettingMasterKey() //this function get and validate the input master key for entrance
{
global $db;
global $user_id;
global $text;
global $message_id;
global $locale;
if ($text == "Ca_nC_31")
{
mysqli_query($db, "UPDATE padporsc_bot4.users SET current_level = 'has_email_go_to_entrance' WHERE user_id = {$user_id}");
if ($locale == "farsi") {
makeCurl("editMessageText", ["chat_id" => $user_id, "message_id" => $message_id, "text" =>"از چه راهی میخواهی وارد مسابقه بشی؟", "reply_markup" => json_encode([
"inline_keyboard" =>[
[
["text" => "شاه کلید دارم", "callback_data" => "Ent3R_V1a_Ma3t3R_k3Y"]
],
[
["text" => "ازم سوال بپرس", "callback_data" => "asK_m3_Qu3sT1an"]
]
]
])]);
}
elseif ($locale == "english"){
makeCurl("editMessageText", ["chat_id" => $user_id, "message_id" => $message_id, "text" =>"How do you want to enter?", "reply_markup" => json_encode([
"inline_keyboard" =>[
[
["text" => "I have a MASTER KEY", "callback_data" => "Ent3R_V1a_Ma3t3R_k3Y"]
],
[
["text" => "Ask me question", "callback_data" => "asK_m3_Qu3sT1an"]
]
]
])]);
}
}
else{
$b = 0;
$result = mysqli_query($db, "SELECT * FROM padporsc_bot4.teams WHERE master_key = {$text}");
while ($row = mysqli_fetch_array($result)) {
$b = 1;
$teams = mysqli_query($db, "SELECT * FROM padporsc_bot4.team{$text}");
}
$a = 0;
while ($row2 = mysqli_fetch_array($teams))
{
$a++;
}
if ($a == 5 || $b == 0) {
mysqli_query($db, "UPDATE padporsc_bot4.users SET current_level = 'has_email_go_to_entrance' WHERE user_id = {$user_id}");
if ($a == 5){
if ($locale == "farsi")
{
makeCurl("sendMessage", ["chat_id" => $user_id, "text" => "ظرفیت تیم تکمیل است.", "reply_markup" => json_encode([
"inline_keyboard" => [
[
["text" => "ادامه", "callback_data" => "C0nT1nu3"]
]
]
])]);
}elseif ($locale == "english")
{
makeCurl("sendMessage", ["chat_id" => $user_id, "text" => "Team is full", "reply_markup" => json_encode([
"inline_keyboard" => [
[
["text" => "Continue", "callback_data" => "C0nT1nu3"]
]
]
])]);
}
}
elseif ($b == 0)
{
if ($locale == "farsi")
{
makeCurl("sendMessage", ["chat_id" => $user_id, "text" => "شاه کلید شما پیدا نشد.", "reply_markup" => json_encode([
"inline_keyboard" => [
[
["text" => "ادامه", "callback_data" => "C0nT1nu3"]
]
]
])]);
}elseif ($locale == "english")
{
makeCurl("sendMessage", ["chat_id" => $user_id, "text" => "MASTER KEY Not Found", "reply_markup" => json_encode([
"inline_keyboard" => [
[
["text" => "Continue", "callback_data" => "C0nT1nu3"]
]
]
])]);
}
}
}
elseif ($b == 1){
$ans = mysqli_query($db, "SELECT * FROM padporsc_bot4.team{$text}");
$z = 0;
while ($g = mysqli_fetch_array($ans))
$z++;
$z++;
mysqli_query($db, "INSERT INTO padporsc_bot4.team{$text} (user_id, level) VALUE ({$user_id}, {$z})");
if ($z == 5)
mysqli_query($db,"UPDATE padporsc_bot4.teams SET open = 0 WHERE master_key = {$text} ");
mysqli_query($db, "UPDATE padporsc_bot4.users SET team_master_key = {$text}, current_level = 'question_menu' WHERE user_id = {$user_id}");
$result = mysqli_query($db, "SELECT * FROM padporsc_bot4.teams WHERE master_key = {$text}");
while ($row = mysqli_fetch_array($result)) {
$teamName = $row['name'];
}
if($locale == "farsi")
makeCurl("sendMessage", ["text" => " شما به تیم {$teamName} اضافه شدید", "chat_id" => $user_id, "reply_markup" =>
json_encode([
"inline_keyboard" =>[
[
["text" => "ادامه", "callback_data" => "C0nT1nu3"]
]
]
])]);
elseif($locale == "english")
makeCurl("sendMessage", ["text" => "You have been added to team {$teamName}", "chat_id" => $user_id, "reply_markup" =>
json_encode([
"inline_keyboard" =>[
[
["text" => "Continue", "callback_data" => "C0nT1nu3"]
]
]
])]);
}
}
}