@@ -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(); |
@@ -78,11 +78,9 @@ |
||
| 78 | 78 | $value = 'bots_files/' . $value . '/'; |
| 79 | 79 | } |
| 80 | 80 | self::$$setting = $value; |
| 81 | - } |
|
| 82 | - catch (TypeError) { |
|
| 81 | + } catch (TypeError) { |
|
| 83 | 82 | logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING); |
| 84 | - } |
|
| 85 | - catch (Error) { |
|
| 83 | + } catch (Error) { |
|
| 86 | 84 | logger::write("$setting setting is not one of library settings", loggerTypes::WARNING); |
| 87 | 85 | } |
| 88 | 86 | } |
@@ -49,8 +49,7 @@ |
||
| 49 | 49 | foreach ($data as $key=>&$value){ |
| 50 | 50 | if (!isset($value)){ |
| 51 | 51 | unset($data[$key]); |
| 52 | - } |
|
| 53 | - elseif (is_array($value) || is_object($value)){ |
|
| 52 | + } elseif (is_array($value) || is_object($value)){ |
|
| 54 | 53 | $value = json_encode($value); |
| 55 | 54 | } |
| 56 | 55 | } |
@@ -92,11 +92,9 @@ |
||
| 92 | 92 | public static function processCallback (): bool|int { |
| 93 | 93 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
| 94 | 94 | $response = $_POST; |
| 95 | - } |
|
| 96 | - elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 95 | + } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 97 | 96 | $response = $_GET; |
| 98 | - } |
|
| 99 | - else { |
|
| 97 | + } else { |
|
| 100 | 98 | return false; |
| 101 | 99 | } |
| 102 | 100 | |
@@ -43,8 +43,7 @@ |
||
| 43 | 43 | private static function getUrl (string $endpoint, bool $pay = false): string { |
| 44 | 44 | if ($pay) { |
| 45 | 45 | $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE; |
| 46 | - } |
|
| 47 | - else { |
|
| 46 | + } else { |
|
| 48 | 47 | $url = self::$sandbox ? self::SANDBOX_API_BASE : self::API_BASE; |
| 49 | 48 | } |
| 50 | 49 | $url .= $endpoint; |
@@ -156,12 +156,13 @@ discard block |
||
| 156 | 156 | break; |
| 157 | 157 | case 'W': |
| 158 | 158 | $avs = ($date[7] == 6 ? 0 : $date[7] + 1) - $doy % 7; |
| 159 | - if ($avs < 0) $avs += 7; |
|
| 159 | + if ($avs < 0) { |
|
| 160 | + $avs += 7; |
|
| 161 | + } |
|
| 160 | 162 | $num = (int) (($doy + $avs) / 7); |
| 161 | 163 | if ($avs < 4) { |
| 162 | 164 | $num++; |
| 163 | - } |
|
| 164 | - elseif ($num < 1) { |
|
| 165 | + } elseif ($num < 1) { |
|
| 165 | 166 | $num = ($avs == 4 or $avs == ($jalali_year % 33 % 4 - 2 == (int) ($jalali_year % 33 * 0.05) ? 5 : 4)) ? 53 : 52; |
| 166 | 167 | } |
| 167 | 168 | $aks = $avs + $leap_year; |
@@ -187,7 +188,9 @@ discard block |
||
| 187 | 188 | } |
| 188 | 189 | public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
| 189 | 190 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
| 190 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 191 | + if ($time_zone != 'local') { |
|
| 192 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 193 | + } |
|
| 191 | 194 | $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 192 | 195 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp)); |
| 193 | 196 | [$jalali_year, $jalali_month, $jalali_day] = self::gregorian_to_jalali($date[7], $date[4], $date[3]); |
@@ -199,8 +202,7 @@ discard block |
||
| 199 | 202 | $sub = substr($format, $i, 1); |
| 200 | 203 | if ($sub == '%') { |
| 201 | 204 | $sub = substr($format, ++$i, 1); |
| 202 | - } |
|
| 203 | - else { |
|
| 205 | + } else { |
|
| 204 | 206 | $output .= $sub; |
| 205 | 207 | continue; |
| 206 | 208 | } |
@@ -229,30 +231,41 @@ discard block |
||
| 229 | 231 | break; |
| 230 | 232 | /* Week */ case 'U': |
| 231 | 233 | $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7); |
| 232 | - if ($avs < 0) $avs += 7; |
|
| 234 | + if ($avs < 0) { |
|
| 235 | + $avs += 7; |
|
| 236 | + } |
|
| 233 | 237 | $num = (int) (($doy + $avs) / 7) + 1; |
| 234 | - if ($avs > 3 or $avs == 1) $num--; |
|
| 238 | + if ($avs > 3 or $avs == 1) { |
|
| 239 | + $num--; |
|
| 240 | + } |
|
| 235 | 241 | $output .= ($num < 10) ? '0' . $num : $num; |
| 236 | 242 | break; |
| 237 | 243 | case 'V': |
| 238 | 244 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 239 | - if ($avs < 0) $avs += 7; |
|
| 245 | + if ($avs < 0) { |
|
| 246 | + $avs += 7; |
|
| 247 | + } |
|
| 240 | 248 | $num = (int) (($doy + $avs) / 7); |
| 241 | 249 | if ($avs < 4) { |
| 242 | 250 | $num++; |
| 243 | - } |
|
| 244 | - elseif ($num < 1) { |
|
| 251 | + } elseif ($num < 1) { |
|
| 245 | 252 | $num = ($avs == 4 or $avs == ((((($jalali_year % 33) % 4) - 2) == ((int) (($jalali_year % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
| 246 | 253 | } |
| 247 | 254 | $aks = $avs + $leap_year; |
| 248 | - if ($aks == 7) $aks = 0; |
|
| 255 | + if ($aks == 7) { |
|
| 256 | + $aks = 0; |
|
| 257 | + } |
|
| 249 | 258 | $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
| 250 | 259 | break; |
| 251 | 260 | case 'W': |
| 252 | 261 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 253 | - if ($avs < 0) $avs += 7; |
|
| 262 | + if ($avs < 0) { |
|
| 263 | + $avs += 7; |
|
| 264 | + } |
|
| 254 | 265 | $num = (int) (($doy + $avs) / 7) + 1; |
| 255 | - if ($avs > 3) $num--; |
|
| 266 | + if ($avs > 3) { |
|
| 267 | + $num--; |
|
| 268 | + } |
|
| 256 | 269 | $output .= ($num < 10) ? '0' . $num : $num; |
| 257 | 270 | break; |
| 258 | 271 | /* Month */ case 'b': |
@@ -356,11 +369,12 @@ discard block |
||
| 356 | 369 | return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output; |
| 357 | 370 | } |
| 358 | 371 | public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int { |
| 359 | - if ($timezone != 'local') date_default_timezone_set($timezone); |
|
| 372 | + if ($timezone != 'local') { |
|
| 373 | + date_default_timezone_set($timezone); |
|
| 374 | + } |
|
| 360 | 375 | if ($hour === '') { |
| 361 | 376 | return time(); |
| 362 | - } |
|
| 363 | - else { |
|
| 377 | + } else { |
|
| 364 | 378 | [ |
| 365 | 379 | $hour, |
| 366 | 380 | $minute, |
@@ -371,16 +385,13 @@ discard block |
||
| 371 | 385 | ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year)); |
| 372 | 386 | if ($minute === '') { |
| 373 | 387 | return mktime($hour); |
| 374 | - } |
|
| 375 | - else { |
|
| 388 | + } else { |
|
| 376 | 389 | if ($second === '') { |
| 377 | 390 | return mktime($hour, $minute); |
| 378 | - } |
|
| 379 | - else { |
|
| 391 | + } else { |
|
| 380 | 392 | if ($jalali_month === '') { |
| 381 | 393 | return mktime($hour, $minute, $second); |
| 382 | - } |
|
| 383 | - else { |
|
| 394 | + } else { |
|
| 384 | 395 | $jdate = explode('_', self::jdate('Y_j', '', '', $timezone, 'en')); |
| 385 | 396 | if ($jalali_day === '') { |
| 386 | 397 | [ |
@@ -389,8 +400,7 @@ discard block |
||
| 389 | 400 | $gregorian_day |
| 390 | 401 | ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jdate[1]); |
| 391 | 402 | return mktime($hour, $minute, $second, $gregorian_month); |
| 392 | - } |
|
| 393 | - else { |
|
| 403 | + } else { |
|
| 394 | 404 | if ($jalali_year === '') { |
| 395 | 405 | [ |
| 396 | 406 | $gregorian_year, |
@@ -398,8 +408,7 @@ discard block |
||
| 398 | 408 | $gregorian_day |
| 399 | 409 | ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jalali_day); |
| 400 | 410 | return mktime($hour, $minute, $second, $gregorian_month, $gregorian_day); |
| 401 | - } |
|
| 402 | - else { |
|
| 411 | + } else { |
|
| 403 | 412 | [ |
| 404 | 413 | $gregorian_year, |
| 405 | 414 | $gregorian_month, |
@@ -463,8 +472,7 @@ discard block |
||
| 463 | 472 | 'نوزده' |
| 464 | 473 | ]; |
| 465 | 474 | $h34 = $k34[substr($num, 2 - $length, 2) - 10]; |
| 466 | - } |
|
| 467 | - else { |
|
| 475 | + } else { |
|
| 468 | 476 | $xy4 = substr($num, 3 - $length, 1); |
| 469 | 477 | $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و '; |
| 470 | 478 | $k3 = ['', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود']; |
@@ -610,8 +618,7 @@ discard block |
||
| 610 | 618 | if ($days < 186) { |
| 611 | 619 | $jalali_month = 1 + (int) ($days / 31); |
| 612 | 620 | $jalali_day = 1 + ($days % 31); |
| 613 | - } |
|
| 614 | - else { |
|
| 621 | + } else { |
|
| 615 | 622 | $jalali_month = 7 + (int) (($days - 186) / 30); |
| 616 | 623 | $jalali_day = 1 + (($days - 186) % 30); |
| 617 | 624 | } |
@@ -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 | } |
@@ -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 [ |