|
|
|
@@ -13,6 +13,7 @@ class Bot
|
|
|
|
|
public $mtu;
|
|
|
|
|
public $logs;
|
|
|
|
|
public $reg;
|
|
|
|
|
public $pool;
|
|
|
|
|
|
|
|
|
|
public function __construct($key, $i18n)
|
|
|
|
|
{
|
|
|
|
@@ -161,6 +162,9 @@ class Bot
|
|
|
|
|
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
|
|
|
|
|
$this->switchBanIp();
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/setIpLimit$~', $this->input['callback'], $m):
|
|
|
|
|
$this->setIpLimit();
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/searchLogs (.+)$~', $this->input['message'], $m):
|
|
|
|
|
$this->searchLogs($m[1]);
|
|
|
|
|
break;
|
|
|
|
@@ -381,6 +385,9 @@ class Bot
|
|
|
|
|
case preg_match('~^/resetXrUser (\d+)$~', $this->input['callback'], $m):
|
|
|
|
|
$this->resetXrUser($m[1]);
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/resetXrStats$~', $this->input['callback'], $m):
|
|
|
|
|
$this->resetXrStats();
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/v2ray$~', $this->input['callback'], $m):
|
|
|
|
|
$this->v2ray();
|
|
|
|
|
break;
|
|
|
|
@@ -577,6 +584,9 @@ class Bot
|
|
|
|
|
case preg_match('~^/changeFakeDomain$~', $this->input['callback'], $m):
|
|
|
|
|
$this->changeFakeDomain();
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/autoCleanLogs$~', $this->input['callback'], $m):
|
|
|
|
|
$this->autoCleanLogs();
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/selfFakeDomain$~', $this->input['callback'], $m):
|
|
|
|
|
$this->selfFakeDomain();
|
|
|
|
|
break;
|
|
|
|
@@ -736,9 +746,21 @@ class Bot
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function collectSession($c) {
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$p['vlessstat']['global'] = [
|
|
|
|
|
'download' => $p['vlessstat']['global']['download'] + $p['vlessstat']['session']['download'],
|
|
|
|
|
'upload' => $p['vlessstat']['global']['upload'] + $p['vlessstat']['session']['upload'],
|
|
|
|
|
];
|
|
|
|
|
$p['vlessstat']['session'] = [
|
|
|
|
|
'download' => 0,
|
|
|
|
|
'upload' => 0,
|
|
|
|
|
];
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
foreach ($c['inbounds'][0]['settings']['clients'] as $k => $v) {
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][$k]['global']['download'] += $v['session']['download'];
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][$k]['session']['download'] = 0;
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][$k]['global']['upload'] += $v['session']['upload'];
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][$k]['session']['upload'] = 0;
|
|
|
|
|
}
|
|
|
|
|
return $c;
|
|
|
|
|
}
|
|
|
|
@@ -1006,7 +1028,7 @@ class Bot
|
|
|
|
|
$this->input['chat'],
|
|
|
|
|
"@{$this->input['username']} enter name",
|
|
|
|
|
$this->input['message_id'],
|
|
|
|
|
reply: 'enter password',
|
|
|
|
|
reply: 'enter name:uuid [,name:uuid]',
|
|
|
|
|
);
|
|
|
|
|
$_SESSION['reply'][$r['result']['message_id']] = [
|
|
|
|
|
'start_message' => $this->input['message_id'],
|
|
|
|
@@ -1316,6 +1338,7 @@ class Bot
|
|
|
|
|
$this->shutdownClientXr();
|
|
|
|
|
$this->checkVersion();
|
|
|
|
|
$this->checkBackup($period);
|
|
|
|
|
$this->checkLogs($period);
|
|
|
|
|
$this->checkCert();
|
|
|
|
|
$this->autoAnalyzeLogs();
|
|
|
|
|
$this->xrayStatsUser();
|
|
|
|
@@ -1326,7 +1349,13 @@ class Bot
|
|
|
|
|
public function xrayStatsUser()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$x = $this->getXray();
|
|
|
|
|
$x = $this->getXray();
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$td = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "inbound>>>vless_tls>>>traffic>>>downlink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
|
|
|
|
|
$tu = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "inbound>>>vless_tls>>>traffic>>>uplink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
|
|
|
|
|
$p['vlessstat']['session']['download'] = $td;
|
|
|
|
|
$p['vlessstat']['session']['upload'] = $tu;
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
if (!empty($users = $x['inbounds'][0]['settings']['clients'])) {
|
|
|
|
|
foreach ($users as $k => $v) {
|
|
|
|
|
$d = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "user>>>' . $v['email'] . '>>>traffic>>>downlink" 2>&1', 'xr'), true)['stat']['value'] ?: 0;
|
|
|
|
@@ -1408,6 +1437,26 @@ class Bot
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checkLogs($delta)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
|
if (!empty($c['autocleanlogs'])) {
|
|
|
|
|
$now = strtotime(date('Y-m-d H:i:s'));
|
|
|
|
|
[$start, $period] = explode('/', $c['autocleanlogs']);
|
|
|
|
|
$start = strtotime(trim($start));
|
|
|
|
|
$period = strtotime(trim($period), 0);
|
|
|
|
|
if (
|
|
|
|
|
!empty($start)
|
|
|
|
|
&& !empty($period)
|
|
|
|
|
&& empty($this->backup)
|
|
|
|
|
&& $now - $start >= 0
|
|
|
|
|
&& (($now - $start) % $period < $delta)
|
|
|
|
|
) {
|
|
|
|
|
$this->cleanLog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cleanQueue(): void
|
|
|
|
|
{
|
|
|
|
|
$r = $this->request('deleteWebhook', []);
|
|
|
|
@@ -2368,6 +2417,21 @@ class Bot
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setIpLimit()
|
|
|
|
|
{
|
|
|
|
|
$r = $this->send(
|
|
|
|
|
$this->input['chat'],
|
|
|
|
|
"@{$this->input['username']} enter seconds",
|
|
|
|
|
$this->input['message_id'],
|
|
|
|
|
reply: 'enter seconds',
|
|
|
|
|
);
|
|
|
|
|
$_SESSION['reply'][$r['result']['message_id']] = [
|
|
|
|
|
'start_message' => $this->input['message_id'],
|
|
|
|
|
'callback' => 'switchIpLimit',
|
|
|
|
|
'args' => [],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addLinkDomain()
|
|
|
|
|
{
|
|
|
|
|
$r = $this->send(
|
|
|
|
@@ -4382,6 +4446,18 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$this->ipMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function switchIpLimit(int $limit)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
|
if ($limit <= 0) {
|
|
|
|
|
unset($c['ip_limit']);
|
|
|
|
|
} else {
|
|
|
|
|
$c['ip_limit'] = $limit;
|
|
|
|
|
}
|
|
|
|
|
$this->setPacConf($c);
|
|
|
|
|
$this->xray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function switchSilence()
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
@@ -4396,12 +4472,6 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$pac = $this->getPacConf();
|
|
|
|
|
$d = count($pac['deny'] ?: []);
|
|
|
|
|
$w = count($pac['white'] ?: []);
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('logs'),
|
|
|
|
|
'callback_data' => "/logs",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('autoscan') . ': ' . ($pac['autoscan'] ? $this->getTime(strtotime(($pac['autoscan_timeout'] ?: 3600) . ' seconds')) : $this->i18n('off')),
|
|
|
|
@@ -5250,22 +5320,30 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$this->menu('oc');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addxrus($user)
|
|
|
|
|
public function addxrus($users)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getXray();
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$uuid = trim($this->ssh('xray uuid', 'xr'));
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
|
|
|
|
|
'id' => $uuid,
|
|
|
|
|
'email' => $user,
|
|
|
|
|
] : [
|
|
|
|
|
'id' => $uuid,
|
|
|
|
|
'flow' => 'xtls-rprx-vision',
|
|
|
|
|
'email' => $user,
|
|
|
|
|
];
|
|
|
|
|
$c = $this->getXray();
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$users = array_map(fn ($e) => trim($e), explode(',', $users));
|
|
|
|
|
$users = array_map(fn ($e) => explode(':', $e), $users);
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$uuid = $user[1] ?: trim($this->ssh('xray uuid', 'xr'));
|
|
|
|
|
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] != 'Reality' ? [
|
|
|
|
|
'id' => $uuid,
|
|
|
|
|
'email' => $user[0],
|
|
|
|
|
] : [
|
|
|
|
|
'id' => $uuid,
|
|
|
|
|
'flow' => 'xtls-rprx-vision',
|
|
|
|
|
'email' => $user[0],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$this->restartXray($c);
|
|
|
|
|
$this->adguardXrayClients();
|
|
|
|
|
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
|
|
|
|
|
if (count($users) == 1) {
|
|
|
|
|
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
|
|
|
|
|
} else {
|
|
|
|
|
$this->xray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setTimerXr($time, $i)
|
|
|
|
@@ -5326,6 +5404,15 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$this->userXr($i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function resetXrStats()
|
|
|
|
|
{
|
|
|
|
|
$this->restartXray($this->getXray());
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
unset($p['vlessstat']);
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
$this->xray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function listXr($i)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
@@ -5492,6 +5579,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
<code>~pac~</code>
|
|
|
|
|
<code>~package~</code>
|
|
|
|
|
<code>~process~</code>
|
|
|
|
|
<code>~subnet~</code>
|
|
|
|
|
<code>~block~</code>
|
|
|
|
|
<code>~warp~</code>
|
|
|
|
|
<code>~dns~</code>
|
|
|
|
@@ -5500,6 +5588,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
<code>~directdomain~</code>
|
|
|
|
|
<code>~cdndomain~</code>
|
|
|
|
|
<code>~short_id~</code>
|
|
|
|
|
<code>~email~</code>
|
|
|
|
|
<code>~public_key~</code>
|
|
|
|
|
<code>~server_name~</code>
|
|
|
|
|
<code>~ip~</code>
|
|
|
|
@@ -5624,6 +5713,14 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$text[] = "fake domain: <code>$fake</code>";
|
|
|
|
|
}
|
|
|
|
|
$text[] = 'transport: ' . ($p['transport'] ?: 'Websocket');
|
|
|
|
|
$td = $this->getBytes($p['vlessstat']['global']['download'] + $p['vlessstat']['session']['download']);
|
|
|
|
|
$tu = $this->getBytes($p['vlessstat']['global']['upload'] + $p['vlessstat']['session']['upload']);
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('reset stats') . ": ↓$td ↑$tu",
|
|
|
|
|
'callback_data' => '/resetXrStats',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
|
|
|
|
@@ -5645,6 +5742,10 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
'text' => $this->i18n('Websocket') . ' ' . ($p['transport'] != 'Reality' ? $this->i18n('on') : $this->i18n('off')),
|
|
|
|
|
'callback_data' => "/changeTransport 1",
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('ip limit') . ' ' . ($p['ip_limit'] ? ": {$p['ip_limit']} sec" : $this->i18n('off')),
|
|
|
|
|
'callback_data' => "/setIpLimit",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
if ($p['transport'] == 'Reality') {
|
|
|
|
|
$data[] = [
|
|
|
|
@@ -5833,6 +5934,79 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
return 'off';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function analyzeXray()
|
|
|
|
|
{
|
|
|
|
|
while (true) {
|
|
|
|
|
if (!empty($this->getPacConf()['ip_limit'])) {
|
|
|
|
|
$this->pool = [];
|
|
|
|
|
$log = '/logs/xray';
|
|
|
|
|
$r = fopen($log, 'r');
|
|
|
|
|
fseek($r, 0, SEEK_END);
|
|
|
|
|
while (true) {
|
|
|
|
|
$pac = $this->getPacConf();
|
|
|
|
|
if (empty($pac['ip_limit'])) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$currentPosition = ftell($r);
|
|
|
|
|
clearstatcache();
|
|
|
|
|
$fileSize = filesize($log);
|
|
|
|
|
if ($fileSize > $currentPosition) {
|
|
|
|
|
fseek($r, $currentPosition); // сброс флага feof
|
|
|
|
|
while (!feof($r)) {
|
|
|
|
|
$line = fgets($r);
|
|
|
|
|
if ($line !== false) {
|
|
|
|
|
$this->frequencyAnalyze($line, $pac);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|
|
|
|
|
fclose($r);
|
|
|
|
|
}
|
|
|
|
|
sleep(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function frequencyAnalyze($line, $pac)
|
|
|
|
|
{
|
|
|
|
|
preg_match('~(?<date>.+)\sfrom\s(?<ip>\d+\.\d+\.\d+\.\d+)(?=.+email:\s(?<email>.+))~', $line, $m);
|
|
|
|
|
if (!empty($this->pool)) {
|
|
|
|
|
foreach ($this->pool as $i => $j) {
|
|
|
|
|
if (!empty($j['ips'])) {
|
|
|
|
|
foreach ($j['ips'] as $k => $v) {
|
|
|
|
|
if ($v + $pac['ip_limit'] < time()) {
|
|
|
|
|
unset($this->pool[$i]['ips'][$k]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($m['ip']) && !empty($m['email'])) {
|
|
|
|
|
$ip = ip2long($m['ip']);
|
|
|
|
|
if (!empty($this->pool[$m['email']]['ip']) && $this->pool[$m['email']]['ip'] != $ip) {
|
|
|
|
|
$this->pool[$m['email']]['ips'][$ip] = time();
|
|
|
|
|
}
|
|
|
|
|
if (!empty($this->pool[$m['email']]['ips']) && count($this->pool[$m['email']]['ips']) > 1) {
|
|
|
|
|
$xr = $this->getXray();
|
|
|
|
|
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
|
|
|
|
|
if (empty($v['off']) && $v['email'] == $m['email']) {
|
|
|
|
|
require __DIR__ . '/config.php';
|
|
|
|
|
foreach ($c['admin'] as $k => $v) {
|
|
|
|
|
$this->send($v, "vless: {$m['email']} is turned off (limit by one IP)");
|
|
|
|
|
}
|
|
|
|
|
unset($this->pool[$m['email']]);
|
|
|
|
|
$this->switchXr($k, 1);
|
|
|
|
|
$flag = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (empty($flag)) {
|
|
|
|
|
$this->pool[$m['email']]['ip'] = $ip;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function offWarp()
|
|
|
|
|
{
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
@@ -5988,7 +6162,14 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$text[] = "mihomo config: <pre><code>$cl</code></pre>";
|
|
|
|
|
|
|
|
|
|
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac$hash?t=si&r=w&s={$c['id']}'>windows service</a>";
|
|
|
|
|
|
|
|
|
|
$download = $this->getBytes($c['global']['download'] + $c['session']['download']);
|
|
|
|
|
$upload = $this->getBytes($c['global']['upload'] + $c['session']['upload']);
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('reset stats') . ": ↓$download ↑$upload",
|
|
|
|
|
'callback_data' => "/resetXrUser $i",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('v2ray'),
|
|
|
|
@@ -6044,14 +6225,6 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
'callback_data' => "/qrXray {$i}_2",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$download = $this->getBytes($c['global']['download'] + $c['session']['download']);
|
|
|
|
|
$upload = $this->getBytes($c['global']['upload'] + $c['session']['upload']);
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('reset stats') . ": ↓$download ↑$upload",
|
|
|
|
|
'callback_data' => "/resetXrUser $i",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('rename'),
|
|
|
|
@@ -6299,6 +6472,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
'~directdomain~' => $pac['domain'],
|
|
|
|
|
'~cdndomain~' => $pac['linkdomain'],
|
|
|
|
|
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
|
|
|
|
'~email~' => $email,
|
|
|
|
|
'~public_key~' => $pac['xray'],
|
|
|
|
|
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
|
|
|
|
'~ip~' => $this->ip,
|
|
|
|
@@ -6601,7 +6775,13 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
|
|
|
|
|
public function getHashBot()
|
|
|
|
|
{
|
|
|
|
|
return substr(hash('sha256', $this->key), 0, 8);
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
if (!empty($p['hashbot'])) {
|
|
|
|
|
return $p['hashbot'];
|
|
|
|
|
}
|
|
|
|
|
$p['hashbot'] = substr(hash('sha256', $this->key), 0, 8);
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
return $p['hashbot'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cloakNginx()
|
|
|
|
@@ -7000,10 +7180,12 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
'text' => $this->i18n('Ports'),
|
|
|
|
|
'callback_data' => "/ports",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('IP ban & Logs'),
|
|
|
|
|
'text' => $this->i18n('logs'),
|
|
|
|
|
'callback_data' => "/logs",
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('IP ban'),
|
|
|
|
|
'callback_data' => "/ipMenu",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
@@ -7199,6 +7381,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
|
|
|
|
|
public function logs()
|
|
|
|
|
{
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
foreach (scandir('/logs/') as $k => $v) {
|
|
|
|
|
if (!preg_match('~^\.~', $v)) {
|
|
|
|
|
$size = filesize("/logs/$v");
|
|
|
|
@@ -7220,10 +7403,24 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
'callback_data' => "/cleanLog",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$autocleanlogs = array_filter(explode('/', $p['autocleanlogs']));
|
|
|
|
|
if (!empty($autocleanlogs)) {
|
|
|
|
|
if (!empty(strtotime($autocleanlogs[0])) && !empty(strtotime($autocleanlogs[1]))) {
|
|
|
|
|
$autocleanlogs = "{$autocleanlogs[0]} start / {$autocleanlogs[1]} period";
|
|
|
|
|
} else {
|
|
|
|
|
$autocleanlogs = $this->i18n('off') . " {$p['autocleanlogs']} - wrong format";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('autoclean'). ': ' . ($autocleanlogs ?: $this->i18n('off')),
|
|
|
|
|
'callback_data' => "/autoCleanLogs",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('back'),
|
|
|
|
|
'callback_data' => "/ipMenu",
|
|
|
|
|
'callback_data' => "/menu config",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->update(
|
|
|
|
@@ -7319,6 +7516,22 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function autoCleanLogs()
|
|
|
|
|
{
|
|
|
|
|
$r = $this->send(
|
|
|
|
|
$this->input['chat'],
|
|
|
|
|
"@{$this->input['username']} enter like: start / period",
|
|
|
|
|
$this->input['message_id'],
|
|
|
|
|
reply: 'enter like: now / 12 hours',
|
|
|
|
|
);
|
|
|
|
|
$_SESSION['reply'][$r['result']['message_id']] = [
|
|
|
|
|
'start_message' => $this->input['message_id'],
|
|
|
|
|
'start_callback' => $this->input['callback_id'],
|
|
|
|
|
'callback' => 'setAutoCleanLogs',
|
|
|
|
|
'args' => [],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function changeFakeDomain()
|
|
|
|
|
{
|
|
|
|
|
$r = $this->send(
|
|
|
|
@@ -7452,6 +7665,24 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$this->menu('config');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setAutoCleanLogs($text)
|
|
|
|
|
{
|
|
|
|
|
$text = trim($text);
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
|
if (empty($text)) {
|
|
|
|
|
$c['autocleanlogs'] = '';
|
|
|
|
|
} else {
|
|
|
|
|
[$start, $period] = explode('/', $text);
|
|
|
|
|
if (!empty(strtotime($start)) && !empty(strtotime($period))) {
|
|
|
|
|
$c['autocleanlogs'] = implode(' / ', [date('Y-m-d H:i', strtotime($start)), trim($period)]);
|
|
|
|
|
} else {
|
|
|
|
|
$this->send($this->input['from'], $this->input['message'] . ' - wrong format');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->setPacConf($c);
|
|
|
|
|
$this->logs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function debug()
|
|
|
|
|
{
|
|
|
|
|
$file = __DIR__ . '/config.php';
|
|
|
|
|