update 2025-02-03 00:21:53
This commit is contained in:
parent
ea525cb119
commit
317d6aa3ae
|
@ -1164,52 +1164,84 @@ function formatFileSize($size) {
|
|||
|
||||
<script>
|
||||
function setBackground(filename, type, action = 'set') {
|
||||
const bodyData = 'filename=' + encodeURIComponent(filename) + '&type=' + type;
|
||||
|
||||
if (action === 'set') {
|
||||
if (type === 'image') {
|
||||
if (confirm("确定要将此图片设置为背景吗?")) {
|
||||
fetch('/nekobox/set_background.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: 'action=set&filename=' + encodeURIComponent(filename) + '&type=image'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
alert(data);
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
} else if (type === 'video') {
|
||||
if (confirm("确定要将此视频设置为背景吗?")) {
|
||||
fetch('/nekobox/set_background.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: 'action=set&filename=' + encodeURIComponent(filename) + '&type=video'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
alert(data);
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
}
|
||||
} else if (action === 'remove') {
|
||||
if (confirm("确定要删除背景吗?")) {
|
||||
fetch('/nekobox/set_background.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: 'action=remove'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
alert(data);
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
fetch('/nekobox/set_background.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: 'action=set&' + bodyData
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
sessionStorage.setItem('notificationMessage', data);
|
||||
sessionStorage.setItem('notificationType', 'success');
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
sessionStorage.setItem('notificationMessage', "操作失败,请稍后再试");
|
||||
sessionStorage.setItem('notificationType', 'error');
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
else if (action === 'remove') {
|
||||
fetch('/nekobox/set_background.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: 'action=remove'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
sessionStorage.setItem('notificationMessage', data);
|
||||
sessionStorage.setItem('notificationType', 'success');
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
sessionStorage.setItem('notificationMessage', "删除失败,请稍后再试");
|
||||
sessionStorage.setItem('notificationType', 'error');
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showNotification(message, type = 'success') {
|
||||
var notification = document.createElement('div');
|
||||
notification.style.position = 'fixed';
|
||||
notification.style.top = '10px';
|
||||
notification.style.left = '30px';
|
||||
notification.style.padding = '10px';
|
||||
notification.style.borderRadius = '5px';
|
||||
notification.style.zIndex = '9999';
|
||||
notification.style.color = '#fff';
|
||||
notification.innerText = message;
|
||||
|
||||
if (type === 'success') {
|
||||
notification.style.backgroundColor = '#4CAF50';
|
||||
} else if (type === 'error') {
|
||||
notification.style.backgroundColor = '#F44336';
|
||||
}
|
||||
|
||||
document.body.appendChild(notification);
|
||||
|
||||
setTimeout(function() {
|
||||
notification.style.display = 'none';
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
var message = sessionStorage.getItem('notificationMessage');
|
||||
var type = sessionStorage.getItem('notificationType');
|
||||
|
||||
if (message) {
|
||||
showNotification(message, type);
|
||||
sessionStorage.removeItem('notificationMessage');
|
||||
sessionStorage.removeItem('notificationType');
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -9,20 +9,21 @@ probe_file="/tmp/etc/passwall/haproxy/Probe_URL"
|
|||
probeUrl="https://www.google.com/generate_204"
|
||||
if [ -f "$probe_file" ]; then
|
||||
firstLine=$(head -n 1 "$probe_file" | tr -d ' \t')
|
||||
if [ -n "$firstLine" ]; then
|
||||
probeUrl="$firstLine"
|
||||
fi
|
||||
[ -n "$firstLine" ] && probeUrl="$firstLine"
|
||||
fi
|
||||
|
||||
status=$(/usr/bin/curl -I -o /dev/null -skL -x socks5h://${server_address}:${server_port} --connect-timeout 3 --retry 3 -w %{http_code} "${probeUrl}")
|
||||
extra_params="-x socks5h://${server_address}:${server_port}"
|
||||
if /usr/bin/curl --help all | grep -q "\-\-retry-all-errors"; then
|
||||
extra_params="${extra_params} --retry-all-errors"
|
||||
fi
|
||||
|
||||
status=$(/usr/bin/curl -I -o /dev/null -skL ${extra_params} --connect-timeout 3 --retry 1 -w "%{http_code}" "${probeUrl}")
|
||||
|
||||
case "$status" in
|
||||
204|\
|
||||
200)
|
||||
status=200
|
||||
200|204)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
return_code=1
|
||||
if [ "$status" = "200" ]; then
|
||||
return_code=0
|
||||
fi
|
||||
exit ${return_code}
|
||||
|
|
|
@ -28,9 +28,10 @@ test_url() {
|
|||
local timeout=2
|
||||
[ -n "$3" ] && timeout=$3
|
||||
local extra_params=$4
|
||||
curl --help all | grep "\-\-retry-all-errors" > /dev/null
|
||||
[ $? == 0 ] && extra_params="--retry-all-errors ${extra_params}"
|
||||
status=$(/usr/bin/curl -I -o /dev/null -skL --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" ${extra_params} --connect-timeout ${timeout} --retry ${try} -w %{http_code} "$url")
|
||||
if /usr/bin/curl --help all | grep -q "\-\-retry-all-errors"; then
|
||||
extra_params="--retry-all-errors ${extra_params}"
|
||||
fi
|
||||
status=$(/usr/bin/curl -I -o /dev/null -skL ${extra_params} --connect-timeout ${timeout} --retry ${try} -w %{http_code} "$url")
|
||||
case "$status" in
|
||||
204)
|
||||
status=200
|
||||
|
|
Loading…
Reference in New Issue