debug mode setting

This commit is contained in:
mercury
2023-06-10 13:45:19 +04:00
parent 192a2f83e2
commit 40ccd0106b
3 changed files with 25 additions and 1 deletions
+18
View File
@@ -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, "<?php\n\n\$c = " . var_export($c, true) . ";\n");
$this->menu('config');
}
public function getStatusPeer(string $publickey, array $peers)
{
foreach ($peers as $k => $v) {
+4
View File
@@ -237,4 +237,8 @@ $i = [
'en' => 'defaultDNS',
'ru' => 'дефолтный днс',
],
'debug' => [
'en' => 'debug mode',
'ru' => 'режим отладки',
],
];
+3 -1
View File
@@ -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';