Passed
Push — main ( f6df14...831caf )
by Miaad
01:32
created
logger.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
         if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) {
14 14
             $mode = 'a';
15 15
             $write = false;
16
-        }
17
-        else {
16
+        } else {
18 17
             $mode = 'w';
19 18
             $write = true;
20 19
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     private static $handler;
11 11
 
12 12
 
13
-    public static function init (int $log_size = 10) {
13
+    public static function init(int $log_size = 10) {
14 14
         self::$log_size = $log_size;
15 15
         if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) {
16 16
             $mode = 'a';
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
         self::$handler = fopen('BPT.log', $mode);
25 25
 
26 26
         if ($write) {
27
-            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
+            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");
28 28
         }
29 29
     }
30 30
 
31 31
     public static function write(string $data, string $type = loggerTypes::NONE) {
32 32
         if (!is_null(self::$handler)) {
33
-            $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
33
+            $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
34 34
             fwrite(self::$handler, $text);
35 35
         }
36 36
     }
Please login to merge, or discard this patch.
lock.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
         return touch("$name.lock");
12 12
     }
13 13
 
14
-    public static function save(string $name, string $data): bool|int {
14
+    public static function save(string $name, string $data): bool | int {
15 15
         return file_put_contents("$name.lock", $data);
16 16
 
17 17
     }
18 18
 
19
-    public static function read(string $name): bool|string {
19
+    public static function read(string $name): bool | string {
20 20
         return file_get_contents("$name.lock");
21 21
     }
22 22
 
23
-    public static function mtime(string $name): bool|int {
23
+    public static function mtime(string $name): bool | int {
24 24
         return filemtime("$name.lock");
25 25
     }
26 26
 
Please login to merge, or discard this patch.
receiver/multi.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
         if (lock::exist('BPT-MULTI-EXEC')) {
14 14
             self::setUpdate(exec::init());
15 15
         }
16
-        elseif(lock::exist('BPT-MULTI-CURL')) {
16
+        elseif (lock::exist('BPT-MULTI-CURL')) {
17 17
             self::setUpdate(curl::init());
18 18
         }
19 19
         else {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,11 +12,9 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
api/request/curl.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@  discard block
 block discarded – undo
36 36
             $curl_handler = curl_init(settings::$base_url."$token/");
37 37
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
38 38
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
39
-        }
40
-        else{
39
+        } else{
41 40
             $token = settings::$token;
42 41
             if (!isset(self::$curl_handler)){
43 42
                 self::$curl_handler = curl_init(settings::$base_url."$token/");
@@ -59,11 +58,9 @@  discard block
 block discarded – undo
59 58
         if (isset($data['forgot'])) {
60 59
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
61 60
             unset($data['forgot']);
62
-        }
63
-        elseif ($method === 'getUpdates'){
61
+        } elseif ($method === 'getUpdates'){
64 62
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
65
-        }
66
-        else{
63
+        } else{
67 64
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300);
68 65
         }
69 66
     }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@  discard block
 block discarded – undo
10 10
 class curl {
11 11
     private static CurlHandle $curl_handler;
12 12
 
13
-    public static function init(string $method,array $data) {
13
+    public static function init(string $method, array $data) {
14 14
         $info = self::getInfo($data);
15 15
         $data = $info['data'];
16 16
         $handler = $info['handler'];
17
-        self::setTimeout($data,$handler,$method);
17
+        self::setTimeout($data, $handler, $method);
18 18
         self::setData($data);
19 19
         $data['method'] = $method;
20 20
         curl_setopt($handler, CURLOPT_POSTFIELDS, $data);
21 21
         $result = curl_exec($handler);
22 22
         if (curl_errno($handler)) {
23
-            logger::write(curl_error($handler),loggerTypes::WARNING);
23
+            logger::write(curl_error($handler), loggerTypes::WARNING);
24 24
         }
25 25
         if ($info['token'] != settings::$token) {
26 26
             curl_close($handler);
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
37 37
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
38 38
         }
39
-        else{
39
+        else {
40 40
             $token = settings::$token;
41
-            if (!isset(self::$curl_handler)){
41
+            if (!isset(self::$curl_handler)) {
42 42
                 self::$curl_handler = curl_init(settings::$base_url."$token/");
43 43
                 curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true);
44 44
                 curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false);
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
         ];
55 55
     }
56 56
 
57
-    private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method) {
57
+    private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method) {
58 58
         if (isset($data['forgot'])) {
59 59
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
60 60
             unset($data['forgot']);
61 61
         }
62
-        elseif ($method === 'getUpdates'){
62
+        elseif ($method === 'getUpdates') {
63 63
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
64 64
         }
65
-        else{
65
+        else {
66 66
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300);
67 67
         }
68 68
     }
69 69
 
70 70
     private static function setData(array &$data) {
71
-        foreach ($data as &$value){
72
-            if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
71
+        foreach ($data as &$value) {
72
+            if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) {
73 73
                 $value = json_encode($value);
74 74
             }
75 75
         }
Please login to merge, or discard this patch.
receiver/multi/curl.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 use BPT\settings;
11 11
 
12 12
 class curl extends webhook {
13
-    public static function init (): string|null {
13
+    public static function init(): string | null {
14 14
         if (self::checkIP()) {
15 15
             return self::getUpdate();
16 16
         }
17 17
         else {
18
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
18
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
19 19
             BPT::exit();
20 20
         }
21 21
     }
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR'];
25 25
     }
26 26
 
27
-    private static function getUpdate (): string {
27
+    private static function getUpdate(): string {
28 28
         $input = json_decode(file_get_contents("php://input"), true);
29 29
         webhook::telegramVerify($input['ip']);
30 30
         return $input['update'];
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
         $urls = self::setURLS();
35 35
         $file = $urls['file'];
36 36
         $timeout = self::getTimeout($file);
37
-        self::create($file,$timeout);
37
+        self::create($file, $timeout);
38 38
         self::setWebhook($urls['url']);
39 39
         lock::set('BPT-MULTI-CURL');
40 40
     }
41 41
 
42
-    private static function getTimeout($url): float|int {
42
+    private static function getTimeout($url): float | int {
43 43
         $times = [];
44
-        for ($i = 0; $i < 10; $i ++) {
44
+        for ($i = 0; $i < 10; $i++) {
45 45
             $ch = curl_init($url);
46 46
             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']]);
47 47
             $start = microtime(true);
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
         return $timeout > 50 ? $timeout + 10 : 50;
53 53
     }
54 54
 
55
-    private static function create($file,$timeout) {
56
-        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);?>');
55
+    private static function create($file, $timeout) {
56
+        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);?>');
57 57
     }
58 58
 
59 59
     private static function setURLS(): array {
60
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
60
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
61 61
         $file = basename($_SERVER['REQUEST_URI']);
62 62
         return [
63 63
             '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
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
     public static function init (): string|null {
14 14
         if (self::checkIP()) {
15 15
             return self::getUpdate();
16
-        }
17
-        else {
16
+        } else {
18 17
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
19 18
             BPT::exit();
20 19
         }
Please login to merge, or discard this patch.
receiver/multi/exec.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 use BPT\settings;
11 11
 
12 12
 class exec extends webhook {
13
-    public static function init(): string|null {
13
+    public static function init(): string | null {
14 14
         return self::getUpdate();
15 15
     }
16 16
 
17
-    private static function getUpdate (): string|null {
17
+    private static function getUpdate(): string | null {
18 18
         $up = glob('*.update');
19 19
         if (isset($up[0])) {
20 20
             $up = end($up);
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
             return $update;
26 26
         }
27 27
         else {
28
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
28
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
29 29
             BPT::exit();
30 30
         }
31 31
     }
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
     }
46 46
 
47 47
     private static function create($file) {
48
-        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php ' . $file . ' > /dev/null &");');
48
+        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php '.$file.' > /dev/null &");');
49 49
     }
50 50
 
51 51
     private static function setURLS(): array {
52
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
52
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
53 53
         return [
54 54
             'url'=>str_replace(basename($_SERVER['REQUEST_URI']), 'receiver.php', $base_url),
55 55
             'file'=>basename($_SERVER['SCRIPT_NAME'])
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
             $update = file_get_contents($up);
24 24
             unlink($up);
25 25
             return $update;
26
-        }
27
-        else {
26
+        } else {
28 27
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
29 28
             BPT::exit();
30 29
         }
Please login to merge, or discard this patch.
tools.php 2 patches
Braces   +14 added lines, -12 removed lines patch added patch discarded remove patch
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
             curl_exec($ch);
258 258
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
259 259
             curl_close($ch);
260
-        }
261
-        else {
260
+        } else {
262 261
             $size = file_exists($path) ? filesize($path) : false;
263 262
         }
264 263
 
265 264
         if (isset($size) && is_numeric($size)) {
266 265
             return $format ? tools::byteFormat($size) : $size;
267
-        }
268
-        else return false;
266
+        } else {
267
+            return false;
268
+        }
269 269
     }
270 270
 
271 271
     //fix methods after here comments
@@ -293,15 +293,16 @@  discard block
 block discarded – undo
293 293
                         $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
294 294
                     }
295 295
                     rmdir($path);
296
-                }
297
-                else {
296
+                } else {
298 297
                     logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::WARNING);
299 298
                     return false;
300 299
                 }
301
-            }
302
-            else rmdir($path);
303
-        }
304
-        else unlink($path);
300
+            } else {
301
+                rmdir($path);
302
+            }
303
+        } else {
304
+            unlink($path);
305
+        }
305 306
 
306 307
         return true;
307 308
     }
@@ -328,8 +329,9 @@  discard block
 block discarded – undo
328 329
         foreach ($string as $k => &$v) {
329 330
             if ($diff->$v) {
330 331
                 $v = $diff->$v;
331
-            }
332
-            else unset($string[$k]);
332
+            } else {
333
+                unset($string[$k]);
334
+            }
333 335
         }
334 336
         $string['status'] = $status;
335 337
         return count($string) > 1 ? $string : ['status' => 'now'];
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param string $username Your text to be check is username or not e.g. : 'BPT_CH' | '@BPT_CH'
23 23
      * @return bool
24 24
      */
25
-    public static function isUsername (string $username): bool {
25
+    public static function isUsername(string $username): bool {
26 26
         $length = strlen($username);
27 27
         return strpos($username, '__') === false && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username);
28 28
     }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param string $range Your range ip for check , if you didn't specify the block , it will be 32
39 39
      * @return bool
40 40
      */
41
-    public static function ipInRange (string $ip, string $range): bool {
41
+    public static function ipInRange(string $ip, string $range): bool {
42 42
         if (!str_contains($range, '/')) {
43 43
             $range .= '/32';
44 44
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param string $ip     Your ip to be check is telegram or not e.g. '192.168.1.1'
58 58
      * @return bool
59 59
      */
60
-    public static function isTelegram (string $ip): bool {
60
+    public static function isTelegram(string $ip): bool {
61 61
         return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22');
62 62
     }
63 63
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
      * @param string $ip Your ip to be check is CloudFlare or not e.g. '192.168.1.1'
72 72
      * @return bool
73 73
      */
74
-    public static function isCloudFlare (string $ip): bool {
74
+    public static function isCloudFlare(string $ip): bool {
75 75
         $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '172.64.0.0/13', '131.0.72.0/22'];
76 76
         foreach ($cf_ips as $cf_ip) {
77
-            if (self::ipInRange($ip,$cf_ip)) {
77
+            if (self::ipInRange($ip, $cf_ip)) {
78 78
                 return true;
79 79
             }
80 80
         }
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
      *
98 98
      * @return types\responseError|types\user return array when verify is active and token is true array of telegram getMe result
99 99
      */
100
-    public static function isToken (string $token, bool $verify = false): bool|types\user {
100
+    public static function isToken(string $token, bool $verify = false): bool | types\user {
101 101
         if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
102
-            if ($verify){
102
+            if ($verify) {
103 103
                 $res = telegram::me($token);
104 104
                 if (telegram::$status) {
105 105
                     return $res;
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
      * @param int|null $user_id e.g. => '442109602'
133 133
      * @return bool
134 134
      */
135
-    public static function isJoined (array|string|int $ids , int|null $user_id = null): bool {
135
+    public static function isJoined(array | string | int $ids, int | null $user_id = null): bool {
136 136
         if (!is_array($ids)) {
137 137
             $ids = [$ids];
138 138
         }
139 139
         //$user_id = $user_id ?? $this->catchFields(['field' => 'user_id']);
140 140
 
141 141
         foreach ($ids as $id) {
142
-            $check = telegram::getChatMember($id,$user_id);
142
+            $check = telegram::getChatMember($id, $user_id);
143 143
             if (telegram::$status) {
144 144
                 $check = $check->status;
145 145
                 return !($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED);
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
      * @param string $characters e.g. => 'abcdefg'
168 168
      * @return string
169 169
      */
170
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
170
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
171 171
         $rand_string = '';
172 172
         $char_len = strlen($characters) - 1;
173
-        for ($i = 0; $i < $length; $i ++) {
173
+        for ($i = 0; $i < $length; $i++) {
174 174
             $rand_string .= $characters[rand(0, $char_len)];
175 175
         }
176 176
         return $rand_string;
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
      * @param string $mode Your selected mode e.g. => `parseMode::HTML` | `HTML`
190 190
      * @return string|false return false when mode is incorrect
191 191
      */
192
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
192
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
193 193
         return match ($mode) {
194
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
195
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
194
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
195
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
196 196
             parseMode::MARKDOWNV2 => str_replace(
197 197
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
198 198
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
      * @param int $precision e.g. => 2
219 219
      * @return string
220 220
      */
221
-    public static function byteFormat (int $byte, int $precision = 2): string {
221
+    public static function byteFormat(int $byte, int $precision = 2): string {
222 222
         $rate_counter = 0;
223 223
 
224
-        while ($byte > 1024){
224
+        while ($byte > 1024) {
225 225
             $byte /= 1024;
226 226
             $rate_counter++;
227 227
         }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
             $byte = round($byte, $precision);
231 231
         }
232 232
 
233
-        return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
233
+        return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
234 234
     }
235 235
 
236 236
     /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @param bool $format if you set this true , you will receive symbolic string like 2.76MB
251 251
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
252 252
      */
253
-    public static function size (string $path, bool $format = true): string|int|false {
253
+    public static function size(string $path, bool $format = true): string | int | false {
254 254
         if (filter_var($path, FILTER_VALIDATE_URL)) {
255 255
             $ch = curl_init($path);
256 256
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * @param array $array e.g. => ['path'=>'xfolder/yfolder','sub'=>true]
286 286
      * @return bool
287 287
      */
288
-    public static function delete (string $path, bool $sub = true): bool {
288
+    public static function delete(string $path, bool $sub = true): bool {
289 289
         if (is_dir($path)) {
290 290
             if (count(scandir($path)) > 2) {
291 291
                 if ($sub) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                     rmdir($path);
298 298
                 }
299 299
                 else {
300
-                    logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::WARNING);
300
+                    logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::WARNING);
301 301
                     return false;
302 302
                 }
303 303
             }
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
      * @return array
321 321
      * @throws Exception
322 322
      */
323
-    public static function time2string (int $datetime): array {
323
+    public static function time2string(int $datetime): array {
324 324
         $now = new DateTime;
325
-        $input = new DateTime('@' . $datetime);
325
+        $input = new DateTime('@'.$datetime);
326 326
         $status = $now < $input ? 'later' : 'ago';
327 327
         $diff = $now->diff($input);
328 328
         $diff->w = floor($diff->d / 7);
Please login to merge, or discard this patch.
api/request/answer.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@  discard block
 block discarded – undo
12 12
 class answer {
13 13
     private static bool $is_answered = false;
14 14
 
15
-    public static function init(string $method,array $data) {
15
+    public static function init(string $method, array $data) {
16 16
         self::checkAnswered();
17 17
         self::checkWebhook();
18 18
         self::deleteAdditionalData($data);
19 19
         self::$is_answered = true;
20 20
         $data['method'] = $method;
21 21
         $payload = json_encode($data);
22
-        header('Content-Type: application/json;Content-Length: ' . strlen($payload));
22
+        header('Content-Type: application/json;Content-Length: '.strlen($payload));
23 23
         echo $payload;
24 24
         return true;
25 25
     }
26 26
 
27 27
     private static function checkAnswered() {
28 28
         if (self::$is_answered) {
29
-            logger::write('You can use answer mode only once for each webhook update , You already did it!',loggerTypes::ERROR);
29
+            logger::write('You can use answer mode only once for each webhook update , You already did it!', loggerTypes::ERROR);
30 30
             throw new bptException('ANSWER_MODE_USED');
31 31
         }
32 32
     }
33 33
 
34 34
     private static function checkWebhook() {
35
-        if(settings::$receiver === receiver::GETUPDATES) {
36
-            logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
35
+        if (settings::$receiver === receiver::GETUPDATES) {
36
+            logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR);
37 37
             throw new bptException('ANSWER_MODE_GETUPDATES');
38 38
         }
39
-        elseif(settings::$multi) {
40
-            logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
39
+        elseif (settings::$multi) {
40
+            logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR);
41 41
             throw new bptException('ANSWER_MODE_MULTI');
42 42
         }
43 43
     }
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
         if (isset($data['return_array'])) {
53 53
             unset($data['return_array']);
54 54
         }
55
-        foreach ($data as $key=>&$value){
56
-            if (!isset($value)){
55
+        foreach ($data as $key=>&$value) {
56
+            if (!isset($value)) {
57 57
                 unset($data[$key]);
58 58
             }
59
-            elseif (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
59
+            elseif (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) {
60 60
                 $value = json_encode($value);
61 61
             }
62 62
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
         if(settings::$receiver === receiver::GETUPDATES) {
36 36
             logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
37 37
             throw new bptException('ANSWER_MODE_GETUPDATES');
38
-        }
39
-        elseif(settings::$multi) {
38
+        } elseif(settings::$multi) {
40 39
             logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
41 40
             throw new bptException('ANSWER_MODE_MULTI');
42 41
         }
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
         foreach ($data as $key=>&$value){
56 55
             if (!isset($value)){
57 56
                 unset($data[$key]);
58
-            }
59
-            elseif (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
57
+            } elseif (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
60 58
                 $value = json_encode($value);
61 59
             }
62 60
         }
Please login to merge, or discard this patch.
api/telegram.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 namespace BPT\api;
4 4
 
5 5
 class telegram extends request {
6
-    public function __call (string $name, array $arguments) {
6
+    public function __call(string $name, array $arguments) {
7 7
         if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) {
8 8
             return request::$name(...$arguments[0]);
9 9
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -233,8 +233,7 @@
 block discarded – undo
233 233
     public function __call (string $name, array $arguments) {
234 234
         if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) {
235 235
             return request::$name(...$arguments[0]);
236
-        }
237
-        else {
236
+        } else {
238 237
             return request::$name(...$arguments);
239 238
         }
240 239
     }
Please login to merge, or discard this patch.