diff --git a/system/admin.php b/system/admin.php index d1e75de..a017322 100644 --- a/system/admin.php +++ b/system/admin.php @@ -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(); //记录当前时间 diff --git a/system/api.php b/system/api.php index ce12537..7975c76 100644 --- a/system/api.php +++ b/system/api.php @@ -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(); //清除缓存 diff --git a/system/api_root.php b/system/api_root.php index 2cfba49..9ffb4d6 100644 --- a/system/api_root.php +++ b/system/api_root.php @@ -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'=>'留言管理参数错误'], diff --git a/system/click.php b/system/click.php index f2184f7..352056f 100644 --- a/system/click.php +++ b/system/click.php @@ -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']); diff --git a/system/install.php b/system/install.php index 5914d6c..8eca803 100644 --- a/system/install.php +++ b/system/install.php @@ -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('')) { + layer.alert( + "系统检测到您的站点可能配置了不属于TwoNav的伪静态规则
通常是因为之前使用过其他程序,例如:OneNav Extend 或 OneNav
您需要将它清除,否则会影响到程序的正常使用 ( 如登录页异常 )
并在安装完成后在站长工具>生成伪静态>重新配置到站点中" + ,{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: '
管理员账号: '+u+'
管理员密码: '+p+'


>>点我进入后台


>>点我进入首页

' + ,content: '
管理员账号: '+u+'
管理员密码: '+p+'


>>点我进入后台


>>点我进入首页


>>安全配置说明

' }); } diff --git a/system/version.txt b/system/version.txt index 4475360..c702375 100644 --- a/system/version.txt +++ b/system/version.txt @@ -1 +1 @@ -v2.0.26-20230611 \ No newline at end of file +v2.0.27-20230618 \ No newline at end of file diff --git a/templates/admin/page/home.php b/templates/admin/page/home.php index aa5a6c5..e95bbb4 100644 --- a/templates/admin/page/home.php +++ b/templates/admin/page/home.php @@ -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'])){ diff --git a/templates/admin/page/root/sys_setting.php b/templates/admin/page/root/sys_setting.php index 32930b7..656cf89 100644 --- a/templates/admin/page/root/sys_setting.php +++ b/templates/admin/page/root/sys_setting.php @@ -180,14 +180,35 @@ $title='系统设置';require(dirname(__DIR__).'/header.php'); -