@@ -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 | } |
@@ -259,8 +260,7 @@ discard block |
||
| 259 | 260 | curl_exec($ch); |
| 260 | 261 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
| 261 | 262 | curl_close($ch); |
| 262 | - } |
|
| 263 | - else { |
|
| 263 | + } else { |
|
| 264 | 264 | $path = realpath($path); |
| 265 | 265 | $size = file_exists($path) ? filesize($path) : false; |
| 266 | 266 | } |
@@ -331,8 +331,7 @@ discard block |
||
| 331 | 331 | $zip->addFile($filePath, substr($filePath, $root_len)); |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - } |
|
| 335 | - else { |
|
| 334 | + } else { |
|
| 336 | 335 | $zip->addFile($path, basename($path)); |
| 337 | 336 | } |
| 338 | 337 | return $zip->close(); |
@@ -351,9 +350,13 @@ discard block |
||
| 351 | 350 | */ |
| 352 | 351 | public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool { |
| 353 | 352 | $file = fopen($url, 'rb'); |
| 354 | - if (!$file) return false; |
|
| 353 | + if (!$file) { |
|
| 354 | + return false; |
|
| 355 | + } |
|
| 355 | 356 | $path = fopen($path, 'wb'); |
| 356 | - if (!$path) return false; |
|
| 357 | + if (!$path) { |
|
| 358 | + return false; |
|
| 359 | + } |
|
| 357 | 360 | |
| 358 | 361 | $length = $chunk_size * 1024; |
| 359 | 362 | while (!feof($file)){ |
@@ -463,8 +466,9 @@ discard block |
||
| 463 | 466 | foreach ($string as $k => &$v) { |
| 464 | 467 | if ($diff->$v) { |
| 465 | 468 | $v = $diff->$v; |
| 469 | + } else { |
|
| 470 | + unset($string[$k]); |
|
| 466 | 471 | } |
| 467 | - else unset($string[$k]); |
|
| 468 | 472 | } |
| 469 | 473 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
| 470 | 474 | |
@@ -530,8 +534,7 @@ discard block |
||
| 530 | 534 | if ($last === "\0") { |
| 531 | 535 | $new .= str_repeat($last, ord($char)); |
| 532 | 536 | $last = ''; |
| 533 | - } |
|
| 534 | - else { |
|
| 537 | + } else { |
|
| 535 | 538 | $new .= $last; |
| 536 | 539 | $last = $char; |
| 537 | 540 | } |
@@ -615,7 +618,9 @@ discard block |
||
| 615 | 618 | } |
| 616 | 619 | $rows = []; |
| 617 | 620 | foreach ($keyboard as $row) { |
| 618 | - if (!is_array($row)) continue; |
|
| 621 | + if (!is_array($row)) { |
|
| 622 | + continue; |
|
| 623 | + } |
|
| 619 | 624 | $buttons = []; |
| 620 | 625 | foreach ($row as $base_button) { |
| 621 | 626 | $button_info = explode('||', $base_button); |
@@ -624,15 +629,12 @@ discard block |
||
| 624 | 629 | if (count($button_info) > 1) { |
| 625 | 630 | if ($button_info[1] === 'con') { |
| 626 | 631 | $button->setRequest_contact(true); |
| 627 | - } |
|
| 628 | - elseif ($button_info[1] === 'loc') { |
|
| 632 | + } elseif ($button_info[1] === 'loc') { |
|
| 629 | 633 | $button->setRequest_location(true); |
| 630 | - } |
|
| 631 | - elseif ($button_info[1] === 'poll') { |
|
| 634 | + } elseif ($button_info[1] === 'poll') { |
|
| 632 | 635 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
| 633 | 636 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
| 634 | - } |
|
| 635 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
| 637 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
| 636 | 638 | $url = $button_info[2]; |
| 637 | 639 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
| 638 | 640 | } |
@@ -643,8 +645,7 @@ discard block |
||
| 643 | 645 | } |
| 644 | 646 | $keyboard_object->setKeyboard($rows); |
| 645 | 647 | return $keyboard_object; |
| 646 | - } |
|
| 647 | - elseif (!empty($inline)) { |
|
| 648 | + } elseif (!empty($inline)) { |
|
| 648 | 649 | $keyboard_object = new inlineKeyboardMarkup(); |
| 649 | 650 | $rows = []; |
| 650 | 651 | foreach ($inline as $row) { |
@@ -654,12 +655,10 @@ discard block |
||
| 654 | 655 | if (isset($button_info[1])) { |
| 655 | 656 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
| 656 | 657 | $button->setText($button_info[0])->setUrl($button_info[1]); |
| 657 | - } |
|
| 658 | - else { |
|
| 658 | + } else { |
|
| 659 | 659 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
| 660 | 660 | } |
| 661 | - } |
|
| 662 | - else { |
|
| 661 | + } else { |
|
| 663 | 662 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
| 664 | 663 | } |
| 665 | 664 | $buttons[] = $button; |
@@ -668,8 +667,7 @@ discard block |
||
| 668 | 667 | } |
| 669 | 668 | $keyboard_object->setInline_keyboard($rows); |
| 670 | 669 | return $keyboard_object; |
| 671 | - } |
|
| 672 | - else { |
|
| 670 | + } else { |
|
| 673 | 671 | logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
| 674 | 672 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
| 675 | 673 | } |
@@ -688,8 +686,12 @@ discard block |
||
| 688 | 686 | * @return string |
| 689 | 687 | */ |
| 690 | 688 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
| 691 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
| 692 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
| 689 | + if (empty($user_id)) { |
|
| 690 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
| 691 | + } |
|
| 692 | + if (empty($bot_username)) { |
|
| 693 | + $bot_username = telegram::getMe()->username; |
|
| 694 | + } |
|
| 693 | 695 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
| 694 | 696 | } |
| 695 | 697 | |
@@ -724,8 +726,7 @@ discard block |
||
| 724 | 726 | $iv = self::randomString(); |
| 725 | 727 | $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv)); |
| 726 | 728 | return ['hash' => $output, 'key' => $key, 'iv' => $iv]; |
| 727 | - } |
|
| 728 | - elseif ($action === codecAction::DECRYPT) { |
|
| 729 | + } elseif ($action === codecAction::DECRYPT) { |
|
| 729 | 730 | if (empty($key)) { |
| 730 | 731 | logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
| 731 | 732 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
@@ -735,8 +736,7 @@ discard block |
||
| 735 | 736 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 736 | 737 | } |
| 737 | 738 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 738 | - } |
|
| 739 | - else { |
|
| 739 | + } else { |
|
| 740 | 740 | logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
| 741 | 741 | return false; |
| 742 | 742 | } |
@@ -765,7 +765,9 @@ discard block |
||
| 765 | 765 | $array[] = $num % 62; |
| 766 | 766 | $num = floor($num / 62); |
| 767 | 767 | } |
| 768 | - if (count($array) < 1) $array = [0]; |
|
| 768 | + if (count($array) < 1) { |
|
| 769 | + $array = [0]; |
|
| 770 | + } |
|
| 769 | 771 | foreach ($array as &$value) { |
| 770 | 772 | $value = $codes[$value]; |
| 771 | 773 | } |
@@ -158,8 +158,7 @@ |
||
| 158 | 158 | if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && tools::isCloudFlare($ip)) { |
| 159 | 159 | $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; |
| 160 | 160 | } |
| 161 | - } |
|
| 162 | - elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
| 161 | + } elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
| 163 | 162 | $ip = $_SERVER['HTTP_AR_REAL_IP']; |
| 164 | 163 | } |
| 165 | 164 | |