v2.0.27-20230618

This commit is contained in:
MI15\Win
2023-06-18 21:28:30 +08:00
parent 65edb94998
commit 4bc10f7c25
10 changed files with 167 additions and 32 deletions

View File

@@ -129,14 +129,22 @@ if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit'
//没有缓存 或 禁止缓存 或 缓存过时
if(empty($template) || $_GET['cache'] === 'no' || time() - $data["time"] > 1800 ){
$urls = [ "https://update.lm21.top/TwoNav/{$fn}_template.json"];
$urls = [
"lm21" => "https://update.lm21.top/TwoNav/{$fn}_template.json",
"gitee" => "https://gitee.com/tznb/twonav_updata/raw/master/{$fn}_template.json"
];
$Source = $global_config['Update_Source'] ?? '';
if (!empty($Source) && isset($urls[$Source])) {
$urls = [$Source => $urls[$Source]];
}
}else{
$cache = true;
}
//读取超时参数
$overtime = !isset($global_config['Update_Overtime']) ? 3 : ($global_config['Update_Overtime'] < 3 || $global_config['Update_Overtime'] > 60 ? 3 : $global_config['Update_Overtime']);
//远程获取
foreach($urls as $url){
$Res = ccurl($url,3);
foreach($urls as $key => $url){
$Res = ccurl($url,$overtime);
$data = json_decode($Res["content"], true);
if($data["code"] == 200 ){ //如果获取成功
$data["time"] = time(); //记录当前时间

View File

@@ -705,7 +705,7 @@ function write_link(){
}
$api = Get_Index_URL().'?c=icon&url='.base64_encode($link['url']);
$res = ccurl($api);
$res = ccurl($api,30);
$data = get_db('global_icon','*',['url_md5'=>md5($link['url'])]);
if(empty($data)){
msg(1,'fail');
@@ -1117,7 +1117,7 @@ function other_testing_link(){
if ( $global_config['offline'] == '1'){ msg(-1,"离线模式无法使用此功能"); }
$code = get_http_code($_POST['url']);
if($code != 200 && $code != 302 && $code != 301){
$code = ccurl($_POST['url'])['code'];
$code = ccurl($_POST['url'],30)['code'];
}
msgA(['code' => 0 ,'StatusCode'=> $code]);
}
@@ -1453,7 +1453,7 @@ function write_data_control(){
function read_data(){
global $USER_DB;
//指定类型限制仅root账号可用!
if(in_array($USER_DB['UserGroup'] != 'root' && $_GET['type'],['diagnostic_log','phpinfo'])){
if(in_array($USER_DB['UserGroup'] != 'root' && $_GET['type'],['diagnostic_log','connectivity_test','phpinfo'])){
msg(-1,'无权限');
}
@@ -1464,7 +1464,24 @@ function read_data(){
$index_count = get_db('user_count','v',['uid'=>UID,'k'=>date('Ym'),'t'=>'index_Ym'])??0;
$click_count = get_db('user_count','v',['uid'=>UID,'k'=>date('Ym'),'t'=>'click_Ym'])??0;
msgA( ['code'=>1,'data'=>[$category_count,$link_count,$index_count,$click_count] ]);
//连通测试
}elseif($_GET['type'] == 'connectivity_test'){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_POST['url']);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$start = microtime(true);
$response = curl_exec($ch);
$end = microtime(true);
$time = round(($end - $start) * 1000, 2);
if(curl_errno($ch)) {
$log .= "请求发生错误:".curl_error($ch);
} else {
$log .= "响应内容:".$response ?? 'Null' ;
$log .= ",访问耗时:{$time} 毫秒。" ;
}
curl_close($ch);
msg(1,$log);
//一键诊断
}elseif($_GET['type'] == 'diagnostic_log'){
clearstatcache(); //清除缓存

View File

@@ -48,10 +48,20 @@ function other_upsys(){
}
//设置执行最长时间0为无限制。单位秒!
set_time_limit(5*60);
$overtime = !isset($GLOBALS['global_config']['Update_Overtime']) ? 3 : ($GLOBALS['global_config']['Update_Overtime'] < 3 || $GLOBALS['global_config']['Update_Overtime'] > 60 ? 3 : $GLOBALS['global_config']['Update_Overtime']);
//加载远程数据
$urls = [ "https://update.lm21.top/TwoNav/updata.json"];
foreach($urls as $url){
$Res = ccurl($url,3);
$urls = [
"lm21" => "https://update.lm21.top/TwoNav/updata.json",
"gitee" => "https://gitee.com/tznb/twonav_updata/raw/master/updata.json"
];
$Source = $GLOBALS['global_config']['Update_Source'] ?? '';
if (!empty($Source) && isset($urls[$Source])) {
$urls = [$Source => $urls[$Source]];
}
foreach($urls as $key => $url){
$Res = ccurl($url,$overtime);
$data = json_decode($Res["content"], true);
if($data["code"] == 200 ){ //如果获取成功
break; //跳出循环.
@@ -537,6 +547,9 @@ function write_sys_settings(){
'global_header'=>['empty'=>true],
'global_footer'=>['empty'=>true],
'api_extend'=>['empty'=>true],
//更新设置
'Update_Source'=>['empty'=>true],
'Update_Overtime'=>['int'=>true,'min'=>3,'max'=>60,'msg'=>'资源超时参数错误'],
//扩展功能-(全局开关)
'apply'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'收录管理参数错误'],
'guestbook'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'留言管理参数错误'],

View File

@@ -128,6 +128,9 @@ if($global_config['link_extend'] == 1 && check_purview('link_extend',1) && in_ar
$extend = empty($link['extend']) ? [] : unserialize($link['extend']);
}
//载入过渡页设置
$transition_page = unserialize(get_db("user_config", "v", ["uid"=>UID,"k"=>"s_transition_page"]));
//如果存在备用链接,则强制载入过渡页
if(!empty($link['url_standby'])) {
$link['url_standby'] = unserialize($link['url_standby']);

View File

@@ -447,6 +447,25 @@ set_db_type(db_type);
layui.use(['form'], function(){
var form = layui.form;
//伪静态检测
var request = new XMLHttpRequest();
request.open('GET', './static/Other/login.css?t=' + new Date().getTime(), true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var fileContent = request.responseText;
if (fileContent.startsWith('<!DOCTYPE html>')) {
layer.alert(
"系统检测到您的站点可能配置了不属于TwoNav的伪静态规则<br />通常是因为之前使用过其他程序,例如:OneNav Extend 或 OneNav <br />您需要将它清除,否则会影响到程序的正常使用 ( 如登录页异常 )<br />并在安装完成后在站长工具>生成伪静态>重新配置到站点中"
,{title:'环境异常提示',anim: 2,closeBtn: 0,btn: ['刷新页面']},function () {
location.reload();
}
);
}
}
};
request.send();
//开始安装
form.on('submit(register)', function(data){
var d = data.field;
@@ -510,12 +529,12 @@ function open_msg(u,p){
layer.open({ //弹出结果
type: 1
,title: '安装成功'
,area: ['230px', '220px']
,area: ['230px', '260px']
,maxmin: false
,shadeClose: false
,resize: false
,closeBtn: 0
,content: '<div style="padding: 15px;">管理员账号: '+u+'<br>管理员密码: '+p+'<br><h3><a href="?c=admin&u='+u+'" style="color: #0000FF;" class="fl"> <br> >>点我进入后台</a></h3><h3><a href="?u='+u+'" style="color: #0000FF;" class="fl"> <br> >>点我进入首页</a></h3></div>'
,content: '<div style="padding: 15px;">管理员账号: '+u+'<br>管理员密码: '+p+'<br><h3><a href="?c=admin&u='+u+'" style="color: #0000FF;" class="fl"> <br> >>点我进入后台</a></h3><h3><a href="?u='+u+'" style="color: #0000FF;" class="fl"> <br> >>点我进入首页</a></h3> <h3><a href="https://gitee.com/tznb/TwoNav/wikis/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/%E5%AE%89%E5%85%A8%E9%85%8D%E7%BD%AE" style="color: #0000FF;" class="fl" target="_blank"> <br> >>安全配置说明</a></h3> </div>'
});
}

View File

@@ -1 +1 @@
v2.0.26-20230611
v2.0.27-20230618

View File

@@ -14,14 +14,27 @@ if(!empty($Notice)){
}
//是否下载数据
if(!offline && $reload){
$Res = ccurl('https://update.lm21.top/TwoNav/Notice.json',3);
$new_data = json_decode($Res['content'], true);unset($Res);
if($new_data["code"] == 200 ){ //下载成功,写入缓存
$new_data['download_time'] = time();
write_global_config('notice',json_encode($new_data),'官方公告(缓存)');
$data = $new_data;
$overtime = !isset($global_config['Update_Overtime']) ? 3 : ($global_config['Update_Overtime'] < 3 || $global_config['Update_Overtime'] > 60 ? 3 : $global_config['Update_Overtime']);
$urls = [
"lm21" => "https://update.lm21.top/TwoNav/Notice.json",
"gitee" => "https://gitee.com/tznb/twonav_updata/raw/master/Notice.json"
];
$Source = $global_config['Update_Source'] ?? '';
if (!empty($Source) && isset($urls[$Source])) {
$urls = [$Source => $urls[$Source]];
}
foreach($urls as $key => $url){
$Res = ccurl($url,$overtime);
$new_data = json_decode($Res['content'], true);unset($Res);
if($new_data["code"] == 200 ){ //下载成功,写入缓存
$new_data['download_time'] = time();
write_global_config('notice',json_encode($new_data),'官方公告(缓存)');
$data = $new_data;
unset($new_data);
break;
}
}
unset($new_data);
}
//判断是否为空
if(empty($data['version'])){

View File

@@ -180,14 +180,35 @@ $title='系统设置';require(dirname(__DIR__).'/header.php');
</div>
</div>
<div class="layui-form-item" id="api_extend" style="display:none;">
<label class="layui-form-label required">api_extend</label>
<div class="layui-form-item layui-hide" id="api_extend">
<label class="layui-form-label">api_extend</label>
<div class="layui-input-inline">
<select name="api_extend">
<option value="0" selected="">关闭</option>
<option value="1" >开启</option>
</select>
</div>
<div class="layui-form-mid layui-word-aux">请勿开启!请勿开启!请勿开启!</div>
</div>
<div class="layui-form-item layui-hide">
<label class="layui-form-label">资源接口</label>
<div class="layui-input-inline">
<select name="Update_Source">
<option value="0" selected="">自动</option>
<option value="lm21">主线路</option>
<option value="gitee">备用线路(gitee)</option>
</select>
</div>
<div class="layui-form-mid layui-word-aux">备用资源不定期更新,非必要请勿使用!</div>
</div>
<div class="layui-form-item layui-hide">
<label class="layui-form-label">资源超时</label>
<div class="layui-input-inline">
<input type="number" name="Update_Overtime" autocomplete="off" value="3" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">默认3秒,范围3-60</div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"><legend>扩展功能</legend></fieldset>
@@ -279,8 +300,6 @@ layui.use(['jquery','form'], function () {
form.val('form', <?php echo json_encode($global_config);?>);
form.val('form', <?php echo json_encode(unserialize( get_db("global_config", "v", ["k" => "length_limit"])));?>);
//监听提交
form.on('submit(save)', function (data) {
$.post('./index.php?c=api&method=write_sys_settings&u='+u,data.field,function(data,status){
@@ -299,14 +318,13 @@ layui.use(['jquery','form'], function () {
//开启隐藏功能
$('.layui-elem-field').click(function () {
if(Number( $(this).attr('click')) >= 6){
$("#api_extend").show();
}else{
let click = $(this).attr('click') ? Number($(this).attr('click')) + 1 : 0;
$(this).attr('click',click)
let clickCount = Number($(this).attr('click') || 0);
if (clickCount >= 6) {
$(".layui-hide").removeClass("layui-hide");
} else {
$(this).attr('click', clickCount + 1);
}
});
});
});
</script>

View File

@@ -18,6 +18,7 @@ require(dirname(__DIR__).'/header.php');
<div class="layui-btn-container">
<button type="button" class="layui-btn copy_log">复制内容</button>
<button type="button" class="layui-btn diagnose">一键诊断</button>
<button type="button" class="layui-btn connectivity_test">连通测试</button>
<button type="button" class="layui-btn phpinfo">phpinfo</button>
<?php if(preg_match('/nginx/i',$_SERVER['SERVER_SOFTWARE']) ){ ?>
<button type="button" class="layui-btn rewrite">生成伪静态</button>
@@ -75,6 +76,34 @@ layui.use(['layer','form','miniTab'], function () {
});
});
//连通测试
$('.connectivity_test').on('click', function(){
$("#console_log").text("");
$("#console_log").append("浏览器UA" + navigator.userAgent +"\n");
$("#console_log").append("客户端时间:" + timestampToTime(Math.round(new Date() / 1000) ) +"\n");
var urls = [
['主线路', 'https://update.lm21.top/connectivity_test.txt'],
['备用线路(Gitee)', 'https://gitee.com/tznb/twonav_updata/raw/master/connectivity_test.txt']
];
urls.forEach(function(route) {
var routeName = route[0];
var url = route[1];
$("#console_log").append("正在检测: " + routeName +"\n");
$.ajax({
url: get_api('read_data', 'connectivity_test'),
type: 'POST',
data: { url: url },
async: false,
success: function(data, status) {
$("#console_log").append(data.msg + "\n");
},
error: function(jqXHR, textStatus, errorThrown) {
$("#console_log").append(routeName + ": 请求 " + url + " 发生错误:" + errorThrown + "\n");
}
});
});
});
//phpinfo
$('.phpinfo').on('click', function(){
layer.open({

View File

@@ -2,6 +2,21 @@
<body>
<div class="layuimini-container">
<div class="layuimini-main" style=" margin-left: 20px;">
<li class="layui-timeline-item">
<i class="layui-icon layui-timeline-axis"></i>
<div class="layui-timeline-content layui-text">
<h4 class="layui-timeline-title">v2.0.27-20230618</h4>
<ul>
<li>[优化] 增加在线数据冗余线路,以适应更多环境</li>
<li>[优化] 安装时检测是否存在不属于本程序的伪静态规则,存在时提醒用户处理</li>
<li>[优化] 安装成功提示内容添加安全配置说明</li>
<li>[新增] 站长工具新增连通测试,用于检测是否能与资源服务器连通! </li>
<li>[模板] 主页模板 WebStack-Hugo, 新增拖拽排序支持(默认关闭),修复使用分类个性图标时无法定位分类,优化iframe的自适应</li>
<li>[模板] 非默认登录模板无法登录的bug</li>
<li>[修复] 过度页停留时间设置无效的bug</li>
</ul>
</div>
</li>
<li class="layui-timeline-item">
<i class="layui-icon layui-timeline-axis"></i>
<div class="layui-timeline-content layui-text">