@@ -17,7 +17,7 @@ discard block |
||
| 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 | $log_file = realpath(settings::$name.'BPT.log'); |
| 23 | 23 | if (file_exists($log_file) && !(filesize($log_file) > self::$log_size * 1024 * 1024)) { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | self::$handler = fopen($log_file, $mode); |
| 32 | 32 | |
| 33 | 33 | if ($write) { |
| 34 | - 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 | + 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"); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (self::$waited_logs != []) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | 54 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
| 55 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
| 55 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
| 56 | 56 | if (!is_null(self::$handler)) { |
| 57 | 57 | fwrite(self::$handler, $text); |
| 58 | 58 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @internal Only for BPT self usage , Don't use it in your source! |
| 22 | 22 | */ |
| 23 | - public static function init () { |
|
| 23 | + public static function init() { |
|
| 24 | 24 | if (settings::$multi) { |
| 25 | 25 | multi::init(); |
| 26 | 26 | } |
@@ -49,24 +49,24 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected static function setWebhook(string $url,string $secret = '') { |
|
| 52 | + protected static function setWebhook(string $url, string $secret = '') { |
|
| 53 | 53 | $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); |
| 54 | 54 | if (!telegram::$status) { |
| 55 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
| 56 | - BPT::exit(print_r($res,true)); |
|
| 55 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
| 56 | + BPT::exit(print_r($res, true)); |
|
| 57 | 57 | } |
| 58 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
| 58 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | protected static function checkURL() { |
| 62 | 62 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
| 63 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
| 63 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
| 64 | 64 | throw new bptException('WEBHOOK_NEED_URL'); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private static function setURL(): string { |
| 69 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
| 69 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | protected static function setCertificate() { |
@@ -89,15 +89,15 @@ discard block |
||
| 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 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | - public static function fastClose (int $timeout = 86400): bool { |
|
| 118 | + public static function fastClose(int $timeout = 86400): bool { |
|
| 119 | 119 | if (settings::$multi || !lock::exist('BPT-HOOK')) { |
| 120 | 120 | return false; |
| 121 | 121 | } |
@@ -23,15 +23,13 @@ discard block |
||
| 23 | 23 | public static function init () { |
| 24 | 24 | if (settings::$multi) { |
| 25 | 25 | multi::init(); |
| 26 | - } |
|
| 27 | - else { |
|
| 26 | + } else { |
|
| 28 | 27 | if (lock::exist('BPT-HOOK')) { |
| 29 | 28 | receiver::telegramVerify(); |
| 30 | 29 | self::checkSecret(); |
| 31 | 30 | logger::write('Update received , lets process it ;)'); |
| 32 | 31 | receiver::processUpdate(); |
| 33 | - } |
|
| 34 | - else { |
|
| 32 | + } else { |
|
| 35 | 33 | self::processSetWebhook(); |
| 36 | 34 | } |
| 37 | 35 | } |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | if (is_string(settings::$certificate)) { |
| 75 | 73 | if (file_exists(realpath(settings::$certificate))) { |
| 76 | 74 | settings::$certificate = new CURLFile(settings::$certificate); |
| 77 | - } |
|
| 78 | - else { |
|
| 75 | + } else { |
|
| 79 | 76 | settings::$certificate = null; |
| 80 | 77 | } |
| 81 | 78 | } |
@@ -125,11 +122,9 @@ discard block |
||
| 125 | 122 | ignore_user_abort(true); |
| 126 | 123 | if (function_exists('fastcgi_finish_request')) { |
| 127 | 124 | fastcgi_finish_request(); |
| 128 | - } |
|
| 129 | - elseif (function_exists('litespeed_finish_request')) { |
|
| 125 | + } elseif (function_exists('litespeed_finish_request')) { |
|
| 130 | 126 | litespeed_finish_request(); |
| 131 | - } |
|
| 132 | - else { |
|
| 127 | + } else { |
|
| 133 | 128 | return false; |
| 134 | 129 | } |
| 135 | 130 | |