@@ -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 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use CURLFile; |
| 14 | 14 | |
| 15 | 15 | class webhook extends receiver { |
| 16 | - public static function init () { |
|
| 16 | + public static function init() { |
|
| 17 | 17 | if (settings::$multi) { |
| 18 | 18 | multi::init(); |
| 19 | 19 | } |
@@ -42,26 +42,26 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected static function setWebhook(string $url,string $secret = '') { |
|
| 45 | + protected static function setWebhook(string $url, string $secret = '') { |
|
| 46 | 46 | $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); |
| 47 | 47 | if (telegram::$status) { |
| 48 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
| 48 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
| 49 | 49 | } |
| 50 | 50 | else { |
| 51 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
| 52 | - BPT::exit(print_r($res,true)); |
|
| 51 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
| 52 | + BPT::exit(print_r($res, true)); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | protected static function checkURL() { |
| 57 | 57 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
| 58 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
| 58 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
| 59 | 59 | throw new bptException('WEBHOOK_NEED_URL'); |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | private static function setURL(): string { |
| 64 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
| 64 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected static function setCertificate() { |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | self::setCertificate(); |
| 84 | 84 | $url = self::setURL(); |
| 85 | 85 | $secret = settings::$secret ?? tools::randomString(64); |
| 86 | - self::setWebhook($url,$secret); |
|
| 87 | - lock::save('BPT-HOOK',$secret); |
|
| 86 | + self::setWebhook($url, $secret); |
|
| 87 | + lock::save('BPT-HOOK', $secret); |
|
| 88 | 88 | BPT::exit('Done'); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private static function checkSecret() { |
| 92 | 92 | $secret = lock::read('BPT-HOOK'); |
| 93 | 93 | if ($secret !== self::getSecret()) { |
| 94 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING); |
|
| 94 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING); |
|
| 95 | 95 | self::processSetWebhook(); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -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 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | private static $handler; |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - public static function init (int $log_size = 10): void { |
|
| 15 | + public static function init(int $log_size = 10): void { |
|
| 16 | 16 | self::$log_size = $log_size; |
| 17 | 17 | if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) { |
| 18 | 18 | $mode = 'a'; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | self::$handler = fopen(settings::$name.'BPT.log', $mode); |
| 26 | 26 | |
| 27 | 27 | if ($write) { |
| 28 | - 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 | + 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"); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | if (self::$waited_logs != []) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
| 39 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
| 39 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
| 40 | 40 | if (!is_null(self::$handler)) { |
| 41 | 41 | fwrite(self::$handler, $text); |
| 42 | 42 | } |
@@ -10,17 +10,17 @@ discard block |
||
| 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 |
||
| 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."/bot$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 |
||
| 54 | 54 | ]; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
| 57 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
| 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): void { |
| 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 | } |
@@ -11,15 +11,15 @@ |
||
| 11 | 11 | return touch(settings::$name."$name.lock"); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function save(string $name, string $data): bool|int { |
|
| 15 | - return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock",0640); |
|
| 14 | + public static function save(string $name, string $data): bool | int { |
|
| 15 | + return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock", 0640); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public static function read(string $name): bool|string { |
|
| 18 | + public static function read(string $name): bool | string { |
|
| 19 | 19 | return file_get_contents(settings::$name."$name.lock"); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function mtime(string $name): bool|int { |
|
| 22 | + public static function mtime(string $name): bool | int { |
|
| 23 | 23 | return filemtime(settings::$name."$name.lock"); |
| 24 | 24 | } |
| 25 | 25 | |