|
@@ -18,7 +18,6 @@ final class Tool extends Command
|
|
|
{
|
|
|
public $description = <<<EOL
|
|
|
├─=: php xcat Tool [选项]
|
|
|
-│ ├─ initQQWry - 下载 IP 解析库
|
|
|
│ ├─ setTelegram - 设置 Telegram 机器人
|
|
|
│ ├─ resetAllSettings - 使用默认值覆盖设置中心设置
|
|
|
│ ├─ exportAllSettings - 导出所有设置
|
|
@@ -50,37 +49,6 @@ EOL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function initQQWry(): void
|
|
|
- {
|
|
|
- echo '正在下载或更新纯真 IP 数据库...' . PHP_EOL;
|
|
|
- $path = BASE_PATH . '/storage/qqwry.dat';
|
|
|
- $qqwry = file_get_contents('https://cdn.jsdelivr.net/gh/sspanel-uim/qqwry.dat@latest/qqwry.dat');
|
|
|
- if ($qqwry !== '') {
|
|
|
- if (is_file($path)) {
|
|
|
- rename($path, $path . '.bak');
|
|
|
- }
|
|
|
- $fp = fopen($path, 'wb');
|
|
|
- if ($fp) {
|
|
|
- fwrite($fp, $qqwry);
|
|
|
- fclose($fp);
|
|
|
- echo '纯真 IP 数据库下载成功.' . PHP_EOL;
|
|
|
- $iplocation = new QQWry();
|
|
|
- $location = $iplocation->getlocation('8.8.8.8');
|
|
|
- $Userlocation = $location['country'];
|
|
|
- if (iconv('gbk', 'utf-8//IGNORE', $Userlocation) !== '美国') {
|
|
|
- unlink($path);
|
|
|
- if (is_file($path . '.bak')) {
|
|
|
- rename($path . '.bak', $path);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo '纯真 IP 数据库保存失败,请检查权限' . PHP_EOL;
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo '纯真 IP 数据库下载失败,请检查下载地址' . PHP_EOL;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function setTelegram(): void
|
|
|
{
|
|
|
$WebhookUrl = $_ENV['baseUrl'] . '/telegram_callback?token=' . $_ENV['telegram_request_token'];
|