@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class bptException extends Exception{} |
|
8 | 7 | \ No newline at end of file |
8 | +class bptException extends Exception {} |
|
9 | 9 | \ No newline at end of file |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class telegramException extends Exception{} |
|
8 | 7 | \ No newline at end of file |
8 | +class telegramException extends Exception {} |
|
9 | 9 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public static int $log_size = 10; |
25 | 25 | |
26 | - public static string|CURLFile|null $certificate = null; |
|
26 | + public static string | CURLFile | null $certificate = null; |
|
27 | 27 | |
28 | 28 | public static bool $handler = true; |
29 | 29 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | |
54 | 54 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
55 | 55 | |
56 | - public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
56 | + public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
57 | 57 | |
58 | 58 | |
59 | - public static function init (array|stdClass $settings) { |
|
59 | + public static function init(array | stdClass $settings) { |
|
60 | 60 | $settings = (array) $settings; |
61 | 61 | |
62 | 62 | if (!(isset($settings['logger']) && $settings['logger'] == false)) { |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | foreach ($settings as $setting => $value) { |
67 | - try{ |
|
67 | + try { |
|
68 | 68 | self::$$setting = $value; |
69 | 69 | } |
70 | - catch (TypeError){ |
|
71 | - logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING); |
|
70 | + catch (TypeError) { |
|
71 | + logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING); |
|
72 | 72 | } |
73 | - catch (Error){ |
|
74 | - logger::write("$setting setting is not one of library settings",loggerTypes::WARNING); |
|
73 | + catch (Error) { |
|
74 | + logger::write("$setting setting is not one of library settings", loggerTypes::WARNING); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
84 | 84 | } |
85 | 85 | else { |
86 | - logger::write('token format is not right, check it and try again',loggerTypes::ERROR); |
|
86 | + logger::write('token format is not right, check it and try again', loggerTypes::ERROR); |
|
87 | 87 | throw new bptException('TOKEN_NOT_TRUE'); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | else { |
91 | - logger::write('You must specify token parameter in settings',loggerTypes::ERROR); |
|
91 | + logger::write('You must specify token parameter in settings', loggerTypes::ERROR); |
|
92 | 92 | throw new bptException('TOKEN_NOT_FOUND'); |
93 | 93 | } |
94 | 94 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if (self::$secure_folder) { |
113 | 113 | $address = explode('/', $_SERVER['REQUEST_URI']); |
114 | 114 | unset($address[count($address) - 1]); |
115 | - $address = implode('/', $address) . '/BPT.php'; |
|
115 | + $address = implode('/', $address).'/BPT.php'; |
|
116 | 116 | $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>"; |
117 | 117 | if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) { |
118 | 118 | file_put_contents('.htaccess', $text); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | getUpdates::init(); |
132 | 132 | } |
133 | 133 | else { |
134 | - logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR); |
|
134 | + logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
|
135 | 135 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
136 | 136 | } |
137 | 137 | } |
@@ -66,11 +66,9 @@ discard block |
||
66 | 66 | foreach ($settings as $setting => $value) { |
67 | 67 | try{ |
68 | 68 | self::$$setting = $value; |
69 | - } |
|
70 | - catch (TypeError){ |
|
69 | + } catch (TypeError){ |
|
71 | 70 | logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING); |
72 | - } |
|
73 | - catch (Error){ |
|
71 | + } catch (Error){ |
|
74 | 72 | logger::write("$setting setting is not one of library settings",loggerTypes::WARNING); |
75 | 73 | } |
76 | 74 | } |
@@ -81,13 +79,11 @@ discard block |
||
81 | 79 | self::secureFolder(); |
82 | 80 | self::db(); |
83 | 81 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
84 | - } |
|
85 | - else { |
|
82 | + } else { |
|
86 | 83 | logger::write('token format is not right, check it and try again',loggerTypes::ERROR); |
87 | 84 | throw new bptException('TOKEN_NOT_TRUE'); |
88 | 85 | } |
89 | - } |
|
90 | - else { |
|
86 | + } else { |
|
91 | 87 | logger::write('You must specify token parameter in settings',loggerTypes::ERROR); |
92 | 88 | throw new bptException('TOKEN_NOT_FOUND'); |
93 | 89 | } |
@@ -129,8 +125,7 @@ discard block |
||
129 | 125 | private static function getUpdates() { |
130 | 126 | if (self::$handler) { |
131 | 127 | getUpdates::init(); |
132 | - } |
|
133 | - else { |
|
128 | + } else { |
|
134 | 129 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR); |
135 | 130 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
136 | 131 | } |