@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public static int $log_size = 10; |
23 | 23 | |
24 | - public static string|CURLFile|null $certificate = null; |
|
24 | + public static string | CURLFile | null $certificate = null; |
|
25 | 25 | |
26 | 26 | public static bool $handler = true; |
27 | 27 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | |
52 | 52 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
53 | 53 | |
54 | - public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
54 | + public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
55 | 55 | |
56 | 56 | |
57 | - public static function init (array|stdClass $settings) { |
|
57 | + public static function init(array | stdClass $settings) { |
|
58 | 58 | $settings = (array) $settings; |
59 | 59 | |
60 | 60 | if (!(isset($settings['logger']) && $settings['logger'] == false)) { |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | foreach ($settings as $setting => $value) { |
65 | - try{ |
|
65 | + try { |
|
66 | 66 | self::$$setting = $value; |
67 | 67 | } |
68 | - catch (TypeError){ |
|
69 | - logger::write("$setting setting has wrong type , its set to default value",'warning'); |
|
68 | + catch (TypeError) { |
|
69 | + logger::write("$setting setting has wrong type , its set to default value", 'warning'); |
|
70 | 70 | } |
71 | - catch (Error){ |
|
72 | - logger::write("$setting setting is not one of library settings",'warning'); |
|
71 | + catch (Error) { |
|
72 | + logger::write("$setting setting is not one of library settings", 'warning'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
82 | 82 | } |
83 | 83 | else { |
84 | - logger::write('token format is not right, check it and try again','error'); |
|
84 | + logger::write('token format is not right, check it and try again', 'error'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | else { |
88 | - logger::write('You must specify token parameter in settings','error'); |
|
88 | + logger::write('You must specify token parameter in settings', 'error'); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | if (self::$secure_folder) { |
109 | 109 | $address = explode('/', $_SERVER['REQUEST_URI']); |
110 | 110 | unset($address[count($address) - 1]); |
111 | - $address = implode('/', $address) . '/BPT.php'; |
|
111 | + $address = implode('/', $address).'/BPT.php'; |
|
112 | 112 | $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>"; |
113 | 113 | if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) { |
114 | 114 | file_put_contents('.htaccess', $text); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | getUpdates::init(); |
128 | 128 | } |
129 | 129 | else { |
130 | - logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler','error'); |
|
130 | + logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', 'error'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace BPT\receiver; |
4 | 4 | |
5 | 5 | class getUpdates { |
6 | - public static function init () { |
|
6 | + public static function init() { |
|
7 | 7 | |
8 | 8 | } |
9 | 9 | } |
10 | 10 | \ No newline at end of file |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace BPT\receiver; |
4 | 4 | |
5 | 5 | class webhook { |
6 | - public static function init () { |
|
6 | + public static function init() { |
|
7 | 7 | |
8 | 8 | } |
9 | 9 | } |
10 | 10 | \ No newline at end of file |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string $range Your range ip for check , if you didn't specify the block , it will be 32 |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public static function ipInRange (string $ip, string $range): bool { |
|
35 | + public static function ipInRange(string $ip, string $range): bool { |
|
36 | 36 | if (!str_contains($range, '/')) { |
37 | 37 | $range .= '/32'; |
38 | 38 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param string $ip Your ip to be check is telegram or not e.g. '192.168.1.1' |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public static function isTelegram (string $ip): bool { |
|
54 | + public static function isTelegram(string $ip): bool { |
|
55 | 55 | return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22'); |
56 | 56 | } |
57 | 57 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * @param string $ip Your ip to be check is CloudFlare or not e.g. '192.168.1.1' |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public static function isCloudFlare (string $ip): bool { |
|
68 | + public static function isCloudFlare(string $ip): bool { |
|
69 | 69 | $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']; |
70 | 70 | foreach ($cf_ips as $cf_ip) { |
71 | - if (self::ipInRange($ip,$cf_ip)) { |
|
71 | + if (self::ipInRange($ip, $cf_ip)) { |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @param bool $verify check token with telegram or not |
90 | 90 | * @return bool|array return array when verify is active and token is true array of telegram getMe result |
91 | 91 | */ |
92 | - public static function isToken (string $token, bool $verify = false): bool|array { |
|
92 | + public static function isToken(string $token, bool $verify = false): bool | array { |
|
93 | 93 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
94 | - if ($verify){ |
|
94 | + if ($verify) { |
|
95 | 95 | $res = telegram::me($token); |
96 | 96 | if ($res['ok']) { |
97 | 97 | return $res['result']; |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * @param string $characters e.g. => 'abcdefg' |
123 | 123 | * @return string |
124 | 124 | */ |
125 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
125 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
126 | 126 | $rand_string = ''; |
127 | 127 | $char_len = strlen($characters) - 1; |
128 | - for ($i = 0; $i < $length; $i ++) { |
|
128 | + for ($i = 0; $i < $length; $i++) { |
|
129 | 129 | $rand_string .= $characters[rand(0, $char_len)]; |
130 | 130 | } |
131 | 131 | return $rand_string; |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @param string $mode Your selected mode e.g. => `parseMode::HTML` | `HTML` |
145 | 145 | * @return string|false return false when mode is incorrect |
146 | 146 | */ |
147 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
147 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
148 | 148 | return match ($mode) { |
149 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
150 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
149 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
150 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
151 | 151 | parseMode::MARKDOWNV2 => str_replace( |
152 | 152 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
153 | 153 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | * @param int $precision e.g. => 2 |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public static function byteFormat (int $byte, int $precision = 2): string { |
|
176 | + public static function byteFormat(int $byte, int $precision = 2): string { |
|
177 | 177 | $rate_counter = 0; |
178 | 178 | |
179 | - while ($byte > 1024){ |
|
179 | + while ($byte > 1024) { |
|
180 | 180 | $byte /= 1024; |
181 | 181 | $rate_counter++; |
182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $byte = round($byte, $precision); |
186 | 186 | } |
187 | 187 | |
188 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
188 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param bool $format if you set this true , you will receive symbolic string like 2.76MB |
206 | 206 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
207 | 207 | */ |
208 | - public static function size (string $path, bool $format = true): string|int|false { |
|
208 | + public static function size(string $path, bool $format = true): string | int | false { |
|
209 | 209 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
210 | 210 | $ch = curl_init($path); |
211 | 211 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | else return false; |
226 | 226 | } |
227 | 227 | |
228 | - public static function error2trace (\Throwable $error,$seen = null): string { |
|
228 | + public static function error2trace(\Throwable $error, $seen = null): string { |
|
229 | 229 | $starter = $seen ? 'Caused by: ' : ''; |
230 | 230 | $result = []; |
231 | 231 | if (!$seen) $seen = []; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $file = $error->getFile(); |
236 | 236 | $line = $error->getLine(); |
237 | 237 | |
238 | - while (true){ |
|
238 | + while (true) { |
|
239 | 239 | $current = "$file:$line"; |
240 | 240 | if (is_array($seen) && in_array($current, $seen)) { |
241 | 241 | $result[] = sprintf(' ... %d more', count($trace) + 1); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $result = join("\n", $result); |
263 | 263 | if ($prev) { |
264 | - $result .= "\n" . self::error2trace($prev, $seen); |
|
264 | + $result .= "\n".self::error2trace($prev, $seen); |
|
265 | 265 | } |
266 | 266 | return $result; |
267 | 267 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | use mysqli; |
6 | 6 | |
7 | 7 | class db { |
8 | - public static function init (array|mysqli $db) { |
|
8 | + public static function init(array | mysqli $db) { |
|
9 | 9 | |
10 | 10 | } |
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -225,18 +225,18 @@ discard block |
||
225 | 225 | ]; |
226 | 226 | |
227 | 227 | |
228 | - public static function __callStatic (string $name, array $arguments) { |
|
228 | + public static function __callStatic(string $name, array $arguments) { |
|
229 | 229 | if ($action = self::methodAction($name)) { |
230 | - self::keysName($action,$arguments); |
|
231 | - self::readyFile($action,$arguments); |
|
230 | + self::keysName($action, $arguments); |
|
231 | + self::readyFile($action, $arguments); |
|
232 | 232 | print_r($arguments); |
233 | 233 | } |
234 | 234 | else { |
235 | - logger::write("$name method is not supported",'error'); |
|
235 | + logger::write("$name method is not supported", 'error'); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - private static function keysName (string $name, array &$arguments) { |
|
239 | + private static function keysName(string $name, array &$arguments) { |
|
240 | 240 | foreach ($arguments as $key => $argument) { |
241 | 241 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
242 | 242 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - private static function methodAction(string $name): string|false { |
|
248 | + private static function methodAction(string $name): string | false { |
|
249 | 249 | return self::METHODS_ACTION[strtolower($name)] ?? false; |
250 | 250 | } |
251 | 251 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - private static function methodFile(string $name): array|false { |
|
269 | + private static function methodFile(string $name): array | false { |
|
270 | 270 | return self::METHODS_WITH_FILE[$name] ?? false; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | \ No newline at end of file |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace BPT\api; |
4 | 4 | |
5 | 5 | class telegram { |
6 | - public function __call (string $name, array $arguments) { |
|
6 | + public function __call(string $name, array $arguments) { |
|
7 | 7 | if (!isset($arguments[1]) && is_array($arguments[0])) { |
8 | 8 | request::$name(...$arguments[0]); |
9 | 9 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | - public static function __callStatic (string $name, array $arguments) { |
|
15 | + public static function __callStatic(string $name, array $arguments) { |
|
16 | 16 | if (!isset($arguments[1]) && is_array($arguments[0])) { |
17 | 17 | request::$name(...$arguments[0]); |
18 | 18 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | private static $handler; |
9 | 9 | |
10 | 10 | |
11 | - public static function init (int $log_size = 10) { |
|
11 | + public static function init(int $log_size = 10) { |
|
12 | 12 | self::$log_size = $log_size; |
13 | 13 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) { |
14 | 14 | $mode = 'a'; |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | self::$handler = fopen('BPT.log', $mode); |
23 | 23 | |
24 | 24 | if ($write) { |
25 | - 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"); |
|
25 | + 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"); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function write($data, $type = '') { |
30 | 30 | if (!is_null(self::$handler)) { |
31 | - $text = date('Y/m/d H:i:s') . ( $type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
31 | + $text = date('Y/m/d H:i:s').($type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
32 | 32 | fwrite(self::$handler, $text); |
33 | 33 | } |
34 | 34 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | use BPT\types\update; |
7 | 7 | use stdClass; |
8 | 8 | |
9 | -class BPT{ |
|
9 | +class BPT { |
|
10 | 10 | public update $update; |
11 | 11 | |
12 | 12 | |
13 | - public function __construct (array|stdClass $settings) { |
|
13 | + public function __construct(array | stdClass $settings) { |
|
14 | 14 | settings::init($settings); |
15 | 15 | } |
16 | 16 | |
17 | - public function __call (string $name, array $arguments) { |
|
17 | + public function __call(string $name, array $arguments) { |
|
18 | 18 | if (!isset($arguments[1]) && is_array($arguments[0])) { |
19 | 19 | request::$name(...$arguments[0]); |
20 | 20 | } |