@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public static int $log_size = 10; |
| 23 | 23 | |
| 24 | - public static string|CURLFile|null $certificate = null; |
|
| 24 | + public static string | CURLFile | null $certificate = null; |
|
| 25 | 25 | |
| 26 | 26 | public static bool $handler = true; |
| 27 | 27 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
| 53 | 53 | |
| 54 | - public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
| 54 | + public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public static function init (array|stdClass $settings) {
|
|
| 57 | + public static function init(array | stdClass $settings) {
|
|
| 58 | 58 | $settings = (array) $settings; |
| 59 | 59 | |
| 60 | 60 | if (!(isset($settings['logger']) && $settings['logger'] == false)) {
|
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | foreach ($settings as $setting => $value) {
|
| 65 | - try{
|
|
| 65 | + try {
|
|
| 66 | 66 | self::$$setting = $value; |
| 67 | 67 | } |
| 68 | - catch (TypeError){
|
|
| 69 | - logger::write("$setting setting has wrong type , its set to default value",'warning');
|
|
| 68 | + catch (TypeError) {
|
|
| 69 | + logger::write("$setting setting has wrong type , its set to default value", 'warning');
|
|
| 70 | 70 | } |
| 71 | - catch (Error){
|
|
| 72 | - logger::write("$setting setting is not one of library settings",'warning');
|
|
| 71 | + catch (Error) {
|
|
| 72 | + logger::write("$setting setting is not one of library settings", 'warning');
|
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
| 82 | 82 | } |
| 83 | 83 | else {
|
| 84 | - logger::write('token format is not right, check it and try again','error');
|
|
| 84 | + logger::write('token format is not right, check it and try again', 'error');
|
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | else {
|
| 88 | - logger::write('You must specify token parameter in settings','error');
|
|
| 88 | + logger::write('You must specify token parameter in settings', 'error');
|
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | if (self::$secure_folder) {
|
| 109 | 109 | $address = explode('/', $_SERVER['REQUEST_URI']);
|
| 110 | 110 | unset($address[count($address) - 1]); |
| 111 | - $address = implode('/', $address) . '/BPT.php';
|
|
| 111 | + $address = implode('/', $address).'/BPT.php';
|
|
| 112 | 112 | $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>"; |
| 113 | 113 | if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
|
| 114 | 114 | file_put_contents('.htaccess', $text);
|
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | getUpdates::init(); |
| 128 | 128 | } |
| 129 | 129 | else {
|
| 130 | - logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler','error');
|
|
| 130 | + logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', 'error');
|
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace BPT\receiver; |
| 4 | 4 | |
| 5 | 5 | class getUpdates {
|
| 6 | - public static function init () {
|
|
| 6 | + public static function init() {
|
|
| 7 | 7 | |
| 8 | 8 | } |
| 9 | 9 | } |
| 10 | 10 | \ No newline at end of file |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use mysqli; |
| 6 | 6 | |
| 7 | 7 | class db {
|
| 8 | - public static function init (array|mysqli $db) {
|
|
| 8 | + public static function init(array | mysqli $db) {
|
|
| 9 | 9 | |
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | 12 | \ No newline at end of file |
@@ -225,18 +225,18 @@ discard block |
||
| 225 | 225 | ]; |
| 226 | 226 | |
| 227 | 227 | |
| 228 | - public static function __callStatic (string $name, array $arguments) {
|
|
| 228 | + public static function __callStatic(string $name, array $arguments) {
|
|
| 229 | 229 | if ($action = self::methodAction($name)) {
|
| 230 | - self::keysName($action,$arguments); |
|
| 231 | - self::readyFile($action,$arguments); |
|
| 230 | + self::keysName($action, $arguments); |
|
| 231 | + self::readyFile($action, $arguments); |
|
| 232 | 232 | print_r($arguments); |
| 233 | 233 | } |
| 234 | 234 | else {
|
| 235 | - logger::write("$name method is not supported",'error');
|
|
| 235 | + logger::write("$name method is not supported", 'error');
|
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - private static function keysName (string $name, array &$arguments) {
|
|
| 239 | + private static function keysName(string $name, array &$arguments) {
|
|
| 240 | 240 | foreach ($arguments as $key => $argument) {
|
| 241 | 241 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
|
| 242 | 242 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - private static function methodAction(string $name): string|false {
|
|
| 248 | + private static function methodAction(string $name): string | false {
|
|
| 249 | 249 | return self::METHODS_ACTION[strtolower($name)] ?? false; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - private static function methodFile(string $name): array|false {
|
|
| 269 | + private static function methodFile(string $name): array | false {
|
|
| 270 | 270 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | private static $handler; |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - public static function init (int $log_size = 10) {
|
|
| 11 | + public static function init(int $log_size = 10) {
|
|
| 12 | 12 | self::$log_size = $log_size; |
| 13 | 13 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) {
|
| 14 | 14 | $mode = 'a'; |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | self::$handler = fopen('BPT.log', $mode);
|
| 23 | 23 | |
| 24 | 24 | if ($write) {
|
| 25 | - 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"); |
|
| 25 | + 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"); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function write($data, $type = '') {
|
| 30 | 30 | if (!is_null(self::$handler)) {
|
| 31 | - $text = date('Y/m/d H:i:s') . ( $type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
|
|
| 31 | + $text = date('Y/m/d H:i:s').($type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
|
|
| 32 | 32 | fwrite(self::$handler, $text); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @method static getGameHigh (int|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $return_array = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects. |
| 215 | 215 | */ |
| 216 | 216 | class telegram {
|
| 217 | - public function __call (string $name, array $arguments) {
|
|
| 217 | + public function __call(string $name, array $arguments) {
|
|
| 218 | 218 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 219 | 219 | request::$name(...$arguments[0]); |
| 220 | 220 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public static function __callStatic (string $name, array $arguments) {
|
|
| 226 | + public static function __callStatic(string $name, array $arguments) {
|
|
| 227 | 227 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 228 | 228 | request::$name(...$arguments[0]); |
| 229 | 229 | } |
@@ -225,18 +225,18 @@ discard block |
||
| 225 | 225 | ]; |
| 226 | 226 | |
| 227 | 227 | |
| 228 | - public static function __callStatic (string $name, array $arguments) {
|
|
| 228 | + public static function __callStatic(string $name, array $arguments) {
|
|
| 229 | 229 | if ($action = self::methodAction($name)) {
|
| 230 | - self::keysName($action,$arguments); |
|
| 231 | - self::readyFile($action,$arguments); |
|
| 230 | + self::keysName($action, $arguments); |
|
| 231 | + self::readyFile($action, $arguments); |
|
| 232 | 232 | print_r($arguments); |
| 233 | 233 | } |
| 234 | 234 | else {
|
| 235 | - logger::write("$name method is not supported",'error');
|
|
| 235 | + logger::write("$name method is not supported", 'error');
|
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - private static function keysName (string $name, array &$arguments) {
|
|
| 239 | + private static function keysName(string $name, array &$arguments) {
|
|
| 240 | 240 | foreach ($arguments as $key => $argument) {
|
| 241 | 241 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
|
| 242 | 242 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - private static function methodAction(string $name): string|false {
|
|
| 248 | + private static function methodAction(string $name): string | false {
|
|
| 249 | 249 | return self::METHODS_ACTION[strtolower($name)] ?? false; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - private static function methodFile(string $name): array|false {
|
|
| 269 | + private static function methodFile(string $name): array | false {
|
|
| 270 | 270 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | \ No newline at end of file |
@@ -11,16 +11,16 @@ |
||
| 11 | 11 | return touch("$name.lock");
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function save(string $name, string $data): bool|int {
|
|
| 14 | + public static function save(string $name, string $data): bool | int {
|
|
| 15 | 15 | return file_put_contents("$name.lock", $data);
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public static function read(string $name): bool|string {
|
|
| 19 | + public static function read(string $name): bool | string {
|
|
| 20 | 20 | return file_get_contents("$name.lock");
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function mtime(string $name): bool|int {
|
|
| 23 | + public static function mtime(string $name): bool | int {
|
|
| 24 | 24 | return filemtime("$name.lock");
|
| 25 | 25 | } |
| 26 | 26 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use CURLFile; |
| 13 | 13 | |
| 14 | 14 | class webhook {
|
| 15 | - public static function init () {
|
|
| 15 | + public static function init() {
|
|
| 16 | 16 | if (settings::$multi) {
|
| 17 | 17 | multi::init(); |
| 18 | 18 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | private static function telegramVerify() {
|
| 33 | 33 | if (settings::$telegram_verify) {
|
| 34 | 34 | if (!tools::isTelegram($_SERVER['REMOTE_ADDR'])) {
|
| 35 | - logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'],'error');
|
|
| 35 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'], 'error');
|
|
| 36 | 36 | BPT::exit(); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | private static function setWebhook() {
|
| 64 | 64 | if (isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI'])) {
|
| 65 | 65 | self::setCertificate(); |
| 66 | - $url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
| 66 | + $url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
| 67 | 67 | |
| 68 | 68 | $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates); |
| 69 | 69 | if ($res->ok) {
|
| 70 | 70 | lock::set('BPT');
|
| 71 | - logger::write('Webhook was set successfully','info');
|
|
| 71 | + logger::write('Webhook was set successfully', 'info');
|
|
| 72 | 72 | BPT::exit('Done');
|
| 73 | 73 | } |
| 74 | 74 | else {
|
| 75 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),'error');
|
|
| 76 | - BPT::exit(print_r($res,true)); |
|
| 75 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), 'error');
|
|
| 76 | + BPT::exit(print_r($res, true)); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | else {
|
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - private static function setMessageExtra(update &$update) {
|
|
| 98 | - if((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))){
|
|
| 97 | + private static function setMessageExtra(update & $update) {
|
|
| 98 | + if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) {
|
|
| 99 | 99 | if (isset($update->message)) $type = 'message'; |
| 100 | 100 | else $type = 'edited_message'; |
| 101 | 101 | |
| 102 | 102 | $text = &$update->$type->text; |
| 103 | - if (settings::$security){
|
|
| 103 | + if (settings::$security) {
|
|
| 104 | 104 | $text = tools::clearText($text); |
| 105 | 105 | } |
| 106 | - if (str_starts_with($text, '/')){
|
|
| 107 | - preg_match('/\/([a-zA-Z_0-9]{1,64})(@[a-zA-Z]\w{1,28}bot)?( [\S]{1,64})?/',$text,$result);
|
|
| 108 | - if (!empty($result[1])){
|
|
| 106 | + if (str_starts_with($text, '/')) {
|
|
| 107 | + preg_match('/\/([a-zA-Z_0-9]{1,64})(@[a-zA-Z]\w{1,28}bot)?( [\S]{1,64})?/', $text, $result);
|
|
| 108 | + if (!empty($result[1])) {
|
|
| 109 | 109 | $update->$type->commend = $result[1]; |
| 110 | 110 | } |
| 111 | - if (!empty($result[2])){
|
|
| 111 | + if (!empty($result[2])) {
|
|
| 112 | 112 | $update->$type->commend_username = $result[2]; |
| 113 | 113 | } |
| 114 | - if (!empty($result[3])){
|
|
| 114 | + if (!empty($result[3])) {
|
|
| 115 | 115 | $update->$type->commend_payload = $result[3]; |
| 116 | 116 | } |
| 117 | 117 | } |