@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | if (settings::$telegram_verify) { |
35 | 35 | $ip = $ip ?? tools::remoteIP(); |
36 | 36 | if (!tools::isTelegram($ip)) { |
37 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
37 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
38 | 38 | BPT::exit(); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
43 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
44 | 44 | if (!is_object($update)) { |
45 | 45 | $update = json_decode($update ?? file_get_contents('php://input')); |
46 | 46 | if (!$update) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - if (settings::$use_types_classes && !is_a($update,'update')) { |
|
58 | + if (settings::$use_types_classes && !is_a($update, 'update')) { |
|
59 | 59 | $update = new update($update); |
60 | 60 | } |
61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | db::save(); |
67 | 67 | } |
68 | 68 | |
69 | - protected static function setMessageExtra (stdClass|update &$update): void { |
|
69 | + protected static function setMessageExtra(stdClass | update & $update): void { |
|
70 | 70 | if (!isset($update->message->text) && !isset($update->edited_message->text)) { |
71 | 71 | return; |
72 | 72 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | BPT::$handler->something_else(BPT::$update); |
143 | 143 | } |
144 | 144 | else { |
145 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
145 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * tools class , gather what ever you need |
31 | 31 | */ |
32 | -class tools{ |
|
32 | +class tools { |
|
33 | 33 | /** |
34 | 34 | * Check the given username format |
35 | 35 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public static function isUsername (string $username): bool { |
|
44 | + public static function isUsername(string $username): bool { |
|
45 | 45 | $length = strlen($username); |
46 | 46 | return !str_contains($username, '__') && $length >= 4 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
47 | 47 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - public static function ipInRange (string $ip, string $range): bool { |
|
61 | + public static function ipInRange(string $ip, string $range): bool { |
|
62 | 62 | if (!str_contains($range, '/')) { |
63 | 63 | $range .= '/32'; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function isTelegram (string $ip): bool { |
|
81 | + public static function isTelegram(string $ip): bool { |
|
82 | 82 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
83 | 83 | } |
84 | 84 | |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return bool |
95 | 95 | */ |
96 | - public static function isCloudFlare (string $ip): bool { |
|
96 | + public static function isCloudFlare(string $ip): bool { |
|
97 | 97 | $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22']; |
98 | 98 | foreach ($cf_ips as $cf_ip) { |
99 | - if (self::ipInRange($ip,$cf_ip)) { |
|
99 | + if (self::ipInRange($ip, $cf_ip)) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | } |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return bool |
116 | 116 | */ |
117 | - public static function isArvanCloud (string $ip): bool { |
|
117 | + public static function isArvanCloud(string $ip): bool { |
|
118 | 118 | $ar_ips = ['185.143.232.0/22', '92.114.16.80/28', '2.146.0.0/28', '46.224.2.32/29', '89.187.178.96/29', '195.181.173.128/29', '89.187.169.88/29', '188.229.116.16/29', '83.123.255.56/31', '164.138.128.28/31', '94.182.182.28/30', '185.17.115.176/30', '5.213.255.36/31', '138.128.139.144/29', '5.200.14.8/29', '188.122.68.224/29', '188.122.83.176/29', '213.179.217.16/29', '185.179.201.192/29', '43.239.139.192/29', '213.179.197.16/29', '213.179.201.192/29', '109.200.214.248/29', '138.128.141.16/29', '188.122.78.136/29', '213.179.211.32/29', '103.194.164.24/29', '185.50.105.136/29', '213.179.213.16/29', '162.244.52.120/29', '188.122.80.240/29', '109.200.195.64/29', '109.200.199.224/29', '185.228.238.0/28', '94.182.153.24/29', '94.101.182.0/27', '37.152.184.208/28', '78.39.156.192/28', '158.255.77.238/31', '81.12.28.16/29', '176.65.192.202/31', '2.144.3.128/28', '89.45.48.64/28', '37.32.16.0/27', '37.32.17.0/27', '37.32.18.0/27']; |
119 | 119 | foreach ($ar_ips as $ar_ip) { |
120 | - if (self::ipInRange($ip,$ar_ip)) { |
|
120 | + if (self::ipInRange($ip, $ar_ip)) { |
|
121 | 121 | return true; |
122 | 122 | } |
123 | 123 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
139 | 139 | */ |
140 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
140 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
141 | 141 | if (!preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
142 | 142 | return false; |
143 | 143 | } |
144 | - if (!$verify){ |
|
144 | + if (!$verify) { |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | $res = telegram::me($token); |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return bool |
173 | 173 | */ |
174 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
174 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
175 | 175 | if (!is_array($ids)) { |
176 | 176 | $ids = [$ids]; |
177 | 177 | } |
178 | 178 | $user_id = $user_id ?? request::catchFields('user_id'); |
179 | 179 | |
180 | 180 | foreach ($ids as $id) { |
181 | - $check = telegram::getChatMember($id,$user_id); |
|
181 | + $check = telegram::getChatMember($id, $user_id); |
|
182 | 182 | if (telegram::$status) { |
183 | 183 | $check = $check->status; |
184 | 184 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return array keys will be id and values will be bool(null for not founded ids) |
207 | 207 | */ |
208 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
208 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
209 | 209 | if (!is_array($ids)) { |
210 | 210 | $ids = [$ids]; |
211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $result = []; |
215 | 215 | foreach ($ids as $id) { |
216 | - $check = telegram::getChatMember($id,$user_id); |
|
216 | + $check = telegram::getChatMember($id, $user_id); |
|
217 | 217 | if (telegram::$status) { |
218 | 218 | $check = $check->status; |
219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @return bool |
234 | 234 | */ |
235 | 235 | public static function isShorted(string $text): bool{ |
236 | - return preg_match('/^[a-zA-Z0-9]+$/',$text); |
|
236 | + return preg_match('/^[a-zA-Z0-9]+$/', $text); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
253 | 253 | */ |
254 | - public static function size (string $path, bool $format = true, bool $space_between = true): string|int|false { |
|
254 | + public static function size(string $path, bool $format = true, bool $space_between = true): string | int | false { |
|
255 | 255 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
256 | 256 | $ch = curl_init($path); |
257 | 257 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $size = file_exists($path) ? filesize($path) : false; |
267 | 267 | } |
268 | 268 | if (isset($size) && is_numeric($size)) { |
269 | - return $format ? tools::byteFormat($size, space_between: $space_between) : $size; |
|
269 | + return $format ? tools::byteFormat($size, space_between : $space_between) : $size; |
|
270 | 270 | } |
271 | 271 | return false; |
272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @return bool |
285 | 285 | * @throws bptException |
286 | 286 | */ |
287 | - public static function delete (string $path, bool $sub = true): bool { |
|
287 | + public static function delete(string $path, bool $sub = true): bool { |
|
288 | 288 | $path = realpath($path); |
289 | 289 | if (!is_dir($path)) { |
290 | 290 | return unlink($path); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | return rmdir($path); |
294 | 294 | } |
295 | 295 | if (!$sub) { |
296 | - logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR); |
|
296 | + logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR); |
|
297 | 297 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
298 | 298 | } |
299 | 299 | $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return bool |
316 | 316 | * @throws bptException when zip extension not found |
317 | 317 | */ |
318 | - public static function zip (string $path, string $destination): bool { |
|
318 | + public static function zip(string $path, string $destination): bool { |
|
319 | 319 | if (!extension_loaded('zip')) { |
320 | 320 | logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
321 | 321 | throw new bptException('ZIP_EXTENSION_MISSING'); |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return bool true on success and false in failure |
352 | 352 | */ |
353 | - public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
|
353 | + public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool { |
|
354 | 354 | $file = fopen($url, 'rb'); |
355 | 355 | if (!$file) return false; |
356 | 356 | $path = fopen($path, 'wb'); |
357 | 357 | if (!$path) return false; |
358 | 358 | |
359 | 359 | $length = $chunk_size * 1024; |
360 | - while (!feof($file)){ |
|
360 | + while (!feof($file)) { |
|
361 | 361 | fwrite($path, fread($file, $length), $length); |
362 | 362 | } |
363 | 363 | fclose($path); |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public static function byteFormat (int $byte, int $precision = 2, bool $space_between = true): string { |
|
383 | + public static function byteFormat(int $byte, int $precision = 2, bool $space_between = true): string { |
|
384 | 384 | $rate_counter = 0; |
385 | 385 | |
386 | - while ($byte > 1024){ |
|
386 | + while ($byte > 1024) { |
|
387 | 387 | $byte /= 1024; |
388 | 388 | $rate_counter++; |
389 | 389 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $byte = round($byte, $precision); |
393 | 393 | } |
394 | 394 | |
395 | - return $byte . ($space_between ? ' ' : '') . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
395 | + return $byte.($space_between ? ' ' : '').['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return string|false return false when mode is incorrect |
411 | 411 | */ |
412 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
412 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
413 | 413 | return match ($mode) { |
414 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
415 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
414 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
415 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
416 | 416 | parseMode::MARKDOWNV2 => str_replace( |
417 | 417 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
418 | 418 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
452 | 452 | * @throws Exception |
453 | 453 | */ |
454 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
454 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
455 | 455 | $base_time = new DateTime($base_time ?? '@'.time()); |
456 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
456 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
457 | 457 | |
458 | 458 | $diff = $base_time->diff($target_time); |
459 | 459 | |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return string[]|string |
482 | 482 | */ |
483 | - public static function realEscapeString(string|array $input): string|array { |
|
484 | - if(is_array($input)) { |
|
483 | + public static function realEscapeString(string | array $input): string | array { |
|
484 | + if (is_array($input)) { |
|
485 | 485 | return array_map(__METHOD__, $input); |
486 | 486 | } |
487 | 487 | |
488 | - if(!empty($input) && is_string($input)) { |
|
488 | + if (!empty($input) && is_string($input)) { |
|
489 | 489 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
490 | 490 | } |
491 | 491 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return string[]|string |
505 | 505 | */ |
506 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
506 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
507 | 507 | $pos = strpos($subject, $search); |
508 | 508 | if ($pos !== false) { |
509 | 509 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return string see possible values in fileType class |
522 | 522 | */ |
523 | - public static function fileType (string $file_id): string { |
|
523 | + public static function fileType(string $file_id): string { |
|
524 | 524 | $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '=')); |
525 | 525 | $new = ''; |
526 | 526 | $last = ''; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $last = $char; |
535 | 535 | } |
536 | 536 | } |
537 | - $data = unpack('VtypeId/Vdc_id', $new . $last); |
|
537 | + $data = unpack('VtypeId/Vdc_id', $new.$last); |
|
538 | 538 | $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216; |
539 | 539 | return [ |
540 | 540 | fileTypes::THUMBNAIL, |
@@ -572,10 +572,10 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return string |
574 | 574 | */ |
575 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
575 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
576 | 576 | $rand_string = ''; |
577 | 577 | $char_len = strlen($characters) - 1; |
578 | - for ($i = 0; $i < $length; $i ++) { |
|
578 | + for ($i = 0; $i < $length; $i++) { |
|
579 | 579 | $rand_string .= $characters[rand(0, $char_len)]; |
580 | 580 | } |
581 | 581 | return $rand_string; |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
605 | 605 | * @throws bptException |
606 | 606 | */ |
607 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
607 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
608 | 608 | if (!empty($keyboard)) { |
609 | 609 | $keyboard_object = new replyKeyboardMarkup(); |
610 | 610 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $keyboard_object->setInline_keyboard($rows); |
668 | 668 | return $keyboard_object; |
669 | 669 | } |
670 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
670 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
671 | 671 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
672 | 672 | } |
673 | 673 | |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
686 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
687 | 687 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
688 | 688 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
689 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
689 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | * @return string|bool|array{hash:string, key:string, iv:string} |
711 | 711 | * @throws bptException |
712 | 712 | */ |
713 | - public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
713 | + public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
714 | 714 | if (!extension_loaded('openssl')) { |
715 | - logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
715 | + logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
716 | 716 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
717 | 717 | } |
718 | 718 | if ($action === codecAction::ENCRYPT) { |
@@ -723,16 +723,16 @@ discard block |
||
723 | 723 | } |
724 | 724 | if ($action === codecAction::DECRYPT) { |
725 | 725 | if (empty($key)) { |
726 | - logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
|
726 | + logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR); |
|
727 | 727 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
728 | 728 | } |
729 | 729 | if (empty($iv)) { |
730 | - logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR); |
|
730 | + logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR); |
|
731 | 731 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
732 | 732 | } |
733 | 733 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
734 | 734 | } |
735 | - logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
735 | + logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
736 | 736 | return false; |
737 | 737 | } |
738 | 738 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | public static function shortEncode(int $num): string { |
749 | 749 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
750 | 750 | $array = []; |
751 | - while ($num > 0){ |
|
751 | + while ($num > 0) { |
|
752 | 752 | $array[] = $num % 62; |
753 | 753 | $num = floor($num / 62); |
754 | 754 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | foreach ($array as &$value) { |
757 | 757 | $value = $codes[$value]; |
758 | 758 | } |
759 | - return strrev(implode('',$array)); |
|
759 | + return strrev(implode('', $array)); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $num = 0; |
774 | 774 | $text = str_split(strrev($text)); |
775 | 775 | foreach ($text as $key=>$value) { |
776 | - $num += strpos($codes,$value) * pow(62,$key); |
|
776 | + $num += strpos($codes, $value) * pow(62, $key); |
|
777 | 777 | } |
778 | 778 | return $num; |
779 | 779 | } |
@@ -217,8 +217,9 @@ discard block |
||
217 | 217 | if (telegram::$status) { |
218 | 218 | $check = $check->status; |
219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
220 | + } else { |
|
221 | + $result[$id] = null; |
|
220 | 222 | } |
221 | - else $result[$id] = null; |
|
222 | 223 | } |
223 | 224 | return $result; |
224 | 225 | } |
@@ -260,8 +261,7 @@ discard block |
||
260 | 261 | curl_exec($ch); |
261 | 262 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
262 | 263 | curl_close($ch); |
263 | - } |
|
264 | - else { |
|
264 | + } else { |
|
265 | 265 | $path = realpath($path); |
266 | 266 | $size = file_exists($path) ? filesize($path) : false; |
267 | 267 | } |
@@ -332,8 +332,7 @@ discard block |
||
332 | 332 | $zip->addFile($filePath, substr($filePath, $root_len)); |
333 | 333 | } |
334 | 334 | } |
335 | - } |
|
336 | - else { |
|
335 | + } else { |
|
337 | 336 | $zip->addFile($path, basename($path)); |
338 | 337 | } |
339 | 338 | return $zip->close(); |
@@ -352,9 +351,13 @@ discard block |
||
352 | 351 | */ |
353 | 352 | public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
354 | 353 | $file = fopen($url, 'rb'); |
355 | - if (!$file) return false; |
|
354 | + if (!$file) { |
|
355 | + return false; |
|
356 | + } |
|
356 | 357 | $path = fopen($path, 'wb'); |
357 | - if (!$path) return false; |
|
358 | + if (!$path) { |
|
359 | + return false; |
|
360 | + } |
|
358 | 361 | |
359 | 362 | $length = $chunk_size * 1024; |
360 | 363 | while (!feof($file)){ |
@@ -461,8 +464,9 @@ discard block |
||
461 | 464 | foreach ($string as $k => &$v) { |
462 | 465 | if ($diff->$v) { |
463 | 466 | $v = $diff->$v; |
467 | + } else { |
|
468 | + unset($string[$k]); |
|
464 | 469 | } |
465 | - else unset($string[$k]); |
|
466 | 470 | } |
467 | 471 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
468 | 472 | |
@@ -528,8 +532,7 @@ discard block |
||
528 | 532 | if ($last === "\0") { |
529 | 533 | $new .= str_repeat($last, ord($char)); |
530 | 534 | $last = ''; |
531 | - } |
|
532 | - else { |
|
535 | + } else { |
|
533 | 536 | $new .= $last; |
534 | 537 | $last = $char; |
535 | 538 | } |
@@ -613,7 +616,9 @@ discard block |
||
613 | 616 | } |
614 | 617 | $rows = []; |
615 | 618 | foreach ($keyboard as $row) { |
616 | - if (!is_array($row)) continue; |
|
619 | + if (!is_array($row)) { |
|
620 | + continue; |
|
621 | + } |
|
617 | 622 | $buttons = []; |
618 | 623 | foreach ($row as $base_button) { |
619 | 624 | $button_info = explode('||', $base_button); |
@@ -622,15 +627,12 @@ discard block |
||
622 | 627 | if (count($button_info) > 1) { |
623 | 628 | if ($button_info[1] === 'con') { |
624 | 629 | $button->setRequest_contact(true); |
625 | - } |
|
626 | - elseif ($button_info[1] === 'loc') { |
|
630 | + } elseif ($button_info[1] === 'loc') { |
|
627 | 631 | $button->setRequest_location(true); |
628 | - } |
|
629 | - elseif ($button_info[1] === 'poll') { |
|
632 | + } elseif ($button_info[1] === 'poll') { |
|
630 | 633 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
631 | 634 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
632 | - } |
|
633 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
635 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
634 | 636 | $url = $button_info[2]; |
635 | 637 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
636 | 638 | } |
@@ -652,12 +654,10 @@ discard block |
||
652 | 654 | if (isset($button_info[1])) { |
653 | 655 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
654 | 656 | $button->setText($button_info[0])->setUrl($button_info[1]); |
655 | - } |
|
656 | - else { |
|
657 | + } else { |
|
657 | 658 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
658 | 659 | } |
659 | - } |
|
660 | - else { |
|
660 | + } else { |
|
661 | 661 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
662 | 662 | } |
663 | 663 | $buttons[] = $button; |
@@ -684,8 +684,12 @@ discard block |
||
684 | 684 | * @return string |
685 | 685 | */ |
686 | 686 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
687 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
688 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
687 | + if (empty($user_id)) { |
|
688 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
689 | + } |
|
690 | + if (empty($bot_username)) { |
|
691 | + $bot_username = telegram::getMe()->username; |
|
692 | + } |
|
689 | 693 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
690 | 694 | } |
691 | 695 | |
@@ -752,7 +756,9 @@ discard block |
||
752 | 756 | $array[] = $num % 62; |
753 | 757 | $num = floor($num / 62); |
754 | 758 | } |
755 | - if (count($array) < 1) $array = [0]; |
|
759 | + if (count($array) < 1) { |
|
760 | + $array = [0]; |
|
761 | + } |
|
756 | 762 | foreach ($array as &$value) { |
757 | 763 | $value = $codes[$value]; |
758 | 764 | } |
@@ -22,30 +22,30 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return void |
24 | 24 | */ |
25 | - public static function init (string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void { |
|
25 | + public static function init(string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void { |
|
26 | 26 | self::$cpanelUser = $cpanelUser; |
27 | 27 | self::$cpanelPassword = $cpanelPassword; |
28 | 28 | self::$cpanelUrl = $cpanelUrl; |
29 | 29 | self::$cpanelPort = $cpanelPort; |
30 | 30 | } |
31 | 31 | |
32 | - private static function createCurl () { |
|
32 | + private static function createCurl() { |
|
33 | 33 | $curl = curl_init(); |
34 | 34 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); |
35 | 35 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); |
36 | 36 | curl_setopt($curl, CURLOPT_HEADER, 0); |
37 | 37 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
38 | - $header[0] = 'Authorization: Basic ' . base64_encode(self::$cpanelUser . ':' . self::$cpanelPassword) . "\n\r"; |
|
38 | + $header[0] = 'Authorization: Basic '.base64_encode(self::$cpanelUser.':'.self::$cpanelPassword)."\n\r"; |
|
39 | 39 | curl_setopt($curl, CURLOPT_HTTPHEADER, $header); |
40 | 40 | return $curl; |
41 | 41 | } |
42 | 42 | |
43 | - private static function execute (string $query = ''): bool|stdClass|array { |
|
43 | + private static function execute(string $query = ''): bool | stdClass | array { |
|
44 | 44 | $curl = self::createCurl(); |
45 | - curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/execute/' . $query); |
|
45 | + curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/execute/'.$query); |
|
46 | 46 | $result = curl_exec($curl); |
47 | 47 | if (!$result) { |
48 | - error_log('curl_exec threw error `' . curl_error($curl) . "` for $query"); |
|
48 | + error_log('curl_exec threw error `'.curl_error($curl)."` for $query"); |
|
49 | 49 | } |
50 | 50 | curl_close($curl); |
51 | 51 | $result = json_decode($result); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $result->data ?? true; |
56 | 56 | } |
57 | 57 | |
58 | - private static function executev2 (string $module, string $function, array $vars = []) { |
|
58 | + private static function executev2(string $module, string $function, array $vars = []) { |
|
59 | 59 | $curl = self::createCurl(); |
60 | 60 | $vars = array_merge([ |
61 | 61 | 'cpanel_jsonapi_user' => 'user', |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | 'cpanel_jsonapi_module' => $module, |
64 | 64 | 'cpanel_jsonapi_func' => $function, |
65 | 65 | ], $vars); |
66 | - curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/json-api/cpanel?' . http_build_query($vars)); |
|
66 | + curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/json-api/cpanel?'.http_build_query($vars)); |
|
67 | 67 | $result = curl_exec($curl); |
68 | 68 | if (!$result) { |
69 | - error_log('curl_exec threw error `' . curl_error($curl) . '` for ' . json_encode($vars)); |
|
69 | + error_log('curl_exec threw error `'.curl_error($curl).'` for '.json_encode($vars)); |
|
70 | 70 | } |
71 | 71 | curl_close($curl); |
72 | 72 | return $result; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public static function mysqlWizard (string $database, string $user, string $password, array $privileges = []): array { |
|
83 | + public static function mysqlWizard(string $database, string $user, string $password, array $privileges = []): array { |
|
84 | 84 | $create_database = self::createMysqlDatabase($database); |
85 | 85 | $create_user = self::createMysqlUser($user, $password); |
86 | 86 | if (empty($privileges)) { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|array|stdClass |
103 | 103 | */ |
104 | - public static function createMysqlDatabase (string $database): bool|array|stdClass { |
|
104 | + public static function createMysqlDatabase(string $database): bool | array | stdClass { |
|
105 | 105 | if (!str_starts_with($database, self::$cpanelUser)) { |
106 | - $database = self::$cpanelUser . '_' . $database; |
|
106 | + $database = self::$cpanelUser.'_'.$database; |
|
107 | 107 | } |
108 | 108 | return self::execute("Mysql/create_database?name=$database"); |
109 | 109 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return bool|array|stdClass |
115 | 115 | */ |
116 | - public static function deleteMysqlDatabase (string $database): bool|array|stdClass { |
|
116 | + public static function deleteMysqlDatabase(string $database): bool | array | stdClass { |
|
117 | 117 | if (!str_starts_with($database, self::$cpanelUser)) { |
118 | - $database = self::$cpanelUser . '_' . $database; |
|
118 | + $database = self::$cpanelUser.'_'.$database; |
|
119 | 119 | } |
120 | 120 | return self::execute("Mysql/delete_database?name=$database"); |
121 | 121 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return bool|array|stdClass |
128 | 128 | */ |
129 | - public static function createMysqlUser (string $user, string $password): bool|array|stdClass { |
|
129 | + public static function createMysqlUser(string $user, string $password): bool | array | stdClass { |
|
130 | 130 | if (!str_starts_with($user, self::$cpanelUser)) { |
131 | - $user = self::$cpanelUser . '_' . $user; |
|
131 | + $user = self::$cpanelUser.'_'.$user; |
|
132 | 132 | } |
133 | 133 | return self::execute("Mysql/create_user?name=$user&password=$password"); |
134 | 134 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return bool|array|stdClass |
140 | 140 | */ |
141 | - public static function deleteMysqlUser (string $user): bool|array|stdClass { |
|
141 | + public static function deleteMysqlUser(string $user): bool | array | stdClass { |
|
142 | 142 | if (!str_starts_with($user, self::$cpanelUser)) { |
143 | - $user = self::$cpanelUser . '_' . $user; |
|
143 | + $user = self::$cpanelUser.'_'.$user; |
|
144 | 144 | } |
145 | 145 | return self::execute("Mysql/delete_user?name=$user"); |
146 | 146 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return bool|array|stdClass |
154 | 154 | */ |
155 | - public static function setMysqlPrivileges (string $database, string $user, array $privileges): bool|array|stdClass { |
|
155 | + public static function setMysqlPrivileges(string $database, string $user, array $privileges): bool | array | stdClass { |
|
156 | 156 | if (!str_starts_with($database, self::$cpanelUser)) { |
157 | - $database = self::$cpanelUser . '_' . $database; |
|
157 | + $database = self::$cpanelUser.'_'.$database; |
|
158 | 158 | } |
159 | 159 | if (!str_starts_with($user, self::$cpanelUser)) { |
160 | - $user = self::$cpanelUser . '_' . $user; |
|
160 | + $user = self::$cpanelUser.'_'.$user; |
|
161 | 161 | } |
162 | 162 | $all_privileges = [ |
163 | 163 | 'ALTER', |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return bool|array|stdClass |
195 | 195 | */ |
196 | - public static function setMysqlPrivilegesAll (string $database, string $user): bool|array|stdClass { |
|
196 | + public static function setMysqlPrivilegesAll(string $database, string $user): bool | array | stdClass { |
|
197 | 197 | if (!str_starts_with($database, self::$cpanelUser)) { |
198 | - $database = self::$cpanelUser . '_' . $database; |
|
198 | + $database = self::$cpanelUser.'_'.$database; |
|
199 | 199 | } |
200 | 200 | if (!str_starts_with($user, self::$cpanelUser)) { |
201 | - $user = self::$cpanelUser . '_' . $user; |
|
201 | + $user = self::$cpanelUser.'_'.$user; |
|
202 | 202 | } |
203 | 203 | return self::execute("Mysql/set_privileges_on_database?user=$user&database=$database&privileges=ALL"); |
204 | 204 | } |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return bool|array|stdClass |
211 | 211 | */ |
212 | - public static function changeMysqlDatabaseName (string $old_name, string $new_name): bool|array|stdClass { |
|
212 | + public static function changeMysqlDatabaseName(string $old_name, string $new_name): bool | array | stdClass { |
|
213 | 213 | if (!str_starts_with($old_name, self::$cpanelUser)) { |
214 | - $old_name = self::$cpanelUser . '_' . $old_name; |
|
214 | + $old_name = self::$cpanelUser.'_'.$old_name; |
|
215 | 215 | } |
216 | 216 | if (!str_starts_with($new_name, self::$cpanelUser)) { |
217 | - $new_name = self::$cpanelUser . '_' . $new_name; |
|
217 | + $new_name = self::$cpanelUser.'_'.$new_name; |
|
218 | 218 | } |
219 | 219 | return self::execute("Mysql/rename_database?oldname=$old_name&newname=$new_name"); |
220 | 220 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return bool|array|stdClass |
227 | 227 | */ |
228 | - public static function changeMysqlUserName (string $old_name, string $new_name): bool|array|stdClass { |
|
228 | + public static function changeMysqlUserName(string $old_name, string $new_name): bool | array | stdClass { |
|
229 | 229 | if (!str_starts_with($old_name, self::$cpanelUser)) { |
230 | - $old_name = self::$cpanelUser . '_' . $old_name; |
|
230 | + $old_name = self::$cpanelUser.'_'.$old_name; |
|
231 | 231 | } |
232 | 232 | if (!str_starts_with($new_name, self::$cpanelUser)) { |
233 | - $new_name = self::$cpanelUser . '_' . $new_name; |
|
233 | + $new_name = self::$cpanelUser.'_'.$new_name; |
|
234 | 234 | } |
235 | 235 | return self::execute("Mysql/rename_user?oldname=$old_name&newname=$new_name"); |
236 | 236 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool|array|stdClass |
242 | 242 | */ |
243 | - public static function dumpMysqlDatabaseSchema (string $database): bool|array|stdClass { |
|
243 | + public static function dumpMysqlDatabaseSchema(string $database): bool | array | stdClass { |
|
244 | 244 | if (!str_starts_with($database, self::$cpanelUser)) { |
245 | - $database = self::$cpanelUser . '_' . $database; |
|
245 | + $database = self::$cpanelUser.'_'.$database; |
|
246 | 246 | } |
247 | 247 | return self::execute("Mysql/dump_database_schema?dbname=$database"); |
248 | 248 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | /** |
251 | 251 | * @return bool|array|stdClass |
252 | 252 | */ |
253 | - public static function mysqlDatabases (): bool|array|stdClass { |
|
253 | + public static function mysqlDatabases(): bool | array | stdClass { |
|
254 | 254 | return self::execute('Mysql/list_databases'); |
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | 258 | * @return bool|array|stdClass |
259 | 259 | */ |
260 | - public static function mysqlUsers (): bool|array|stdClass { |
|
260 | + public static function mysqlUsers(): bool | array | stdClass { |
|
261 | 261 | return self::execute('Mysql/list_users'); |
262 | 262 | } |
263 | 263 | } |
264 | 264 | \ No newline at end of file |
@@ -85,8 +85,7 @@ |
||
85 | 85 | $create_user = self::createMysqlUser($user, $password); |
86 | 86 | if (empty($privileges)) { |
87 | 87 | $set_privileges = self::setMysqlPrivilegesAll($database, $user); |
88 | - } |
|
89 | - else { |
|
88 | + } else { |
|
90 | 89 | $set_privileges = self::setMysqlPrivileges($database, $user, $privileges); |
91 | 90 | } |
92 | 91 | return [ |
@@ -825,30 +825,30 @@ discard block |
||
825 | 825 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
826 | 826 | ]; |
827 | 827 | |
828 | - public static function __callStatic (string $name, array $arguments) { |
|
828 | + public static function __callStatic(string $name, array $arguments) { |
|
829 | 829 | if (!$action = self::methodAction($name)) { |
830 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
830 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
831 | 831 | throw new bptException('METHOD_NOT_FOUND'); |
832 | 832 | } |
833 | 833 | self::checkArguments($arguments); |
834 | - self::keysName($action,$arguments); |
|
835 | - self::readyFile($action,$arguments); |
|
834 | + self::keysName($action, $arguments); |
|
835 | + self::readyFile($action, $arguments); |
|
836 | 836 | self::cleanArguments($arguments); |
837 | - self::setDefaults($action,$arguments); |
|
837 | + self::setDefaults($action, $arguments); |
|
838 | 838 | |
839 | 839 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
840 | 840 | unset($arguments['answer']); |
841 | 841 | if (!answer::isAnswered()) { |
842 | - return answer::init($action,$arguments); |
|
842 | + return answer::init($action, $arguments); |
|
843 | 843 | } |
844 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
844 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
845 | 845 | } |
846 | - $result = curl::init($action,$arguments); |
|
846 | + $result = curl::init($action, $arguments); |
|
847 | 847 | if (!is_object($result)) { |
848 | - logger::write("Telegram $action method failed : " . $result, loggerTypes::WARNING); |
|
848 | + logger::write("Telegram $action method failed : ".$result, loggerTypes::WARNING); |
|
849 | 849 | return false; |
850 | 850 | } |
851 | - return self::processResponse($action,$result); |
|
851 | + return self::processResponse($action, $result); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | private static function checkArguments(array &$arguments): void { |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
860 | - private static function keysName (string $name, array &$arguments): void { |
|
860 | + private static function keysName(string $name, array &$arguments): void { |
|
861 | 861 | foreach ($arguments as $key => $argument) { |
862 | 862 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
863 | 863 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | } |
867 | 867 | } |
868 | 868 | |
869 | - private static function methodAction(string $name): string|false { |
|
869 | + private static function methodAction(string $name): string | false { |
|
870 | 870 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
871 | 871 | } |
872 | 872 | |
@@ -902,11 +902,11 @@ discard block |
||
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
905 | - private static function methodFile(string $name): array|false { |
|
905 | + private static function methodFile(string $name): array | false { |
|
906 | 906 | return self::METHODS_WITH_FILE[$name] ?? false; |
907 | 907 | } |
908 | 908 | |
909 | - private static function methodReturn(string $name,stdClass $response) { |
|
909 | + private static function methodReturn(string $name, stdClass $response) { |
|
910 | 910 | if (!settings::$use_types_classes) { |
911 | 911 | return $response; |
912 | 912 | } |
@@ -928,13 +928,13 @@ discard block |
||
928 | 928 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name] ?? []; |
929 | 929 | foreach ($defaults as $key => $default) { |
930 | 930 | if (is_numeric($key)) { |
931 | - if (!isset($arguments[$default])){ |
|
931 | + if (!isset($arguments[$default])) { |
|
932 | 932 | $arguments[$default] = self::catchFields($default); |
933 | 933 | } |
934 | 934 | } |
935 | 935 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
936 | 936 | foreach ($default as $def) { |
937 | - if (!isset($arguments[$def])){ |
|
937 | + if (!isset($arguments[$def])) { |
|
938 | 938 | $arguments[$def] = self::catchFields($def); |
939 | 939 | } |
940 | 940 | } |
@@ -953,13 +953,13 @@ discard block |
||
953 | 953 | self::$status = $response->ok; |
954 | 954 | self::$pure_response = $response; |
955 | 955 | if (!$response->ok) { |
956 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
956 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
957 | 957 | return new responseError($response); |
958 | 958 | } |
959 | - return self::methodReturn($name,$response); |
|
959 | + return self::methodReturn($name, $response); |
|
960 | 960 | } |
961 | 961 | |
962 | - private static function cleanArguments (array &$arguments): void { |
|
962 | + private static function cleanArguments(array &$arguments): void { |
|
963 | 963 | foreach ($arguments as $key => $argument) { |
964 | 964 | if ($argument == [] || $argument === null) { |
965 | 965 | unset($arguments[$key]); |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * |
975 | 975 | * @return int|string|bool |
976 | 976 | */ |
977 | - public static function catchFields (string $field): int|string|bool { |
|
977 | + public static function catchFields(string $field): int | string | bool { |
|
978 | 978 | switch ($field) { |
979 | 979 | case fields::CHAT_ID : |
980 | 980 | case fields::FROM_CHAT_ID : |
@@ -1121,13 +1121,13 @@ discard block |
||
1121 | 1121 | default => false |
1122 | 1122 | }; |
1123 | 1123 | case fields::URL : |
1124 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1124 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1125 | 1125 | default: |
1126 | 1126 | return false; |
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
1130 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
1131 | 1131 | $file = request::getFile($file_id); |
1132 | 1132 | if (!isset($file->file_path)) { |
1133 | 1133 | return false; |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | * |
1150 | 1150 | * @return bool |
1151 | 1151 | */ |
1152 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
1152 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
1153 | 1153 | return tools::downloadFile(self::fileLink($file_id), $destination); |
1154 | 1154 | } |
1155 | 1155 | |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | * |
1168 | 1168 | * @return message|bool|responseError |
1169 | 1169 | */ |
1170 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
1170 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
1171 | 1171 | $type = tools::fileType($file_id); |
1172 | 1172 | return match ($type) { |
1173 | - fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false,null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
|
1173 | + fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
|
1174 | 1174 | fileTypes::VIDEO_NOTE => request::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
1175 | 1175 | fileTypes::ANIMATION => request::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
1176 | 1176 | fileTypes::AUDIO => request::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | * @method gameHighScore[]|responseError getGameHighScores (int|array|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. |
297 | 297 | * @method gameHighScore[]|responseError getGameHigh (int|array|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. |
298 | 298 | */ |
299 | -class BPT extends telegram{ |
|
300 | - public static stdClass|update $update; |
|
299 | +class BPT extends telegram { |
|
300 | + public static stdClass | update $update; |
|
301 | 301 | |
302 | 302 | public static BPT $handler; |
303 | 303 | |
304 | 304 | |
305 | - public function __construct (array|stdClass $settings) { |
|
305 | + public function __construct(array | stdClass $settings) { |
|
306 | 306 | static::$handler = &$this; |
307 | 307 | settings::init($settings); |
308 | 308 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | #[NoReturn] |
315 | - public static function exit (string|null $message = null): void { |
|
315 | + public static function exit (string | null $message = null): void { |
|
316 | 316 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
317 | 317 | } |
318 | 318 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public static int $log_size = 10; |
31 | 31 | |
32 | - public static string|CURLFile|null $certificate = null; |
|
32 | + public static string | CURLFile | null $certificate = null; |
|
33 | 33 | |
34 | 34 | public static bool $handler = true; |
35 | 35 | |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | |
72 | 72 | public static bool $use_types_classes = true; |
73 | 73 | |
74 | - public static array|null $db = null; |
|
74 | + public static array | null $db = null; |
|
75 | 75 | |
76 | - public static array|null $pay = null; |
|
76 | + public static array | null $pay = null; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @internal Only for BPT self usage , Don't use it in your source! |
80 | 80 | */ |
81 | - public static function init (array|stdClass $settings): void { |
|
81 | + public static function init(array | stdClass $settings): void { |
|
82 | 82 | $settings = (array) $settings; |
83 | 83 | foreach ($settings as $setting => $value) { |
84 | 84 | try { |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | if (!is_dir(realpath('bots_files'))) { |
87 | 87 | mkdir('bots_files'); |
88 | 88 | } |
89 | - if (!is_dir(realpath('bots_files/' . $value))) { |
|
90 | - mkdir('bots_files/' . $value); |
|
89 | + if (!is_dir(realpath('bots_files/'.$value))) { |
|
90 | + mkdir('bots_files/'.$value); |
|
91 | 91 | } |
92 | - $value = 'bots_files/' . $value . '/'; |
|
92 | + $value = 'bots_files/'.$value.'/'; |
|
93 | 93 | } |
94 | 94 | self::$$setting = $value; |
95 | 95 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * @internal Only for BPT self usage , Don't use it in your source! |
134 | 134 | */ |
135 | - public static function done (): void { |
|
135 | + public static function done(): void { |
|
136 | 136 | if (!self::$logger) { |
137 | 137 | return; |
138 | 138 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | logger::write("BPT Done in $estimated ms , $status_message", $type); |
149 | 149 | } |
150 | 150 | |
151 | - private static function security (): void { |
|
151 | + private static function security(): void { |
|
152 | 152 | if (!self::$security) { |
153 | 153 | return; |
154 | 154 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | ini_set('error_reporting', 0); |
165 | 165 | } |
166 | 166 | |
167 | - private static function secureFolder (): void { |
|
167 | + private static function secureFolder(): void { |
|
168 | 168 | if (!self::$secure_folder) { |
169 | 169 | return; |
170 | 170 | } |
171 | 171 | $address = explode('/', $_SERVER['REQUEST_URI']); |
172 | 172 | unset($address[count($address) - 1]); |
173 | - $address = implode('/', $address) . '/BPT.php'; |
|
173 | + $address = implode('/', $address).'/BPT.php'; |
|
174 | 174 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
175 | 175 | $htaccess = realpath('.htaccess'); |
176 | 176 | if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) { |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - private static function getUpdates (): void { |
|
181 | + private static function getUpdates(): void { |
|
182 | 182 | if (!self::$handler) { |
183 | 183 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
184 | 184 | throw new bptException('GETUPDATE_NEED_HANDLER'); |