From 40ccd0106b5089bd667b61f226cf58fd31c004f1 Mon Sep 17 00:00:00 2001 From: mercury Date: Sat, 10 Jun 2023 13:45:19 +0400 Subject: [PATCH] debug mode setting --- app/bot.php | 18 ++++++++++++++++++ app/i18n.php | 4 ++++ app/index.php | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/bot.php b/app/bot.php index c9d992c..5afe5bd 100644 --- a/app/bot.php +++ b/app/bot.php @@ -124,6 +124,9 @@ class Bot case preg_match('~^/mtproto$~', $this->input['callback'], $m): $this->mtproto(); break; + case preg_match('~^/debug$~', $this->input['callback'], $m): + $this->debug(); + break; case preg_match('~^/generateSecret$~', $this->input['callback'], $m): $this->generateSecret(); break; @@ -2632,6 +2635,12 @@ DNS-over-HTTPS with IP: 'callback_data' => "/blinkmenuswitch", ], ]; + $data[] = [ + [ + 'text' => $this->i18n('debug') . ': ' . $this->i18n($c['debug'] ? 'on' : 'off'), + 'callback_data' => "/debug", + ], + ]; $data[] = [ [ 'text' => $this->i18n('back'), @@ -2644,6 +2653,15 @@ DNS-over-HTTPS with IP: ]; } + public function debug() + { + $file = __DIR__ . '/config.php'; + require $file; + $c['debug'] = !$c['debug']; + file_put_contents($file, "menu('config'); + } + public function getStatusPeer(string $publickey, array $peers) { foreach ($peers as $k => $v) { diff --git a/app/i18n.php b/app/i18n.php index 6f2b77e..fa9f070 100644 --- a/app/i18n.php +++ b/app/i18n.php @@ -237,4 +237,8 @@ $i = [ 'en' => 'defaultDNS', 'ru' => 'дефолтный днс', ], + 'debug' => [ + 'en' => 'debug mode', + 'ru' => 'режим отладки', + ], ]; diff --git a/app/index.php b/app/index.php index 51e85b4..6f2c1a8 100644 --- a/app/index.php +++ b/app/index.php @@ -5,7 +5,9 @@ require __DIR__ . '/timezone.php'; // bot require __DIR__ . '/config.php'; if ('POST' == $_SERVER['REQUEST_METHOD'] && $_GET['k'] == $c['key']) { - // require __DIR__ . '/debug.php'; + if ($c['debug']) { + require __DIR__ . '/debug.php'; + } require __DIR__ . '/calc.php'; require __DIR__ . '/bot.php'; require __DIR__ . '/i18n.php';