@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
17 | 17 | */ |
18 | 18 | class telegram extends request { |
19 | - public function __call (string $name, array $arguments) { |
|
19 | + public function __call(string $name, array $arguments) { |
|
20 | 20 | return request::$name(...$arguments); |
21 | 21 | } |
22 | 22 | |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return bool |
36 | 36 | */ |
37 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
37 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
38 | 38 | $file = telegram::getFile($file_id); |
39 | 39 | if (!isset($file->file_path)) { |
40 | 40 | return false; |
41 | 41 | } |
42 | - $file_path = settings::$down_url . 'bot' . settings::$token . '/' . $file->file_path; |
|
42 | + $file_path = settings::$down_url.'bot'.settings::$token.'/'.$file->file_path; |
|
43 | 43 | return tools::downloadFile($file_path, $destination); |
44 | 44 | } |
45 | 45 | |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return message|bool|responseError |
59 | 59 | */ |
60 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
60 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
61 | 61 | $type = tools::fileType($file_id); |
62 | 62 | if ($type === fileTypes::VIDEO) { |
63 | - return self::sendVideo($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
63 | + return self::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
64 | 64 | } |
65 | 65 | elseif ($type === fileTypes::VIDEO_NOTE) { |
66 | - return self::sendVideoNote($file_id,$chat_id,$message_thread_id,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
66 | + return self::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
67 | 67 | } |
68 | 68 | elseif ($type === fileTypes::ANIMATION) { |
69 | - return self::sendAnimation($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
69 | + return self::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
70 | 70 | } |
71 | 71 | elseif ($type === fileTypes::AUDIO) { |
72 | - return self::sendAudio($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
72 | + return self::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
73 | 73 | } |
74 | 74 | elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
75 | - return self::sendPhoto($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
75 | + return self::sendPhoto($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
76 | 76 | } |
77 | 77 | elseif ($type === fileTypes::VOICE) { |
78 | - return self::sendVoice($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
78 | + return self::sendVoice($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
79 | 79 | } |
80 | 80 | elseif ($type === fileTypes::STICKER) { |
81 | - return self::sendSticker($file_id,$chat_id,$message_thread_id,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
81 | + return self::sendSticker($file_id, $chat_id, $message_thread_id, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
82 | 82 | } |
83 | 83 | elseif ($type === fileTypes::DOCUMENT) { |
84 | - return self::sendDocument($file_id,$chat_id,$message_thread_id,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
84 | + return self::sendDocument($file_id, $chat_id, $message_thread_id, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
85 | 85 | } |
86 | 86 | else return false; |
87 | 87 | } |
@@ -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), |
@@ -16,23 +16,23 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class getUpdates extends receiver { |
18 | 18 | #[NoReturn] |
19 | - public static function init () { |
|
19 | + public static function init() { |
|
20 | 20 | $last_update_id = self::loadData(); |
21 | - while(true) { |
|
21 | + while (true) { |
|
22 | 22 | if (!lock::exist('getUpdate')) { |
23 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates); |
|
23 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates); |
|
24 | 24 | if (!telegram::$status) { |
25 | - logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
|
26 | - BPT::exit(print_r($updates,true)); |
|
25 | + logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR); |
|
26 | + BPT::exit(print_r($updates, true)); |
|
27 | 27 | } |
28 | 28 | self::handleUpdates($updates); |
29 | - lock::save('getUpdate',BPT::$update->update_id+1); |
|
30 | - $last_update_id = BPT::$update->update_id+1; |
|
29 | + lock::save('getUpdate', BPT::$update->update_id + 1); |
|
30 | + $last_update_id = BPT::$update->update_id + 1; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - private static function loadData(): bool|int|string { |
|
35 | + private static function loadData(): bool | int | string { |
|
36 | 36 | if (lock::exist('getUpdate')) { |
37 | 37 | $last_update_id = lock::read('getUpdate'); |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | self::deleteOldLocks(); |
41 | 41 | telegram::deleteWebhook(); |
42 | 42 | $last_update_id = 0; |
43 | - lock::save('getUpdate',0); |
|
43 | + lock::save('getUpdate', 0); |
|
44 | 44 | } |
45 | 45 | return $last_update_id; |
46 | 46 | } |
@@ -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 | } |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | * @method bool|responseError unpinAllForumTopicMessages (int|string|array $chat_id, int $message_thread_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. |
258 | 258 | * @method bool|responseError unpinTopicMessages (int|string|array $chat_id, int $message_thread_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. |
259 | 259 | */ |
260 | -class BPT extends telegram{ |
|
260 | +class BPT extends telegram { |
|
261 | 261 | public static update $update; |
262 | 262 | |
263 | 263 | public static BPT $handler; |
264 | 264 | |
265 | 265 | |
266 | - public function __construct (array|stdClass $settings) { |
|
266 | + public function __construct(array | stdClass $settings) { |
|
267 | 267 | static::$handler = &$this; |
268 | 268 | settings::init($settings); |
269 | 269 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | #[NoReturn] |
276 | - public static function exit (string|null $message = null) { |
|
276 | + public static function exit (string | null $message = null) { |
|
277 | 277 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
278 | 278 | } |
279 | 279 | } |
@@ -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 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public static int $log_size = 10; |
27 | 27 | |
28 | - public static string|CURLFile|null $certificate = null; |
|
28 | + public static string | CURLFile | null $certificate = null; |
|
29 | 29 | |
30 | 30 | public static bool $handler = true; |
31 | 31 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | |
60 | 60 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
61 | 61 | |
62 | - public static array|null $db = ['type' => 'json']; |
|
62 | + public static array | null $db = ['type' => 'json']; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @internal Only for BPT self usage , Don't use it in your source! |
66 | 66 | */ |
67 | - public static function init (array|stdClass $settings): void { |
|
67 | + public static function init(array | stdClass $settings): void { |
|
68 | 68 | $settings = (array) $settings; |
69 | 69 | foreach ($settings as $setting => $value) { |
70 | 70 | try { |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | if (!is_dir(realpath('bots_files'))) { |
73 | 73 | mkdir('bots_files'); |
74 | 74 | } |
75 | - if (!is_dir(realpath('bots_files/' . $value))) { |
|
76 | - mkdir('bots_files/' . $value); |
|
75 | + if (!is_dir(realpath('bots_files/'.$value))) { |
|
76 | + mkdir('bots_files/'.$value); |
|
77 | 77 | } |
78 | - $value = 'bots_files/' . $value . '/'; |
|
78 | + $value = 'bots_files/'.$value.'/'; |
|
79 | 79 | } |
80 | 80 | self::$$setting = $value; |
81 | 81 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @internal Only for BPT self usage , Don't use it in your source! |
110 | 110 | */ |
111 | - public static function done (): void { |
|
111 | + public static function done(): void { |
|
112 | 112 | if (self::$logger) { |
113 | 113 | $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2); |
114 | 114 | $status_message = match (true) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - private static function security (): void { |
|
126 | + private static function security(): void { |
|
127 | 127 | if (self::$security) { |
128 | 128 | ini_set('magic_quotes_gpc', 'off'); |
129 | 129 | ini_set('sql.safe_mode', 'on'); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - private static function secureFolder (): void { |
|
141 | + private static function secureFolder(): void { |
|
142 | 142 | if (self::$secure_folder) { |
143 | 143 | $address = explode('/', $_SERVER['REQUEST_URI']); |
144 | 144 | unset($address[count($address) - 1]); |
145 | - $address = implode('/', $address) . '/BPT.php'; |
|
145 | + $address = implode('/', $address).'/BPT.php'; |
|
146 | 146 | $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>"; |
147 | 147 | $htaccess = realpath('.htaccess'); |
148 | 148 | if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - private static function getUpdates (): void { |
|
154 | + private static function getUpdates(): void { |
|
155 | 155 | if (!self::$handler) { |
156 | 156 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
157 | 157 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
@@ -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 |