@@ -79,7 +79,7 @@ |
||
| 79 | 79 | public string $hash; |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - public function __construct(stdClass|null $object = null) { |
|
| 82 | + public function __construct(stdClass | null $object = null) { |
|
| 83 | 83 | if ($object != null) { |
| 84 | 84 | parent::__construct($object, self::subs); |
| 85 | 85 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | public array $allowed_updates; |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - public function __construct(stdClass|null $object = null) { |
|
| 51 | + public function __construct(stdClass | null $object = null) { |
|
| 52 | 52 | if ($object != null) { |
| 53 | 53 | parent::__construct($object, self::subs); |
| 54 | 54 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | public shippingAddress $shipping_address; |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - public function __construct(stdClass|null $object = null) { |
|
| 27 | + public function __construct(stdClass | null $object = null) { |
|
| 28 | 28 | if ($object != null) { |
| 29 | 29 | parent::__construct($object, self::subs); |
| 30 | 30 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | public int $duration; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct(stdClass|null $object = null) { |
|
| 56 | + public function __construct(stdClass | null $object = null) { |
|
| 57 | 57 | if ($object != null) { |
| 58 | 58 | parent::__construct($object, self::subs); |
| 59 | 59 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public int $score; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - public function __construct(stdClass|null $object = null) { |
|
| 24 | + public function __construct(stdClass | null $object = null) { |
|
| 25 | 25 | if ($object != null) { |
| 26 | 26 | parent::__construct($object, self::subs); |
| 27 | 27 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the |
| 53 | 53 | * thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
| 54 | 54 | */ |
| 55 | - public CURLFile|string $thumb; |
|
| 55 | + public CURLFile | string $thumb; |
|
| 56 | 56 | |
| 57 | 57 | /** `video` and `animation` only. width */ |
| 58 | 58 | public int $width; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public bool $disable_content_type_detection; |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - public function __construct(stdClass|null $object = null) { |
|
| 82 | + public function __construct(stdClass | null $object = null) { |
|
| 83 | 83 | if ($object != null) { |
| 84 | 84 | parent::__construct($object, self::subs); |
| 85 | 85 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return string|bool|array{hash:string, key:string, iv:string} |
| 30 | 30 | * @throws bptException |
| 31 | 31 | */ |
| 32 | - public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
| 32 | + public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
| 33 | 33 | if (extension_loaded('openssl')) { |
| 34 | 34 | if ($action === cryptoAction::ENCRYPT) { |
| 35 | 35 | $key = self::randomString(64); |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | elseif ($action === cryptoAction::DECRYPT) { |
| 41 | 41 | if (empty($key)) { |
| 42 | - logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
|
| 42 | + logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR); |
|
| 43 | 43 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
| 44 | 44 | } |
| 45 | 45 | elseif (empty($iv)) { |
| 46 | - logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR); |
|
| 46 | + logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR); |
|
| 47 | 47 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 48 | 48 | } |
| 49 | 49 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 50 | 50 | } |
| 51 | 51 | else { |
| 52 | - logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
| 52 | + logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | else { |
| 57 | - logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
| 57 | + logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
| 58 | 58 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public static function shortEncode(int $num): string { |
| 72 | 72 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 73 | 73 | $array = []; |
| 74 | - while ($num > 0){ |
|
| 74 | + while ($num > 0) { |
|
| 75 | 75 | $array[] = $num % 62; |
| 76 | 76 | $num = floor($num / 62); |
| 77 | 77 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | foreach ($array as &$value) { |
| 80 | 80 | $value = $codes[$value]; |
| 81 | 81 | } |
| 82 | - return strrev(implode('',$array)); |
|
| 82 | + return strrev(implode('', $array)); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $num = 0; |
| 97 | 97 | $text = str_split(strrev($text)); |
| 98 | 98 | foreach ($text as $key=>$value) { |
| 99 | - $num += strpos($codes,$value) * pow(62,$key); |
|
| 99 | + $num += strpos($codes, $value) * pow(62, $key); |
|
| 100 | 100 | } |
| 101 | 101 | return $num; |
| 102 | 102 | } |
@@ -36,24 +36,20 @@ discard block |
||
| 36 | 36 | $iv = self::randomString(); |
| 37 | 37 | $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv)); |
| 38 | 38 | return ['hash' => $output, 'key' => $key, 'iv' => $iv]; |
| 39 | - } |
|
| 40 | - elseif ($action === cryptoAction::DECRYPT) { |
|
| 39 | + } elseif ($action === cryptoAction::DECRYPT) { |
|
| 41 | 40 | if (empty($key)) { |
| 42 | 41 | logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
| 43 | 42 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
| 44 | - } |
|
| 45 | - elseif (empty($iv)) { |
|
| 43 | + } elseif (empty($iv)) { |
|
| 46 | 44 | logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR); |
| 47 | 45 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 48 | 46 | } |
| 49 | 47 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 50 | - } |
|
| 51 | - else { |
|
| 48 | + } else { |
|
| 52 | 49 | logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
| 53 | 50 | return false; |
| 54 | 51 | } |
| 55 | - } |
|
| 56 | - else { |
|
| 52 | + } else { |
|
| 57 | 53 | logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
| 58 | 54 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
| 59 | 55 | } |
@@ -75,7 +71,9 @@ discard block |
||
| 75 | 71 | $array[] = $num % 62; |
| 76 | 72 | $num = floor($num / 62); |
| 77 | 73 | } |
| 78 | - if (count($array) < 1) $array = [0]; |
|
| 74 | + if (count($array) < 1) { |
|
| 75 | + $array = [0]; |
|
| 76 | + } |
|
| 79 | 77 | foreach ($array as &$value) { |
| 80 | 78 | $value = $codes[$value]; |
| 81 | 79 | } |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) { |
| 18 | 18 | $mode = 'a'; |
| 19 | 19 | $write = false; |
| 20 | - } |
|
| 21 | - else { |
|
| 20 | + } else { |
|
| 22 | 21 | $mode = 'w'; |
| 23 | 22 | $write = true; |
| 24 | 23 | } |
@@ -39,8 +38,7 @@ discard block |
||
| 39 | 38 | $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
| 40 | 39 | if (!is_null(self::$handler)) { |
| 41 | 40 | fwrite(self::$handler, $text); |
| 42 | - } |
|
| 43 | - else { |
|
| 41 | + } else { |
|
| 44 | 42 | self::$waited_logs[] = $text; |
| 45 | 43 | } |
| 46 | 44 | } |
@@ -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 | if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) { |
| 23 | 23 | $mode = 'a'; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | self::$handler = fopen(settings::$name.'BPT.log', $mode); |
| 31 | 31 | |
| 32 | 32 | if ($write) { |
| 33 | - 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"); |
|
| 33 | + 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 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if (self::$waited_logs != []) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | 53 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
| 54 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
| 54 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
| 55 | 55 | if (!is_null(self::$handler)) { |
| 56 | 56 | fwrite(self::$handler, $text); |
| 57 | 57 | } |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | $curl_handler = curl_init(settings::$base_url."/bot$token/"); |
| 36 | 36 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 37 | 37 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 38 | - } |
|
| 39 | - else{ |
|
| 38 | + } else{ |
|
| 40 | 39 | $token = settings::$token; |
| 41 | 40 | if (!isset(self::$curl_handler)){ |
| 42 | 41 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
@@ -58,11 +57,9 @@ discard block |
||
| 58 | 57 | if (isset($data['forgot'])) { |
| 59 | 58 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 60 | 59 | unset($data['forgot']); |
| 61 | - } |
|
| 62 | - elseif ($method === 'getUpdates'){ |
|
| 60 | + } elseif ($method === 'getUpdates'){ |
|
| 63 | 61 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 64 | - } |
|
| 65 | - else{ |
|
| 62 | + } else{ |
|
| 66 | 63 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
| 67 | 64 | } |
| 68 | 65 | } |
@@ -17,17 +17,17 @@ 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(string $method,array $data) { |
|
| 20 | + public static function init(string $method, array $data) { |
|
| 21 | 21 | $info = self::getInfo($data); |
| 22 | 22 | $data = $info['data']; |
| 23 | 23 | $handler = $info['handler']; |
| 24 | - self::setTimeout($data,$handler,$method); |
|
| 24 | + self::setTimeout($data, $handler, $method); |
|
| 25 | 25 | self::setData($data); |
| 26 | 26 | $data['method'] = $method; |
| 27 | 27 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
| 28 | 28 | $result = curl_exec($handler); |
| 29 | 29 | if (curl_errno($handler)) { |
| 30 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
| 30 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
| 31 | 31 | } |
| 32 | 32 | if ($info['token'] != settings::$token) { |
| 33 | 33 | curl_close($handler); |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 44 | 44 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 45 | 45 | } |
| 46 | - else{ |
|
| 46 | + else { |
|
| 47 | 47 | $token = settings::$token; |
| 48 | - if (!isset(self::$curl_handler)){ |
|
| 48 | + if (!isset(self::$curl_handler)) { |
|
| 49 | 49 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
| 50 | 50 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 51 | 51 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -61,22 +61,22 @@ discard block |
||
| 61 | 61 | ]; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
| 64 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
| 65 | 65 | if (isset($data['forgot'])) { |
| 66 | 66 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 67 | 67 | unset($data['forgot']); |
| 68 | 68 | } |
| 69 | - elseif ($method === 'getUpdates'){ |
|
| 69 | + elseif ($method === 'getUpdates') { |
|
| 70 | 70 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 71 | 71 | } |
| 72 | - else{ |
|
| 72 | + else { |
|
| 73 | 73 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | private static function setData(array &$data): void { |
| 78 | - foreach ($data as &$value){ |
|
| 79 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
| 78 | + foreach ($data as &$value) { |
|
| 79 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
| 80 | 80 | $value = json_encode($value); |
| 81 | 81 | } |
| 82 | 82 | } |