diff --git a/system/ATool.php b/system/ATool.php new file mode 100644 index 0000000..fe64930 --- /dev/null +++ b/system/ATool.php @@ -0,0 +1,398 @@ + 2. 进入TwoNav的程序目录
3. 编辑 data/ATool_config.php 将"switch" => 0 改为 "switch" => 1
4. 复制Key的内容,保存后刷新此页面,使用Key验证即可进入ATool'; + require DIR.'/templates/admin/other/error.php'; + exit; +} + +session_name('ATool_SSID'); +session_start(); + +if(!empty($_GET['type'])){ + if($_GET['type'] == 'verify'){ + if(isset($_SESSION['verify']) && $_SESSION['verify'] === true){ + msg(-1,'您已经验证过了,无需重复验证!'); + }else{ + if(!empty($_POST['Key']) && $_POST['Key'] === md5($config['key'])){ + $_SESSION['verify'] = true; + msg(1,'验证成功'); + }else{ + msg(-1,'Key错误'); + } + } + } + + //判断是否已验证 + if(isset($_SESSION['verify']) && $_SESSION['verify'] === true){ + $db = Load_db(); + $global_config = unserialize( get_db("global_config", "v", ["k" => "o_config"]) ); + }else{ + msg(-1,'鉴权失败'); + } + + if($_GET['type'] == 'logout'){ + $_SESSION['verify'] = false; + Reset_Config(); + msg(1,'退出成功'); + }elseif($_GET['type'] == 'user_list'){ + $query = $_POST['query']; + $UserGroup = @$_POST['UserGroup']; + $page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']); + $limit = empty(intval($_REQUEST['limit'])) ? 50 : intval($_REQUEST['limit']); + $offset = ($page - 1) * $limit; //起始行号 + //用户组筛选 + if(!empty($UserGroup)){ + $where['AND']['UserGroup'] = $UserGroup; + } + //关键字筛选 + if(!empty($query)){ + $where['AND']['OR'] = ["User[~]" => $query,"Email[~]" => $query,"RegIP[~]" => $query]; + } + //统计条数 + $count = count_db('global_user',$where); + //权重排序(数字小的排前面) + $where['ORDER']['RegTime'] = 'DESC'; + //分页 + $where['LIMIT'] = [$offset,$limit]; + //查询 + $datas = select_db('global_user',['ID','User','UserGroup','Email','RegIP','RegTime','Login'],$where); + if(!empty($datas)){ + $user_group = select_db('user_group',['name','code'],'');//读用户组 + $user_group = array_column($user_group, 'name', 'code');//以代号为键 + $user_group['root'] = '站长'; + $user_group['default'] = '默认'; + foreach ($datas as $key => $data){ + $datas[$key]['UserGroupName'] = $user_group[$data['UserGroup']]??'Null'; + } + } + msgA(['code'=>1,'msg'=>'获取成功','count'=>$count,'data'=>$datas]); + }elseif($_GET['type'] == 'set_pwd'){ + if(!has_db('global_user',['ID'=>$_POST['ID']])){ + msg(-1,'用户不存在!'); + } + //空字符串md5 防止意外出现空密码 + if( $_POST['new_pwd']== 'd41d8cd98f00b204e9800998ecf8427e'){ + msg(-1,'密码不能为空'); + } + $RegTime = get_db('global_user','RegTime',['ID'=>$_POST['ID']]); + update_db('global_user',['Password'=>Get_MD5_Password($_POST['new_pwd'],$RegTime)],["ID" => $_POST['ID'] ],[1,'修改成功']); + }elseif($_GET['type'] == 'set_root'){ + update_db('global_user',['UserGroup'=>'root'],["ID" => $_POST['ID'] ],[1,'修改成功']); + //设为允许注册 + }elseif($_GET['type'] == 'set_allow_register'){ + $global_config['RegOption'] = 1; + update_db("global_config", ["v" => $global_config], ["k" => "o_config"],[1,'设置成功']); + //关闭维护模式 + }elseif($_GET['type'] == 'set_close_Maintenance'){ + $global_config['Maintenance'] = 0; + update_db("global_config", ["v" => $global_config], ["k" => "o_config"],[1,'设置成功']); + //重置静态路径 + }elseif($_GET['type'] == 'Set_Libs'){ + $global_config['Libs'] = "./static"; + update_db("global_config", ["v" => $global_config], ["k" => "o_config"],[1,'设置成功']); + //清理缓存 + }elseif($_GET['type'] == 'Set_clear_cache'){ + clearstatcache(); + if(function_exists("opcache_reset")){ + opcache_reset(); //清理PHP缓存 + } + msgA(['code'=>1,'msg'=>'操作成功']); + } + msgA(['code'=>-1,'msg'=>'请求类型错误']); +}else{ + //判断是否已验证 + if(isset($_SESSION['verify']) && $_SESSION['verify'] === true){ + $db = Load_db(); + $global_config = unserialize( get_db("global_config", "v", ["k" => "o_config"]) ); + echo_Atool(); + }else{ + echo_verify(); + } +} + + + +//载入数据库 +function Load_db(){ + require DIR."/data/config.php"; + require DIR.'/system/Medoo.php'; + if($db_config['type'] == 'sqlite'){ + try { + $db_config['path'] = DIR."/data/".$db_config['file']; + $db = new Medoo\Medoo(['type'=>'sqlite','database'=>$db_config['path']]); + }catch (Exception $e) { + Amsg(-1,'载入数据库失败'.$db_config['path']); + } + }elseif($db_config['type'] == 'mysql'){ + try { + $db = new Medoo\Medoo(['type' => 'mysql', + 'host' => $db_config['host'], + 'port' => $db_config['port'], + 'database' => $db_config['name'], + 'username' => $db_config['user'], + 'password' => $db_config['password'] + ]); + }catch (Exception $e) { + Amsg(-1,'链接数据库失败!'); + } + } + require DIR.'/system/public.php'; + return $db; +} + +function echo_Atool(){ + global $global_config; +?> + + + + + + ATool 工具箱 + + + + +
+
+ ATool 工具箱 +
+
+ + 打开登录页 + 打开注册页 + + + + + 帮助 +
+
+
+
+ +
+
+
+ +
+ +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + ATool 工具箱 + + + + +
+
+ + +
+
+ + + + + + + "'.Get_Rand_Str(32).'", "switch" => 0 );?>'; + if(!file_put_contents(config_path,$text)) { + exit('写初始配置失败,请检查data目录权限'); + } +} diff --git a/system/index.php b/system/index.php index 6c7ad9a..d501605 100644 --- a/system/index.php +++ b/system/index.php @@ -70,6 +70,10 @@ $fid_s = array_column($fid_s,null,'cid'); //根据分类ID查询二级分类 function get_category_sub($id) { global $site,$share,$data; + //禁止搜索非数字 + if(intval($id) == 0){ + return; + } //书签分享>限定范围内的分类ID if(!empty($share)){ $where['cid'] = $data; @@ -101,6 +105,7 @@ function get_links($fid) { $where['ORDER']['lid'] = 'ASC'; if(!is_login){ $where['property'] = 0; + } //书签分享>私有可见 if(isset($share['pv']) && $share['pv'] == 1){ @@ -112,18 +117,23 @@ function get_links($fid) { unset($where['fid']); } - if($fid == 'top_link'){ - unset($where['fid']); + //虚拟分类,根据特定条件查找 + if($fid == 'top_link' || $fid == 'new_link' ){ unset($where['ORDER']); - $where['ORDER']['click'] = 'DESC'; + if(!is_login) { + $where['fid'] = get_open_category(); + }else{ + unset($where['fid']); + } + if($fid == 'top_link'){ + $where['ORDER']['click'] = 'DESC'; + $where['LIMIT'] = $site['top_link']; + }elseif($fid == 'new_link'){ + $where['ORDER']['add_time'] = 'DESC'; + $where['LIMIT'] = $site['new_link']; + } $where['ORDER']['lid'] = 'DESC'; - $where['LIMIT'] = $site['top_link']; - }elseif($fid == 'new_link'){ - unset($where['fid']); - unset($where['ORDER']); - $where['ORDER']['add_time'] = 'DESC'; - $where['ORDER']['lid'] = 'DESC'; - $where['LIMIT'] = $site['new_link']; + //输出上限&不在子页面&例外主题 }elseif($site['max_link'] > 0 && empty(Get('oc')) && !$site['ex_theme']){ $count = count_db('user_links',$where); $where['LIMIT'] = $site['max_link']; @@ -225,38 +235,38 @@ if($category_parent == []){ $categorys = array_merge ($categorys,$category_subitem); } } - -if(empty(Get('oc'))){ - //热门链接 - if($site['top_link'] > 0 && !$site['ex_theme']){ - $top_link = ['name' => "热门网址","font_icon" =>"fa fa-bookmark-o" , "id" => 'top_link' ,"description" => ""]; - array_unshift($category_parent,$top_link); - array_unshift($categorys,$top_link); +//书签分享/例外主题禁止热门和最新 +if(empty($_GET['share']) && !$site['ex_theme']){ + //非指定分类页面 + if(empty(Get('oc'))){ + //热门链接 + if($site['top_link'] > 0){ + $top_link = ['name' => "热门网址","font_icon" =>"fa fa-bookmark-o" , "id" => 'top_link' ,"description" => ""]; + array_unshift($category_parent,$top_link); + array_unshift($categorys,$top_link); + } + //最新链接 + if($site['new_link'] > 0){ + $new_link = ['name' => "最新网址","font_icon" =>"fa fa-bookmark-o" , "id" => 'new_link' ,"description" => ""]; + array_unshift($category_parent,$new_link); + array_unshift($categorys,$new_link); + } + }else{ + unset($where['fid']); + $where['cid'] = Get('oc'); + $categorys = select_db('user_categorys',$content,$where); + $category_parent = $categorys; } - //最新链接 - if($site['new_link'] > 0 && !$site['ex_theme']){ - $new_link = ['name' => "最新网址","font_icon" =>"fa fa-bookmark-o" , "id" => 'new_link' ,"description" => ""]; - array_unshift($category_parent,$new_link); - array_unshift($categorys,$new_link); - } -}elseif(!$site['ex_theme']){ - unset($where['fid']); - $where['cid'] = Get('oc'); - $categorys = select_db('user_categorys',$content,$where); - $category_parent = $categorys; } + //访问统计 write_user_count(date('Ym'),'index_Ym'); write_user_count(date('Ymd'),'index_Ymd'); -//var_dump($site); -//var_dump(is_login); -//var_dump($theme_info); -//var_dump($categorys); - +//载入模板 require($index_path); -//辅助函数 +//取分类图标(六零系主题在用) function get_category($content){ if(empty($content)){ return ''; @@ -267,7 +277,17 @@ function get_category($content){ return $content; } } - +//获取公开分类(返回数组cid) +function get_open_category(){ + $where['uid'] = UID; + $where['fid'] = 0; + $where['status'] = 1; + $where['property'] = 0; + $categorys = select_db('user_categorys','cid',$where); + $where['fid'] = $categorys; + $categorys = array_merge ($categorys,select_db('user_categorys','cid',$where)); + return $categorys; +} //获取图标URL function geticourl($icon,$link){ if( !empty( $link['icon']) ){ diff --git a/system/install.php b/system/install.php index 0129585..909be1b 100644 --- a/system/install.php +++ b/system/install.php @@ -2,6 +2,7 @@ if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;} //初始化 +session_name('TwoNav_initial'); session_start(); //判断请求类型 diff --git a/system/version.txt b/system/version.txt index 5a1cb33..72f5c31 100644 --- a/system/version.txt +++ b/system/version.txt @@ -1 +1 @@ -v2.0.10-20230413 \ No newline at end of file +v2.0.11-20230414 \ No newline at end of file diff --git a/templates/admin/js/public.js b/templates/admin/js/public.js index 9917102..f1a9309 100644 --- a/templates/admin/js/public.js +++ b/templates/admin/js/public.js @@ -35,13 +35,16 @@ function _GET(letiable,top = false){ return false; } //时间戳格式化 -function timestampToTime(timestamp) { +function timestampToTime(timestamp,ymd = false) { let date = new Date(timestamp * 1000); let y = date.getFullYear(); let m = date.getMonth() + 1; m = m < 10 ? ('0' + m) : m; let d = date.getDate(); d = d < 10 ? ('0' + d) : d; + if(ymd){ + return y + '-' + m + '-' + d; + } let h = date.getHours(); h = h < 10 ? ('0' + h) : h; let minute = date.getMinutes(); diff --git a/templates/admin/other/error.php b/templates/admin/other/error.php index baa4828..e4fed86 100644 --- a/templates/admin/other/error.php +++ b/templates/admin/other/error.php @@ -66,7 +66,7 @@

-

可能原因:

+

diff --git a/templates/admin/page/updatelog.php b/templates/admin/page/updatelog.php index 07a1cc5..1ab7009 100644 --- a/templates/admin/page/updatelog.php +++ b/templates/admin/page/updatelog.php @@ -2,6 +2,17 @@
+
  • + +
    +

    v2.0.11-20230414

    +
      +
    • 修复热门网址/最新网址的一些问题
    • +
    • 新增Atool工具 (应急工具),用于强行修改密码/配置等 使用说明
    • +
    • 调整安装脚本session_name避免与其他面板冲突(如小皮面板,造成安装提示无法满足)
    • +
    +
    +