-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.php
396 lines (373 loc) · 14.2 KB
/
lib.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php
define('SETTING',"update_bot");
define('LINKST',"LinkRemoverHistory");
define('BANDUSER',"UsersBands");
define('CHALESH',"chalesh");
define('BIO',"bio");
define('TEXT',"text");
define('JOCK',"jock");
define('FACT',"fact");
define('ETRAF',"etraf");
define('QUSPEAK',"questions");
define('ANSSPEAK',"answers");
define('DEBUGMS',"All things are ok now...");
define('CHANNEL',"@L8PSTUDIO");
define('TIMEMAIN',600);
define('STEP_1S',300);
define('STEP_2S',400);
define('STEP_3S',500);
define('STEP_4S',600);
define('TIMEOUTS',30);
define('TIMENULLS',30);
define('GUID_OWNER','u0Dile909969f5fa7c856253d420c117');
define('GUID_OMG','u0Dile909969f5fa7c856253d420c117');
define('SERVER_NAME','xxxx');
define("USER_NAME","xxxx");
define("USER_PASSWORD","xxxx");
define("DB_NM","xxxx");
class lib{
private $SERVER_NAME;
private $USER_NAME;
private $USER_PASSWORD;
private $DB_NM;
public function __Construct($SERVER_NAME,$USER_NAME,$USER_PASSWORD,$DB_NM){
$this->SERVER_NAME = $SERVER_NAME;
$this->USER_NAME = $USER_NAME;
$this->USER_PASSWORD = $USER_PASSWORD;
$this->DB_NM = $DB_NM;
}
private function cov(){
$SERVER_NAME = $this->SERVER_NAME;
$USER_NAME = $this->USER_NAME;
$USER_PASSWORD = $this->USER_PASSWORD;
$DB_NM = $this->DB_NM;
$all = array(
'S'=>$SERVER_NAME,
'UN'=>$USER_NAME,
'UP'=>$USER_PASSWORD,
'D'=>$DB_NM
);
return $all;
}
private function connect(){
$all = $this->cov();
$link = mysqli_connect($all['S'],$all['UN'],$all['UP'],$all['D']);
if (mysqli_connect_errno($link)){
return "Failed to connect to MySQL: " . mysqli_connect_error($link);
}
return $link;
}
private function query($qr){
$link = $this->connect();
$result = mysqli_query($link,$qr);
mysqli_close($link);
return $result;
}
// SELECT * FROM `update_bot` WHERE `id` = 1 AND `State` LIKE 'false'
public function insert($pats){
$phone = $pats['phone'];
$AUTH = $pats['AUTH'];
$GUID = $pats['GUID'];
$GUID_U = $pats['GUID_U'];
$DATE = $pats['DATE'];
$DATEX = $pats['DATEX'];
$State = $pats['State'];
$connection_time = $pats['connection_time'];
$Time = $pats['Time'];
$State_X = $pats['State_X'];
$EndTime = $pats['EndTime'];
$EndTime = $pats['Regester'];
$qr = "INSERT INTO `".SETTING."` (`id`,`phone`,`AUTH`, `GUID`, `GUID_U`, `DATE`, `DATEX` , `State`, `connection_time`, `Time`, `State_X`, `EndTime`, `Regester`, `Owner`, `FullAdmins`) VALUES (NULL, '$phone', '$AUTH', '$GUID', '$GUID_U', '$DATE', '$DATEX', '$State', '$connection_time', '$Time', '$State_X', '$EndTime', '$Regester', '$Owner', '$FullAdmins')";
$result = $this->query($qr);
return $result;
}
public function insert_new($AUTH,$GUID,$EndTime,$guidowner,$phone){
$qr = "INSERT INTO `".SETTING."` (`id`, `phone` , `AUTH`, `GUID`, `GUID_U`, `DATE`, `DATEX` , `State`, `connection_time`, `Time`, `State_X`, `EndTime`, `Regester`, `Owner`, `FullAdmins`, `Admins`) VALUES (NULL,'$phone', '$AUTH', '$GUID',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$EndTime',0,'$guidowner',NULL,'NULL')";
$result = $this->query($qr);
return $result;
}
public function select($AUTH){
$qr = "SELECT `phone`,`GUID`, `GUID_U`,`DATE`, `DATEX` , `State`, `connection_time`, `Time`, `State_X`, `EndTime`, `Regester` , `Owner`, `FullAdmins`, `Admins` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function select_All(){
$qr = "SELECT `AUTH` FROM `update_bot` WHERE 1";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$array[] = $row;
}
}
return $array;
}
public function select_GUID_U(){
$qr = "SELECT `GUID_U` FROM `update_bot` WHERE 1";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$array[] = $row;
}
}
return $array;
}
public function select_GUID(){
$qr = "SELECT `GUID` FROM `update_bot` WHERE 1";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$array[] = $row;
}
}
return $array;
}
public function selectEndTime($AUTH){
$qr = "SELECT `EndTime` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectOwner($AUTH){
$qr = "SELECT `Owner` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectFullAdmins($AUTH){
$qr = "SELECT `FullAdmins` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectFullAdminsX($AUTH){
$qr = "SELECT `FullAdmins`,`Admins` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectAdmins($AUTH){
$qr = "SELECT `Admins` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectRegester($AUTH){
$qr = "SELECT `Regester` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectDate_GUID($AUTH){
$qr = "SELECT `DATE` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectId_GUID_U($AUTH){
$qr = "SELECT `id` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectAuthGuid_GUID_U($AUTH){
$qr = "SELECT `GUID_U` , `GUID` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectGUIDU($AUTH){
$qr = "SELECT `GUID_U` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectGUID($GUID_U){
$qr = "SELECT `GUID` FROM `".SETTING."` WHERE `GUID_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectDateX_GUID($AUTH){
$qr = "SELECT `DATEX` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectDateDateX_GUID($AUTH){
$qr = "SELECT `DATE`, `DATEX` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectDateTime_GUiD($AUTH){
$qr = "SELECT `DATE`, `Time` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectState_GUID($AUTH){
$qr = "SELECT `State` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectState_X_GUID($AUTH){
$qr = "SELECT `State_X` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectconnection_time_GUID($AUTH){
$qr = "SELECT `connection_time` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectrequests_GUID($AUTH){
$qr = "SELECT `requests` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selecttime_GUID($AUTH){
$qr = "SELECT `Time` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectTime_null_GUID($AUTH){
$qr = "SELECT `Time_null` FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function delete($id){
$qr = "DELETE FROM `".SETTING."` WHERE id = '$id'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function update($id,$pats){
$AUTH = $pats['AUTH'];
$GUID = $pats['GUID'];
$GUID_U = $pats['GUID_U'];
$DATE = $pats['DATE'];
$State = $pats['State'];
$connection_time = $pats['connection_time'];
$State_X = $pats['State_X'];
$qr = "UPDATE `".SETTING."` SET `AUTH`='$AUTH',`GUID`='$GUID',`GUID_U`='$GUID_U',`DATE`='$DATE',`State`='$State',`connection_time`='$connection_time',`State_X`='$State_X' WHERE `id`='$id'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
// update_options
public function updateGuidU($AUTH,$GUID){
$qr = "UPDATE `".SETTING."` SET `GUID`='$GUID' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateRegester($AUTH,$Regester){
$qr = "UPDATE `".SETTING."` SET `Regester`='$Regester' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateGuid_U($AUTH,$GUID_U){
$qr = "UPDATE `".SETTING."` SET `GUID_U` = '$GUID_U' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateDate_GUiD($AUTH,$DATE){
$qr = "UPDATE `".SETTING."` SET `DATE` = '$DATE' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateDateX_GUiD($AUTH,$DATEX){
$qr = "UPDATE `".SETTING."` SET `DATEX` = '$DATEX' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateDateDateX_GUiD($AUTH,$DATE,$DATEX){
$qr = "UPDATE `".SETTING."` SET `DATE` = '$DATE' , `DATEX` = '$DATEX' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateDateTime_GUiD($AUTH,$DATE,$Time){
$qr = "UPDATE `".SETTING."` SET `DATE` = '$DATE' , `Time` = '$Time' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateState_GUiD($AUTH,$State){
$qr = "UPDATE `".SETTING."` SET `State` = '$State' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateState_X_GUiD($AUTH,$State_X){
$qr = "UPDATE `".SETTING."` SET `State_X` = '$State_X' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateconnection_time_GUiD($AUTH,$connection_time){
$qr = "UPDATE `".SETTING."` SET `connection_time` = '$connection_time' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updaterequests_GUiD($AUTH,$requests){
$qr = "UPDATE `".SETTING."` SET `requests` = '$requests' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updatetime_GUiD($AUTH,$time){
$qr = "UPDATE `".SETTING."` SET `Time` = '$time' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateTime_null_GUiD($AUTH,$Time_null){
$qr = "UPDATE `".SETTING."` SET `Time_null` = '$Time_null' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateDateTime_null_GUiD($AUTH,$DATE,$Time_null){
$qr = "UPDATE `".SETTING."` SET `DATE` = '$DATE' , `Time_null` = '$Time_null' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateFullAdmins($AUTH,$FullAdmins){
$qr = "UPDATE `".SETTING."` SET `FullAdmins` = '$FullAdmins' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateAdmins($AUTH,$Admins){
$qr = "UPDATE `".SETTING."` SET `Admins` = '$Admins' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateOwner($AUTH,$Owner){
$qr = "UPDATE `".SETTING."` SET `Owner` = '$Owner' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updateEndTime($AUTH,$EndTime){
$qr = "UPDATE `".SETTING."` SET `EndTime` = '$EndTime' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function updatephone($AUTH,$phone){
$qr = "UPDATE `".SETTING."` SET `phone` = '$phone' WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return $result;
}
public function count(){
$qr = "select * from ".SETTING;
$result = $this->query($qr);
return mysqli_num_rows($result);
}
public function Delete_robot($AUTH){
$qr = "DELETE FROM `".SETTING."` WHERE `AUTH` = '$AUTH'";
$result = $this->query($qr);
return mysqli_num_rows($result);
}
}