update 2024-12-07 09:40:48
This commit is contained in:
parent
159f9fd028
commit
84cdbd4e34
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_MAINTAINER:=Thaolga <https://github.com/Thaolga/luci-app-nekobox>
|
PKG_MAINTAINER:=Thaolga <https://github.com/Thaolga/luci-app-nekobox>
|
||||||
PKG_NAME:=luci-app-nekobox
|
PKG_NAME:=luci-app-nekobox
|
||||||
PKG_VERSION:=1.5.7
|
PKG_VERSION:=1.5.8
|
||||||
PKG_RELEASE:=cn
|
PKG_RELEASE:=cn
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.7">
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.8">
|
||||||
<title>Current Version: v1.5.7</title>
|
<title>Current Version: v1.5.8</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||||
<text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
<text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
||||||
<text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
<text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="700" style="letter-spacing: -5;">Current Version</text>
|
||||||
<text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.7</text>
|
<text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.8</text>
|
||||||
<text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.7</text>
|
<text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.8</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -315,13 +315,20 @@ EOL;
|
||||||
|
|
||||||
$completeSubscribeUrl = "https://sing-box-subscribe-doraemon.vercel.app/config/{$subscribeUrlEncoded}&file={$templateUrlEncoded}";
|
$completeSubscribeUrl = "https://sing-box-subscribe-doraemon.vercel.app/config/{$subscribeUrlEncoded}&file={$templateUrlEncoded}";
|
||||||
$tempFilePath = '/tmp/' . $customFileName;
|
$tempFilePath = '/tmp/' . $customFileName;
|
||||||
|
$logMessages = [];
|
||||||
$command = "wget -O " . escapeshellarg($tempFilePath) . " " . escapeshellarg($completeSubscribeUrl);
|
$command = "wget -O " . escapeshellarg($tempFilePath) . " " . escapeshellarg($completeSubscribeUrl);
|
||||||
exec($command, $output, $returnVar);
|
exec($command, $output, $returnVar);
|
||||||
$logMessages = [];
|
|
||||||
|
if ($returnVar !== 0) {
|
||||||
|
$command = "curl -s -L -o " . escapeshellarg($tempFilePath) . " " . escapeshellarg($completeSubscribeUrl);
|
||||||
|
exec($command, $output, $returnVar);
|
||||||
|
|
||||||
if ($returnVar !== 0) {
|
if ($returnVar !== 0) {
|
||||||
$logMessages[] = "无法下载内容: " . htmlspecialchars($completeSubscribeUrl);
|
$logMessages[] = "无法下载内容: " . htmlspecialchars($completeSubscribeUrl);
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($returnVar === 0) {
|
||||||
$downloadedContent = file_get_contents($tempFilePath);
|
$downloadedContent = file_get_contents($tempFilePath);
|
||||||
if ($downloadedContent === false) {
|
if ($downloadedContent === false) {
|
||||||
$logMessages[] = "无法读取下载的文件内容";
|
$logMessages[] = "无法读取下载的文件内容";
|
||||||
|
|
|
@ -32,19 +32,39 @@ function getSingboxVersion() {
|
||||||
foreach ($output as $line) {
|
foreach ($output as $line) {
|
||||||
if (strpos($line, 'version') !== false) {
|
if (strpos($line, 'version') !== false) {
|
||||||
$parts = explode(' ', $line);
|
$parts = explode(' ', $line);
|
||||||
return end($parts);
|
$version = end($parts);
|
||||||
|
|
||||||
|
if (strpos($version, 'alpha') !== false || strpos($version, 'beta') !== false) {
|
||||||
|
if (strpos($version, '1.10.0-alpha.29-067c81a7') !== false) {
|
||||||
|
return ['version' => $version, 'type' => 'Puernya 预览版'];
|
||||||
|
}
|
||||||
|
return ['version' => $version, 'type' => 'Singbox 预览版'];
|
||||||
|
} else {
|
||||||
|
return ['version' => $version, 'type' => 'Singbox 正式版'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '未安装';
|
return ['version' => '未安装', 'type' => '未知'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$singBoxVersion = getSingboxVersion();
|
function getMihomoVersion() {
|
||||||
|
$versionFile = '/etc/neko/core/mihomo_version.txt';
|
||||||
|
|
||||||
?>
|
if (file_exists($versionFile)) {
|
||||||
|
$content = trim(file_get_contents($versionFile));
|
||||||
|
|
||||||
|
if (strpos($content, 'alpha') !== false) {
|
||||||
|
return ['version' => $content, 'type' => '预览版'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['version' => $content, 'type' => '正式版'];
|
||||||
|
} else {
|
||||||
|
return ['version' => '未安装', 'type' => '未知'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<?php
|
|
||||||
function getUiVersion() {
|
function getUiVersion() {
|
||||||
$versionFile = '/etc/neko/ui/zashboard/version.txt';
|
$versionFile = '/etc/neko/ui/zashboard/version.txt';
|
||||||
|
|
||||||
|
@ -75,9 +95,27 @@ function getMetaVersion() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRazordVersion() {
|
||||||
|
$versionFile = '/etc/neko/ui/dashboard/version.txt';
|
||||||
|
|
||||||
|
if (file_exists($versionFile)) {
|
||||||
|
return trim(file_get_contents($versionFile));
|
||||||
|
} else {
|
||||||
|
return "未安装";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$singBoxVersionInfo = getSingboxVersion();
|
||||||
|
$singBoxVersion = $singBoxVersionInfo['version'];
|
||||||
|
$singBoxType = $singBoxVersionInfo['type'];
|
||||||
|
$puernyaVersion = ($singBoxType === 'Puernya 预览版') ? $singBoxVersion : '未安装';
|
||||||
|
$singboxPreviewVersion = ($singBoxType === 'Singbox 预览版') ? $singBoxVersion : '未安装';
|
||||||
|
$mihomoVersionInfo = getMihomoVersion();
|
||||||
|
$mihomoVersion = $mihomoVersionInfo['version'];
|
||||||
|
$mihomoType = $mihomoVersionInfo['type'];
|
||||||
$uiVersion = getUiVersion();
|
$uiVersion = getUiVersion();
|
||||||
$metaCubexdVersion = getMetaCubexdVersion();
|
$metaCubexdVersion = getMetaCubexdVersion();
|
||||||
$metaVersion = getMetaVersion();
|
$metaVersion = getMetaVersion();
|
||||||
|
$razordVersion = getRazordVersion();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -104,7 +142,7 @@ $metaVersion = getMetaVersion();
|
||||||
<a href="./" class="col btn btn-lg">🏠 首页</a>
|
<a href="./" class="col btn btn-lg">🏠 首页</a>
|
||||||
<a href="./dashboard.php" class="col btn btn-lg">📊 面板</a>
|
<a href="./dashboard.php" class="col btn btn-lg">📊 面板</a>
|
||||||
<a href="./configs.php" class="col btn btn-lg">⚙️ 配置</a>
|
<a href="./configs.php" class="col btn btn-lg">⚙️ 配置</a>
|
||||||
<a href="/nekobox/mon.php" class="col btn btn-lg"></i>📦 订阅</a>
|
<a href="./mon.php" class="col btn btn-lg"></i>📦 订阅</a>
|
||||||
<a href="#" class="col btn btn-lg">🛠️ 设定</a>
|
<a href="#" class="col btn btn-lg">🛠️ 设定</a>
|
||||||
<div class="container px-4">
|
<div class="container px-4">
|
||||||
<h2 class="text-center p-2 mb-3">主题设定</h2>
|
<h2 class="text-center p-2 mb-3">主题设定</h2>
|
||||||
|
@ -281,10 +319,6 @@ $metaVersion = getMetaVersion();
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<select id="singboxVersionSelect" class="form-select">
|
<select id="singboxVersionSelect" class="form-select">
|
||||||
<option value="v1.11.0-alpha.6">v1.11.0-alpha.6</option>
|
|
||||||
<option value="v1.11.0-alpha.7">v1.11.0-alpha.7</option>
|
|
||||||
<option value="v1.11.0-alpha.8">v1.11.0-alpha.8</option>
|
|
||||||
<option value="v1.11.0-alpha.9">v1.11.0-alpha.9</option>
|
|
||||||
<option value="v1.11.0-alpha.10">v1.11.0-alpha.10</option>
|
<option value="v1.11.0-alpha.10">v1.11.0-alpha.10</option>
|
||||||
<option value="v1.11.0-alpha.15">v1.11.0-alpha.15</option>
|
<option value="v1.11.0-alpha.15">v1.11.0-alpha.15</option>
|
||||||
<option value="v1.11.0-alpha.20">v1.11.0-alpha.20</option>
|
<option value="v1.11.0-alpha.20">v1.11.0-alpha.20</option>
|
||||||
|
@ -337,6 +371,7 @@ $metaVersion = getMetaVersion();
|
||||||
<option value="zashboard">Zashboard 面板</option>
|
<option value="zashboard">Zashboard 面板</option>
|
||||||
<option value="metacubexd">Metacubexd 面板</option>
|
<option value="metacubexd">Metacubexd 面板</option>
|
||||||
<option value="yacd-meat">Yacd-Meat 面板</option>
|
<option value="yacd-meat">Yacd-Meat 面板</option>
|
||||||
|
<option value="dashboard">Dashboard 面板</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -432,7 +467,7 @@ $metaVersion = getMetaVersion();
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let selectedSingboxVersion = 'v1.11.0-alpha.6';
|
let selectedSingboxVersion = 'v1.11.0-alpha.10';
|
||||||
let selectedMihomoVersion = 'stable';
|
let selectedMihomoVersion = 'stable';
|
||||||
let selectedLanguage = 'cn';
|
let selectedLanguage = 'cn';
|
||||||
let selectedSingboxVersionForChannelTwo = 'preview';
|
let selectedSingboxVersionForChannelTwo = 'preview';
|
||||||
|
@ -545,6 +580,8 @@ function selectOperation(type) {
|
||||||
? 'update_meta.php'
|
? 'update_meta.php'
|
||||||
: selectedPanel === 'metacubexd'
|
: selectedPanel === 'metacubexd'
|
||||||
? 'update_metacubexd.php'
|
? 'update_metacubexd.php'
|
||||||
|
: selectedPanel === 'dashboard'
|
||||||
|
? 'update_dashboard.php'
|
||||||
: 'unknown_panel.php',
|
: 'unknown_panel.php',
|
||||||
message: selectedPanel === 'zashboard'
|
message: selectedPanel === 'zashboard'
|
||||||
? '开始下载 Zashboard 面板更新...'
|
? '开始下载 Zashboard 面板更新...'
|
||||||
|
@ -552,6 +589,8 @@ function selectOperation(type) {
|
||||||
? '开始下载 Yacd-Meat 面板更新...'
|
? '开始下载 Yacd-Meat 面板更新...'
|
||||||
: selectedPanel === 'metacubexd'
|
: selectedPanel === 'metacubexd'
|
||||||
? '开始下载 Metacubexd 面板更新...'
|
? '开始下载 Metacubexd 面板更新...'
|
||||||
|
: selectedPanel === 'dashboard'
|
||||||
|
? '开始下载 Dashboard 面板更新...'
|
||||||
: '未知面板更新类型...',
|
: '未知面板更新类型...',
|
||||||
description: selectedPanel === 'zashboard'
|
description: selectedPanel === 'zashboard'
|
||||||
? '正在更新 Zashboard 面板到最新版本'
|
? '正在更新 Zashboard 面板到最新版本'
|
||||||
|
@ -559,6 +598,8 @@ function selectOperation(type) {
|
||||||
? '正在更新 Yacd-Meat 面板到最新版本'
|
? '正在更新 Yacd-Meat 面板到最新版本'
|
||||||
: selectedPanel === 'metacubexd'
|
: selectedPanel === 'metacubexd'
|
||||||
? '正在更新 Metacubexd 面板到最新版本'
|
? '正在更新 Metacubexd 面板到最新版本'
|
||||||
|
: selectedPanel === 'dashboard'
|
||||||
|
? '正在更新 Dashboard 面板到最新版本'
|
||||||
: '无法识别的面板类型,无法更新。'
|
: '无法识别的面板类型,无法更新。'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -689,9 +730,14 @@ function checkVersion(outputId, updateFiles, currentVersions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('checkSingboxButton').addEventListener('click', function () {
|
document.getElementById('checkSingboxButton').addEventListener('click', function () {
|
||||||
|
const singBoxVersion = "<?php echo htmlspecialchars($singBoxVersion); ?>";
|
||||||
|
const singBoxType = "<?php echo htmlspecialchars($singBoxType); ?>";
|
||||||
|
const puernyaVersion = "<?php echo htmlspecialchars($puernyaVersion); ?>";
|
||||||
|
const singboxPreviewVersion = "<?php echo htmlspecialchars($singboxPreviewVersion); ?>";
|
||||||
const currentVersions = {
|
const currentVersions = {
|
||||||
'Singbox 正式版': '<?php echo htmlspecialchars($singBoxVersion); ?>',
|
'Singbox 正式版': singBoxType === 'Singbox 正式版' ? singBoxVersion : '未安装',
|
||||||
'Singbox 预览版': '<?php echo htmlspecialchars($singBoxVersion); ?>',
|
'Singbox 预览版': singboxPreviewVersion,
|
||||||
|
'Puernya 预览版': puernyaVersion
|
||||||
};
|
};
|
||||||
const updateFiles = [
|
const updateFiles = [
|
||||||
{ name: 'Singbox 正式版', url: 'update_singbox_stable.php' },
|
{ name: 'Singbox 正式版', url: 'update_singbox_stable.php' },
|
||||||
|
@ -702,14 +748,19 @@ document.getElementById('checkSingboxButton').addEventListener('click', function
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('checkMihomoButton').addEventListener('click', function () {
|
document.getElementById('checkMihomoButton').addEventListener('click', function () {
|
||||||
|
const mihomoVersion = "<?php echo htmlspecialchars($mihomoVersion); ?>";
|
||||||
|
const mihomoType = "<?php echo htmlspecialchars($mihomoType); ?>";
|
||||||
|
|
||||||
const currentVersions = {
|
const currentVersions = {
|
||||||
'Mihomo 正式版': document.getElementById('corever').textContent,
|
'Mihomo 正式版': mihomoType === '正式版' ? mihomoVersion : '未安装',
|
||||||
'Mihomo 预览版': document.getElementById('corever').textContent,
|
'Mihomo 预览版': mihomoType === '预览版' ? mihomoVersion : '未安装',
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateFiles = [
|
const updateFiles = [
|
||||||
{ name: 'Mihomo 正式版', url: 'update_mihomo_stable.php' },
|
{ name: 'Mihomo 正式版', url: 'update_mihomo_stable.php' },
|
||||||
{ name: 'Mihomo 预览版', url: 'update_mihomo_preview.php' }
|
{ name: 'Mihomo 预览版', url: 'update_mihomo_preview.php' }
|
||||||
];
|
];
|
||||||
|
|
||||||
checkVersion('NewMihomo', updateFiles, currentVersions);
|
checkVersion('NewMihomo', updateFiles, currentVersions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -718,11 +769,13 @@ document.getElementById('checkUiButton').addEventListener('click', function () {
|
||||||
'MetaCube': '<?php echo htmlspecialchars($metaCubexdVersion); ?>',
|
'MetaCube': '<?php echo htmlspecialchars($metaCubexdVersion); ?>',
|
||||||
'Zashboard': '<?php echo htmlspecialchars($uiVersion); ?>',
|
'Zashboard': '<?php echo htmlspecialchars($uiVersion); ?>',
|
||||||
'Yacd-Meat': '<?php echo htmlspecialchars($metaVersion); ?>',
|
'Yacd-Meat': '<?php echo htmlspecialchars($metaVersion); ?>',
|
||||||
|
'Dashboard': '<?php echo htmlspecialchars($razordVersion); ?>',
|
||||||
};
|
};
|
||||||
const updateFiles = [
|
const updateFiles = [
|
||||||
{ name: 'MetaCube', url: 'update_metacubexd.php' },
|
{ name: 'MetaCube', url: 'update_metacubexd.php' },
|
||||||
{ name: 'Zashboard', url: 'update_zashboard.php' },
|
{ name: 'Zashboard', url: 'update_zashboard.php' },
|
||||||
{ name: 'Yacd-Meat', url: 'update_meta.php' }
|
{ name: 'Yacd-Meat', url: 'update_meta.php' },
|
||||||
|
{ name: 'Dashboard', url: 'update_dashboard.php' }
|
||||||
];
|
];
|
||||||
checkVersion('NewUi', updateFiles, currentVersions);
|
checkVersion('NewUi', updateFiles, currentVersions);
|
||||||
});
|
});
|
||||||
|
@ -734,6 +787,7 @@ document.getElementById('checkCliverButton').addEventListener('click', function
|
||||||
const updateFiles = [{ name: '客户端', url: 'update_script.php' }];
|
const updateFiles = [{ name: '客户端', url: 'update_script.php' }];
|
||||||
checkVersion('NewCliver', updateFiles, currentVersions);
|
checkVersion('NewCliver', updateFiles, currentVersions);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set('memory_limit', '128M');
|
||||||
|
|
||||||
|
$fixed_version = "v0.3.0";
|
||||||
|
|
||||||
|
function getUiVersion() {
|
||||||
|
$versionFile = '/etc/neko/ui/dashboard/version.txt';
|
||||||
|
|
||||||
|
if (file_exists($versionFile)) {
|
||||||
|
return trim(file_get_contents($versionFile));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeVersionToFile($version) {
|
||||||
|
$versionFile = '/etc/neko/ui/dashboard/version.txt';
|
||||||
|
file_put_contents($versionFile, $version);
|
||||||
|
}
|
||||||
|
|
||||||
|
$download_url = "https://github.com/Thaolga/neko/releases/download/$fixed_version/dashboard.tar";
|
||||||
|
$install_path = '/etc/neko/ui/dashboard';
|
||||||
|
$temp_file = '/tmp/dashboard-dist.tar';
|
||||||
|
|
||||||
|
if (!is_dir($install_path)) {
|
||||||
|
mkdir($install_path, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_version = getUiVersion();
|
||||||
|
|
||||||
|
if (isset($_GET['check_version'])) {
|
||||||
|
echo "最新版本: $fixed_version\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
||||||
|
if ($return_var !== 0) {
|
||||||
|
die("下载失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($temp_file)) {
|
||||||
|
die("下载的文件不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "开始解压文件...\n";
|
||||||
|
exec("tar -xf '$temp_file' -C '$install_path' --overwrite", $output, $return_var);
|
||||||
|
if ($return_var !== 0) {
|
||||||
|
echo "解压失败,错误信息: " . implode("\n", $output);
|
||||||
|
die("解压失败!");
|
||||||
|
}
|
||||||
|
echo "解压成功!\n";
|
||||||
|
|
||||||
|
exec("chown -R root:root '$install_path' 2>&1", $output, $return_var);
|
||||||
|
if ($return_var !== 0) {
|
||||||
|
echo "更改文件拥有者失败,错误信息: " . implode("\n", $output) . "\n";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
echo "文件拥有者已更改为 root。\n";
|
||||||
|
|
||||||
|
writeVersionToFile($fixed_version);
|
||||||
|
echo "更新完成!当前版本: $fixed_version\n";
|
||||||
|
|
||||||
|
unlink($temp_file);
|
||||||
|
|
||||||
|
?>
|
|
@ -21,12 +21,24 @@ $repo_owner = "MetaCubeX";
|
||||||
$repo_name = "metacubexd";
|
$repo_name = "metacubexd";
|
||||||
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest";
|
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest";
|
||||||
|
|
||||||
$curl_command = "curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url);
|
function getApiResponseWithCurl($api_url) {
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec("curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getApiResponseWithWget($api_url) {
|
||||||
|
$response = shell_exec("wget -qO- '$api_url'");
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = getApiResponseWithCurl($api_url);
|
||||||
|
|
||||||
|
if ($response === false || empty($response)) {
|
||||||
|
$response = getApiResponseWithWget($api_url);
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
|
@ -55,11 +67,32 @@ if (empty($download_url)) {
|
||||||
die("未找到下载链接,请检查发布版本的资源。");
|
die("未找到下载链接,请检查发布版本的资源。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "开始下载文件...\n";
|
||||||
|
$download_success = false;
|
||||||
|
|
||||||
|
if (shell_exec("which wget")) {
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
||||||
if ($return_var !== 0) {
|
if ($return_var === 0) {
|
||||||
die("下载失败!");
|
$download_success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$download_success && shell_exec("which curl")) {
|
||||||
|
exec("curl -s -L -o '$temp_file' '$download_url'", $output, $return_var);
|
||||||
|
if ($return_var === 0) {
|
||||||
|
$download_success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$download_success) {
|
||||||
|
die("下载失败!请检查网络连接或稍后重试。");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($temp_file)) {
|
||||||
|
die("下载的文件不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "开始解压文件...\n";
|
||||||
exec("tar -xzf '$temp_file' -C '$install_path'", $output, $return_var);
|
exec("tar -xzf '$temp_file' -C '$install_path'", $output, $return_var);
|
||||||
if ($return_var !== 0) {
|
if ($return_var !== 0) {
|
||||||
echo "解压失败,错误信息: " . implode("\n", $output);
|
echo "解压失败,错误信息: " . implode("\n", $output);
|
||||||
|
|
|
@ -24,9 +24,19 @@ $curl_command = "curl -s -H 'User-Agent: PHP' " . escapeshellarg($api_url);
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec($curl_command);
|
||||||
|
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
|
logMessage("curl 请求失败,尝试使用 wget...");
|
||||||
|
$wget_command = "wget -q --no-check-certificate --timeout=10 " . escapeshellarg($api_url) . " -O /tmp/api_response.json";
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists('/tmp/api_response.json')) {
|
||||||
|
logMessage("GitHub API 请求失败,curl 和 wget 都失败了。");
|
||||||
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = file_get_contents('/tmp/api_response.json');
|
||||||
|
unlink('/tmp/api_response.json');
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
@ -46,20 +56,16 @@ if ($latest_prerelease === null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$latest_version = $latest_prerelease['tag_name'] ?? '';
|
$latest_version = $latest_prerelease['tag_name'] ?? '';
|
||||||
|
|
||||||
$assets = $latest_prerelease['assets'] ?? [];
|
$assets = $latest_prerelease['assets'] ?? [];
|
||||||
|
|
||||||
if (empty($latest_version)) {
|
if (empty($latest_version)) {
|
||||||
echo "未找到最新版本信息。";
|
die("未找到最新版本信息。");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "最新版本: " . htmlspecialchars($latest_version) . "\n";
|
|
||||||
|
|
||||||
$current_arch = trim(shell_exec("uname -m"));
|
|
||||||
$base_version = ltrim($latest_version, 'v');
|
|
||||||
|
|
||||||
$download_url = '';
|
$download_url = '';
|
||||||
$asset_found = false;
|
$asset_found = false;
|
||||||
|
$current_arch = trim(shell_exec("uname -m"));
|
||||||
|
|
||||||
foreach ($assets as $asset) {
|
foreach ($assets as $asset) {
|
||||||
if ($current_arch === 'x86_64' && strpos($asset['name'], 'linux-amd64-alpha') !== false && strpos($asset['name'], '.gz') !== false) {
|
if ($current_arch === 'x86_64' && strpos($asset['name'], 'linux-amd64-alpha') !== false && strpos($asset['name'], '.gz') !== false) {
|
||||||
|
@ -83,12 +89,29 @@ if (!$asset_found) {
|
||||||
die("未找到适合架构的预览版下载链接!");
|
die("未找到适合架构的预览版下载链接!");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "下载链接: $download_url\n";
|
$filename = basename($download_url);
|
||||||
|
preg_match('/alpha-[\w-]+/', $filename, $matches);
|
||||||
|
$version_from_filename = $matches[0] ?? '未知版本';
|
||||||
|
|
||||||
|
$latest_version = $version_from_filename;
|
||||||
|
|
||||||
|
echo "最新版本: " . htmlspecialchars($latest_version) . "\n";
|
||||||
|
|
||||||
$temp_file = '/tmp/mihomo_prerelease.gz';
|
$temp_file = '/tmp/mihomo_prerelease.gz';
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($temp_file);
|
||||||
|
exec($curl_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("下载失败,尝试使用 wget...");
|
||||||
|
$wget_command = "wget -q --show-progress --no-check-certificate " . escapeshellarg($download_url) . " -O " . escapeshellarg($temp_file);
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("下载失败,curl 和 wget 都失败了。");
|
||||||
|
die("下载失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($return_var === 0) {
|
|
||||||
exec("gzip -d -c '$temp_file' > '/tmp/mihomo-linux-$current_arch'", $output, $return_var);
|
exec("gzip -d -c '$temp_file' > '/tmp/mihomo-linux-$current_arch'", $output, $return_var);
|
||||||
|
|
||||||
if ($return_var === 0) {
|
if ($return_var === 0) {
|
||||||
|
@ -99,22 +122,24 @@ if ($return_var === 0) {
|
||||||
exec("chmod 0755 '$install_path'", $output, $return_var);
|
exec("chmod 0755 '$install_path'", $output, $return_var);
|
||||||
|
|
||||||
if ($return_var === 0) {
|
if ($return_var === 0) {
|
||||||
|
logMessage("更新完成!当前版本: $latest_version");
|
||||||
echo "更新完成!当前版本: $latest_version";
|
echo "更新完成!当前版本: $latest_version";
|
||||||
writeVersionToFile($latest_version);
|
writeVersionToFile($latest_version);
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("设置权限失败!");
|
||||||
echo "设置权限失败!";
|
echo "设置权限失败!";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("移动文件失败!");
|
||||||
echo "移动文件失败!";
|
echo "移动文件失败!";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("解压失败!");
|
||||||
echo "解压失败!";
|
echo "解压失败!";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
echo "下载失败!";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists($temp_file)) {
|
if (file_exists($temp_file)) {
|
||||||
unlink($temp_file);
|
unlink($temp_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -22,10 +22,20 @@ if (isset($_GET['check_version'])) {
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec($curl_command);
|
||||||
|
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
|
logMessage("GitHub API 请求失败,尝试使用 wget...");
|
||||||
|
$wget_command = "wget -q --no-check-certificate --timeout=10 " . escapeshellarg($api_url) . " -O /tmp/api_response.json";
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists('/tmp/api_response.json')) {
|
||||||
|
logMessage("GitHub API 请求失败,curl 和 wget 都失败了。");
|
||||||
echo "GitHub API 请求失败。";
|
echo "GitHub API 请求失败。";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = file_get_contents('/tmp/api_response.json');
|
||||||
|
unlink('/tmp/api_response.json');
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
@ -48,9 +58,19 @@ $curl_command = "curl -s -H 'User-Agent: PHP' " . escapeshellarg($api_url);
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec($curl_command);
|
||||||
|
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
|
logMessage("GitHub API 请求失败,尝试使用 wget...");
|
||||||
|
$wget_command = "wget -q --no-check-certificate --timeout=10 " . escapeshellarg($api_url) . " -O /tmp/api_response.json";
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists('/tmp/api_response.json')) {
|
||||||
|
logMessage("GitHub API 请求失败,curl 和 wget 都失败了。");
|
||||||
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = file_get_contents('/tmp/api_response.json');
|
||||||
|
unlink('/tmp/api_response.json');
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
@ -82,8 +102,7 @@ switch ($current_arch) {
|
||||||
$download_url = "https://github.com/MetaCubeX/mihomo/releases/download/$latest_version/mihomo-linux-amd64-v$base_version.gz";
|
$download_url = "https://github.com/MetaCubeX/mihomo/releases/download/$latest_version/mihomo-linux-amd64-v$base_version.gz";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo "未找到适合架构的下载链接: $current_arch";
|
die("未找到适合架构的下载链接: $current_arch");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($current_version) === trim($latest_version)) {
|
if (trim($current_version) === trim($latest_version)) {
|
||||||
|
@ -91,9 +110,20 @@ if (trim($current_version) === trim($latest_version)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($temp_file);
|
||||||
|
exec($curl_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("下载失败,尝试使用 wget...");
|
||||||
|
$wget_command = "wget -q --show-progress --no-check-certificate " . escapeshellarg($download_url) . " -O " . escapeshellarg($temp_file);
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("下载失败,curl 和 wget 都失败了。");
|
||||||
|
die("下载失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($return_var === 0) {
|
|
||||||
exec("gzip -d -c '$temp_file' > '/tmp/mihomo-linux-arm64'", $output, $return_var);
|
exec("gzip -d -c '$temp_file' > '/tmp/mihomo-linux-arm64'", $output, $return_var);
|
||||||
|
|
||||||
if ($return_var === 0) {
|
if ($return_var === 0) {
|
||||||
|
@ -104,19 +134,20 @@ if ($return_var === 0) {
|
||||||
|
|
||||||
if ($return_var === 0) {
|
if ($return_var === 0) {
|
||||||
writeVersionToFile($latest_version);
|
writeVersionToFile($latest_version);
|
||||||
|
logMessage("更新完成!当前版本: $latest_version");
|
||||||
echo "更新完成!当前版本: $latest_version";
|
echo "更新完成!当前版本: $latest_version";
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("设置权限失败!");
|
||||||
echo "设置权限失败!";
|
echo "设置权限失败!";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("移动文件失败!");
|
||||||
echo "移动文件失败!";
|
echo "移动文件失败!";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("解压失败!");
|
||||||
echo "解压失败!";
|
echo "解压失败!";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
echo "下载失败!";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists($temp_file)) {
|
if (file_exists($temp_file)) {
|
||||||
unlink($temp_file);
|
unlink($temp_file);
|
||||||
|
|
|
@ -9,10 +9,18 @@ $local_api_response = "/tmp/api_response.json";
|
||||||
$curl_command = "curl -H 'User-Agent: PHP' -s " . escapeshellarg($api_url) . " -o " . escapeshellarg($local_api_response);
|
$curl_command = "curl -H 'User-Agent: PHP' -s " . escapeshellarg($api_url) . " -o " . escapeshellarg($local_api_response);
|
||||||
exec($curl_command . " 2>&1", $output, $return_var);
|
exec($curl_command . " 2>&1", $output, $return_var);
|
||||||
|
|
||||||
if (!file_exists($local_api_response)) {
|
if ($return_var !== 0 || !file_exists($local_api_response)) {
|
||||||
|
echo "<script>appendLog('curl 获取版本信息失败,尝试使用 wget...');</script>";
|
||||||
|
$wget_command = "wget -q --no-check-certificate " . escapeshellarg($api_url) . " -O " . escapeshellarg($local_api_response);
|
||||||
|
exec($wget_command . " 2>&1", $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($local_api_response)) {
|
||||||
die("无法访问GitHub API。请检查URL或网络连接。输出: " . implode("\n", $output));
|
die("无法访问GitHub API。请检查URL或网络连接。输出: " . implode("\n", $output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "<script>appendLog('wget 获取版本信息完成。');</script>";
|
||||||
|
}
|
||||||
|
|
||||||
$response = file_get_contents($local_api_response);
|
$response = file_get_contents($local_api_response);
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
unlink($local_api_response);
|
unlink($local_api_response);
|
||||||
|
@ -49,15 +57,24 @@ echo "<script>
|
||||||
echo "<script>appendLog('开始下载更新...');</script>";
|
echo "<script>appendLog('开始下载更新...');</script>";
|
||||||
|
|
||||||
$local_file = "/tmp/{$package_name}_{$new_version}-{$installed_lang}_all.ipk";
|
$local_file = "/tmp/{$package_name}_{$new_version}-{$installed_lang}_all.ipk";
|
||||||
|
|
||||||
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($local_file);
|
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($local_file);
|
||||||
exec($curl_command . " 2>&1", $output, $return_var);
|
exec($curl_command . " 2>&1", $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($local_file)) {
|
||||||
|
echo "<script>appendLog('curl 下载失败,尝试使用 wget...');</script>";
|
||||||
|
$wget_command = "wget -q --show-progress --no-check-certificate " . escapeshellarg($download_url) . " -O " . escapeshellarg($local_file);
|
||||||
|
exec($wget_command . " 2>&1", $output, $return_var);
|
||||||
|
|
||||||
if ($return_var !== 0 || !file_exists($local_file)) {
|
if ($return_var !== 0 || !file_exists($local_file)) {
|
||||||
echo "<pre>下载失败。命令输出: " . implode("\n", $output) . "</pre>";
|
echo "<pre>下载失败。命令输出: " . implode("\n", $output) . "</pre>";
|
||||||
die("下载失败。未找到下载的文件。");
|
die("下载失败。未找到下载的文件。");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<script>appendLog('下载完成。');</script>";
|
echo "<script>appendLog('wget 下载完成。');</script>";
|
||||||
|
} else {
|
||||||
|
echo "<script>appendLog('curl 下载完成。');</script>";
|
||||||
|
}
|
||||||
|
|
||||||
echo "<script>appendLog('更新软件包列表...');</script>";
|
echo "<script>appendLog('更新软件包列表...');</script>";
|
||||||
$output = shell_exec("opkg update");
|
$output = shell_exec("opkg update");
|
||||||
|
|
|
@ -4,7 +4,7 @@ $repo_owner = "Thaolga";
|
||||||
$repo_name = "luci-app-nekoclash";
|
$repo_name = "luci-app-nekoclash";
|
||||||
$package_name = "sing-box";
|
$package_name = "sing-box";
|
||||||
|
|
||||||
$new_version = isset($_GET['version']) ? $_GET['version'] : "v1.11.0-alpha.6";
|
$new_version = isset($_GET['version']) ? $_GET['version'] : "v1.11.0-alpha.10";
|
||||||
|
|
||||||
$new_version_cleaned = str_replace('v', '', $new_version);
|
$new_version_cleaned = str_replace('v', '', $new_version);
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,24 @@ function writeVersionToFile($version) {
|
||||||
$repo_owner = "SagerNet";
|
$repo_owner = "SagerNet";
|
||||||
$repo_name = "sing-box";
|
$repo_name = "sing-box";
|
||||||
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases";
|
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases";
|
||||||
|
|
||||||
$curl_command = "curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url);
|
$curl_command = "curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url);
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec($curl_command);
|
||||||
|
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
logMessage("GitHub API request failed, possibly due to network issues or GitHub API restrictions.");
|
logMessage("GitHub API request using curl failed, trying wget...");
|
||||||
|
$wget_command = "wget -q --no-check-certificate --timeout=10 " . escapeshellarg($api_url) . " -O /tmp/api_response.json";
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists('/tmp/api_response.json')) {
|
||||||
|
logMessage("GitHub API request using wget failed.");
|
||||||
die("GitHub API request failed. Please check your network connection or try again later.");
|
die("GitHub API request failed. Please check your network connection or try again later.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = file_get_contents('/tmp/api_response.json');
|
||||||
|
unlink('/tmp/api_response.json');
|
||||||
|
}
|
||||||
|
|
||||||
logMessage("GitHub API response: " . substr($response, 0, 200) . "...");
|
logMessage("GitHub API response: " . substr($response, 0, 200) . "...");
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
@ -83,10 +93,19 @@ if (trim($current_version) === trim($latest_version)) {
|
||||||
die("Current version is already the latest.");
|
die("Current version is already the latest.");
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($temp_file);
|
||||||
if ($return_var !== 0) {
|
exec($curl_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("Download failed using curl, trying wget...");
|
||||||
|
$wget_command = "wget -q --show-progress --no-check-certificate " . escapeshellarg($download_url) . " -O " . escapeshellarg($temp_file);
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("Download failed using wget.");
|
||||||
die("Download failed!");
|
die("Download failed!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_dir($temp_dir)) {
|
if (!is_dir($temp_dir)) {
|
||||||
mkdir($temp_dir, 0755, true);
|
mkdir($temp_dir, 0755, true);
|
||||||
|
@ -94,6 +113,7 @@ if (!is_dir($temp_dir)) {
|
||||||
|
|
||||||
exec("tar -xzf '$temp_file' -C '$temp_dir'", $output, $return_var);
|
exec("tar -xzf '$temp_file' -C '$temp_dir'", $output, $return_var);
|
||||||
if ($return_var !== 0) {
|
if ($return_var !== 0) {
|
||||||
|
logMessage("Extraction failed.");
|
||||||
die("Extraction failed!");
|
die("Extraction failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +122,10 @@ if ($extracted_file && file_exists($extracted_file)) {
|
||||||
exec("cp -f '$extracted_file' '$install_path'");
|
exec("cp -f '$extracted_file' '$install_path'");
|
||||||
exec("chmod 0755 '$install_path'");
|
exec("chmod 0755 '$install_path'");
|
||||||
writeVersionToFile($latest_version);
|
writeVersionToFile($latest_version);
|
||||||
|
logMessage("Update completed! Current version: $latest_version");
|
||||||
echo "更新完成! 当前版本: $latest_version";
|
echo "更新完成! 当前版本: $latest_version";
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("Extracted file 'sing-box' does not exist.");
|
||||||
die("Extracted file 'sing-box' does not exist.");
|
die("Extracted file 'sing-box' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,24 @@ function writeVersionToFile($version) {
|
||||||
$repo_owner = "SagerNet";
|
$repo_owner = "SagerNet";
|
||||||
$repo_name = "sing-box";
|
$repo_name = "sing-box";
|
||||||
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases";
|
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases";
|
||||||
|
|
||||||
$curl_command = "curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url);
|
$curl_command = "curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url);
|
||||||
$response = shell_exec($curl_command);
|
$response = shell_exec($curl_command);
|
||||||
|
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
logMessage("GitHub API request failed, possibly due to network issues or GitHub API restrictions.");
|
logMessage("GitHub API request using curl failed, trying wget...");
|
||||||
|
$wget_command = "wget -q --no-check-certificate --timeout=10 " . escapeshellarg($api_url) . " -O /tmp/api_response.json";
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists('/tmp/api_response.json')) {
|
||||||
|
logMessage("GitHub API request using wget failed.");
|
||||||
die("GitHub API request failed. Please check your network connection or try again later.");
|
die("GitHub API request failed. Please check your network connection or try again later.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = file_get_contents('/tmp/api_response.json');
|
||||||
|
unlink('/tmp/api_response.json');
|
||||||
|
}
|
||||||
|
|
||||||
logMessage("GitHub API response: " . substr($response, 0, 200) . "...");
|
logMessage("GitHub API response: " . substr($response, 0, 200) . "...");
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
@ -32,7 +42,6 @@ if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$latest_version = '';
|
$latest_version = '';
|
||||||
|
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
foreach ($data as $release) {
|
foreach ($data as $release) {
|
||||||
if (isset($release['tag_name']) && isset($release['prerelease']) && !$release['prerelease']) {
|
if (isset($release['tag_name']) && isset($release['prerelease']) && !$release['prerelease']) {
|
||||||
|
@ -84,10 +93,19 @@ if (trim($current_version) === trim($latest_version)) {
|
||||||
die("Current version is already the latest.");
|
die("Current version is already the latest.");
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
$curl_command = "curl -sL " . escapeshellarg($download_url) . " -o " . escapeshellarg($temp_file);
|
||||||
if ($return_var !== 0) {
|
exec($curl_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("Download failed using curl, trying wget...");
|
||||||
|
$wget_command = "wget -q --show-progress --no-check-certificate " . escapeshellarg($download_url) . " -O " . escapeshellarg($temp_file);
|
||||||
|
exec($wget_command, $output, $return_var);
|
||||||
|
|
||||||
|
if ($return_var !== 0 || !file_exists($temp_file)) {
|
||||||
|
logMessage("Download failed using wget.");
|
||||||
die("Download failed!");
|
die("Download failed!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_dir($temp_dir)) {
|
if (!is_dir($temp_dir)) {
|
||||||
mkdir($temp_dir, 0755, true);
|
mkdir($temp_dir, 0755, true);
|
||||||
|
@ -95,6 +113,7 @@ if (!is_dir($temp_dir)) {
|
||||||
|
|
||||||
exec("tar -xzf '$temp_file' -C '$temp_dir'", $output, $return_var);
|
exec("tar -xzf '$temp_file' -C '$temp_dir'", $output, $return_var);
|
||||||
if ($return_var !== 0) {
|
if ($return_var !== 0) {
|
||||||
|
logMessage("Extraction failed.");
|
||||||
die("Extraction failed!");
|
die("Extraction failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +122,10 @@ if ($extracted_file && file_exists($extracted_file)) {
|
||||||
exec("cp -f '$extracted_file' '$install_path'");
|
exec("cp -f '$extracted_file' '$install_path'");
|
||||||
exec("chmod 0755 '$install_path'");
|
exec("chmod 0755 '$install_path'");
|
||||||
writeVersionToFile($latest_version);
|
writeVersionToFile($latest_version);
|
||||||
|
logMessage("Update completed! Current version: $latest_version");
|
||||||
echo "更新完成! 当前版本: $latest_version";
|
echo "更新完成! 当前版本: $latest_version";
|
||||||
} else {
|
} else {
|
||||||
|
logMessage("Extracted file 'sing-box' does not exist.");
|
||||||
die("Extracted file 'sing-box' does not exist.");
|
die("Extracted file 'sing-box' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,25 @@ function writeVersionToFile($version) {
|
||||||
$repo_owner = "Thaolga";
|
$repo_owner = "Thaolga";
|
||||||
$repo_name = "neko";
|
$repo_name = "neko";
|
||||||
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest";
|
$api_url = "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest";
|
||||||
|
|
||||||
|
function getApiResponseWithCurl($api_url) {
|
||||||
$response = shell_exec("curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url));
|
$response = shell_exec("curl -s -H 'User-Agent: PHP' --connect-timeout 10 " . escapeshellarg($api_url));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getApiResponseWithWget($api_url) {
|
||||||
|
$response = shell_exec("wget -qO- '$api_url'");
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = getApiResponseWithCurl($api_url);
|
||||||
|
|
||||||
|
if ($response === false || empty($response)) {
|
||||||
|
$response = getApiResponseWithWget($api_url);
|
||||||
if ($response === false || empty($response)) {
|
if ($response === false || empty($response)) {
|
||||||
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
die("GitHub API 请求失败。请检查网络连接或稍后重试。");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
|
@ -62,9 +76,25 @@ if (isset($_GET['check_version'])) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "开始下载文件...\n";
|
||||||
|
$download_success = false;
|
||||||
|
|
||||||
|
if (shell_exec("which wget")) {
|
||||||
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
exec("wget -O '$temp_file' '$download_url'", $output, $return_var);
|
||||||
if ($return_var !== 0) {
|
if ($return_var === 0) {
|
||||||
die("下载失败!");
|
$download_success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$download_success && shell_exec("which curl")) {
|
||||||
|
exec("curl -s -L -o '$temp_file' '$download_url'", $output, $return_var);
|
||||||
|
if ($return_var === 0) {
|
||||||
|
$download_success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$download_success) {
|
||||||
|
die("下载失败!请检查网络连接或稍后重试。");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($temp_file)) {
|
if (!file_exists($temp_file)) {
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
clash.metacubex.one
|
|
Binary file not shown.
Before Width: | Height: | Size: 47 KiB |
Binary file not shown.
Before Width: | Height: | Size: 177 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 79 KiB |
File diff suppressed because one or more lines are too long
|
@ -1,41 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel="Bookmark" href="./assets/Icon.3ddc065b.png">
|
|
||||||
<link rel="shortcut icon" href="./assets/Icon.3ddc065b.png"/>
|
|
||||||
<link rel="apple-touch-icon" href="./assets/Icon.3ddc065b.png"/>
|
|
||||||
<link rel="icon" href="./assets/Icon.48ce63a7.ico"/>
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
||||||
<meta name="application-name" content="Clash" />
|
|
||||||
<meta name="theme-color" content="#f4f5f6"/>
|
|
||||||
<meta name="description" content="Clash web port"/>
|
|
||||||
<!--meta name="external-controller" content="http://secret@example.com:9090"-->
|
|
||||||
<title>Clash</title>
|
|
||||||
<script type="module" crossorigin src="./assets/index.628acf3b.js"></script>
|
|
||||||
<link rel="modulepreload" href="./assets/vendor.356502e2.js">
|
|
||||||
<link rel="stylesheet" href="./assets/index.d7f07683.css">
|
|
||||||
<link rel="manifest" href="./manifest.webmanifest"><script>if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('./sw.js', { scope: './' })})}</script></head>
|
|
||||||
<body>
|
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
||||||
<div id="root"></div>
|
|
||||||
<script>
|
|
||||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
||||||
const { host, port, secret, protocol } = Object.fromEntries(
|
|
||||||
urlSearchParams.entries()
|
|
||||||
);
|
|
||||||
if (host && port) {
|
|
||||||
const meta = document.createElement("meta");
|
|
||||||
meta.name = "external-controller";
|
|
||||||
meta.content = `${protocol || window.location.protocol}//${
|
|
||||||
secret || ""
|
|
||||||
}@${host}:${port}`;
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(meta);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1 +0,0 @@
|
||||||
{"name":"Clash Dashboard","short_name":"Clash Dashboard","start_url":"./","display":"standalone","background_color":"#ffffff","lang":"en","scope":"./","icons":[{"src":"https://raw.githubusercontents.com/MetaCubeX/clash-dashboard/master/src/assets/Icon.png","sizes":"512x512","type":"image/png"}]}
|
|
|
@ -1 +0,0 @@
|
||||||
if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let o={};const l=e=>n(e,r),d={module:{uri:r},exports:o,require:l};s[r]=Promise.all(i.map((e=>d[e]||l(e)))).then((e=>(t(...e),o)))}}define(["./workbox-4ee7f24a"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.precacheAndRoute([{url:"assets/index.628acf3b.js",revision:null},{url:"assets/index.d7f07683.css",revision:null},{url:"assets/vendor.356502e2.js",revision:null},{url:"index.html",revision:"24c4013e306091d60d3bac8dd74d481f"},{url:"manifest.webmanifest",revision:"f7e51bd07af7699e1422bce9dedf3da5"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}));
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue