Passed
Push — main ( e8ebe8...e1a2dc )
by Miaad
01:30
created
receiver/multi/curl.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 use BPT\settings;
10 10
 
11 11
 class curl extends webhook {
12
-    public static function init (): string {
12
+    public static function init(): string {
13 13
         if (self::checkIP()) {
14 14
             return self::getUpdate();
15 15
         }
16 16
         else {
17
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown','error');
17
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', 'error');
18 18
             BPT::exit();
19 19
         }
20 20
     }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR'];
24 24
     }
25 25
 
26
-    private static function getUpdate (): string {
26
+    private static function getUpdate(): string {
27 27
         $input = json_decode(file_get_contents("php://input"), true);
28 28
         webhook::telegramVerify($input['ip']);
29 29
         return $input['update'];
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
         $urls = self::setURLS();
34 34
         $file = $urls['file'];
35 35
         $timeout = self::getTimeout($file);
36
-        self::create($file,$timeout);
36
+        self::create($file, $timeout);
37 37
         self::setWebhook($urls['url']);
38 38
         lock::set('BPT-MULTI-CURL');
39 39
     }
40 40
 
41
-    private static function getTimeout($url): float|int {
41
+    private static function getTimeout($url): float | int {
42 42
         $times = [];
43
-        for ($i = 0; $i < 10; $i ++) {
43
+        for ($i = 0; $i < 10; $i++) {
44 44
             $ch = curl_init($url);
45 45
             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']]);
46 46
             $start = microtime(true);
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
         return $timeout > 50 ? $timeout + 10 : 50;
52 52
     }
53 53
 
54
-    private static function create($file,$timeout) {
55
-        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);?>');
54
+    private static function create($file, $timeout) {
55
+        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);?>');
56 56
     }
57 57
 
58 58
     private static function setURLS(): array {
59
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
59
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
60 60
         $file = basename($_SERVER['REQUEST_URI']);
61 61
         return [
62 62
             'url'=>str_replace($file, 'receiver.php', $base_url),
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
     public static function init (): string {
13 13
         if (self::checkIP()) {
14 14
             return self::getUpdate();
15
-        }
16
-        else {
15
+        } else {
17 16
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown','error');
18 17
             BPT::exit();
19 18
         }
Please login to merge, or discard this patch.
receiver/multi/exec.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
         return self::getUpdate();
14 14
     }
15 15
 
16
-    private static function getUpdate (): string {
16
+    private static function getUpdate(): string {
17 17
         $up = glob('*.update');
18 18
         if (isset($up[0])) {
19 19
             $up = end($up);
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
             return $update;
25 25
         }
26 26
         else {
27
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown','error');
27
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', 'error');
28 28
             BPT::exit();
29 29
         }
30 30
     }
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     private static function create($file) {
47
-        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 &");');
47
+        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 &");');
48 48
     }
49 49
 
50 50
     private static function setURLS(): array {
51
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
51
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
52 52
         $file = basename($_SERVER['REQUEST_URI']);
53 53
         return [
54 54
             'url'=>str_replace($file, 'receiver.php', $base_url),
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
             $update = file_get_contents($up);
23 23
             unlink($up);
24 24
             return $update;
25
-        }
26
-        else {
25
+        } else {
27 26
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown','error');
28 27
             BPT::exit();
29 28
         }
Please login to merge, or discard this patch.
receiver/webhook.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 use CURLFile;
11 11
 
12 12
 class webhook extends receiver {
13
-    public static function init () {
13
+    public static function init() {
14 14
         if (settings::$multi) {
15 15
             multi::init();
16 16
         }
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
         $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates);
47 47
         if ($res->ok) {
48 48
             lock::set('BPT');
49
-            logger::write('Webhook was set successfully','info');
49
+            logger::write('Webhook was set successfully', 'info');
50 50
             BPT::exit('Done');
51 51
         }
52 52
         else {
53
-            logger::write("There is some problem happened , telegram response : \n".json_encode($res),'error');
54
-            BPT::exit(print_r($res,true));
53
+            logger::write("There is some problem happened , telegram response : \n".json_encode($res), 'error');
54
+            BPT::exit(print_r($res, true));
55 55
         }
56 56
     }
57 57
 
58 58
     protected static function checkURL() {
59 59
         if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
60
-            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)','error');
60
+            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', 'error');
61 61
             BPT::exit();
62 62
         }
63 63
     }
64 64
 
65 65
     private static function setURL(): string {
66
-        return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
66
+        return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
67 67
     }
68 68
 
69 69
     protected static function setCertificate() {
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,14 +13,12 @@  discard block
 block discarded – undo
13 13
     public static function init () {
14 14
         if (settings::$multi) {
15 15
             multi::init();
16
-        }
17
-        else {
16
+        } else {
18 17
             if (lock::exist('BPT-HOOK')) {
19 18
                 receiver::telegramVerify();
20 19
                 BPT::$update = receiver::processUpdate();
21 20
                 logger::write('Update received , lets process it ;)');
22
-            }
23
-            else {
21
+            } else {
24 22
                 self::deleteOldLocks();
25 23
                 self::checkURL();
26 24
                 self::setCertificate();
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
             lock::set('BPT');
49 47
             logger::write('Webhook was set successfully','info');
50 48
             BPT::exit('Done');
51
-        }
52
-        else {
49
+        } else {
53 50
             logger::write("There is some problem happened , telegram response : \n".json_encode($res),'error');
54 51
             BPT::exit(print_r($res,true));
55 52
         }
@@ -71,8 +68,7 @@  discard block
 block discarded – undo
71 68
             if (is_string(settings::$certificate)) {
72 69
                 if (file_exists(settings::$certificate)) {
73 70
                     settings::$certificate = new CURLFile(settings::$certificate);
74
-                }
75
-                else {
71
+                } else {
76 72
                     settings::$certificate = null;
77 73
                 }
78 74
             }
Please login to merge, or discard this patch.
receiver/multi.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
         if (lock::exist('BPT-MULTI-EXEC')) {
14 14
             self::setUpdate(exec::init());
15 15
         }
16
-        elseif(lock::exist('BPT-MULTI-CURL')) {
16
+        elseif (lock::exist('BPT-MULTI-CURL')) {
17 17
             self::setUpdate(curl::init());
18 18
         }
19 19
         else {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,11 +12,9 @@
 block discarded – undo
12 12
     public static function init() {
13 13
         if (lock::exist('BPT-MULTI-EXEC')) {
14 14
             self::setUpdate(exec::init());
15
-        }
16
-        elseif(lock::exist('BPT-MULTI-CURL')) {
15
+        } elseif(lock::exist('BPT-MULTI-CURL')) {
17 16
             self::setUpdate(curl::init());
18
-        }
19
-        else {
17
+        } else {
20 18
             self::deleteOldLocks();
21 19
             self::checkURL();
22 20
             self::setCertificate();
Please login to merge, or discard this patch.
receiver/receiver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     protected static function telegramVerify(string $ip = null) {
13 13
         if (settings::$telegram_verify) {
14 14
             if (!tools::isTelegram($ip ?? $_SERVER['REMOTE_ADDR'] ?? '')) {
15
-                logger::write('not authorized access denied. IP : '. $ip ?? $_SERVER['REMOTE_ADDR'] ?? 'unknown','error');
15
+                logger::write('not authorized access denied. IP : '.$ip ?? $_SERVER['REMOTE_ADDR'] ?? 'unknown', 'error');
16 16
                 BPT::exit();
17 17
             }
18 18
         }
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         return $update;
29 29
     }
30 30
 
31
-    protected static function setMessageExtra (update &$update) {
31
+    protected static function setMessageExtra(update & $update) {
32 32
         if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) {
33 33
             $type = isset($update->message) ? 'message' : 'edited_message';
34 34
             $text = &$update->$type->text;
Please login to merge, or discard this patch.