@@ -13,8 +13,7 @@ |
||
13 | 13 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) { |
14 | 14 | $mode = 'a'; |
15 | 15 | $write = false; |
16 | - } |
|
17 | - else { |
|
16 | + } else { |
|
18 | 17 | $mode = 'w'; |
19 | 18 | $write = true; |
20 | 19 | } |
@@ -12,11 +12,9 @@ |
||
12 | 12 | public static function init() { |
13 | 13 | if (lock::exist('BPT-MULTI-EXEC')) { |
14 | 14 | self::setUpdate(exec::init()); |
15 | - } |
|
16 | - elseif(lock::exist('BPT-MULTI-CURL')) { |
|
15 | + } elseif(lock::exist('BPT-MULTI-CURL')) { |
|
17 | 16 | self::setUpdate(curl::init()); |
18 | - } |
|
19 | - else { |
|
17 | + } else { |
|
20 | 18 | self::deleteOldLocks(); |
21 | 19 | self::checkURL(); |
22 | 20 | self::setCertificate(); |
@@ -36,8 +36,7 @@ discard block |
||
36 | 36 | $curl_handler = curl_init(settings::$base_url."$token/"); |
37 | 37 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
38 | 38 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
39 | - } |
|
40 | - else{ |
|
39 | + } else{ |
|
41 | 40 | $token = settings::$token; |
42 | 41 | if (!isset(self::$curl_handler)){ |
43 | 42 | self::$curl_handler = curl_init(settings::$base_url."$token/"); |
@@ -59,11 +58,9 @@ discard block |
||
59 | 58 | if (isset($data['forgot'])) { |
60 | 59 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
61 | 60 | unset($data['forgot']); |
62 | - } |
|
63 | - elseif ($method === 'getUpdates'){ |
|
61 | + } elseif ($method === 'getUpdates'){ |
|
64 | 62 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
65 | - } |
|
66 | - else{ |
|
63 | + } else{ |
|
67 | 64 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
68 | 65 | } |
69 | 66 | } |
@@ -13,8 +13,7 @@ |
||
13 | 13 | public static function init (): string|null { |
14 | 14 | if (self::checkIP()) { |
15 | 15 | return self::getUpdate(); |
16 | - } |
|
17 | - else { |
|
16 | + } else { |
|
18 | 17 | logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
19 | 18 | BPT::exit(); |
20 | 19 | } |
@@ -23,8 +23,7 @@ |
||
23 | 23 | $update = file_get_contents($up); |
24 | 24 | unlink($up); |
25 | 25 | return $update; |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
29 | 28 | BPT::exit(); |
30 | 29 | } |
@@ -233,8 +233,7 @@ |
||
233 | 233 | public function __call (string $name, array $arguments) { |
234 | 234 | if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) { |
235 | 235 | return request::$name(...$arguments[0]); |
236 | - } |
|
237 | - else { |
|
236 | + } else { |
|
238 | 237 | return request::$name(...$arguments); |
239 | 238 | } |
240 | 239 | } |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | self::handleUpdates($updates); |
23 | 23 | lock::save('getUpdate',BPT::$update->update_id+1); |
24 | 24 | $last_update_id = BPT::$update->update_id+1; |
25 | - } |
|
26 | - else { |
|
25 | + } else { |
|
27 | 26 | logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
28 | 27 | BPT::exit(print_r($updates,true)); |
29 | 28 | } |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | private static function loadData(): bool|int|string { |
35 | 34 | if (lock::exist('getUpdate')) { |
36 | 35 | $last_update_id = lock::read('getUpdate'); |
37 | - } |
|
38 | - else { |
|
36 | + } else { |
|
39 | 37 | self::deleteOldLocks(); |
40 | 38 | telegram::deleteWebhook(); |
41 | 39 | $last_update_id = 0; |
@@ -15,14 +15,12 @@ discard block |
||
15 | 15 | public static function init () { |
16 | 16 | if (settings::$multi) { |
17 | 17 | multi::init(); |
18 | - } |
|
19 | - else { |
|
18 | + } else { |
|
20 | 19 | if (lock::exist('BPT-HOOK')) { |
21 | 20 | receiver::telegramVerify(); |
22 | 21 | receiver::processUpdate(); |
23 | 22 | logger::write('Update received , lets process it ;)'); |
24 | - } |
|
25 | - else { |
|
23 | + } else { |
|
26 | 24 | self::deleteOldLocks(); |
27 | 25 | self::checkURL(); |
28 | 26 | self::setCertificate(); |
@@ -50,8 +48,7 @@ discard block |
||
50 | 48 | $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates); |
51 | 49 | if (telegram::$status) { |
52 | 50 | logger::write('Webhook was set successfully',loggerTypes::INFO); |
53 | - } |
|
54 | - else { |
|
51 | + } else { |
|
55 | 52 | logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
56 | 53 | BPT::exit(print_r($res,true)); |
57 | 54 | } |
@@ -73,8 +70,7 @@ discard block |
||
73 | 70 | if (is_string(settings::$certificate)) { |
74 | 71 | if (file_exists(settings::$certificate)) { |
75 | 72 | settings::$certificate = new CURLFile(settings::$certificate); |
76 | - } |
|
77 | - else { |
|
73 | + } else { |
|
78 | 74 | settings::$certificate = null; |
79 | 75 | } |
80 | 76 | } |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | if (!$update) { |
35 | 35 | BPT::exit(); |
36 | 36 | } |
37 | - } |
|
38 | - elseif (!is_a($update,'update')) { |
|
37 | + } elseif (!is_a($update,'update')) { |
|
39 | 38 | $update = new update($update); |
40 | 39 | } |
41 | 40 | |
@@ -72,26 +71,21 @@ discard block |
||
72 | 71 | if (self::handlerExist('message')) { |
73 | 72 | BPT::$handler->message(BPT::$update->message); |
74 | 73 | } |
75 | - } |
|
76 | - elseif (isset(BPT::$update->callback_query)) { |
|
74 | + } elseif (isset(BPT::$update->callback_query)) { |
|
77 | 75 | if (self::handlerExist('callback_query')) { |
78 | 76 | BPT::$handler->callback_query(BPT::$update->callback_query); |
79 | 77 | } |
80 | - } |
|
81 | - elseif (isset(BPT::$update->inline_query)) { |
|
78 | + } elseif (isset(BPT::$update->inline_query)) { |
|
82 | 79 | if (self::handlerExist('inline_query')) { |
83 | 80 | BPT::$handler->inline_query(BPT::$update->inline_query); |
84 | 81 | } |
85 | - } |
|
86 | - elseif (isset(BPT::$update->edited_message)) { |
|
82 | + } elseif (isset(BPT::$update->edited_message)) { |
|
87 | 83 | if (self::handlerExist('edited_message')) { |
88 | 84 | BPT::$handler->edited_message(BPT::$update->edited_message); |
89 | 85 | } |
90 | - } |
|
91 | - elseif (self::handlerExist('something_else')) { |
|
86 | + } elseif (self::handlerExist('something_else')) { |
|
92 | 87 | BPT::$handler->something_else(BPT::$update); |
93 | - } |
|
94 | - else { |
|
88 | + } else { |
|
95 | 89 | logger::write('Update received but handlers does not set',loggerTypes::WARNING); |
96 | 90 | } |
97 | 91 | } |