@@ -49,6 +49,6 @@ |
||
49 | 49 | * |
50 | 50 | * @return array|string |
51 | 51 | */ |
52 | -function strReplace(array $replacements, string|array $subject): array|string { |
|
52 | +function strReplace(array $replacements, string | array $subject): array | string { |
|
53 | 53 | return str_replace(array_keys($replacements), array_values($replacements), $subject); |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | const ADMIN = 123456789; |
20 | 20 | const SHOW_STATUS = true; |
21 | 21 | const UNKNOWN = 'I didnt understand it, Please use commands or reply to a user message'; |
22 | - const HELP = 'Hello dear admin |
|
22 | + const HELP = 'Hello dear admin |
|
23 | 23 | This is a simple messenger bot which also support reply for users and admin itself |
24 | 24 | For answering an user message , You must reply on it |
25 | 25 | If you want to reply , You must first use /reply_on command and this will apply on your next message |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | const SEND_FAILED = 'Failed!'; |
35 | 35 | const SEND_SUCCESSFUL = 'Done!'; |
36 | 36 | |
37 | - public function __construct (array $settings) { |
|
37 | + public function __construct(array $settings) { |
|
38 | 38 | parent::__construct($settings); |
39 | 39 | } |
40 | 40 | |
41 | - public function message (message $update) { |
|
41 | + public function message(message $update) { |
|
42 | 42 | $text = $update->text ?? ''; |
43 | 43 | $user_id = $update->from->id; |
44 | 44 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | return $this->sendMessage(self::HELP, answer: true); |
55 | 55 | } |
56 | 56 | if ($text === '/reply_on') { |
57 | - mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1); |
|
57 | + mysql::update('users', ['value'=>'reply_on'], ['id'=>$user_id], 1); |
|
58 | 58 | return $this->sendMessage(self::REPLY_ON, answer: true); |
59 | 59 | } |
60 | 60 | if ($text === '/reply_off') { |
61 | - mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1); |
|
61 | + mysql::update('users', ['value'=>'reply_off'], ['id'=>$user_id], 1); |
|
62 | 62 | return $this->sendMessage(self::REPLY_OFF, answer: true); |
63 | 63 | } |
64 | 64 | if (!isset($update->reply_to_message)) { |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | $reply_message_id = $update->reply_to_message->message_id; |
69 | 69 | |
70 | 70 | if ($update->reply_to_message->from->id === $user_id) { |
71 | - $check_message = mysql::select('messages', ['receiver_message_id','receiver_id'], [ |
|
71 | + $check_message = mysql::select('messages', ['receiver_message_id', 'receiver_id'], [ |
|
72 | 72 | 'sender_message_id' => $reply_message_id, |
73 | 73 | 'sender_id' => $user_id |
74 | - ],1); |
|
74 | + ], 1); |
|
75 | 75 | |
76 | 76 | if ($check_message->num_rows < 1) { |
77 | 77 | return $this->sendMessage(self::NOT_FOUND, answer: true); |
@@ -81,19 +81,19 @@ discard block |
||
81 | 81 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id); |
82 | 82 | } |
83 | 83 | else { |
84 | - $check_message = mysql::select('messages', ['sender_message_id','sender_id'], [ |
|
84 | + $check_message = mysql::select('messages', ['sender_message_id', 'sender_id'], [ |
|
85 | 85 | 'receiver_message_id' => $reply_message_id, |
86 | 86 | 'receiver_id' => $user_id |
87 | - ],1); |
|
87 | + ], 1); |
|
88 | 88 | |
89 | 89 | if ($check_message->num_rows < 1) { |
90 | 90 | return $this->sendMessage(self::NOT_FOUND, answer: true); |
91 | 91 | } |
92 | 92 | $data = $check_message->fetch_object(); |
93 | - $value = mysql::select('users','value',['id'=>$user_id])->fetch_object()->value; |
|
93 | + $value = mysql::select('users', 'value', ['id'=>$user_id])->fetch_object()->value; |
|
94 | 94 | $receiver_id = $data->sender_id; |
95 | 95 | if ($value === 'reply_on') { |
96 | - mysql::update('users',['value'=>''],['id'=>$user_id]); |
|
96 | + mysql::update('users', ['value'=>''], ['id'=>$user_id]); |
|
97 | 97 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id); |
98 | 98 | } |
99 | 99 | else { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | $username = $update->from->username; |
119 | 119 | if (empty($username)) { |
120 | - $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : ''); |
|
120 | + $name = $update->from->first_name.(!empty($update->from->last_name) ? (' '.$update->from->last_name) : ''); |
|
121 | 121 | $keyboard = [ |
122 | 122 | 'inline_keyboard' => [ |
123 | 123 | [ |
@@ -155,33 +155,33 @@ discard block |
||
155 | 155 | } |
156 | 156 | if (isset($update->reply_to_message)) { |
157 | 157 | $reply_message_id = $update->reply_to_message->message_id; |
158 | - if ($update->reply_to_message->from->id === $user_id){ |
|
158 | + if ($update->reply_to_message->from->id === $user_id) { |
|
159 | 159 | $check_message = mysql::select('messages', 'receiver_message_id', [ |
160 | 160 | 'sender_message_id' => $reply_message_id, |
161 | 161 | 'sender_id' => $user_id |
162 | - ],1); |
|
162 | + ], 1); |
|
163 | 163 | if ($check_message->num_rows > 0) { |
164 | - $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard); |
|
164 | + $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id, reply_markup: $keyboard); |
|
165 | 165 | } |
166 | 166 | else { |
167 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
167 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | else { |
171 | 171 | $check_message = mysql::select('messages', 'sender_message_id', [ |
172 | 172 | 'receiver_message_id' => $reply_message_id, |
173 | 173 | 'receiver_id' => $user_id |
174 | - ],1); |
|
174 | + ], 1); |
|
175 | 175 | if ($check_message->num_rows > 0) { |
176 | - $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard); |
|
176 | + $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id, reply_markup: $keyboard); |
|
177 | 177 | } |
178 | 178 | else { |
179 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
179 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
183 | 183 | else { |
184 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
184 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | if (file_exists('vendor/autoload.php')) { |
9 | 9 | require 'vendor/autoload.php'; |
10 | -} |
|
11 | -else { |
|
10 | +} else { |
|
12 | 11 | if (!file_exists('BPT.phar')) { |
13 | 12 | copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar'); |
14 | 13 | } |
@@ -79,8 +78,7 @@ discard block |
||
79 | 78 | $data = $check_message->fetch_object(); |
80 | 79 | $receiver_id = $data->receiver_id; |
81 | 80 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id); |
82 | - } |
|
83 | - else { |
|
81 | + } else { |
|
84 | 82 | $check_message = mysql::select('messages', ['sender_message_id','sender_id'], [ |
85 | 83 | 'receiver_message_id' => $reply_message_id, |
86 | 84 | 'receiver_id' => $user_id |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | if ($value === 'reply_on') { |
96 | 94 | mysql::update('users',['value'=>''],['id'=>$user_id]); |
97 | 95 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id); |
98 | - } |
|
99 | - else { |
|
96 | + } else { |
|
100 | 97 | $result = $this->copyMessage($receiver_id); |
101 | 98 | } |
102 | 99 | } |
@@ -138,8 +135,7 @@ discard block |
||
138 | 135 | ] |
139 | 136 | ] |
140 | 137 | ]; |
141 | - } |
|
142 | - else { |
|
138 | + } else { |
|
143 | 139 | $keyboard = [ |
144 | 140 | 'inline_keyboard' => [ |
145 | 141 | [ |
@@ -162,25 +158,21 @@ discard block |
||
162 | 158 | ],1); |
163 | 159 | if ($check_message->num_rows > 0) { |
164 | 160 | $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard); |
165 | - } |
|
166 | - else { |
|
161 | + } else { |
|
167 | 162 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
168 | 163 | } |
169 | - } |
|
170 | - else { |
|
164 | + } else { |
|
171 | 165 | $check_message = mysql::select('messages', 'sender_message_id', [ |
172 | 166 | 'receiver_message_id' => $reply_message_id, |
173 | 167 | 'receiver_id' => $user_id |
174 | 168 | ],1); |
175 | 169 | if ($check_message->num_rows > 0) { |
176 | 170 | $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard); |
177 | - } |
|
178 | - else { |
|
171 | + } else { |
|
179 | 172 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
180 | 173 | } |
181 | 174 | } |
182 | - } |
|
183 | - else { |
|
175 | + } else { |
|
184 | 176 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
185 | 177 | } |
186 | 178 |
@@ -97,51 +97,41 @@ |
||
97 | 97 | if (self::handlerExist('message')) { |
98 | 98 | BPT::$handler->message(BPT::$update->message); |
99 | 99 | } |
100 | - } |
|
101 | - elseif (isset(BPT::$update->edited_message)) { |
|
100 | + } elseif (isset(BPT::$update->edited_message)) { |
|
102 | 101 | if (self::handlerExist('edited_message')) { |
103 | 102 | BPT::$handler->edited_message(BPT::$update->edited_message); |
104 | 103 | } |
105 | - } |
|
106 | - elseif (isset(BPT::$update->channel_post)) { |
|
104 | + } elseif (isset(BPT::$update->channel_post)) { |
|
107 | 105 | if (self::handlerExist('channel_post')) { |
108 | 106 | BPT::$handler->channel_post(BPT::$update->channel_post); |
109 | 107 | } |
110 | - } |
|
111 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
108 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
112 | 109 | if (self::handlerExist('edited_channel_post')) { |
113 | 110 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
114 | 111 | } |
115 | - } |
|
116 | - elseif (isset(BPT::$update->inline_query)) { |
|
112 | + } elseif (isset(BPT::$update->inline_query)) { |
|
117 | 113 | if (self::handlerExist('inline_query')) { |
118 | 114 | BPT::$handler->inline_query(BPT::$update->inline_query); |
119 | 115 | } |
120 | - } |
|
121 | - elseif (isset(BPT::$update->callback_query)) { |
|
116 | + } elseif (isset(BPT::$update->callback_query)) { |
|
122 | 117 | if (self::handlerExist('callback_query')) { |
123 | 118 | BPT::$handler->callback_query(BPT::$update->callback_query); |
124 | 119 | } |
125 | - } |
|
126 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
120 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
127 | 121 | if (self::handlerExist('my_chat_member')) { |
128 | 122 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
129 | 123 | } |
130 | - } |
|
131 | - elseif (isset(BPT::$update->chat_member)) { |
|
124 | + } elseif (isset(BPT::$update->chat_member)) { |
|
132 | 125 | if (self::handlerExist('chat_member')) { |
133 | 126 | BPT::$handler->chat_member(BPT::$update->chat_member); |
134 | 127 | } |
135 | - } |
|
136 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
128 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
137 | 129 | if (self::handlerExist('chat_join_request')) { |
138 | 130 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
139 | 131 | } |
140 | - } |
|
141 | - elseif (self::handlerExist('something_else')) { |
|
132 | + } elseif (self::handlerExist('something_else')) { |
|
142 | 133 | BPT::$handler->something_else(BPT::$update); |
143 | - } |
|
144 | - else { |
|
134 | + } else { |
|
145 | 135 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
146 | 136 | } |
147 | 137 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $ip = $ip ?? tools::remoteIP(); |
36 | 36 | if (!tools::isTelegram($ip)) { |
37 | 37 | if (!callback::process()) { |
38 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
38 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
39 | 39 | BPT::exit(); |
40 | 40 | } |
41 | 41 | die('callback handler stole the process :('); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
46 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
47 | 47 | if (!is_object($update)) { |
48 | 48 | $update = json_decode($update ?? file_get_contents('php://input')); |
49 | 49 | if (!$update) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - if (settings::$use_types_classes && !is_a($update,'update')) { |
|
61 | + if (settings::$use_types_classes && !is_a($update, 'update')) { |
|
62 | 62 | $update = new update($update); |
63 | 63 | } |
64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | db::save(); |
70 | 70 | } |
71 | 71 | |
72 | - protected static function setMessageExtra (stdClass|update &$update): void { |
|
72 | + protected static function setMessageExtra(stdClass | update & $update): void { |
|
73 | 73 | if (!isset($update->message->text) && !isset($update->edited_message->text)) { |
74 | 74 | return; |
75 | 75 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | BPT::$handler->something_else(BPT::$update); |
146 | 146 | } |
147 | 147 | else { |
148 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
148 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 |
@@ -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 [ |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | const MAX_MONEY_DECIMAL = 2; |
29 | 29 | const MAX_MONEY_LENGTH = 10; |
30 | 30 | |
31 | - public function __construct (array $settings) { |
|
31 | + public function __construct(array $settings) { |
|
32 | 32 | parent::__construct($settings); |
33 | 33 | } |
34 | 34 | |
35 | - public function cryptoCallback (cryptoCallback $cryptoData) { |
|
35 | + public function cryptoCallback(cryptoCallback $cryptoData) { |
|
36 | 36 | $paid_amount = $cryptoData->paid_amount; |
37 | 37 | $user_id = $cryptoData->user_id; |
38 | 38 | $real_amount = $cryptoData->real_amount; |
@@ -43,25 +43,25 @@ discard block |
||
43 | 43 | } |
44 | 44 | if ($cryptoData->status === cryptoCallbackStatus::PARTIALLY_PAID) { |
45 | 45 | $need_to_pay = $real_amount - $total_paid; |
46 | - mysql::update('users', ['balance' => '+=' . $paid_amount], ['id' => $user_id], 1); |
|
46 | + mysql::update('users', ['balance' => '+='.$paid_amount], ['id' => $user_id], 1); |
|
47 | 47 | return $this->sendMessage(strReplace(['$amount' => $paid_amount, '$real_amount' => $real_amount, '$need_amount' => $need_to_pay], texts::PARTIALLY_PAID), $user_id); |
48 | 48 | } |
49 | 49 | if ($cryptoData->status === cryptoCallbackStatus::FINISHED) { |
50 | 50 | if ($paid_amount != $total_paid) { |
51 | 51 | $old_amount = $total_paid - $paid_amount; |
52 | - mysql::update('users', ['balance' => '+=' . $paid_amount], ['id' => $user_id], 1); |
|
52 | + mysql::update('users', ['balance' => '+='.$paid_amount], ['id' => $user_id], 1); |
|
53 | 53 | return $this->sendMessage(strReplace(['$amount' => $total_paid, '$old_amount' => $old_amount, '$new_amount' => $paid_amount], texts::FINISHED_PARTIALLY), $user_id); |
54 | 54 | } |
55 | - mysql::update('users', ['balance' => '+=' . $paid_amount], ['id' => $user_id], 1); |
|
55 | + mysql::update('users', ['balance' => '+='.$paid_amount], ['id' => $user_id], 1); |
|
56 | 56 | return $this->sendMessage(strReplace(['$amount' => $paid_amount], texts::FINISHED), $user_id); |
57 | 57 | } |
58 | 58 | if ($cryptoData->status === cryptoCallbackStatus::EXTRA_PAID) { |
59 | 59 | if ($paid_amount != $total_paid) { |
60 | 60 | $old_amount = $total_paid - $paid_amount; |
61 | - mysql::update('users', ['balance' => '+=' . $paid_amount], ['id' => $user_id], 1); |
|
61 | + mysql::update('users', ['balance' => '+='.$paid_amount], ['id' => $user_id], 1); |
|
62 | 62 | return $this->sendMessage(strReplace(['$amount' => $total_paid, '$real_amount' => $real_amount, '$old_amount' => $old_amount, '$new_amount' => $paid_amount], texts::EXTRA_PAID_PARTIALLY), $user_id); |
63 | 63 | } |
64 | - mysql::update('users', ['balance' => '+=' . $paid_amount], ['id' => $user_id], 1); |
|
64 | + mysql::update('users', ['balance' => '+='.$paid_amount], ['id' => $user_id], 1); |
|
65 | 65 | return $this->sendMessage(strReplace(['$amount' => $paid_amount, '$real_amount' => $real_amount], texts::EXTRA_PAID), $user_id); |
66 | 66 | } |
67 | 67 | if ($cryptoData->status === cryptoCallbackStatus::SUCCESS) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - public function message (message $update) { |
|
120 | + public function message(message $update) { |
|
121 | 121 | $text = $update->text ?? ''; |
122 | 122 | |
123 | 123 | $user_id = $update->from->id; |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | return $this->sendMessage(strReplace(['$max_transfer' => self::MAX_TRANSFER], texts::MAX_TRANSFER), answer: true); |
217 | 217 | } |
218 | 218 | |
219 | - mysql::update('users', ['balance' => '+=' . $text], ['id' => $user->value], 1); |
|
219 | + mysql::update('users', ['balance' => '+='.$text], ['id' => $user->value], 1); |
|
220 | 220 | $this->sendMessage(strReplace(['$amount' => $text, '$id' => $user_id], texts::MONEY_RECEIVED), $user->value); |
221 | 221 | |
222 | 222 | mysql::insert('history', ['type', 'amount', 'date', 'user_id', 'target_id'], ['transfer', $text, time(), $user_id, $user->value]); |
223 | 223 | |
224 | - mysql::update('users', ['balance' => '-=' . $text, 'step' => 'main', 'value' => ''], ['id' => $user_id], 1); |
|
224 | + mysql::update('users', ['balance' => '-='.$text, 'step' => 'main', 'value' => ''], ['id' => $user_id], 1); |
|
225 | 225 | return $this->sendMessage(texts::TRANSFER_DONE, reply_markup: keyboards::START, answer: true); |
226 | 226 | } |
227 | 227 | if ($user->step === 'deposit') { |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (file_exists('vendor/autoload.php')) { |
13 | 13 | require 'vendor/autoload.php'; |
14 | -} |
|
15 | -else { |
|
14 | +} else { |
|
16 | 15 | if (!file_exists('BPT.phar')) { |
17 | 16 | copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar'); |
18 | 17 | } |
@@ -174,14 +173,12 @@ discard block |
||
174 | 173 | } |
175 | 174 | if (isset($update->user_shared)) { |
176 | 175 | $target_id = $update->user_shared->user_id; |
177 | - } |
|
178 | - elseif (isset($update->forward_date)) { |
|
176 | + } elseif (isset($update->forward_date)) { |
|
179 | 177 | if (!isset($update->forward_from)) { |
180 | 178 | return $this->sendMessage(texts::USER_FORWARD_CLOSED, answer: true); |
181 | 179 | } |
182 | 180 | $target_id = $update->forward_from->id; |
183 | - } |
|
184 | - else { |
|
181 | + } else { |
|
185 | 182 | if (!is_numeric($text) || $text != floor($text)) { |
186 | 183 | return $this->sendMessage(texts::ONLY_INT, answer: true); |
187 | 184 | } |
@@ -21,8 +21,7 @@ |
||
21 | 21 | public static function init () { |
22 | 22 | if (settings::$multi) { |
23 | 23 | multi::init(); |
24 | - } |
|
25 | - else { |
|
24 | + } else { |
|
26 | 25 | if (!lock::exist('BPT-HOOK')) { |
27 | 26 | self::processSetWebhook(); |
28 | 27 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @internal Only for BPT self usage , Don't use it in your source! |
20 | 20 | */ |
21 | - public static function init () { |
|
21 | + public static function init() { |
|
22 | 22 | if (settings::$multi) { |
23 | 23 | multi::init(); |
24 | 24 | } |
@@ -38,28 +38,28 @@ discard block |
||
38 | 38 | lock::deleteIfExist(['BPT-MULTI-EXEC', 'BPT-MULTI-CURL', 'getUpdate', 'getUpdateHook']); |
39 | 39 | } |
40 | 40 | |
41 | - protected static function setWebhook(string $url,string $secret = '') { |
|
41 | + protected static function setWebhook(string $url, string $secret = '') { |
|
42 | 42 | $res = BPT::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret); |
43 | 43 | if (!BPT::$status) { |
44 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
45 | - BPT::exit(print_r($res,true)); |
|
44 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
45 | + BPT::exit(print_r($res, true)); |
|
46 | 46 | } |
47 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
47 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | protected static function checkURL() { |
51 | 51 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
52 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
52 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
53 | 53 | throw new bptException('WEBHOOK_NEED_URL'); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | protected static function setURL(): string { |
58 | 58 | if (isset($_GET['token'])) { |
59 | - logger::write('You can not specify token in url',loggerTypes::ERROR); |
|
59 | + logger::write('You can not specify token in url', loggerTypes::ERROR); |
|
60 | 60 | BPT::exit('You can not specify token in url'); |
61 | 61 | } |
62 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
62 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | protected static function setCertificate() { |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | self::checkURL(); |
75 | 75 | self::setCertificate(); |
76 | 76 | $url = self::setURL(); |
77 | - $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':','---',settings::$token); |
|
78 | - self::setWebhook($url,$secret); |
|
77 | + $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':', '---', settings::$token); |
|
78 | + self::setWebhook($url, $secret); |
|
79 | 79 | lock::save('BPT-HOOK', md5($secret)); |
80 | 80 | BPT::exit('Done'); |
81 | 81 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | BPT::exit(); |
89 | 89 | } |
90 | 90 | if (settings::$telegram_verify) { |
91 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING); |
|
91 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING); |
|
92 | 92 | self::processSetWebhook(); |
93 | 93 | } |
94 | 94 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public static function fastClose (int $timeout = 86400): bool { |
|
113 | + public static function fastClose(int $timeout = 86400): bool { |
|
114 | 114 | if (settings::$multi || !lock::exist('BPT-HOOK') || settings::$receiver !== \BPT\constants\receiver::WEBHOOK) { |
115 | 115 | return false; |
116 | 116 | } |
@@ -46,8 +46,7 @@ |
||
46 | 46 | $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n"; |
47 | 47 | if (!is_null(self::$handler)) { |
48 | 48 | fwrite(self::$handler, $text); |
49 | - } |
|
50 | - else { |
|
49 | + } else { |
|
51 | 50 | self::$waited_logs[] = $text; |
52 | 51 | } |
53 | 52 | } |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init (string $bot_name, int $log_size = 10): void { |
|
20 | + public static function init(string $bot_name, int $log_size = 10): void { |
|
21 | 21 | self::$log_size = $log_size; |
22 | 22 | $log_file = realpath($bot_name.'BPT.log'); |
23 | 23 | $mode = file_exists($log_file) && self::$log_size * 1024 * 1024 > filesize($log_file) ? 'a' : 'w'; |
24 | 24 | self::$handler = fopen($bot_name.'BPT.log', $mode); |
25 | 25 | if ($mode === 'w') { |
26 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
26 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
27 | 27 | } |
28 | 28 | if (self::$waited_logs != []) { |
29 | 29 | foreach (self::$waited_logs as $log) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
46 | - $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n"; |
|
46 | + $text = date('Y/m/d H:i:s').($type !== loggerTypes::NONE ? " : ⤵\n$type" : '')." : $data\n\n"; |
|
47 | 47 | if (!is_null(self::$handler)) { |
48 | 48 | fwrite(self::$handler, $text); |
49 | 49 | } |
@@ -20,18 +20,18 @@ |
||
20 | 20 | public string $description; |
21 | 21 | |
22 | 22 | /** @var int|float Real amount or known as requested amount */ |
23 | - public int|float $real_amount; |
|
23 | + public int | float $real_amount; |
|
24 | 24 | |
25 | 25 | /** @var string Fiat currency(aka usd, euro, ...) */ |
26 | 26 | public string $currency; |
27 | 27 | |
28 | 28 | /** @var int|float Paid amount in this payment */ |
29 | - public int|float $paid_amount; |
|
29 | + public int | float $paid_amount; |
|
30 | 30 | |
31 | 31 | /** @var int|float Total paid amount for the order id */ |
32 | - public int|float $total_paid; |
|
32 | + public int | float $total_paid; |
|
33 | 33 | |
34 | - public function __construct(stdClass|null $object = null) { |
|
34 | + public function __construct(stdClass | null $object = null) { |
|
35 | 35 | if ($object != null) { |
36 | 36 | parent::__construct($object, self::subs); |
37 | 37 | } |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init(string $method,array $data) { |
|
20 | + public static function init(string $method, array $data) { |
|
21 | 21 | $info = self::getInfo($data); |
22 | 22 | $data = $info['data']; |
23 | 23 | $handler = $info['handler']; |
24 | - self::setTimeout($data,$handler,$method); |
|
24 | + self::setTimeout($data, $handler, $method); |
|
25 | 25 | self::setData($data); |
26 | 26 | $data['method'] = $method; |
27 | 27 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
28 | 28 | $result = curl_exec($handler); |
29 | 29 | if (curl_errno($handler)) { |
30 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
30 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
31 | 31 | } |
32 | 32 | if ($info['token'] != settings::$token) { |
33 | 33 | curl_close($handler); |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
45 | 45 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $token = settings::$token; |
49 | - if (!isset(self::$curl_handler)){ |
|
49 | + if (!isset(self::$curl_handler)) { |
|
50 | 50 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
51 | 51 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
52 | 52 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
65 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
65 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
66 | 66 | if (isset($data['forgot'])) { |
67 | 67 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
68 | 68 | unset($data['forgot']); |
69 | 69 | } |
70 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
70 | + elseif ($method === 'getUpdates' || $method === 'setWebhook') { |
|
71 | 71 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
72 | 72 | } |
73 | 73 | elseif (settings::$base_timeout > 0) { |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | private static function setData(array &$data): void { |
79 | - foreach ($data as &$value){ |
|
80 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
79 | + foreach ($data as &$value) { |
|
80 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
81 | 81 | $value = json_encode($value); |
82 | 82 | } |
83 | 83 | } |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | $curl_handler = curl_init(settings::$base_url."/bot$token/"); |
44 | 44 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
45 | 45 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
46 | - } |
|
47 | - else{ |
|
46 | + } else{ |
|
48 | 47 | $token = settings::$token; |
49 | 48 | if (!isset(self::$curl_handler)){ |
50 | 49 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
@@ -66,11 +65,9 @@ discard block |
||
66 | 65 | if (isset($data['forgot'])) { |
67 | 66 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
68 | 67 | unset($data['forgot']); |
69 | - } |
|
70 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
68 | + } elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
71 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
72 | - } |
|
73 | - elseif (settings::$base_timeout > 0) { |
|
70 | + } elseif (settings::$base_timeout > 0) { |
|
74 | 71 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
75 | 72 | } |
76 | 73 | } |