mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
v2.0.27-20230618
This commit is contained in:
1 parent
65edb94998
commit
4bc10f7c25
10 files changed
+167
-32
No files matched your search
+12
-4
@@ -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(); //记录当前时间
|
||||
|
||||
+21
-4
@@ -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(); //清除缓存
|
||||
|
||||
+16
-3
@@ -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'=>'留言管理参数错误'],
|
||||
|
||||
@@ -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']);
|
||||
|
||||
+21
-2
@@ -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>'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v2.0.26-20230611
|
||||
v2.0.27-20230618
|
||||
Reference in new issue
Block a user