@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | public string $sticker_type; |
22 | 22 | |
23 | 23 | /** True, if the sticker set contains animated stickers */ |
24 | - public null|bool $is_animated = null; |
|
24 | + public null | bool $is_animated = null; |
|
25 | 25 | |
26 | 26 | /** True, if the sticker set contains video stickers */ |
27 | - public null|bool $is_video = null; |
|
27 | + public null | bool $is_video = null; |
|
28 | 28 | |
29 | 29 | /** Deprecated use sticker_type instead, True, if the sticker set contains masks */ |
30 | - public null|bool $contains_masks = null; |
|
30 | + public null | bool $contains_masks = null; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * List of all set stickers |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | public array $stickers; |
37 | 37 | |
38 | 38 | /** Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format */ |
39 | - public null|photoSize $thumb = null; |
|
39 | + public null | photoSize $thumb = null; |
|
40 | 40 | |
41 | 41 | |
42 | - public function __construct(stdClass|null $object = null) { |
|
42 | + public function __construct(stdClass | null $object = null) { |
|
43 | 43 | if ($object != null) { |
44 | 44 | parent::__construct($object, self::subs); |
45 | 45 | } |
@@ -17,16 +17,16 @@ |
||
17 | 17 | * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for |
18 | 18 | * storing this identifier. |
19 | 19 | */ |
20 | - public null|int $migrate_to_chat_id = null; |
|
20 | + public null | int $migrate_to_chat_id = null; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be |
24 | 24 | * repeated |
25 | 25 | */ |
26 | - public null|int $retry_after = null; |
|
26 | + public null | int $retry_after = null; |
|
27 | 27 | |
28 | 28 | |
29 | - public function __construct(stdClass|null $object = null) { |
|
29 | + public function __construct(stdClass | null $object = null) { |
|
30 | 30 | if ($object != null) { |
31 | 31 | parent::__construct($object, self::subs); |
32 | 32 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | * Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the |
16 | 16 | * message. |
17 | 17 | */ |
18 | - public null|string $inline_message_id = null; |
|
18 | + public null | string $inline_message_id = null; |
|
19 | 19 | |
20 | 20 | |
21 | - public function __construct(stdClass|null $object = null) { |
|
21 | + public function __construct(stdClass | null $object = null) { |
|
22 | 22 | if ($object != null) { |
23 | 23 | parent::__construct($object, self::subs); |
24 | 24 | } |
@@ -29,43 +29,43 @@ |
||
29 | 29 | public int $total_voter_count; |
30 | 30 | |
31 | 31 | /** True, if the poll is closed */ |
32 | - public null|bool $is_closed = null; |
|
32 | + public null | bool $is_closed = null; |
|
33 | 33 | |
34 | 34 | /** True, if the poll is anonymous */ |
35 | - public null|bool $is_anonymous = null; |
|
35 | + public null | bool $is_anonymous = null; |
|
36 | 36 | |
37 | 37 | /** Poll type, currently can be “regular” or “quiz” */ |
38 | 38 | public string $type; |
39 | 39 | |
40 | 40 | /** True, if the poll allows multiple answers */ |
41 | - public null|bool $allows_multiple_answers = null; |
|
41 | + public null | bool $allows_multiple_answers = null; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which |
45 | 45 | * are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. |
46 | 46 | */ |
47 | - public null|int $correct_option_id = null; |
|
47 | + public null | int $correct_option_id = null; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style |
51 | 51 | * poll, 0-200 characters |
52 | 52 | */ |
53 | - public null|string $explanation = null; |
|
53 | + public null | string $explanation = null; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation |
57 | 57 | * @var messageEntity[] |
58 | 58 | */ |
59 | - public null|array $explanation_entities = null; |
|
59 | + public null | array $explanation_entities = null; |
|
60 | 60 | |
61 | 61 | /** Optional. Amount of time in seconds the poll will be active after creation */ |
62 | - public null|int $open_period = null; |
|
62 | + public null | int $open_period = null; |
|
63 | 63 | |
64 | 64 | /** Optional. Point in time (Unix timestamp) when the poll will be automatically closed */ |
65 | - public null|int $close_date = null; |
|
65 | + public null | int $close_date = null; |
|
66 | 66 | |
67 | 67 | |
68 | - public function __construct(stdClass|null $object = null) { |
|
68 | + public function __construct(stdClass | null $object = null) { |
|
69 | 69 | if ($object != null) { |
70 | 70 | parent::__construct($object, self::subs); |
71 | 71 | } |
@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @internal Only for BPT self usage , Don't use it in your source! |
18 | 18 | */ |
19 | - public static function init(string $method,array $data) { |
|
19 | + public static function init(string $method, array $data) { |
|
20 | 20 | $info = self::getInfo($data); |
21 | 21 | $data = $info['data']; |
22 | 22 | $handler = $info['handler']; |
23 | - self::setTimeout($data,$handler,$method); |
|
23 | + self::setTimeout($data, $handler, $method); |
|
24 | 24 | self::setData($data); |
25 | 25 | $data['method'] = $method; |
26 | 26 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
27 | 27 | $result = curl_exec($handler); |
28 | 28 | if (curl_errno($handler)) { |
29 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
29 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
30 | 30 | } |
31 | 31 | if ($info['token'] != settings::$token) { |
32 | 32 | curl_close($handler); |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
43 | 43 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
44 | 44 | } |
45 | - else{ |
|
45 | + else { |
|
46 | 46 | $token = settings::$token; |
47 | - if (!isset(self::$curl_handler)){ |
|
47 | + if (!isset(self::$curl_handler)) { |
|
48 | 48 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
49 | 49 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
50 | 50 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | ]; |
61 | 61 | } |
62 | 62 | |
63 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
63 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
64 | 64 | if (isset($data['forgot'])) { |
65 | 65 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
66 | 66 | unset($data['forgot']); |
67 | 67 | } |
68 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
68 | + elseif ($method === 'getUpdates' || $method === 'setWebhook') { |
|
69 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
70 | 70 | } |
71 | - else{ |
|
71 | + else { |
|
72 | 72 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | private static function setData(array &$data): void { |
77 | - foreach ($data as &$value){ |
|
78 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
77 | + foreach ($data as &$value) { |
|
78 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
79 | 79 | $value = json_encode($value); |
80 | 80 | } |
81 | 81 | } |
@@ -17,14 +17,14 @@ 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|null { |
|
20 | + public static function init(): string | null { |
|
21 | 21 | return self::getUpdate(); |
22 | 22 | } |
23 | 23 | |
24 | - private static function getUpdate (): string|null { |
|
24 | + private static function getUpdate(): string | null { |
|
25 | 25 | $up = glob('*.update'); |
26 | 26 | if (!isset($up[0])) { |
27 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
27 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
28 | 28 | BPT::exit(); |
29 | 29 | } |
30 | 30 | $up = end($up); |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | private static function create($file) { |
59 | - file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php ' . $file . ' > /dev/null &");'); |
|
59 | + file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php '.$file.' > /dev/null &");'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | #[ArrayShape(['url' => "array|string|string[]", 'file' => "string"])] |
63 | 63 | private static function setURLS(): array { |
64 | - $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
64 | + $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
65 | 65 | return [ |
66 | 66 | 'url'=>str_replace(basename($_SERVER['REQUEST_URI']), 'receiver.php', $base_url), |
67 | 67 | 'file'=>basename($_SERVER['SCRIPT_NAME']) |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * curl class , for multiprocessing with curl tricks |
15 | 15 | */ |
16 | 16 | class curl extends webhook { |
17 | - public static function init (): string|null { |
|
17 | + public static function init(): string | null { |
|
18 | 18 | if (!self::checkIP()) { |
19 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
19 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
20 | 20 | BPT::exit(); |
21 | 21 | } |
22 | 22 | return self::getUpdate(); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']; |
27 | 27 | } |
28 | 28 | |
29 | - private static function getUpdate (): string { |
|
29 | + private static function getUpdate(): string { |
|
30 | 30 | $input = json_decode(file_get_contents("php://input"), true); |
31 | 31 | webhook::telegramVerify($input['ip']); |
32 | 32 | return $input['update']; |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | $urls = self::setURLS(); |
40 | 40 | $file = $urls['file']; |
41 | 41 | $timeout = self::getTimeout($file); |
42 | - self::create($file,$timeout); |
|
42 | + self::create($file, $timeout); |
|
43 | 43 | self::setWebhook($urls['url']); |
44 | 44 | lock::set('BPT-MULTI-CURL'); |
45 | 45 | } |
46 | 46 | |
47 | - private static function getTimeout($url): float|int { |
|
47 | + private static function getTimeout($url): float | int { |
|
48 | 48 | $times = []; |
49 | - for ($i = 0; $i < 10; $i ++) { |
|
49 | + for ($i = 0; $i < 10; $i++) { |
|
50 | 50 | $ch = curl_init($url); |
51 | 51 | curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([]), CURLOPT_TIMEOUT_MS => 100, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 100, CURLOPT_HTTPHEADER => ['accept: application/json', 'content-type: application/json']]); |
52 | 52 | $start = microtime(true); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | return $timeout > 50 ? $timeout + 10 : 50; |
58 | 58 | } |
59 | 59 | |
60 | - private static function create($file,$timeout) { |
|
61 | - file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\'' . $file . '\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => ' . $timeout . ', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => ' . $timeout . ', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>'); |
|
60 | + private static function create($file, $timeout) { |
|
61 | + file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\''.$file.'\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => '.$timeout.', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => '.$timeout.', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | #[ArrayShape(['url' => "array|string|string[]", 'file' => "array|string|string[]"])] |
65 | 65 | private static function setURLS(): array { |
66 | - $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
66 | + $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
67 | 67 | $file = basename($_SERVER['REQUEST_URI']); |
68 | 68 | return [ |
69 | 69 | 'url'=>str_replace($file, 'receiver.php', $base_url), |
@@ -18,10 +18,10 @@ |
||
18 | 18 | public int $icon_color; |
19 | 19 | |
20 | 20 | /** Optional. Unique identifier of the custom emoji shown as the topic icon */ |
21 | - public null|string $icon_custom_emoji_id = null; |
|
21 | + public null | string $icon_custom_emoji_id = null; |
|
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 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool|int |
37 | 37 | */ |
38 | - public static function save(string $name, string $data): bool|int { |
|
39 | - return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock",0640); |
|
38 | + public static function save(string $name, string $data): bool | int { |
|
39 | + return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock", 0640); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return bool|string |
48 | 48 | */ |
49 | - public static function read(string $name): bool|string { |
|
49 | + public static function read(string $name): bool | string { |
|
50 | 50 | return file_get_contents(realpath(settings::$name."$name.lock")); |
51 | 51 | } |
52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return bool|int |
59 | 59 | */ |
60 | - public static function mtime(string $name): bool|int { |
|
60 | + public static function mtime(string $name): bool | int { |
|
61 | 61 | return filemtime(realpath(settings::$name."$name.lock")); |
62 | 62 | } |
63 | 63 |