Passed
Push — main ( 926a07...7834cc )
by Miaad
10:19
created
src/types/shippingAddress.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     public string $post_code;
31 31
 
32 32
 
33
-    public function __construct(stdClass|null $object = null) {
33
+    public function __construct(stdClass | null $object = null) {
34 34
         if ($object != null) {
35 35
             parent::__construct($object, self::subs);
36 36
         }
Please login to merge, or discard this patch.
src/types/videoChatEnded.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
     public int $duration;
54 54
 
55 55
 
56
-    public function __construct(stdClass|null $object = null) {
56
+    public function __construct(stdClass | null $object = null) {
57 57
         if ($object != null) {
58 58
             parent::__construct($object, self::subs);
59 59
         }
Please login to merge, or discard this patch.
src/types/gameHighScore.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     public int $score;
22 22
 
23 23
 
24
-    public function __construct(stdClass|null $object = null) {
24
+    public function __construct(stdClass | null $object = null) {
25 25
         if ($object != null) {
26 26
             parent::__construct($object, self::subs);
27 27
         }
Please login to merge, or discard this patch.
src/tools/encrypt.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @return string|bool|array{hash:string, key:string, iv:string}
30 30
      * @throws bptException
31 31
      */
32
-    public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string {
32
+    public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string {
33 33
         if (extension_loaded('openssl')) {
34 34
             if ($action === cryptoAction::ENCRYPT) {
35 35
                 $key = self::randomString(64);
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
             }
40 40
             elseif ($action === cryptoAction::DECRYPT) {
41 41
                 if (empty($key)) {
42
-                    logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
42
+                    logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR);
43 43
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44 44
                 }
45 45
                 elseif (empty($iv)) {
46
-                    logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
46
+                    logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR);
47 47
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 48
                 }
49 49
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50 50
             }
51 51
             else {
52
-                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
52
+                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING);
53 53
                 return false;
54 54
             }
55 55
         }
56 56
         else {
57
-            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
57
+            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
58 58
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 59
         }
60 60
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public static function shortEncode(int $num): string {
72 72
         $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
73 73
         $array = [];
74
-        while ($num > 0){
74
+        while ($num > 0) {
75 75
             $array[] = $num % 62;
76 76
             $num = floor($num / 62);
77 77
         }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         foreach ($array as &$value) {
80 80
             $value = $codes[$value];
81 81
         }
82
-        return strrev(implode('',$array));
82
+        return strrev(implode('', $array));
83 83
     }
84 84
 
85 85
     /**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $num = 0;
97 97
         $text = str_split(strrev($text));
98 98
         foreach ($text as $key=>$value) {
99
-            $num += strpos($codes,$value) * pow(62,$key);
99
+            $num += strpos($codes, $value) * pow(62, $key);
100 100
         }
101 101
         return $num;
102 102
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,24 +36,20 @@  discard block
 block discarded – undo
36 36
                 $iv = self::randomString();
37 37
                 $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
38 38
                 return ['hash' => $output, 'key' => $key, 'iv' => $iv];
39
-            }
40
-            elseif ($action === cryptoAction::DECRYPT) {
39
+            } elseif ($action === cryptoAction::DECRYPT) {
41 40
                 if (empty($key)) {
42 41
                     logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
43 42
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44
-                }
45
-                elseif (empty($iv)) {
43
+                } elseif (empty($iv)) {
46 44
                     logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
47 45
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 46
                 }
49 47
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50
-            }
51
-            else {
48
+            } else {
52 49
                 logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
53 50
                 return false;
54 51
             }
55
-        }
56
-        else {
52
+        } else {
57 53
             logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
58 54
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 55
         }
@@ -75,7 +71,9 @@  discard block
 block discarded – undo
75 71
             $array[] = $num % 62;
76 72
             $num = floor($num / 62);
77 73
         }
78
-        if (count($array) < 1) $array = [0];
74
+        if (count($array) < 1) {
75
+            $array = [0];
76
+        }
79 77
         foreach ($array as &$value) {
80 78
             $value = $codes[$value];
81 79
         }
Please login to merge, or discard this patch.
src/logger.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@  discard block
 block discarded – undo
17 17
         if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) {
18 18
             $mode = 'a';
19 19
             $write = false;
20
-        }
21
-        else {
20
+        } else {
22 21
             $mode = 'w';
23 22
             $write = true;
24 23
         }
@@ -39,8 +38,7 @@  discard block
 block discarded – undo
39 38
         $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
40 39
         if (!is_null(self::$handler)) {
41 40
             fwrite(self::$handler, $text);
42
-        }
43
-        else {
41
+        } else {
44 42
             self::$waited_logs[] = $text;
45 43
         }
46 44
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @internal Only for BPT self usage , Don't use it in your source!
19 19
      */
20
-    public static function init (int $log_size = 10): void {
20
+    public static function init(int $log_size = 10): void {
21 21
         self::$log_size = $log_size;
22 22
         if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) {
23 23
             $mode = 'a';
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         self::$handler = fopen(settings::$name.'BPT.log', $mode);
31 31
 
32 32
         if ($write) {
33
-            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");
33
+            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");
34 34
         }
35 35
 
36 36
         if (self::$waited_logs != []) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @return void
52 52
      */
53 53
     public static function write(string $data, string $type = loggerTypes::NONE): void {
54
-        $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
54
+        $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
55 55
         if (!is_null(self::$handler)) {
56 56
             fwrite(self::$handler, $text);
57 57
         }
Please login to merge, or discard this patch.
src/tools/generator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return string
33 33
      */
34
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
34
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
35 35
         $rand_string = '';
36 36
         $char_len = strlen($characters) - 1;
37
-        for ($i = 0; $i < $length; $i ++) {
37
+        for ($i = 0; $i < $length; $i++) {
38 38
             $rand_string .= $characters[rand(0, $char_len)];
39 39
         }
40 40
         return $rand_string;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline
64 64
      * @throws bptException
65 65
      */
66
-    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup {
66
+    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup {
67 67
         if (!empty($keyboard)) {
68 68
             $keyboard_object = new replyKeyboardMarkup();
69 69
             $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             return $keyboard_object;
123 123
         }
124 124
         else {
125
-            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
125
+            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR);
126 126
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
127 127
         }
128 128
     }
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return string
141 141
      */
142
-    public static function inviteLink (int $user_id = null, string $bot_username = null): string {
142
+    public static function inviteLink(int $user_id = null, string $bot_username = null): string {
143 143
         if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
144 144
         if (empty($bot_username)) $bot_username = telegram::getMe()->username;
145
-        return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
145
+        return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id);
146 146
     }
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
             }
73 73
             $rows = [];
74 74
             foreach ($keyboard as $row) {
75
-                if (!is_array($row)) continue;
75
+                if (!is_array($row)) {
76
+                    continue;
77
+                }
76 78
                 $buttons = [];
77 79
                 foreach ($row as $base_button) {
78 80
                     $button_info = explode('||', $base_button);
@@ -81,15 +83,12 @@  discard block
 block discarded – undo
81 83
                     if (count($button_info) > 1) {
82 84
                         if ($button_info[1] === 'con') {
83 85
                             $button->setRequest_contact(true);
84
-                        }
85
-                        elseif ($button_info[1] === 'loc') {
86
+                        } elseif ($button_info[1] === 'loc') {
86 87
                             $button->setRequest_location(true);
87
-                        }
88
-                        elseif ($button_info[1] === 'poll') {
88
+                        } elseif ($button_info[1] === 'poll') {
89 89
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
90 90
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
91
-                        }
92
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
91
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
93 92
                             $url = $button_info[2];
94 93
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
95 94
                         }
@@ -100,8 +99,7 @@  discard block
 block discarded – undo
100 99
             }
101 100
             $keyboard_object->setKeyboard($rows);
102 101
             return $keyboard_object;
103
-        }
104
-        elseif (!empty($inline)) {
102
+        } elseif (!empty($inline)) {
105 103
             $keyboard_object = new inlineKeyboardMarkup();
106 104
             $rows = [];
107 105
             foreach ($inline as $row) {
@@ -111,12 +109,10 @@  discard block
 block discarded – undo
111 109
                     if (isset($button_info[1])) {
112 110
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
113 111
                             $button->setText($button_info[0])->setUrl($button_info[1]);
114
-                        }
115
-                        else {
112
+                        } else {
116 113
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
117 114
                         }
118
-                    }
119
-                    else {
115
+                    } else {
120 116
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
121 117
                     }
122 118
                     $buttons[] = $button;
@@ -125,8 +121,7 @@  discard block
 block discarded – undo
125 121
             }
126 122
             $keyboard_object->setInline_keyboard($rows);
127 123
             return $keyboard_object;
128
-        }
129
-        else {
124
+        } else {
130 125
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
131 126
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
132 127
         }
@@ -145,8 +140,12 @@  discard block
 block discarded – undo
145 140
      * @return string
146 141
      */
147 142
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
148
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
149
-        if (empty($bot_username)) $bot_username = telegram::getMe()->username;
143
+        if (empty($user_id)) {
144
+            $user_id = telegram::catchFields(fields::USER_ID);
145
+        }
146
+        if (empty($bot_username)) {
147
+            $bot_username = telegram::getMe()->username;
148
+        }
150 149
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
151 150
     }
152 151
 }
153 152
\ No newline at end of file
Please login to merge, or discard this patch.
src/receiver/webhook.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,15 +16,13 @@  discard block
 block discarded – undo
16 16
     public static function init () {
17 17
         if (settings::$multi) {
18 18
             multi::init();
19
-        }
20
-        else {
19
+        } else {
21 20
             if (lock::exist('BPT-HOOK')) {
22 21
                 receiver::telegramVerify();
23 22
                 self::checkSecret();
24 23
                 logger::write('Update received , lets process it ;)');
25 24
                 receiver::processUpdate();
26
-            }
27
-            else {
25
+            } else {
28 26
                 self::processSetWebhook();
29 27
             }
30 28
         }
@@ -46,8 +44,7 @@  discard block
 block discarded – undo
46 44
         $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
47 45
         if (telegram::$status) {
48 46
             logger::write('Webhook was set successfully',loggerTypes::INFO);
49
-        }
50
-        else {
47
+        } else {
51 48
             logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
52 49
             BPT::exit(print_r($res,true));
53 50
         }
@@ -69,8 +66,7 @@  discard block
 block discarded – undo
69 66
             if (is_string(settings::$certificate)) {
70 67
                 if (file_exists(settings::$certificate)) {
71 68
                     settings::$certificate = new CURLFile(settings::$certificate);
72
-                }
73
-                else {
69
+                } else {
74 70
                     settings::$certificate = null;
75 71
                 }
76 72
             }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @internal Only for BPT self usage , Don't use it in your source!
21 21
      */
22
-    public static function init () {
22
+    public static function init() {
23 23
         if (settings::$multi) {
24 24
             multi::init();
25 25
         }
@@ -48,26 +48,26 @@  discard block
 block discarded – undo
48 48
         }
49 49
     }
50 50
 
51
-    protected static function setWebhook(string $url,string $secret = '') {
51
+    protected static function setWebhook(string $url, string $secret = '') {
52 52
         $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
53 53
         if (telegram::$status) {
54
-            logger::write('Webhook was set successfully',loggerTypes::INFO);
54
+            logger::write('Webhook was set successfully', loggerTypes::INFO);
55 55
         }
56 56
         else {
57
-            logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
58
-            BPT::exit(print_r($res,true));
57
+            logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR);
58
+            BPT::exit(print_r($res, true));
59 59
         }
60 60
     }
61 61
 
62 62
     protected static function checkURL() {
63 63
         if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
64
-            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
64
+            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
65 65
             throw new bptException('WEBHOOK_NEED_URL');
66 66
         }
67 67
     }
68 68
 
69 69
     private static function setURL(): string {
70
-        return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
70
+        return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
71 71
     }
72 72
 
73 73
     protected static function setCertificate() {
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
         self::setCertificate();
90 90
         $url = self::setURL();
91 91
         $secret = !empty(settings::$secret) ? settings::$secret : tools::randomString(64);
92
-        self::setWebhook($url,$secret);
93
-        lock::save('BPT-HOOK',$secret);
92
+        self::setWebhook($url, $secret);
93
+        lock::save('BPT-HOOK', $secret);
94 94
         BPT::exit('Done');
95 95
     }
96 96
 
97 97
     private static function checkSecret() {
98 98
         $secret = lock::read('BPT-HOOK');
99 99
         if ($secret !== self::getSecret()) {
100
-            logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING);
100
+            logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING);
101 101
             self::processSetWebhook();
102 102
         }
103 103
     }
Please login to merge, or discard this patch.
src/exception/telegramException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,4 +9,4 @@
 block discarded – undo
9 9
  *
10 10
  * @todo make it usefully (it's not called at all)
11 11
  */
12
-class telegramException extends Exception{}
13 12
\ No newline at end of file
13
+class telegramException extends Exception {}
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/receiver/multi/curl.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * curl class , for multiprocessing with curl tricks
15 15
  */
16 16
 class curl extends webhook {
17
-    public static function init (): string|null {
17
+    public static function init(): string | null {
18 18
         if (self::checkIP()) {
19 19
             return self::getUpdate();
20 20
         }
21 21
         else {
22
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
22
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
23 23
             BPT::exit();
24 24
             return null;
25 25
         }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR'];
30 30
     }
31 31
 
32
-    private static function getUpdate (): string {
32
+    private static function getUpdate(): string {
33 33
         $input = json_decode(file_get_contents("php://input"), true);
34 34
         webhook::telegramVerify($input['ip']);
35 35
         return $input['update'];
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
         $urls = self::setURLS();
43 43
         $file = $urls['file'];
44 44
         $timeout = self::getTimeout($file);
45
-        self::create($file,$timeout);
45
+        self::create($file, $timeout);
46 46
         self::setWebhook($urls['url']);
47 47
         lock::set('BPT-MULTI-CURL');
48 48
     }
49 49
 
50
-    private static function getTimeout($url): float|int {
50
+    private static function getTimeout($url): float | int {
51 51
         $times = [];
52
-        for ($i = 0; $i < 10; $i ++) {
52
+        for ($i = 0; $i < 10; $i++) {
53 53
             $ch = curl_init($url);
54 54
             curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([]), CURLOPT_TIMEOUT_MS => 100, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 100, CURLOPT_HTTPHEADER => ['accept: application/json', 'content-type: application/json']]);
55 55
             $start = microtime(true);
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
         return $timeout > 50 ? $timeout + 10 : 50;
61 61
     }
62 62
 
63
-    private static function create($file,$timeout) {
64
-        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\'' . $file . '\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => ' . $timeout . ', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => ' . $timeout . ', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
63
+    private static function create($file, $timeout) {
64
+        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\''.$file.'\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => '.$timeout.', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => '.$timeout.', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
65 65
     }
66 66
 
67 67
     private static function setURLS(): array {
68
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
68
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
69 69
         $file = basename($_SERVER['REQUEST_URI']);
70 70
         return [
71 71
             'url'=>str_replace($file, 'receiver.php', $base_url),
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
     public static function init (): string|null {
18 18
         if (self::checkIP()) {
19 19
             return self::getUpdate();
20
-        }
21
-        else {
20
+        } else {
22 21
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
23 22
             BPT::exit();
24 23
             return null;
Please login to merge, or discard this patch.