Passed
Push — main ( 1e0eff...d761d2 )
by Miaad
01:42
created
src/settings.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public static int $log_size = 10;
27 27
 
28
-    public static string|CURLFile|null $certificate = null;
28
+    public static string | CURLFile | null $certificate = null;
29 29
 
30 30
     public static bool $handler = true;
31 31
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 
59 59
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
60 60
 
61
-    public static array|null $db = ['type' => 'json'];
61
+    public static array | null $db = ['type' => 'json'];
62 62
 
63 63
     /**
64 64
      * @internal Only for BPT self usage , Don't use it in your source!
65 65
      */
66
-    public static function init (array|stdClass $settings): void {
66
+    public static function init(array | stdClass $settings): void {
67 67
         $settings = (array) $settings;
68 68
 
69 69
         foreach ($settings as $setting => $value) {
70
-            try{
70
+            try {
71 71
                 if ($setting === 'name') {
72 72
                     if (!is_dir('bots_files')) {
73 73
                         mkdir('bots_files');
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
                 }
80 80
                 self::$$setting = $value;
81 81
             }
82
-            catch (TypeError){
83
-                logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
82
+            catch (TypeError) {
83
+                logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING);
84 84
             }
85
-            catch (Error){
86
-                logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
85
+            catch (Error) {
86
+                logger::write("$setting setting is not one of library settings", loggerTypes::WARNING);
87 87
             }
88 88
         }
89 89
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
                 }
102 102
             }
103 103
             else {
104
-                logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
104
+                logger::write('token format is not right, check it and try again', loggerTypes::ERROR);
105 105
                 throw new bptException('TOKEN_NOT_TRUE');
106 106
             }
107 107
         }
108 108
         else {
109
-            logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
109
+            logger::write('You must specify token parameter in settings', loggerTypes::ERROR);
110 110
             throw new bptException('TOKEN_NOT_FOUND');
111 111
         }
112 112
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public static function done(): void {
118 118
         if (self::$logger) {
119
-            $estimated = round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2);
119
+            $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2);
120 120
             $status_message = match (true) {
121 121
                 $estimated < 100 => 'Excellent',
122 122
                 $estimated < 500 => 'Very good',
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         if (self::$secure_folder) {
149 149
             $address = explode('/', $_SERVER['REQUEST_URI']);
150 150
             unset($address[count($address) - 1]);
151
-            $address = implode('/', $address) . '/BPT.php';
151
+            $address = implode('/', $address).'/BPT.php';
152 152
             $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n  Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n    Order Allow,Deny\n    Allow from all\n</Files>";
153 153
             if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
154 154
                 file_put_contents('.htaccess', $text);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             getUpdates::init();
162 162
         }
163 163
         else {
164
-            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
164
+            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
165 165
             throw new bptException('GETUPDATE_NEED_HANDLER');
166 166
         }
167 167
     }
Please login to merge, or discard this patch.
src/receiver/webhook.php 1 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.