mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
Compare commits
6 Commits
v2.0.09-20
...
v2.0.15-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccae67f236 | ||
|
|
87566c39f3 | ||
|
|
5cae5af159 | ||
|
|
fa292ba2ab | ||
|
|
0ef96aba23 | ||
|
|
d1f4530ded |
@@ -22,7 +22,8 @@ if($db_config['type'] == 'sqlite'){
|
||||
'port' => $db_config['port'],
|
||||
'database' => $db_config['name'],
|
||||
'username' => $db_config['user'],
|
||||
'password' => $db_config['password']
|
||||
'password' => $db_config['password'],
|
||||
'charset' => 'utf8mb4'
|
||||
]);
|
||||
}catch (Exception $e) {
|
||||
Amsg(-1,'链接数据库失败!');
|
||||
@@ -72,6 +73,7 @@ if(empty($c) || $c == 'index'){
|
||||
}elseif(in_array($c,['admin','click','api','ico','verify'])){
|
||||
require "./system/{$c}.php";
|
||||
}elseif(in_array($c,['apply','guestbook'])){
|
||||
if($global_config['Maintenance'] != 0){Amsg(-1,'网站正在进行维护,请稍后再试!');}
|
||||
require "./system/expand/{$c}.php";
|
||||
}else{
|
||||
Amsg(-1,'接口错误'.$c);
|
||||
|
||||
398
system/ATool.php
Normal file
398
system/ATool.php
Normal file
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
//管理员应急工具箱
|
||||
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
|
||||
define('DIR',dirname(__DIR__));
|
||||
define('config_path', DIR . '/data/ATool_config.php'); ;
|
||||
|
||||
//判断配置文件是否存在
|
||||
if(is_file(config_path)){
|
||||
require config_path;
|
||||
if(empty($config['key'])){
|
||||
exit('未读取到Key');
|
||||
}
|
||||
require DIR."/system/Msg.php";
|
||||
}else{
|
||||
require DIR.'/system/public.php';
|
||||
Reset_Config();
|
||||
}
|
||||
|
||||
//switch状态
|
||||
if($config['switch'] === 1){
|
||||
|
||||
}else{
|
||||
$msg['title'] = 'ATool未开启';
|
||||
$msg['methodTitle'] = '开启方式:';
|
||||
$msg['content'] = '1. 登录您的云服务器或虚拟主机<br /> 2. 进入TwoNav的程序目录<br /> 3. 编辑 data/ATool_config.php 将"switch" => 0 改为 "switch" => 1 <br /> 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;
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ATool 工具箱</title>
|
||||
<link rel="stylesheet" href="../static/Layui/v2.6.8/css/layui.css">
|
||||
<style>
|
||||
html, body {min-width: 1200px;background-color: #fff;position: relative;}
|
||||
.page-wrapper {width: 900px;margin: 0 auto;padding: 0 15px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-wrapper">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
<legend> ATool 工具箱 </legend>
|
||||
</fieldset>
|
||||
<div class="layui-btn-container" style="display: inline-block;">
|
||||
<button id="logout" class="layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-snowflake"></i>安全退出</button>
|
||||
<a class="layui-btn layui-btn-sm layui-btn-primary" href="../index.php?c=<?php echo $global_config['Login'];?>" target="_blank"><i class="layui-icon layui-icon-username"></i>打开登录页</a>
|
||||
<a class="layui-btn layui-btn-sm layui-btn-primary" href="../index.php?c=<?php echo $global_config['Register'];?>" target="_blank"><i class="layui-icon layui-icon-add-1"></i>打开注册页</a>
|
||||
<button type="set_allow_register" class="set layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-set-sm"></i>允许注册</button>
|
||||
<button type="set_close_Maintenance" class="set layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-set-sm"></i>关闭维护模式</button>
|
||||
<button type="Set_Libs" class="set layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-set-sm"></i>重置静态路径</button>
|
||||
<button type="Set_clear_cache" class="set layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-set-sm"></i>清除缓存</button>
|
||||
<a class="layui-btn layui-btn-sm layui-btn-primary" href="https://gitee.com/tznb/TwoNav/wikis/pages?sort_id=7993451&doc_id=3767990" target="_blank"><i class="layui-icon layui-icon-align-left"></i>帮助</a>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="layui-inline layui-form" style="padding-bottom: 5px;">
|
||||
<div class="layui-input-inline" style=" width: 150px; ">
|
||||
<select id="UserGroup" name="UserGroup" >
|
||||
<option value="" selected>全部</option>
|
||||
<option value="root">站长</option>
|
||||
<option value="default">默认</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-form" style="padding-bottom: 5px;">
|
||||
<label class="layui-form-label layui-hide-sm" style="width:60px;padding-left: 5px;padding-right: 5px;">关键字:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" name="keyword" id="keyword" placeholder='请输入账号/邮箱/注册IP' value=''autocomplete="off" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-inline layui-form" style="padding-bottom: 5px;">
|
||||
<button class="layui-btn layui-btn-normal " id="search" style="height: 36px;">搜索</button>
|
||||
</div>
|
||||
<table id="table" lay-filter="table"></table>
|
||||
</div>
|
||||
<!-- 表格操作列 -->
|
||||
<script type="text/html" id="tablebar">
|
||||
<div class="layui-btn-group">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="set_pwd">改密码</a>
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="set_root">设站长</a>
|
||||
</div>
|
||||
</script>
|
||||
<script src="../static/Layui/v2.6.8/layui.js"></script>
|
||||
<script src="../static/jquery/jquery-3.6.0.min.js"></script>
|
||||
<script src="../static/jquery/jquery.md5.js"></script>
|
||||
<script src="../templates/admin/js/public.js?v=<?php echo time();?>"></script>
|
||||
<script>
|
||||
layui.use(['layer','table'], function () {
|
||||
var $ = layui.jquery;
|
||||
var layer = layui.layer;
|
||||
var table = layui.table;
|
||||
var cols = [[
|
||||
{field:'ID',title:'ID',width:60,sort:true}
|
||||
,{title:'操作',toolbar:'#tablebar',width:130}
|
||||
,{field:'User',title:'账号',minWidth:120,templet:function(d){
|
||||
return '<a style="color:#3c78d8" title="打开用户主页" target="_blank" href="../?u='+d.User+'">'+d.User+'</a>'
|
||||
}}
|
||||
,{field:'UserGroupName',title:'用户组',minWidth:90}
|
||||
,{field:'Email',title:'Email',minWidth:170}
|
||||
,{field:'RegIP',title:'注册IP',minWidth:140,templet:function(d){
|
||||
return '<a style="color:#3c78d8" title="查询归属地" target="_blank" href="//ip.rss.ink/result/'+d.RegIP+'">'+d.RegIP+'</a>'
|
||||
}}
|
||||
,{field:'RegTime',title: '注册时间',minWidth:100,templet:function(d){
|
||||
return d.RegTime == null ? '' : timestampToTime(d.RegTime,true);
|
||||
}}
|
||||
]]
|
||||
//用户表渲染
|
||||
table.render({
|
||||
elem: '#table'
|
||||
,height: '500'
|
||||
,url: './ATool.php?type=user_list'
|
||||
,page: true
|
||||
,limit:50
|
||||
,even:true
|
||||
,loading:true
|
||||
,id:'table'
|
||||
,method: 'post'
|
||||
,response: {statusCode: 1 }
|
||||
,cols: cols
|
||||
});
|
||||
//关键字回车
|
||||
$('#keyword').keydown(function (e){if(e.keyCode === 13){search();}});
|
||||
//搜索按钮点击
|
||||
$('#search').on('click', function(){search();});
|
||||
//搜索
|
||||
function search(){
|
||||
var UserGroup = document.getElementById("UserGroup").value;
|
||||
var keyword = document.getElementById("keyword").value;
|
||||
table.reload('table', {
|
||||
url: './ATool.php?type=user_list'
|
||||
,method: 'post'
|
||||
,request: {pageName: 'page',limitName: 'limit'}
|
||||
,where: {query:keyword,UserGroup:UserGroup}
|
||||
,page: {curr: 1}
|
||||
});
|
||||
}
|
||||
//行工具
|
||||
table.on('tool(table)', function (obj) {
|
||||
console.log(obj.data);
|
||||
var data = obj.data;
|
||||
if (obj.event == 'set_pwd') {
|
||||
layer.prompt({formType: 3,value: '',title: '请输入新密码'}, function(value, index, elem){
|
||||
$.post('./ATool.php?type=set_pwd',{ID:data.ID,new_pwd:$.md5(value)},function(data,status){
|
||||
if(data.code == 1) {
|
||||
layer.close(index);
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
}else{
|
||||
layer.msg(data.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
});
|
||||
}else if(obj.event == 'set_root'){
|
||||
$.post('./ATool.php?type=set_root',{ID:data.ID},function(data,status){
|
||||
if(data.code == 1) {
|
||||
table.reload('table');
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
}else{
|
||||
layer.msg(data.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('.set').click(function () {
|
||||
let type = $(this).attr("type");
|
||||
$.post('./ATool.php?type='+type,function(re,status){
|
||||
if(re.code == 1) {
|
||||
layer.msg(re.msg, {icon: 6,time: 600,end: function() {window.location.reload();return false;}});
|
||||
}else{
|
||||
layer.msg(re.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('#logout').click(function () {
|
||||
layer.confirm('退出后ATool将被关闭并重置Key',{icon: 3, title:'为了您的站点安全:'}, function(index){
|
||||
$.post('./ATool.php?type=logout',function(re,status){
|
||||
if(re.code == 1) {
|
||||
layer.msg(re.msg, {icon: 6,time: 600,end: function() {window.location.reload();return false;}});
|
||||
}else{
|
||||
layer.msg(re.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit;
|
||||
}
|
||||
|
||||
//输出验证页面
|
||||
function echo_verify(){ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ATool 工具箱</title>
|
||||
<link rel="stylesheet" href="../static/Layui/v2.6.8/css/layui.css">
|
||||
<link rel="stylesheet" href="../static/Other/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="main-body">
|
||||
<div class="login-main">
|
||||
<div class="login-top">
|
||||
<span>ATool 工具箱</span>
|
||||
<span class="bg1"></span>
|
||||
<span class="bg2"></span>
|
||||
</div>
|
||||
<form class="layui-form login-bottom">
|
||||
<div class="center">
|
||||
<div class="item">
|
||||
<span class="icon icon-3"></span>
|
||||
<input type="password" name="Key" lay-verify="required" placeholder="请输入Key">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
|
||||
<button class="login-btn" lay-submit="" lay-filter="verify">验证</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src = "../static/jquery/jquery-3.6.0.min.js"></script>
|
||||
<script src = "../static/Layui/v2.6.8/layui.js"></script>
|
||||
<script src = '../static/jquery/jquery.md5.js'></script>
|
||||
<script>
|
||||
layui.use(['form','jquery'], function () {
|
||||
var form = layui.form,layer = layui.layer;
|
||||
form.on('submit(verify)', function (data) {
|
||||
data.field.Key = $.md5(data.field.Key);
|
||||
$.post('./ATool.php?type=verify',data.field,function(re,status){
|
||||
if(re.code == 1) {
|
||||
layer.msg(re.msg, {icon: 6,time: 600,end: function() {window.location.reload();return false;}});
|
||||
}else{
|
||||
layer.msg(re.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit;
|
||||
}
|
||||
|
||||
function Reset_Config(){
|
||||
clearstatcache();
|
||||
if(function_exists("opcache_reset")){
|
||||
opcache_reset(); //清理PHP缓存
|
||||
}
|
||||
$text = '<?php $config = array( "key" => "'.Get_Rand_Str(32).'", "switch" => 0 );?>';
|
||||
if(!file_put_contents(config_path,$text)) {
|
||||
exit('写初始配置失败,请检查data目录权限');
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,6 @@ function Amsg($code,$msg){
|
||||
msg($code,$msg);
|
||||
}else{
|
||||
header("content-Type: text/html; charset=utf-8");
|
||||
exit('<title>错误</title><font color="red">错误代码:'.$code.'<br />错误信息:'.$msg.'</font>');
|
||||
exit('<title>错误</title><font color="red">代码:'.$code.'<br />信息:'.$msg.'</font>');
|
||||
}
|
||||
}
|
||||
28
system/MySQL/20230417.php
Normal file
28
system/MySQL/20230417.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
$sql ="
|
||||
ALTER DATABASE {$GLOBALS['db_config']['name']} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE global_config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE global_user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE purview_list CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE regcode_list CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE updatadb_logs CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_apply CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_categorys CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_count CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_group CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_links CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_login_info CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_pwd_group CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
ALTER TABLE user_share CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
|
||||
('link_extend', '链接扩展', '允许使用链接扩展字段'),
|
||||
('theme_in', '主题设置', '后台显示主题设置菜单'),
|
||||
('theme_set', '主题配置', '允许自定义主题配置');
|
||||
";
|
||||
if(exe_sql($sql)){
|
||||
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
|
||||
}else{
|
||||
msg(-1,'数据库更新失败');
|
||||
}
|
||||
23
system/MySQL/20230420.php
Normal file
23
system/MySQL/20230420.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
//弥补主题配置目录名相同造成的窜数据的bug
|
||||
//复制主题配置,并重新标记t类型
|
||||
// 'theme_home','theme_login','theme_transit','theme_register';
|
||||
|
||||
$datas = select_db('user_config','*',['t'=>'theme']);
|
||||
foreach ($datas as $data) {
|
||||
$name = $data['k'];
|
||||
unset($data['id']);
|
||||
if($name == 'default'){
|
||||
$data['t'] = 'theme_transit';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
if($name == 'WebStack-Hugo'){
|
||||
$data['t'] = 'theme_transit';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
$data['t'] = 'theme_home';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
|
||||
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
|
||||
delete_db('user_config',['t'=>'theme']);
|
||||
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `global_config` (
|
||||
`v` text NOT NULL COMMENT '值',
|
||||
`d` varchar(32) DEFAULT '' COMMENT '描述',
|
||||
UNIQUE KEY `k` (`k`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 用户配置
|
||||
DROP TABLE IF EXISTS `user_config`;
|
||||
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `user_config` (
|
||||
`t` varchar(32) NOT NULL COMMENT '类型',
|
||||
`d` varchar(32) DEFAULT '' COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
-- 统计
|
||||
@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `user_count` (
|
||||
`k` varchar(32) NOT NULL COMMENT '键',
|
||||
`v` bigint(10) UNSIGNED DEFAULT '0' COMMENT '值',
|
||||
`t` varchar(32) NOT NULL COMMENT '类型'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
-- 数据库升级记录
|
||||
@@ -40,8 +40,10 @@ CREATE TABLE IF NOT EXISTS `updatadb_logs` (
|
||||
`extra` varchar(512) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `file_name` (`file_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230417.php', '1681719049', 'TRUE', '');
|
||||
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230420.php', '1681977368', 'TRUE', '');
|
||||
|
||||
-- 创建用户表
|
||||
DROP TABLE IF EXISTS `global_user`;
|
||||
@@ -64,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `global_user` (
|
||||
PRIMARY KEY (`ID`),
|
||||
UNIQUE KEY `User` (`User`),
|
||||
UNIQUE KEY `Email` (`Email`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 用户分类表
|
||||
DROP TABLE IF EXISTS `user_categorys`;
|
||||
@@ -85,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `user_categorys` (
|
||||
`icon` text NOT NULL DEFAULT '' COMMENT '个性图标',
|
||||
`extend` text NOT NULL COMMENT '扩展',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户分类';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='用户分类';
|
||||
|
||||
INSERT INTO `user_categorys` (`id`, `cid`, `fid`, `uid`, `pid`, `status`, `property`, `name`, `add_time`, `up_time`, `weight`, `description`, `font_icon`, `icon`, `extend`) VALUES
|
||||
(1, 1, 0, 0, 0, 1, 0, '默认分类', 1672502400, 1672502400, 0, 'TwoNav默认分类', 'fa fa-book', '', '');
|
||||
@@ -112,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `user_links` (
|
||||
`up_time` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
`extend` text NOT NULL COMMENT '扩展',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户链接';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='用户链接';
|
||||
|
||||
|
||||
INSERT INTO `user_links` (`id`, `lid`, `uid`, `fid`, `pid`, `status`, `property`, `title`, `url`, `url_standby`, `weight`, `description`, `icon`, `click`, `add_time`, `up_time`, `extend`) VALUES
|
||||
@@ -134,7 +136,7 @@ CREATE TABLE IF NOT EXISTS `user_login_info` (
|
||||
`expire_time` int(10) UNSIGNED NOT NULL COMMENT '过期时间',
|
||||
`cookie_key` varchar(32) NOT NULL COMMENT 'cookie_key',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 日志表
|
||||
DROP TABLE IF EXISTS `user_log`;
|
||||
@@ -148,7 +150,7 @@ CREATE TABLE IF NOT EXISTS `user_log` (
|
||||
`content` text NOT NULL COMMENT '请求内容',
|
||||
`description` varchar(128) NOT NULL COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='日志';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='日志';
|
||||
|
||||
-- 用户组
|
||||
DROP TABLE IF EXISTS `user_group`;
|
||||
@@ -162,7 +164,7 @@ CREATE TABLE IF NOT EXISTS `user_group` (
|
||||
`codes` text NOT NULL COMMENT '允许代号',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 权限列表
|
||||
DROP TABLE IF EXISTS `purview_list`;
|
||||
@@ -172,7 +174,7 @@ CREATE TABLE IF NOT EXISTS `purview_list` (
|
||||
`name` varchar(64) NOT NULL COMMENT '名称',
|
||||
`description` varchar(128) NOT NULL COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
|
||||
('Upload_icon', '上传图标', '允许上传分类和链接图标'),
|
||||
@@ -185,7 +187,10 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
|
||||
('link', '链接管理', '允许添加/编辑/删除链接(未勾选时只读)'),
|
||||
('apply', '收录管理', '允许使用收录功能'),
|
||||
('link_pwd', '加密管理', '允许使用加密管理(未勾选时只读)'),
|
||||
('guestbook', '留言板', '允许使用留言板功能');
|
||||
('guestbook', '留言板', '允许使用留言板功能'),
|
||||
('link_extend', '链接扩展', '允许使用链接扩展字段'),
|
||||
('theme_in', '主题设置', '后台显示主题设置菜单'),
|
||||
('theme_set', '主题配置', '允许自定义主题配置');
|
||||
|
||||
-- 注册码列表
|
||||
DROP TABLE IF EXISTS `regcode_list`;
|
||||
@@ -199,7 +204,7 @@ CREATE TABLE IF NOT EXISTS `regcode_list` (
|
||||
`use_time` int(10) UNSIGNED NOT NULL COMMENT '使用时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `regcode` (`regcode`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 加密分组
|
||||
DROP TABLE IF EXISTS `user_pwd_group`;
|
||||
@@ -212,7 +217,7 @@ CREATE TABLE IF NOT EXISTS `user_pwd_group` (
|
||||
`description` varchar(128) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
`display` int(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '主页显示',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 收录申请
|
||||
DROP TABLE IF EXISTS `user_apply`;
|
||||
@@ -231,7 +236,7 @@ CREATE TABLE IF NOT EXISTS `user_apply` (
|
||||
`category_name` varchar(512) NOT NULL DEFAULT '' COMMENT '分类名',
|
||||
`description` varchar(512) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 书签分享
|
||||
DROP TABLE IF EXISTS `user_share`;
|
||||
@@ -250,5 +255,5 @@ CREATE TABLE IF NOT EXISTS `user_share` (
|
||||
`data` text NOT NULL COMMENT '数据',
|
||||
`pv` int(1) NOT NULL COMMENT '私有可见',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php if(!defined('DIR')||$global_config['RegOption']=='0'){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
if($global_config['Maintenance'] != 0){Amsg(-1,'网站正在进行维护,请稍后再试!');}
|
||||
//注册入口
|
||||
$global_templates = unserialize(get_db("global_config",'v', ["k" => "s_templates"]));
|
||||
//如果是Get请求则载入登录模板
|
||||
@@ -14,7 +15,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET'){
|
||||
$global_templates['register'] = 'default';
|
||||
update_db("global_config", ["v" => $global_templates], ["k"=>"s_templates"]);
|
||||
}
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/twonav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/TwoNav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
|
||||
$reg_tips = get_db('global_config','v',['k'=>'reg_tips']);
|
||||
require $t_path;
|
||||
@@ -55,17 +56,18 @@ if(!preg_match('/^[A-Za-z0-9]{4,13}$/', $user)){
|
||||
msg(-1,'邮箱长度超限');
|
||||
}elseif(strlen($pass)!=32){
|
||||
msg(-1,'POST提交的密码异常≠32!');
|
||||
}elseif(preg_match("/(class|controller|data|favicon|initial|static|templates|index|root|admin|cache|upload)/i",$user) ) {
|
||||
msg(-1,'禁止注册保留用户名!');
|
||||
}elseif(preg_match("/^(system|data|static|templates|index|root|admin)$/i",$user) ) {
|
||||
msg(-1,'改用户名已被系统保留!');
|
||||
}elseif(!empty(get_db('global_user','ID',['User'=>$user ]))){
|
||||
msg(-1,'该账号已被注册!');
|
||||
}elseif(!empty(get_db('global_user','ID',['Email'=>$Email ]))){
|
||||
msg(-1,'该邮箱已被使用!');
|
||||
}elseif(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$Email)){
|
||||
msg(-1,'邮箱错误!');
|
||||
}elseif(username_retain_verify($user)){
|
||||
msg(-1,'该账号已被站长保留!');
|
||||
}
|
||||
|
||||
|
||||
//插入用户表和创建初始数据库
|
||||
$RegTime = time();
|
||||
$PassMD5 = Get_MD5_Password($pass,$RegTime);
|
||||
@@ -182,6 +184,22 @@ $category_id = intval(max_db('user_categorys','cid',['uid'=>$USER_DB['ID']])) +1
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'],"k"=>"category_id","v"=>$category_id,"t"=>"max_id","d"=>'分类ID']);
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'],"k"=>"pwd_group_id","v"=>1,"t"=>"max_id","d"=>'加密组ID']);
|
||||
|
||||
|
||||
//账号保留
|
||||
function username_retain_verify($username){
|
||||
$list = get_db("global_config", "v", ["k" => "username_retain"]);
|
||||
if(empty($list)){
|
||||
return false;
|
||||
}
|
||||
$patterns = explode("\n", $list);
|
||||
foreach($patterns as $pattern){
|
||||
if (preg_match($pattern, $username)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//返回注册成功
|
||||
msg(1,'注册成功');
|
||||
|
||||
|
||||
12
system/SQLite/20230417.php
Normal file
12
system/SQLite/20230417.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
$sql =<<<EOF
|
||||
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
|
||||
('link_extend', '链接扩展', '允许使用链接扩展字段'),
|
||||
('theme_in', '主题设置', '后台显示主题设置菜单'),
|
||||
('theme_set', '主题配置', '允许自定义主题配置');
|
||||
EOF;
|
||||
if(exe_sql($sql)){
|
||||
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
|
||||
}else{
|
||||
msg(-1,'数据库更新失败');
|
||||
}
|
||||
23
system/SQLite/20230420.php
Normal file
23
system/SQLite/20230420.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
//弥补主题配置目录名相同造成的窜数据的bug
|
||||
//复制主题配置,并重新标记t类型
|
||||
// 'theme_home','theme_login','theme_transit','theme_register';
|
||||
|
||||
$datas = select_db('user_config','*',['t'=>'theme']);
|
||||
foreach ($datas as $data) {
|
||||
$name = $data['k'];
|
||||
unset($data['id']);
|
||||
if($name == 'default'){
|
||||
$data['t'] = 'theme_transit';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
if($name == 'WebStack-Hugo'){
|
||||
$data['t'] = 'theme_transit';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
$data['t'] = 'theme_home';
|
||||
insert_db('user_config',$data);
|
||||
}
|
||||
|
||||
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
|
||||
delete_db('user_config',['t'=>'theme']);
|
||||
@@ -35,6 +35,8 @@ CREATE TABLE IF NOT EXISTS "updatadb_logs" (
|
||||
"extra" TEXT(512) NOT NULL DEFAULT "",
|
||||
CONSTRAINT "file_name" UNIQUE ("file_name" ASC)
|
||||
);
|
||||
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230417.php', '1681719049', 'TRUE', '');
|
||||
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230420.php', '1681977368', 'TRUE', '');
|
||||
|
||||
-- 创建用户表
|
||||
CREATE TABLE IF NOT EXISTS "global_user" (
|
||||
@@ -158,7 +160,10 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
|
||||
('link', '链接管理', '允许添加/编辑/删除链接(未勾选时只读)'),
|
||||
('apply', '收录管理', '允许使用收录功能'),
|
||||
('link_pwd', '加密管理', '允许使用加密管理(未勾选时只读)'),
|
||||
('guestbook', '留言板', '允许使用留言板功能');
|
||||
('guestbook', '留言板', '允许使用留言板功能'),
|
||||
('link_extend', '链接扩展', '允许使用链接扩展字段'),
|
||||
('theme_in', '主题设置', '后台显示主题设置菜单'),
|
||||
('theme_set', '主题配置', '允许自定义主题配置');
|
||||
|
||||
-- 注册码列表
|
||||
CREATE TABLE IF NOT EXISTS "regcode_list" (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}AccessControl();
|
||||
|
||||
//获取请求参数
|
||||
$page = trim($_GET['page']);
|
||||
@@ -53,32 +53,8 @@ if ($page == 'home') {
|
||||
array_push($day_data[0]['data'],get_db('user_count','v',['uid'=>UID,'k'=>$date,'t'=>'index_Ymd'])??0);
|
||||
array_push($day_data[1]['data'],get_db('user_count','v',['uid'=>UID,'k'=>$date,'t'=>'click_Ymd'])??0);
|
||||
}
|
||||
//var_dump(json_encode($day),$day_data);
|
||||
}
|
||||
|
||||
//调试
|
||||
if( $page == 'test' ) {
|
||||
$dirs = get_dir_list(DIR.'/templates/home');
|
||||
//var_dump($dirs);
|
||||
foreach ($dirs as $dir) {
|
||||
$path = DIR.'/templates/home/'.$dir; //目录完整路径
|
||||
//没有信息文件则跳过
|
||||
if(!is_file($path.'/info.json') ) {continue;}
|
||||
//读取主题信息
|
||||
$themes[$dir]['info'] = json_decode(@file_get_contents($path.'/info.json'),true);
|
||||
//是否支持配置
|
||||
$themes[$dir]['info']['config'] = is_file($path.'/config.php') ? '1':'0';
|
||||
//预览图优先顺序:png>jpg>info>default
|
||||
if(is_file($dirs.'/screenshot.png')){
|
||||
$themes[$dir]['info']['screenshot'] = "./templates/home/".$dir."/screenshot.png";
|
||||
}elseif(is_file($dirs.'/screenshot.jpg')){
|
||||
$themes[$dir]['info']['screenshot'] = "./templates/home/".$dir."/screenshot.jpg";
|
||||
}elseif(empty($themes[$dir]['info']['screenshot'])){
|
||||
$themes[$dir]['info']['screenshot'] = "./templates/admin/static/42ed3ef2c4a50f6d.png";
|
||||
}
|
||||
//var_dump($themes);
|
||||
}
|
||||
}
|
||||
//载入主题配置
|
||||
if($page == 'config_home'){
|
||||
$theme = $_GET['theme'];
|
||||
@@ -92,7 +68,10 @@ if($page == 'config_home'){
|
||||
$theme_config = empty($theme_config['config']) ? []:$theme_config['config'];
|
||||
|
||||
//读取用户主题配置
|
||||
$theme_config_db = get_db('user_config','v',['t'=>'theme','k'=>$theme,'uid'=>UID]);
|
||||
if(!in_array($_GET['fn'],['home','login','register','transit'])){
|
||||
msg(-1,"参数错误");
|
||||
}
|
||||
$theme_config_db = get_db('user_config','v',['t'=>'theme_'.$_GET['fn'],'k'=>$theme,'uid'=>UID]);
|
||||
$theme_config_db = unserialize($theme_config_db);
|
||||
|
||||
//如果不为空则合并数据
|
||||
@@ -103,7 +82,6 @@ if($page == 'config_home'){
|
||||
if(empty($theme_config)){
|
||||
exit("<h3>获取主题配置失败</h3>");
|
||||
}
|
||||
//var_dump($theme_config);
|
||||
require $config_path;
|
||||
exit;
|
||||
}
|
||||
@@ -129,7 +107,6 @@ if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit'
|
||||
}elseif(empty($themes[$dir]['info']['screenshot'])){
|
||||
$themes[$dir]['info']['screenshot'] = "./templates/admin/static/42ed3ef2c4a50f6d.png";
|
||||
}
|
||||
//var_dump($themes);
|
||||
}
|
||||
|
||||
//获取当前主题
|
||||
@@ -191,15 +168,19 @@ if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit'
|
||||
define('referrer',$data['referrer']);
|
||||
}
|
||||
}
|
||||
//var_dump($themes);exit;
|
||||
}
|
||||
|
||||
|
||||
//菜单接口
|
||||
if ($page == 'menu') {
|
||||
$menu = array(
|
||||
['title'=>'站点设置','href'=>'SiteSetting','icon'=>'fa fa-cog'],
|
||||
['title'=>'主题设置','href'=>'theme_home','icon'=>'fa fa-magic'],
|
||||
$menu = [];
|
||||
if(check_purview('site_info',1)){
|
||||
array_push($menu,['title'=>'站点设置','href'=>'SiteSetting','icon'=>'fa fa-cog']);
|
||||
}
|
||||
if(check_purview('theme_in',1)){
|
||||
array_push($menu,['title'=>'主题设置','href'=>'theme_home','icon'=>'fa fa-magic']);
|
||||
}
|
||||
array_push($menu,
|
||||
['title'=>'分类管理','href'=>'category_list','icon'=>'fa fa-list-ul'],
|
||||
['title'=>'加密管理','href'=>'pwd_group','icon'=>'fa fa-lock'],
|
||||
['title'=>'链接管理','icon'=>'fa fa-folder-open-o','href'=>'','child'=>
|
||||
@@ -225,7 +206,6 @@ if ($page == 'menu') {
|
||||
array_push($menu,$extend);
|
||||
}
|
||||
|
||||
|
||||
//如果是管理员则追加菜单
|
||||
if($USER_DB['UserGroup'] == 'root'){
|
||||
array_push($menu,
|
||||
@@ -246,7 +226,6 @@ if ($page == 'menu') {
|
||||
exit(json_encode($init));
|
||||
}
|
||||
|
||||
|
||||
//不带参数是载入框架
|
||||
if(empty($page)){
|
||||
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
|
||||
@@ -266,7 +245,6 @@ if(!empty($page)){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//加载静态库
|
||||
function load_static($type){
|
||||
if($type == 'css'){
|
||||
|
||||
131
system/api.php
131
system/api.php
@@ -2,7 +2,7 @@
|
||||
//允许跨域访问
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Headers: Access-Control-Allow-Private-Network,Content-Type, AccessToken, X-CSRF-Token, Authorization, Token,X-Token,X-Cid");
|
||||
|
||||
AccessControl();
|
||||
//鉴权验证 Cookie验证通过,验证二级密码,Cookie验证失败时尝试验证token
|
||||
|
||||
//获取请求方法
|
||||
@@ -282,6 +282,18 @@ function write_category(){
|
||||
|
||||
//读链接列表
|
||||
function read_link_list(){
|
||||
if($_GET['type'] == 'extend_list'){
|
||||
if($GLOBALS['global_config']['link_extend'] != 1 || !check_purview('link_extend',1)){
|
||||
msgA(['code'=>1,'msg'=>'无权限','count'=>0,'data'=>[]]);
|
||||
}
|
||||
$list = get_db("user_config","v",["k"=>"s_extend_list","uid"=>UID]);
|
||||
if(empty($list)){
|
||||
msgA(['code'=>1,'msg'=>'无数据','count'=>0,'data'=>[]]);
|
||||
}
|
||||
$list = unserialize($list);
|
||||
msgA(['code'=>1,'msg'=>'获取成功','count'=>count($list),'data'=>$list]);
|
||||
}
|
||||
|
||||
$query = $_POST['query'];
|
||||
$fid = intval(@$_POST['fid']); //获取分类ID
|
||||
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
|
||||
@@ -541,6 +553,22 @@ function write_link(){
|
||||
'icon' => $icon
|
||||
];
|
||||
|
||||
//扩展字段
|
||||
if($GLOBALS['global_config']['link_extend'] == 1 && check_purview('link_extend',1)){
|
||||
$list = get_db("user_config","v",["k"=>"s_extend_list","uid"=>UID]);
|
||||
if(!empty($list)){
|
||||
$list = unserialize($list);
|
||||
$extend = [];
|
||||
foreach($list as $field){
|
||||
$name = "_{$field['name']}";
|
||||
if(isset($_POST[$name])){
|
||||
$data['extend'][$name] = $_POST[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//非必须参数,未传递参数时
|
||||
if(isset($_POST['icon'])){
|
||||
//指定本地图标时检测是否存在
|
||||
@@ -641,12 +669,86 @@ function write_link(){
|
||||
if(empty($fid)){msg(-1,'分类ID错误');}
|
||||
//加一个查找分类是否存在
|
||||
update_db('user_links',['fid'=>$fid],['uid'=>UID ,"lid" => json_decode($_POST['lid']) ],[1,'设置成功']);
|
||||
//图标拉取(不完善,未开放使用)
|
||||
}elseif($_GET['type'] === 'icon_pull'){
|
||||
$link = get_db('user_links','url',['uid'=>UID,'lid'=>$_POST['id']]);
|
||||
if(empty($link)){
|
||||
msg(-1,'请求的链接id不存在');
|
||||
}
|
||||
$s_site = unserialize(get_db("user_config","v",["k"=>"s_site","uid"=>UID]));
|
||||
if(empty($s_site['link_icon']) || $s_site['link_icon'] == 0){
|
||||
msg(-1,'站点设置链接图标不能是离线图标!请先修改配置!');
|
||||
}
|
||||
$icon = $s_site['link_icon'];
|
||||
if($icon ==2){
|
||||
function base64($url){
|
||||
$urls = parse_url($url);
|
||||
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
|
||||
$host = $urls['host']; //获取主机名
|
||||
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
|
||||
$new_url = $scheme.$host.$port;
|
||||
return base64_encode($new_url);
|
||||
}
|
||||
$api = 'https://favicon.rss.ink/v1/'.base64($link);
|
||||
}elseif($icon ==4){
|
||||
$api = 'https://api.15777.cn/get.php?url='.$link;
|
||||
}elseif($icon ==5){
|
||||
$api = 'https://favicon.cccyun.cc/'.$link;
|
||||
}elseif($icon ==6){
|
||||
$api = 'https://api.iowen.cn/favicon/'.parse_url($link)['host'].'.png';
|
||||
}elseif($icon ==7){
|
||||
$api = 'https://toolb.cn/favicon/'.parse_url($link)['host'];
|
||||
}
|
||||
if(downFile($api,$_POST['id'].'.ico',DIR ."/data/user/".U."/favicon/")){
|
||||
update_db('user_links',['icon'=>"./data/user/".U.'/favicon/'.$_POST['id'].'.ico'],['uid'=>UID ,"lid" => $_POST['id'] ],[1,'获取成功']);
|
||||
}
|
||||
msg(-1,'获取失败');
|
||||
|
||||
}elseif($_GET['type'] == 'extend_list'){
|
||||
if($GLOBALS['global_config']['link_extend'] != 1 ||!check_purview('link_extend',1)){
|
||||
msg(-1,'无权限');
|
||||
}
|
||||
$lists = json_decode($_POST['list'],true);
|
||||
|
||||
$weight = [];
|
||||
foreach ($lists as $data ){
|
||||
if(empty($data['weight']) || !preg_match('/^\d$/', $data['weight'])){
|
||||
msgA( ['code' => -1,'msg' => '序号错误,请输入正整数'] );
|
||||
}
|
||||
if(empty($data['title']) || check_xss($data['title'])){
|
||||
msgA( ['code' => -1,'msg' => '标题不能为空'] );
|
||||
}
|
||||
if(empty($data['name']) || check_xss($data['name']) || !preg_match('/^[A-Za-z0-9]{3,18}$/',$data['name'])){
|
||||
msgA( ['code' => -1,'msg' => '字段名错误,请输入长度3-18的字母/数字'] );
|
||||
}
|
||||
if(!in_array($data['type'],['text','textarea'])){
|
||||
msgA( ['code' => -1,'msg' => '类型错误'] );
|
||||
}
|
||||
}
|
||||
if(is_Duplicated($lists,'weight')){
|
||||
msg(-1,'序号不能重复');
|
||||
}elseif(is_Duplicated($lists,'title')){
|
||||
msg(-1,'标题不能重复');
|
||||
}elseif(is_Duplicated($lists,'name')){
|
||||
msg(-1,'字段名不能重复');
|
||||
}
|
||||
|
||||
$datas = [];
|
||||
foreach ($lists as $key => $data ){
|
||||
array_push($datas,['title'=>$data['title'],'name'=>$data['name'],'weight'=>$data['weight'],'type'=>$data['type'],'default'=> "{$data['default']}"]);
|
||||
}
|
||||
//根据序号排序
|
||||
usort($datas, function($a, $b) {
|
||||
return $a['weight'] - $b['weight'];
|
||||
});
|
||||
write_user_config('s_extend_list',$datas,'config','链接扩展字段');
|
||||
msgA( ['code' => 1,'msg' => '保存成功','datas'=>$datas] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
msg(-1,'操作类型错误');
|
||||
}
|
||||
|
||||
|
||||
//写安全设置
|
||||
function write_security_setting(){
|
||||
global $USER_DB;
|
||||
@@ -844,8 +946,11 @@ function write_site_setting(){
|
||||
'keywords'=>['empty'=>true],
|
||||
'description'=>['empty'=>true],
|
||||
'link_model'=>['v'=>['direct','Privacy','Privacy_js','Privacy_meta','301','302','Transition'],'msg'=>'链接模式参数错误'],
|
||||
'link_icon'=>['int'=>true,'min'=>0,'max'=>6,'msg'=>'链接图标参数错误'],
|
||||
'link_icon'=>['int'=>true,'min'=>0,'max'=>10,'msg'=>'链接图标参数错误'],
|
||||
'site_icon'=>['empty'=>true],
|
||||
'top_link'=>['int'=>true,'min'=>0,'max'=>20,'msg'=>'热门链接参数错误'],
|
||||
'new_link'=>['int'=>true,'min'=>0,'max'=>20,'msg'=>'最新链接参数错误'],
|
||||
'max_link'=>['int'=>true,'min'=>0,'max'=>100,'msg'=>'输出上限参数错误'],
|
||||
'custom_header'=>['empty'=>true],
|
||||
'custom_footer'=>['empty'=>true]
|
||||
];
|
||||
@@ -865,6 +970,7 @@ function write_site_setting(){
|
||||
//留空时尝试删除图标
|
||||
if(empty($s_site['site_icon']) && !empty($site['site_icon_file']) && is_file($site['site_icon_file'])){
|
||||
@unlink($site['site_icon_file']);
|
||||
$s_site['site_icon_file'] = '';
|
||||
}
|
||||
update_db("user_config",["v"=>$s_site],["k"=>'s_site',"uid"=>UID],[1,'保存成功']);
|
||||
}
|
||||
@@ -1119,13 +1225,28 @@ function write_theme(){
|
||||
|
||||
//配置主题信息
|
||||
}elseif($_GET['type'] == 'config'){
|
||||
if(!check_purview('theme_set',1)){
|
||||
msg(-1,"无权限!");
|
||||
}
|
||||
if(empty($_POST)){
|
||||
msg(-1,"POST请求数据不能为空!");
|
||||
}
|
||||
write_user_config($_GET['t'],$_POST,'theme','主题配置');
|
||||
//20230420,修复同名窜数据的问题!由于保存主题不提交模板类型,只能从来路中提取
|
||||
parse_str(parse_url($_SERVER['HTTP_REFERER'])['query'],$GET);
|
||||
if(empty($GET['fn']) && empty($_GET['template_type']) ){
|
||||
msg(-1,"获取模板类型错误");
|
||||
}
|
||||
$fn = empty($GET['fn']) ? $_GET['template_type'] : $GET['fn'];
|
||||
if(!in_array($fn,['home','login','register','transit'])){
|
||||
msg(-1,"参数错误");
|
||||
}
|
||||
//0420 END
|
||||
write_user_config($_GET['t'],$_POST,'theme_' . $fn,'主题配置');
|
||||
msg(1,"保存成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//读登录信息
|
||||
function read_login_info(){
|
||||
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
|
||||
|
||||
@@ -42,9 +42,9 @@ function other_upsys(){
|
||||
if($_POST['i'] == 2){
|
||||
if(!is_subscribe('bool')){
|
||||
msg(-1,'未检测到有效授权,请
|
||||
<a href="https://gitee.com/tznb/OneNav/wikis/%E8%AE%A2%E9%98%85%E6%9C%8D%E5%8A%A1%E6%8C%87%E5%BC%95" target="_blank" style="color: #01AAED;">购买授权</a>
|
||||
<a href="https://gitee.com/tznb/TwoNav/wikis/pages?sort_id=7968669&doc_id=3767990" target="_blank" style="color: #01AAED;">购买授权</a>
|
||||
或
|
||||
<a href="https://gitee.com/tznb/TwoNav/releases" target="_blank" style="color: #01AAED;">手动更新</a>');
|
||||
<a href="https://gitee.com/tznb/TwoNav/wikis/pages?sort_id=8013447&doc_id=3767990" target="_blank" style="color: #01AAED;">手动更新</a>');
|
||||
}
|
||||
//设置执行最长时间,0为无限制。单位秒!
|
||||
set_time_limit(5*60);
|
||||
@@ -422,6 +422,9 @@ function write_regcode(){
|
||||
}elseif($_GET['type'] == 'set'){
|
||||
write_global_config('reg_tips',$_POST['content'],'注册提示');
|
||||
msg(1,'保存成功');
|
||||
}elseif($_GET['type'] == 'del'){
|
||||
delete_db("regcode_list",[ "id" => json_decode($_POST['id'])]);
|
||||
msg(1,'删除成功');
|
||||
}
|
||||
|
||||
msg(-1,'无效的请求类型');
|
||||
@@ -496,12 +499,14 @@ function write_sys_settings(){
|
||||
'Debug'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'调试模式参数错误'],
|
||||
'Maintenance'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'维护模式参数错误'],
|
||||
'Sub_domain'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'二级域名参数错误'],
|
||||
'Privacy'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'强制私有参数错误'],
|
||||
'copyright'=>['empty'=>true],
|
||||
'global_header'=>['empty'=>true],
|
||||
'global_footer'=>['empty'=>true],
|
||||
//扩展功能-(全局开关)
|
||||
'apply'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'收录管理参数错误'],
|
||||
'guestbook'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'留言管理参数错误'],
|
||||
'link_extend'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'链接扩展参数错误'],
|
||||
];
|
||||
$o_config = [];
|
||||
foreach ($datas as $key => $data){
|
||||
@@ -515,11 +520,13 @@ function write_sys_settings(){
|
||||
}
|
||||
if(!is_subscribe('bool')){
|
||||
if($_POST['Sub_domain'] == 1){$o_config['Sub_domain'] = 0;$filter = true;}
|
||||
if($_POST['Privacy'] == 1){$o_config['Privacy'] = 0;$filter = true;}
|
||||
if(!empty($_POST['copyright'])){$o_config['copyright'] = "";$filter = true;}
|
||||
if(!empty($_POST['global_header'])){$o_config['global_header'] = "";$filter = true;}
|
||||
if(!empty($_POST['global_footer'])){$o_config['global_footer'] = "";$filter = true;}
|
||||
if(!empty($_POST['apply'])){$o_config['apply'] = 0;$filter = true;}
|
||||
if(!empty($_POST['guestbook'])){$o_config['guestbook'] = 0;$filter = true;}
|
||||
if($_POST['apply'] == 1){$o_config['apply'] = 0;$filter = true;}
|
||||
if($_POST['guestbook'] == 1){$o_config['guestbook'] = 0;$filter = true;}
|
||||
if($_POST['link_extend'] == 1){$o_config['link_extend'] = 0;$filter = true;}
|
||||
}
|
||||
|
||||
update_db("global_config", ["v" => $o_config], ["k" => "o_config"],[1,($filter ?"保存成功,未检测到有效授权,带*号的配置无法为你保存":"保存成功")]);
|
||||
@@ -627,6 +634,22 @@ function other_root(){
|
||||
msg(1,'已释放 '.byteFormat($size).' 缓存');
|
||||
}elseif($_GET['type'] == 'import_data'){
|
||||
require DIR .'/system/UseFew/root_import_data.php';
|
||||
}elseif($_GET['type'] == 'read_username_retain'){
|
||||
$data = get_db("global_config", "v", ["k" => "username_retain"]);
|
||||
msgA(['code'=>1,'msg'=>'获取成功','data'=>$data]);
|
||||
}elseif($_GET['type'] == 'write_username_retain'){
|
||||
//遍历检测语法
|
||||
$patterns = explode("\n",$_POST['username_retain']);
|
||||
foreach($patterns as $pattern){
|
||||
if (@preg_match($pattern, '') === false) {
|
||||
msg(-1,'正则表达式语法错误,请检查');
|
||||
}
|
||||
}
|
||||
if(!is_subscribe('bool')){
|
||||
msg(-1,'未检测到有效授权');
|
||||
}
|
||||
write_global_config('username_retain',$_POST['username_retain'],'账号保留');
|
||||
msg(1,'保存成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php if(!defined('DIR')){Not_Found();}
|
||||
<?php if(!defined('DIR')){Not_Found();}AccessControl();
|
||||
//负责过渡页/跳转/隐私保护/密码访问
|
||||
$id = intval($_GET['id']);
|
||||
|
||||
@@ -8,17 +8,20 @@ if(empty($id)){Not_Found();}
|
||||
//查询链接信息
|
||||
$where['lid'] = $id;
|
||||
$where['uid'] = UID;
|
||||
//$where['status'] = 1;
|
||||
$where['status'] = 1;
|
||||
$link = get_db('user_links','*',$where);
|
||||
|
||||
//查找失败时显示404
|
||||
if(empty($link)){
|
||||
Not_Found();
|
||||
}
|
||||
if(empty($link)){Not_Found();}
|
||||
|
||||
//站点设置和站点图标
|
||||
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
|
||||
$site['Title'] = $site['title'].(empty($site['subtitle'])?'':' - '.$site['subtitle']);
|
||||
//免费用户请保留版权,谢谢!
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/TwoNav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
|
||||
$favicon = ( !empty($site['site_icon_file'])) ? $site['site_icon'] : './favicon.ico';
|
||||
|
||||
|
||||
//取登录状态
|
||||
$is_login = is_login();
|
||||
|
||||
@@ -39,7 +42,6 @@ if(!$is_login){
|
||||
$pv = empty($share['pwd']) || $_SESSION['verify']['share'][$share['id']] == $share['pwd'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//判断链接是否停用/私有
|
||||
if($link['status'] == 0){
|
||||
@@ -64,7 +66,6 @@ if(!$is_login){
|
||||
exit('很抱歉,页面所属的祖分类是私有的!您无权限查看,如果您是管理员,请先登录!');
|
||||
}
|
||||
|
||||
|
||||
//判断链接是否加密
|
||||
if(!empty($link['pid'])){
|
||||
$verify_type = 'link_pwd';
|
||||
@@ -94,9 +95,6 @@ if(!$is_login){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//取模板信息
|
||||
require DIR ."/system/templates.php";
|
||||
$dir_path = DIR.'/templates/transit/'.$s_templates['transit'];
|
||||
@@ -107,36 +105,28 @@ if(!is_file($transit_path)){
|
||||
$transit_path= DIR.'/templates/transit/default/index.php';
|
||||
}
|
||||
|
||||
//免费用户请保留版权,谢谢!
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/twonav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
|
||||
|
||||
//读取站点配置
|
||||
$s_site = unserialize(get_db("user_config","v",["k"=>"s_site","uid"=>UID]));
|
||||
|
||||
//var_dump($link,$transit_path,$category_parent,$category_ancestor,$s_site);
|
||||
|
||||
//统计点击数
|
||||
write_user_count(date('Ym'),'click_Ym');
|
||||
write_user_count(date('Ymd'),'click_Ymd');
|
||||
update_db("user_links", ["click[+]"=>1],['uid'=>UID,'lid'=>$id]);
|
||||
|
||||
//读取过渡页设置
|
||||
$transition_page = unserialize(get_db("user_config","v",["t"=>"config","k"=>"s_transition_page","uid"=>UID]));
|
||||
|
||||
//载入站点设置
|
||||
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
|
||||
|
||||
//读取用户主题配置
|
||||
$theme_config_db = unserialize(get_db('user_config','v',['t'=>'theme','k'=>$s_templates['transit'],'uid'=>UID]));
|
||||
$theme_config_db = unserialize(get_db('user_config','v',['t'=>'theme_transit','k'=>$s_templates['transit'],'uid'=>UID]));
|
||||
|
||||
//读取默认主题配置
|
||||
$theme_info = json_decode(@file_get_contents($dir_path.'/info.json'),true);
|
||||
$theme_config = empty($theme_info['config']) ? []:$theme_info['config'];
|
||||
$theme_ver = !Debug?$theme_info['version']:$theme_info['version'].'.'.time();
|
||||
|
||||
//合并配置数据
|
||||
$theme_config = empty($theme_config_db) ? $theme_config : array_merge ($theme_config??[],$theme_config_db??[]);
|
||||
|
||||
//如果主题信息声明支持扩展字段
|
||||
if($global_config['link_extend'] == 1 && check_purview('link_extend',1) && in_array($theme_info['support']['link_extend'],["true","1"])){
|
||||
$extend = empty($link['extend']) ? [] : unserialize($link['extend']);
|
||||
}
|
||||
|
||||
//如果存在备用链接,则强制载入过渡页
|
||||
if(!empty($link['url_standby'])) {
|
||||
@@ -145,24 +135,24 @@ if(!empty($link['url_standby'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($s_site['link_model'] == '302'){ //302重定向
|
||||
if ($site['link_model'] == '302'){ //302重定向
|
||||
header("HTTP/1.1 302 Moved Permanently");
|
||||
header("Location: ".$link['url']);
|
||||
exit;
|
||||
}elseif($s_site['link_model'] == '301'){ //301重定向
|
||||
}elseif($site['link_model'] == '301'){ //301重定向
|
||||
header("HTTP/1.1 301 Moved Permanently");
|
||||
header("Location: ".$link['url']);
|
||||
exit;
|
||||
}elseif($s_site['link_model'] == 'Privacy'){ //隐私保护_header
|
||||
}elseif($site['link_model'] == 'Privacy'){ //隐私保护_header
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
header("Refresh:0;url=".$link['url']);
|
||||
echo '<html lang="zh-ch"><head><title>正在保护您的隐私..</title><meta name="referrer" content="same-origin"></head>';
|
||||
exit;
|
||||
}elseif($s_site['link_model'] == 'Privacy_js'){ //隐私保护_js
|
||||
}elseif($site['link_model'] == 'Privacy_js'){ //隐私保护_js
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
echo '<html lang="zh-ch"><head><title>正在保护您的隐私..</title><meta name="referrer" content="same-origin"><script>window.location.href="'.$link['url'].'"</script></head>';
|
||||
exit;
|
||||
}elseif($s_site['link_model'] == 'Privacy_meta'){ //隐私保护_meta
|
||||
}elseif($site['link_model'] == 'Privacy_meta'){ //隐私保护_meta
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
echo '<html lang="zh-ch"><head><title>正在保护您的隐私..</title><meta name="referrer" content="same-origin"><meta http-equiv="refresh" content="0;url='.$link['url'].'"></head>';
|
||||
exit;
|
||||
|
||||
145
system/index.php
145
system/index.php
@@ -1,10 +1,9 @@
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
|
||||
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}AccessControl();
|
||||
//主页入口
|
||||
define('is_login',is_login());
|
||||
//var_dump($global_config['offline']);
|
||||
|
||||
//判断用户组,是否允许未登录时访问主页
|
||||
if(!is_login && !check_purview('Common_home',1)){
|
||||
if(!is_login && ($global_config['Privacy'] == 1 || !check_purview('Common_home',1))){
|
||||
header("HTTP/1.1 302 Moved Permanently");
|
||||
header("Location: ./?c=admin");
|
||||
exit;
|
||||
@@ -13,7 +12,7 @@ if(!is_login && !check_purview('Common_home',1)){
|
||||
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
|
||||
$site['Title'] = $site['title'].(empty($site['subtitle'])?'':' - '.$site['subtitle']);
|
||||
//免费用户请保留版权,谢谢!
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/twonav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/TwoNav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
|
||||
$favicon = ( !empty($site['site_icon_file'])) ? $site['site_icon'] : './favicon.ico';
|
||||
//读取默认模板信息
|
||||
@@ -44,13 +43,13 @@ $support_category_svg = $theme_info['support']['category_svg']??0; //0.不支持
|
||||
//主题配置(默认)
|
||||
$theme_config = empty($theme_info['config']) ? []:$theme_info['config'];
|
||||
//主题配置(用户)
|
||||
$theme_config_db = get_db('user_config','v',['t'=>'theme','k'=>$theme,'uid'=>UID]);
|
||||
$theme_config_db = get_db('user_config','v',['t'=>'theme_home','k'=>$theme,'uid'=>UID]);
|
||||
$theme_config_db = unserialize($theme_config_db);
|
||||
//合并配置数据
|
||||
$theme_config = empty($theme_config_db) ? $theme_config : array_merge ($theme_config,$theme_config_db);
|
||||
//主题版本(调试时追加时间戳)
|
||||
$theme_ver = !Debug?$theme_info['version']:$theme_info['version'].'.'.time();
|
||||
|
||||
$site['ex_theme'] = in_array($theme,['snail-nav','heimdall']); //例外主题,不支持热门网址/最新网址/输出上限
|
||||
//分类查找条件
|
||||
$categorys = []; //声明一个空数组
|
||||
$content = ['cid(id)','name','property','font_icon','icon','description'];//需要的内容
|
||||
@@ -69,7 +68,11 @@ $fid_s = array_column($fid_s,null,'cid');
|
||||
|
||||
//根据分类ID查询二级分类
|
||||
function get_category_sub($id) {
|
||||
global $site,$share,$data;
|
||||
global $share,$data;
|
||||
//禁止搜索非数字
|
||||
if(intval($id) == 0){
|
||||
return;
|
||||
}
|
||||
//书签分享>限定范围内的分类ID
|
||||
if(!empty($share)){
|
||||
$where['cid'] = $data;
|
||||
@@ -92,7 +95,7 @@ function get_category_sub($id) {
|
||||
|
||||
//根据分类id查找链接
|
||||
function get_links($fid) {
|
||||
global $site,$fid_s,$share,$data;
|
||||
global $site,$fid_s,$share,$data,$u;
|
||||
$where = [];
|
||||
$where = ["uid"=> UID];
|
||||
$where['fid'] = intval($fid);
|
||||
@@ -101,6 +104,7 @@ function get_links($fid) {
|
||||
$where['ORDER']['lid'] = 'ASC';
|
||||
if(!is_login){
|
||||
$where['property'] = 0;
|
||||
|
||||
}
|
||||
//书签分享>私有可见
|
||||
if(isset($share['pv']) && $share['pv'] == 1){
|
||||
@@ -111,8 +115,30 @@ function get_links($fid) {
|
||||
$where['lid'] = $data;
|
||||
unset($where['fid']);
|
||||
}
|
||||
|
||||
//虚拟分类,根据特定条件查找
|
||||
if($fid == 'top_link' || $fid == 'new_link' ){
|
||||
unset($where['ORDER']);
|
||||
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';
|
||||
//输出上限&不在子页面&例外主题&书签分享
|
||||
}elseif($site['max_link'] > 0 && empty(Get('oc')) && !$site['ex_theme'] && empty($_GET['share'])){
|
||||
$count = count_db('user_links',$where);
|
||||
$where['LIMIT'] = $site['max_link'];
|
||||
$max_link = true;
|
||||
}
|
||||
$links = select_db('user_links',['lid(id)','fid','property','title','url(real_url)','url_standby','description','icon','click','pid'],$where);
|
||||
//var_dump($fid_s);exit;
|
||||
foreach ($links as $key => $link) {
|
||||
$click = false; $lock = false;
|
||||
|
||||
@@ -147,6 +173,11 @@ function get_links($fid) {
|
||||
//获取图标链接
|
||||
$links[$key]['ico'] = $lock ? $GLOBALS['libs'].'/Other/lock.svg' : geticourl($site['link_icon'],$link);
|
||||
}
|
||||
if($max_link && $count > $site['max_link']){
|
||||
$oc_url = "./index.php?u={$u}&oc={$fid}" . (empty($_GET['theme']) ? '':"&theme={$_GET['theme']}");
|
||||
array_push($links,['id'=>0,'title'=>'查看全部','url'=>$oc_url,'real_url'=>$oc_url,'description'=>'该分类共有'.$count.'条数据','ico'=>'./favicon.ico']);
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
@@ -204,75 +235,33 @@ if($category_parent == []){
|
||||
$categorys = array_merge ($categorys,$category_subitem);
|
||||
}
|
||||
}
|
||||
//书签分享/例外主题禁止热门和最新
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//访问统计
|
||||
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 '';
|
||||
}
|
||||
if(substr($content, 0,4) == '<svg'){
|
||||
return 'data:image/svg+xml;base64,'.base64_encode($content);
|
||||
}else{
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
//获取图标URL
|
||||
function geticourl($icon,$link){
|
||||
if( !empty( $link['icon']) ){
|
||||
if(substr($link['icon'], 0,4) == '<svg'){
|
||||
return('data:image/svg+xml;base64,'.base64_encode($link['icon']));
|
||||
}else{
|
||||
return($link['icon']);
|
||||
}
|
||||
}
|
||||
if ($site['link_icon'] == 'default'){
|
||||
return($GLOBALS['libs'].'/Other/default.ico');
|
||||
}elseif ($icon ==1){
|
||||
return('./favicon/index2.php?url='.$link['real_url']);
|
||||
}elseif($icon ==2){
|
||||
return('//favicon.rss.ink/v1/'.base64($link['real_url']));
|
||||
}elseif($icon ==4){
|
||||
return('//api.15777.cn/get.php?url='.$link['real_url']);
|
||||
}elseif($icon ==5){
|
||||
return('//favicon.cccyun.cc/'.$link['real_url']);
|
||||
}elseif($icon ==6){
|
||||
return('//api.iowen.cn/favicon/'.parse_url($link['real_url'])['host'].'.png');
|
||||
}elseif($icon ==0){
|
||||
return('./system/ico.php?text='.mb_strtoupper(mb_substr($link['title'], 0, 1)));
|
||||
}else{
|
||||
return('./favicon/index2.php?url='.$link['real_url']);
|
||||
}//如果参数错误则使用本地服务器
|
||||
}
|
||||
|
||||
//将URL转换为base64编码
|
||||
function base64($url){
|
||||
$urls = parse_url($url);
|
||||
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
|
||||
$host = $urls['host']; //获取主机名
|
||||
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
|
||||
$new_url = $scheme.$host.$port;
|
||||
return base64_encode($new_url);
|
||||
}
|
||||
//是否启用收录
|
||||
function is_apply(){
|
||||
global $global_config;
|
||||
$apply_user = unserialize( get_db("user_config", "v", ["k" => "apply","uid"=>UID]));
|
||||
return ($global_config['apply'] == 1 && $apply_user['apply'] == 1);
|
||||
}
|
||||
//是否启用留言
|
||||
function is_guestbook(){
|
||||
global $global_config;
|
||||
$guestbook_user = unserialize( get_db("user_config", "v", ["k" => "guestbook","uid"=>UID]) );
|
||||
return ($global_config['guestbook'] == 1 && $guestbook_user['allow'] == 1);
|
||||
|
||||
}
|
||||
//载入模板
|
||||
require($index_path);
|
||||
@@ -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();
|
||||
|
||||
//判断请求类型
|
||||
|
||||
@@ -5,7 +5,7 @@ require "./system/templates.php";
|
||||
if($_SERVER['REQUEST_METHOD'] === 'GET'){
|
||||
require DIR ."/system/templates.php";
|
||||
$t_path = DIR ."/templates/login/{$s_templates['login']}/index.php"; //模板路径
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/twonav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/TwoNav">Copyright © TwoNav</a>':$global_config['copyright'];
|
||||
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
|
||||
//检查是否存在,不存在则使用默认
|
||||
if(!is_file($t_path)){
|
||||
|
||||
@@ -155,8 +155,7 @@ function get_db($table,$columns,$where,$rp = []){
|
||||
|
||||
//写全局配置(存在则更新,不存在则创建)
|
||||
function write_global_config($key,$value,$d){
|
||||
$re = get_db('global_config','k',['k'=>$key]);
|
||||
if(empty($re)){
|
||||
if(!has_db('global_config',['k'=>$key])){
|
||||
insert_db("global_config", ["k" => $key,"v" => $value,"d" => $d]);
|
||||
}else{
|
||||
update_db("global_config", ["v" => $value],['k'=>$key]);
|
||||
@@ -165,17 +164,16 @@ function write_global_config($key,$value,$d){
|
||||
|
||||
//写用户配置(存在则更新,不存在则创建)
|
||||
function write_user_config($key,$value,$t,$d){
|
||||
$re = get_db('user_config','k',['uid'=>UID,'k'=>$key]);
|
||||
if(empty($re)){
|
||||
if(!has_db('user_config',['uid'=>UID,'k'=>$key,'t'=>$t])){
|
||||
insert_db("user_config", ['uid'=>UID,"k"=>$key,"v"=>$value,"t"=>$t,"d"=>$d]);
|
||||
}else{
|
||||
update_db("user_config", ["v"=>$value],['uid'=>UID,'k'=>$key]);
|
||||
update_db("user_config", ["v"=>$value],['uid'=>UID,'k'=>$key,'t'=>$t]);
|
||||
}
|
||||
}
|
||||
|
||||
//写用户统计
|
||||
function write_user_count($key,$t){
|
||||
$re = get_db('user_count','k',['uid'=>UID,'t'=>$t,'k'=>$key]);
|
||||
if(empty($re)){
|
||||
if(!has_db('user_count',['uid'=>UID,'t'=>$t,'k'=>$key])){
|
||||
insert_db("user_count", ['uid'=>UID,"k"=>$key,"v"=>1,'t'=>$t]);
|
||||
}else{
|
||||
update_db("user_count", ["v[+]"=>1],['uid'=>UID,'t'=>$t,'k'=>$key]);
|
||||
@@ -582,7 +580,18 @@ function getindexurl(){
|
||||
$HOST = $http_type.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
|
||||
return($HOST);
|
||||
}
|
||||
|
||||
//检查数组指定字段是否有重复值
|
||||
function is_Duplicated($array, $field){
|
||||
$values = [];
|
||||
foreach($array as $item){
|
||||
if(in_array($item[$field], $values)){
|
||||
return true;
|
||||
}else{
|
||||
$values[] = $item[$field];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//检查权限(有权限返回true 没有权限时根传递参数1是返回false 2是直接返回错误信息)
|
||||
function check_purview($name,$return_type){
|
||||
global $USER_DB;
|
||||
|
||||
@@ -12,3 +12,84 @@ if(empty($s_templates)){
|
||||
$s_templates = $global_templates;
|
||||
insert_db("user_config", ["uid" => UID,"k"=>"s_templates","v"=>$global_templates,"t"=>"config","d" => '默认模板']);
|
||||
}
|
||||
|
||||
//载入辅助函数
|
||||
if(empty($c) || in_array($c,['index','click'])){
|
||||
//将URL转换为base64编码
|
||||
function base64($url){
|
||||
$urls = parse_url($url);
|
||||
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
|
||||
$host = $urls['host']; //获取主机名
|
||||
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
|
||||
$new_url = $scheme.$host.$port;
|
||||
return base64_encode($new_url);
|
||||
}
|
||||
//是否启用收录
|
||||
function is_apply(){
|
||||
global $global_config;
|
||||
$apply_user = unserialize( get_db("user_config", "v", ["k" => "apply","uid"=>UID]));
|
||||
return ($global_config['apply'] == 1 && $apply_user['apply'] == 1);
|
||||
}
|
||||
//是否启用留言
|
||||
function is_guestbook(){
|
||||
global $global_config;
|
||||
$guestbook_user = unserialize( get_db("user_config", "v", ["k" => "guestbook","uid"=>UID]) );
|
||||
return ($global_config['guestbook'] == 1 && $guestbook_user['allow'] == 1);
|
||||
|
||||
}
|
||||
//获取图标URL
|
||||
function geticourl($icon,$link){
|
||||
if( !empty( $link['icon']) ){
|
||||
if(substr($link['icon'], 0,4) == '<svg'){
|
||||
return('data:image/svg+xml;base64,'.base64_encode($link['icon']));
|
||||
}else{
|
||||
return($link['icon']);
|
||||
}
|
||||
}
|
||||
if ($site['link_icon'] == 'default'){
|
||||
return($GLOBALS['libs'].'/Other/default.ico');
|
||||
}elseif ($icon ==1){
|
||||
return('./favicon/index2.php?url='.$link['real_url']);
|
||||
}elseif($icon ==2){
|
||||
return('//favicon.rss.ink/v1/'.base64($link['real_url']));
|
||||
}elseif($icon ==4){
|
||||
return('//api.15777.cn/get.php?url='.$link['real_url']);
|
||||
}elseif($icon ==5){
|
||||
return('//favicon.cccyun.cc/'.$link['real_url']);
|
||||
}elseif($icon ==6){
|
||||
return('//api.iowen.cn/favicon/'.parse_url($link['real_url'])['host'].'.png');
|
||||
}elseif($icon ==7){
|
||||
return('https://toolb.cn/favicon/'.parse_url($link['real_url'])['host']);
|
||||
}elseif($icon ==8){
|
||||
return('https://apis.jxcxin.cn/api/Favicon?url='.$link['real_url']);
|
||||
}elseif($icon ==0){
|
||||
return('./system/ico.php?text='.mb_strtoupper(mb_substr($link['title'], 0, 1)));
|
||||
}else{
|
||||
return('./favicon/index2.php?url='.$link['real_url']);
|
||||
}//如果参数错误则使用本地服务器
|
||||
}
|
||||
//取分类图标(六零系主题在用)
|
||||
function get_category($content){
|
||||
if(empty($content)){
|
||||
return '';
|
||||
}
|
||||
if(substr($content, 0,4) == '<svg'){
|
||||
return 'data:image/svg+xml;base64,'.base64_encode($content);
|
||||
}else{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.0.09-20230410
|
||||
v2.0.15-20230422
|
||||
@@ -165,7 +165,7 @@ layui.use(['form','table','dropdown','miniTab'], function () {
|
||||
}
|
||||
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
if( checkStatus.data.length == 0 && ['LAYTABLE_COLS','LAYTABLE_EXPORT','LAYTABLE_PRINT','batch'].indexOf(event) == -1 ) {
|
||||
if( checkStatus.data.length == 0 && ['LAYTABLE_COLS','LAYTABLE_EXPORT','LAYTABLE_PRINT','batch','link_extend'].indexOf(event) == -1 ) {
|
||||
layer.msg('未选中任何数据!');
|
||||
return;
|
||||
}
|
||||
@@ -248,9 +248,63 @@ layui.use(['form','table','dropdown','miniTab'], function () {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}else if(event === 'icon_pull'){
|
||||
let i = 0;
|
||||
let total = checkStatus.data.length;
|
||||
layer.load(1, {shade:[0.3,'#fff']});//加载层
|
||||
let msg_id = layer.msg('正在拉取中', {icon: 16,time: 1000*300});
|
||||
icon_pull(i);
|
||||
function icon_pull(id){
|
||||
if(i >= total){
|
||||
layer.closeAll();
|
||||
layer.alert('拉取完毕',{icon:1,title:'信息',anim: 2,shadeClose: false,closeBtn: 0});
|
||||
return true;
|
||||
}
|
||||
$("#layui-layer"+ msg_id+" .layui-layer-padding").html('<i class="layui-layer-ico layui-layer-ico16"></i>[ ' + i + ' / ' + total + ' ] 正在拉取图标');
|
||||
$.post(get_api('write_link','icon_pull'),{id:checkStatus.data[i].lid},function(data,status){
|
||||
if(data.code == 1){
|
||||
i ++;
|
||||
icon_pull(i);
|
||||
} else{
|
||||
layer.closeAll();
|
||||
layer.alert(data.msg,{icon:5,title:'信息',anim: 2,shadeClose: false,closeBtn: 0});
|
||||
}
|
||||
});
|
||||
}
|
||||
}else if(event === 'link_extend'){
|
||||
extend_data = '';
|
||||
index = layer.open({type: 1,scrollbar: false,shadeClose: true,title: '编辑扩展字段',area : ['100%', '100%'],content: $('.link_extend')});
|
||||
$.post(get_api('read_link_list','extend_list'),function(data,status){
|
||||
if(data.code == 1){
|
||||
extend_data = data.data;
|
||||
table.reload('link_extend_list', {data: extend_data});
|
||||
} else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
table.render({
|
||||
elem: '#link_extend_list'
|
||||
,height: 'full-150'
|
||||
,data: {}
|
||||
,response: {statusCode: 1 }
|
||||
,method: 'post'
|
||||
,page: false
|
||||
,limit: 1000
|
||||
,even:true
|
||||
,id:'link_extend_list'
|
||||
,loading:true
|
||||
,cols: [[
|
||||
{field:'weight',title:'序号',edit:'text',width:80}
|
||||
,{field:'title',title:'标题',edit:'text',width:256}
|
||||
,{field:'name',title:'字段名',edit:'text',width:256}
|
||||
,{field:'type',title:'类型',edit:'text',width:256}
|
||||
,{field:'default',title:'默认值',edit:'text',width:256}
|
||||
,{ title:'操作',toolbar:'#link_extend_toolbar',align:'center',width:118}
|
||||
]]
|
||||
});
|
||||
//监听工具条
|
||||
table.on('tool(table)', function (obj) {
|
||||
var data = obj.data;
|
||||
@@ -375,4 +429,58 @@ layui.use(['form','table','dropdown','miniTab'], function () {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//自定义字段行事件
|
||||
table.on('tool(link_extend_list)', function (obj) {
|
||||
var data = obj.data;
|
||||
var row = $(obj.tr).attr("data-index"); //获取行索引
|
||||
if (obj.event === 'del') {
|
||||
layer.confirm('确认移除?',{icon: 3, title:'温馨提示'}, function(index){
|
||||
obj.del();
|
||||
layer.close(index);
|
||||
layer.msg("移除成功,点击保存后生效!",{icon:1});
|
||||
});
|
||||
}
|
||||
});
|
||||
//添加字段
|
||||
$('#add_field').click(function () {
|
||||
let data = table.cache.link_extend_list;
|
||||
let max_weight = 0;
|
||||
//找出最大的一个排序值
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if( parseInt(data[i].weight) > max_weight ){
|
||||
max_weight = parseInt(data[i].weight);
|
||||
}
|
||||
}
|
||||
data.push({
|
||||
"title": "请输入标题",
|
||||
"name":"请输入字段名(大小写字母或数字)",
|
||||
"weight":(max_weight + 1),
|
||||
"type":"请输入 text 或 textarea",
|
||||
"default":""
|
||||
});
|
||||
table.reload('link_extend_list', {data: data});
|
||||
return false;
|
||||
});
|
||||
//保存字段
|
||||
$('#save_field').click(function () {
|
||||
var data = [];
|
||||
var tableBak = table.cache.link_extend_list;
|
||||
for (var i = 0; i < tableBak.length; i++) {
|
||||
//过滤掉被删除的空数据
|
||||
if(typeof tableBak[i].LAY_TABLE_INDEX == 'number'){
|
||||
data.push(tableBak[i]);
|
||||
}
|
||||
}
|
||||
$.post(get_api('write_link','extend_list') ,{list:JSON.stringify(data)},function(data,status){
|
||||
if(data.code == 1){
|
||||
table.reload("link_extend_list",{data:data.datas});
|
||||
layer.msg('保存成功', {icon: 1});
|
||||
} else{
|
||||
layer.msg(data.msg,{icon:5});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<div class="content">
|
||||
<p class="result"><?php echo $msg['big_title'] ??''; ?></p>
|
||||
<div class="method">
|
||||
<p class="methodTitle">可能原因:</p>
|
||||
<p class="methodTitle"><?php echo $msg['methodTitle'] ??'可能原因:'; ?></p>
|
||||
<div class="methodItems">
|
||||
<?php echo $msg['content']; ?>
|
||||
</div>
|
||||
|
||||
@@ -62,11 +62,49 @@
|
||||
<option value="4" >api.15777.cn</option>
|
||||
<option value="5" >favicon.cccyun.cc</option>
|
||||
<option value="6" >api.iowen.cn</option>
|
||||
<!--<option value="7" >toolb.cn</option>-->
|
||||
<!--<option value="8" >apis.jxcxin.cn</option>-->
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">所有API接口均由其他大佬提供!若有异常请尝试更换接口!</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">热门网址</label>
|
||||
<div class="layui-input-inline" >
|
||||
<select name="top_link">
|
||||
<option value="0" selected>不显示</option>
|
||||
<option value="5" >显示5条</option>
|
||||
<option value="10" >显示10条</option>
|
||||
<option value="15" >显示15条</option>
|
||||
<option value="20" >显示20条</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">在主页显示热门网址(点击排行)</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">最新网址</label>
|
||||
<div class="layui-input-inline" >
|
||||
<select name="new_link">
|
||||
<option value="0" selected>不显示</option>
|
||||
<option value="5" >显示5条</option>
|
||||
<option value="10" >显示10条</option>
|
||||
<option value="15" >显示15条</option>
|
||||
<option value="20" >显示20条</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">在主页显示最新的网址(创建时间)</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">输出上限</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="max_link" class="layui-input" value="0" placeholder="输入范围: 0-100" lay-verify="required">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">限制每个分类下显示多少链接,0表示不限制</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点图标</label>
|
||||
<div class="layui-input-block">
|
||||
@@ -97,14 +135,18 @@
|
||||
<?php } ?>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-primary layui-border-black" id="help" sort_id="7968924">帮助</button>
|
||||
<?php if($global_config['Default_User'] != U ){ ?>
|
||||
<button class="layui-btn layui-btn-primary layui-border-black" id="sdhp" data=>设为默认主页</button>
|
||||
<?php } ?>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src = "<?php echo $libs;?>/jquery/jquery-3.6.0.min.js"></script>
|
||||
<script src = "./templates/admin/js/public.js?v=<?php echo $Ver;?>"></script>
|
||||
<script src="<?php echo $libs;?>/jquery/jquery-3.6.0.min.js"></script>
|
||||
<script src="<?php echo $libs;?>/jquery/jQueryCookie.js"></script>
|
||||
<script src="./templates/admin/js/public.js?v=<?php echo $Ver;?>"></script>
|
||||
<?php load_static('js.layui');?>
|
||||
<script>
|
||||
layui.use(['jquery','form','upload'], function () {
|
||||
@@ -136,6 +178,18 @@ layui.use(['jquery','form','upload'], function () {
|
||||
layer.msg("权限不足", {icon: 2});
|
||||
});
|
||||
|
||||
$("#sdhp").text( getCookie("Default_User") == u ? '取消默认主页' : '设为默认主页')
|
||||
$('#sdhp').click(function () {
|
||||
if(getCookie("Default_User") == u){
|
||||
$.removeCookie("Default_User");
|
||||
$("#sdhp").text('设为默认主页')
|
||||
}else{
|
||||
$.cookie("Default_User",u);
|
||||
$("#sdhp").text('取消默认主页')
|
||||
}
|
||||
layer.msg("设置成功", {icon: 1});
|
||||
return false;
|
||||
});
|
||||
//监听提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.post('./index.php?c=api&method=write_site_setting&u='+u,data.field,function(data,status){
|
||||
|
||||
@@ -58,7 +58,7 @@ if($s['help'] != 'del'|| !count($dbs) || isset($_GET['help'])){
|
||||
$arr['type'] = '使用说明';
|
||||
$arr['contact'] = '271152681@qq.com';
|
||||
$arr['title'] = 'TwoNav 极简留言板';
|
||||
$arr['content'] = "1.极简留言板采用轻量设计,整体只有几KB\n2.留言数据存放路径/data/user/xxx/MessageBoard/ (xxx表示用户名)\n3.默认是禁止留言的,点击上方蓝色字(禁止留言/允许留言)可切换状态\n4.使用方法: 点击极简留言板(蓝字)>把地址栏的URL复制>在后台添加链接即可\n5.本条信息被删除时如果存在留言则不显示,没有留言时依旧会显示!\n6.有提交长度限制,类型32,联系方式64,标题128,内容2048字节!若不够用请自己修改源代码!\n7.为了防止被恶意提交,当留言数超过256时将不在接收留言!";
|
||||
$arr['content'] = "1.极简留言板采用轻量设计,整体只有几KB\n2.留言数据存放路径/data/user/xxx/MessageBoard/ (xxx表示用户名)\n3.默认是禁止留言的,点击上方蓝色字(禁止留言/允许留言)可切换状态\n4.使用方法: 点击极简留言板(蓝字)>把地址栏的URL复制>在后台添加链接即可(部分主题已支持自动展现入口)\n5.本条信息被删除时如果存在留言则不显示,没有留言时依旧会显示!\n6.有提交长度限制,类型32,联系方式64,标题128,内容2048字节!若不够用请自己修改源代码!\n7.为了防止被恶意提交,当留言数超过256时将不在接收留言!";
|
||||
$arr['time'] = date("Y-m-d H:i:s",time());
|
||||
$arr['ip'] = '127.0.0.1';
|
||||
$arr['id'] = $id;
|
||||
@@ -113,7 +113,7 @@ $title='留言管理';require dirname(__DIR__).'/header.php';
|
||||
<?php foreach ( $data as $value ) { ?>
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title"><?php echo $value['id'] .'. [ '. $value['type'] .' ] [ '. $value['title'].' ]'; ?> 
|
||||
<a style="cursor:pointer;" rel = "nofollow" onclick = "del('<?php echo $value['file'] ?>')">删除</a>
|
||||
<a class="click" style="cursor:pointer;" rel = "nofollow" onclick = "del('<?php echo $value['file'] ?>')">删除</a>  
|
||||
</h2>
|
||||
<div class="layui-colla-content <?php if( $value['id'] <= $show ){echo 'layui-show';} ?>">
|
||||
<p><?php echo '提交时间: '. $value['time'] .'<br />终端地址: '. $value['ip'] .'<br />联系方式: '. $value['contact'] .'<br /> <br />'. str_replace("\n","<br />",str_replace(" "," ",$value['content'])) ; ?></p>
|
||||
@@ -134,6 +134,11 @@ layui.use(['layer','element'], function(){
|
||||
var layer = layui.layer;
|
||||
});
|
||||
|
||||
$('.click').click(function (event) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
function del(name) {
|
||||
$.post('',{'type':'del','name':name},function(data,status){
|
||||
if(data.code == 1) {
|
||||
@@ -154,6 +159,7 @@ function set(key){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="layui-container">
|
||||
<div class="layui-col-lg10 ">
|
||||
<form class="layui-form">
|
||||
<fieldset class="layui-elem-field layui-field-title " style="margin-top: 30px;"><legend><a href="https://gitee.com/tznb/OneNav" target="_blank" rel="nofollow">TwoNav</a> 极简留言板</legend></fieldset>
|
||||
<fieldset class="layui-elem-field layui-field-title " style="margin-top: 30px;"><legend><a href="https://gitee.com/tznb/TwoNav" target="_blank" rel="nofollow">TwoNav</a> 极简留言板</legend></fieldset>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">反馈类型</label>
|
||||
<div class="layui-input-inline">
|
||||
@@ -59,7 +59,7 @@
|
||||
</div>
|
||||
</form>
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
|
||||
<legend>Powered by <a href="https://gitee.com/tznb/OneNav" target="_blank" rel="nofollow">lm21</a></legend>
|
||||
<legend>Powered by <a href="https://gitee.com/tznb/TwoNav" target="_blank" rel="nofollow">lm21</a></legend>
|
||||
<!--非订阅用户请勿去除版权,谢谢-->
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
@@ -250,11 +250,12 @@ require 'header.php';
|
||||
<?php }?>
|
||||
<tr>
|
||||
<td>用户交流</td>
|
||||
<td>QQ群:695720839</td>
|
||||
<td><a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=LaIzFK2hfTYBZGR0cKvW3xZL6aNgcSXH&jump_from=webapi&authKey=LHh1NtAiGdK0wNyoZiHWrzAZTWWq26YgAwX0Ak7rBWchh6Y5ocUX/0cCXLMXvq/k" title="TwoNav - 技术交流">QQ群:695720839</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>技术支持</td>
|
||||
<td>QQ:271152681</td>
|
||||
<td><a target="_blank" href="tencent://message/?uin=271152681">QQ:271152681</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>专属地址</td>
|
||||
|
||||
@@ -99,7 +99,11 @@ $title='编辑链接';$awesome=true; require 'header.php';
|
||||
<textarea name="description" id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
//判断全局是否开启扩展
|
||||
if($global_config['link_extend'] && check_purview('link_extend',1)){
|
||||
require 'link_extend.php';
|
||||
}?>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block layui-btn-group">
|
||||
<button class="layui-btn layui-btn-warm" type="button" id="close" >关闭</button>
|
||||
|
||||
47
templates/admin/page/link_extend.php
Normal file
47
templates/admin/page/link_extend.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
|
||||
<legend>扩展字段</legend>
|
||||
</fieldset>
|
||||
<?php
|
||||
//读取扩展字段列表
|
||||
$list = get_db("user_config","v",["k"=>"s_extend_list","uid"=>UID]);
|
||||
//不为空则渲染
|
||||
if(!empty($list)){
|
||||
$list = unserialize($list);
|
||||
$extend_data = get_db('user_links','extend',['uid'=>UID,'lid'=>$link['lid']]);
|
||||
$extend_data = empty($extend_data) ? [] : unserialize($extend_data);
|
||||
|
||||
foreach ($list as $data) {
|
||||
$field = "_".$data['name'];
|
||||
$data['value'] = isset($extend_data[$field]) ? $extend_data[$field] : $data['default'];
|
||||
if($data['type'] == 'text'){
|
||||
echo_text($data);
|
||||
}elseif($data['type'] == 'textarea'){
|
||||
echo_textarea($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function echo_text($data){ ?>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><?php echo $data['title']?></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="_<?php echo $data['name']?>" autocomplete="off" value="<?php echo htmlentities($data['value'])?>" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function echo_textarea($data){ ?>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><?php echo $data['title']?></label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="_<?php echo $data['name']?>" class="layui-textarea"><?php echo htmlentities($data['value'])?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -65,7 +65,12 @@
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-hide-xs" lay-event="batch_public" id="batch_public">设为公开</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-hide-xs" lay-event="batch_start" id="batch_start">设为启用</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-hide-xs" lay-event="batch_disable" id="batch_disable">设为禁用</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-btn-danger layui-hide-xs" lay-event="testing" id="testing" <?php echo $global_config['offline']?'style="display:none;"':''?> >检测</button>
|
||||
<?php if($global_config['link_extend'] == 1 && check_purview('link_extend',1)){ ?>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-btn-danger layui-hide-xs" lay-event="link_extend" id="link_extend">扩展字段</button>
|
||||
<?php }?>
|
||||
<?php if($global_config['offline'] != 1 ){ ?>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-btn-danger layui-hide-xs" lay-event="testing" id="testing">检测</button>
|
||||
<?php }?>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-btn-danger" layuimini-content-href="link_sort" data-title="链接排序">排序模式</button>
|
||||
</div>
|
||||
</script>
|
||||
@@ -73,25 +78,35 @@
|
||||
<script src = "./templates/admin/js/public.js?v=<?php echo $Ver;?>"></script>
|
||||
<?php load_static('js');?>
|
||||
<script src = "./templates/admin/js/link_list.js?v=<?php echo $Ver;?>"></script>
|
||||
<ul class="batch_category" style = "margin-top:18px;display:none;padding-right: 10px;" >
|
||||
<ul class="batch_category" style="margin-top:18px;display:none;padding-right: 10px;">
|
||||
<form class="layui-form" lay-filter="batch_category">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select id="batch_category_fid">
|
||||
<select id="batch_category_fid">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="batch_category" id="batch_category" >确定修改</button>
|
||||
<button class="layui-btn layui-btn-warm" type="button" id="close" >关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</ul>
|
||||
<ul class="link_extend" style="margin-top: 18px;display:none;padding-right: 10px;padding-left: 10px;">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn" lay-submit id="add_field">新增字段</button>
|
||||
<button class="layui-btn" lay-submit id="save_field">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" style="color: red;">数据变更需要点击保存!确定好需要的字段后请勿随意修改,以免造成数据错乱!</button>
|
||||
</div>
|
||||
<table id="link_extend_list" lay-filter="link_extend_list"></table>
|
||||
<script type="text/html" id="link_extend_toolbar">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger del" lay-event="del">移除</button>
|
||||
</div>
|
||||
</script>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,6 +16,7 @@ $user_groups = select_db('user_group',['id','code','name'],'');
|
||||
<script type="text/html" id="toolbar">
|
||||
<div class="layui-btn-group" >
|
||||
<button class="layui-btn layui-btn-sm" lay-event="generate">生成注册码</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="refresh">刷新</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set">设置</button>
|
||||
</div>
|
||||
@@ -81,7 +82,8 @@ layui.use(['table','layer','form'], function(){
|
||||
|
||||
|
||||
var cols=[[ //表头
|
||||
{field:'id',title:'id',width:80,sort:true}
|
||||
{type:'checkbox'}
|
||||
,{field:'id',title:'id',width:80,sort:true}
|
||||
,{field:'regcode',title:'注册码',width:120,sort:true}
|
||||
,{field:'UserGroupName',title:'用户组',width:120,sort:true}
|
||||
,{field:'url',title:'注册链接',minWidth:400,sort:true,templet:function(d){
|
||||
@@ -152,6 +154,25 @@ layui.use(['table','layer','form'], function(){
|
||||
content: $('.Set')
|
||||
});
|
||||
break;
|
||||
case 'del':
|
||||
if( checkStatus.data.length == 0 && ['LAYTABLE_COLS','LAYTABLE_EXPORT','LAYTABLE_PRINT'].indexOf(obj.event) == -1 ) {
|
||||
layer.msg('未选中任何数据!');
|
||||
return;
|
||||
}
|
||||
layer.confirm('确认删除?',{icon: 3, title:'温馨提示'}, function(index){
|
||||
tableIds = checkStatus.data.map(function (value) {return value.id;});
|
||||
tableIds = JSON.stringify(tableIds);
|
||||
$.post(get_api('write_regcode','del') ,{"id":tableIds},function(data,status){
|
||||
if(data.code == 1){
|
||||
table.reload('table');
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
}else{
|
||||
layer.msg(data.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
};
|
||||
});
|
||||
//自定义表单验证
|
||||
|
||||
@@ -123,6 +123,17 @@ $title='系统设置';require(dirname(__DIR__).'/header.php');
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">开启时将关闭主页/登录/注册等服务,站长账号不受影响(网站升级迁移时适用)</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">强制私有</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="Privacy">
|
||||
<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">
|
||||
<label class="layui-form-label required">二级域名</label>
|
||||
@@ -179,7 +190,16 @@ $title='系统设置';require(dirname(__DIR__).'/header.php');
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">此处关闭时即使用户组允许也无法使用!</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">链接扩展</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="link_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">
|
||||
<div class="layui-input-block"><button class="layui-btn layui-btn-normal" lay-submit lay-filter="save">确认保存</button></div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
if($USER_DB['UserGroup'] != 'root'){$content='您没有权限访问此页面'; require(DIR.'/templates/admin/page/404.php');exit;}
|
||||
$title='站长工具';
|
||||
if(function_exists("opcache_reset")){
|
||||
opcache_reset(); //清理PHP缓存
|
||||
}
|
||||
require(dirname(__DIR__).'/header.php');
|
||||
?>
|
||||
<style>
|
||||
|
||||
@@ -35,8 +35,9 @@ $user_groups = select_db('user_group',['id','code','name'],'');
|
||||
<script type="text/html" id="user_tool">
|
||||
<div class="layui-btn-group">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="Del">删除</button>
|
||||
<button class="layui-btn layui-btn-sm " lay-event="register" <?php echo $global_config['RegOption'] == 0? 'style = "display:none;"':'' ?> >注册账号</button>
|
||||
<button class="layui-btn layui-btn-sm " lay-event="set_UserGroup" >设用户组</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="register" <?php echo $global_config['RegOption'] == 0? 'style = "display:none;"':'' ?> >注册账号</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set_UserGroup">设用户组</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="username_retain">账号保留</button>
|
||||
</div>
|
||||
</script>
|
||||
<!-- 操作列 -->
|
||||
@@ -122,6 +123,17 @@ layui.use(['table','layer','form'], function () {
|
||||
if (event == 'register') {
|
||||
window.open('./index.php?c=<?php echo $global_config['Register'];?>');
|
||||
return;
|
||||
}else if(event == 'username_retain'){
|
||||
index = layer.open({type: 1,scrollbar: false,shadeClose: true,title: '账号保留',area : ['100%', '100%'],content: $('.username_retain')});
|
||||
|
||||
$.post(get_api('other_root','read_username_retain'),function(data,status){
|
||||
if(data.code == 1) {
|
||||
form.val('username_retain', {"username_retain": data.data});
|
||||
}else{
|
||||
layer.msg(data.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
@@ -206,6 +218,20 @@ layui.use(['table','layer','form'], function () {
|
||||
});
|
||||
return false;
|
||||
});
|
||||
//保存账号保留
|
||||
form.on('submit(save_username_retain)', function (data) {
|
||||
$.post(get_api('other_root','write_username_retain'),data.field,function(data,status){
|
||||
if(data.code == 1) {
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
}else{
|
||||
layer.msg(data.msg, {icon: 5});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<ul class="set_UserGroup" style = "margin-top:18px;display:none;padding-right: 10px;" >
|
||||
@@ -225,8 +251,47 @@ layui.use(['table','layer','form'], function () {
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save_UserGroup" id ='save_UserGroup'>保存</button>
|
||||
<button class="layui-btn layui-btn-warm" type="button" id="close" >关闭</button>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save_UserGroup" id ='save_UserGroup'>保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</ul>
|
||||
|
||||
<ul class="username_retain" style="margin-left: 10px;padding-right: 10px;margin-top:18px;display:none;" >
|
||||
<form class="layui-form layuimini-form layui-form-pane" lay-filter="username_retain">
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label required">账号保留 - 正则表达式匹配</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="username_retain" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<pre class="layui-code" >
|
||||
使用举例:
|
||||
/^(root|data)$/ 匹配用户等于root或data 区分大小写!
|
||||
/^(root|data)$/i 匹配用户等于root或data 不区分大小写!
|
||||
/root|data/ 匹配用户含有root或data 区分大小写!
|
||||
/root|data/i 匹配用户含有root或data 不区分大小写!
|
||||
/^admin.+/ 匹配admin开头的任意用账号,但不匹配admin
|
||||
/^admin.*/ 同上,但匹配admin本身
|
||||
支持多行,一行一条规则!
|
||||
|
||||
举例中的表达式解释:
|
||||
^ 匹配开头位置
|
||||
$ 匹配结尾位置
|
||||
| 或者
|
||||
. 匹配换行符以外的任何字符
|
||||
+ 匹配前一个字符一次或多次
|
||||
* 匹配前一个字符零次或多次
|
||||
更多语法请自行百度
|
||||
|
||||
注:错误的规则可能会造成程序异常,如需帮助请联系技术支持QQ:271152681或技术交流群695720839
|
||||
</pre>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-warm" type="button" id="close" >关闭</button>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save_username_retain" id ='save_username_retain'>保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -51,7 +51,6 @@ $HTTP_HOST = preg_replace('/:\d+$/','',$_SERVER['HTTP_HOST']); //去除端口号
|
||||
<button class="layui-btn" lay-submit lay-filter="get_subscribe">查询授权</button>
|
||||
</div>
|
||||
|
||||
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top:30px;"><legend>授权用户专享</legend></fieldset>
|
||||
<blockquote class="layui-elem-quote layui-text">
|
||||
<li>1. 可使用一键更新功能</li>
|
||||
|
||||
@@ -200,7 +200,7 @@ layui.use(['form','table','laydate','tableSelect'], function () {
|
||||
,{field:'id',title:'ID',width:60,sort:true,hide:true}
|
||||
,{title: '操作',toolbar: '#tablebar',align:'center',width:140}
|
||||
,{field:'sid',title:'标识',width:118,align:'center',templet:function(d){
|
||||
return '<a style="color:#3c78d8" href = "./index.php?share='+d.sid+'" target = "_blank" title = "点击打开">'+d.sid+'</a>';
|
||||
return '<a style="color:#3c78d8" href = "./index.php?u='+u+'&share='+d.sid+'" target = "_blank" title = "点击打开">'+d.sid+'</a>';
|
||||
}}
|
||||
,{field:'name',title:'名称',width:180}
|
||||
,{field:'pwd',title:'提取码',width:160}
|
||||
@@ -331,7 +331,7 @@ layui.use(['form','table','laydate','tableSelect'], function () {
|
||||
});
|
||||
}else if(obj.event === 'copy'){
|
||||
if(isSupported){
|
||||
ClipboardJS.copy(baseUrl + "index.php?share=" + data.sid +(data.pwd != '' ? '&pwd=' + data.pwd:''));
|
||||
ClipboardJS.copy(baseUrl + "index.php?u="+u+"&share=" + data.sid +(data.pwd != '' ? '&pwd=' + data.pwd:''));
|
||||
layer.msg('复制成功', {icon: 1});
|
||||
}else{
|
||||
layer.msg('复制失败,浏览器不支持', {icon: 5});
|
||||
@@ -339,16 +339,17 @@ layui.use(['form','table','laydate','tableSelect'], function () {
|
||||
}else if(obj.event === 'edit'){
|
||||
form.val('data', data);
|
||||
form.val('data', {'pv':data.pv == 1});
|
||||
console.log(data.data);
|
||||
data.data = ts_selected_format(data.data,/"/g);
|
||||
let ts = ts_selected_format(data.data);
|
||||
if(data.type == '1'){
|
||||
$('#category_data').val(data.data);
|
||||
$('#category_data').attr("ts-selected",data.data.replace('[', '').replace(']', ''));
|
||||
$('#category_data').attr("ts-selected",ts);
|
||||
type = 'category';
|
||||
$('#cf').show();
|
||||
$('#lf').hide();
|
||||
}else if(data.type == '2'){
|
||||
$('#link_data').val(data.data);
|
||||
$('#link_data').attr("ts-selected",data.data.replace('[', '').replace(']', ''));
|
||||
$('#link_data').attr("ts-selected",ts);
|
||||
type = 'link';
|
||||
$('#cf').hide();
|
||||
$('#lf').show();
|
||||
@@ -358,7 +359,9 @@ layui.use(['form','table','laydate','tableSelect'], function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function ts_selected_format(v,z = /"|\[|\]/g){
|
||||
return v.replace(z,'')
|
||||
}
|
||||
|
||||
//书签选择
|
||||
function load_tableSelect(searchPlaceholder,name,url,elem,limit,limits){ tableSelect.render({
|
||||
@@ -386,7 +389,7 @@ layui.use(['form','table','laydate','tableSelect'], function () {
|
||||
id.push(item.id);
|
||||
})
|
||||
elem.val(id.join(","));
|
||||
$(elem).val(JSON.stringify(id));
|
||||
$(elem).val(ts_selected_format(JSON.stringify(id),/"/g) );
|
||||
}
|
||||
})}
|
||||
load_tableSelect('分类名称搜索','分类名',get_api('read_share','categorys'),'#category_data',9999,[9999]);
|
||||
|
||||
@@ -52,6 +52,7 @@ $color = ($s_templates['home_pc'] == $key || $s_templates['home_pad'] == $key ?"
|
||||
<div class="layui-card-header" style="height: auto;" id="home">
|
||||
<div class="layui-btn-group" id="<?php echo $key;?>">
|
||||
<?php
|
||||
$theme_set = check_purview('theme_set',1);
|
||||
if($online){ //如果是在线主题则显示下载
|
||||
echo $Space.'<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" id="dw">下载</button>'."\n";
|
||||
}elseif($theme['info']['up'] == 1){ //如果有更新则同时显示下载和使用
|
||||
@@ -64,7 +65,7 @@ $color = ($s_templates['home_pc'] == $key || $s_templates['home_pad'] == $key ?"
|
||||
if(!$online){ //本地主题显示预览
|
||||
echo $Space.'<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="preview">预览</button>'."\n";
|
||||
}
|
||||
if($theme['info']['config'] == '1'){ //支持配置的主题显示配置
|
||||
if($theme['info']['config'] == '1' && $theme_set){ //支持配置的主题显示配置
|
||||
echo $Space.'<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="config">配置</button>'."\n";
|
||||
}
|
||||
if($USER_DB['UserGroup'] === 'root' && !$online){ //管理员&本地主题>显示删除
|
||||
|
||||
@@ -2,6 +2,76 @@
|
||||
<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.15-20230422</h4>
|
||||
<ul>
|
||||
<li>修复默认版权链接错误的问题</li>
|
||||
<li>修复维护模式未起作用</li>
|
||||
<li>网站管理>用户管理>新增账号保留,方便公开注册的站长保留一些账号</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<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.14-20230420</h4>
|
||||
<ul>
|
||||
<li>修复书签分享和输出上限冲突的问题</li>
|
||||
<li>[数据库更新]修复不同类型的模板目录名相同时存在窜数据的问题</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<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.13-20230418</h4>
|
||||
<ul>
|
||||
<li>修复链接模式不受控的问题(上个版本造成)</li>
|
||||
<li>网站管理/系统设置新增强制私有选项</li>
|
||||
<li>修复书签分享的链接可能无法访问</li>
|
||||
<li>修复扩展字段输入html代码可能造成页面渲染异常的问题</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<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.12-20230417</h4>
|
||||
<ul>
|
||||
<li>优化书签分享的兼容性</li>
|
||||
<li>新增链接自定义扩展信息(用于自定义过渡页模板)</li>
|
||||
<li>[数据库更新] 调整MySQL字符集编码(utf8改为utf8mb4,使其兼容Emoji字符)</li>
|
||||
<li>[数据库更新] 用户组权限列表新增3个选项</li>
|
||||
<li>调整用户无权限配置站点信息时隐藏入口</li>
|
||||
<li>修复已知问题</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<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.11-20230414</h4>
|
||||
<ul>
|
||||
<li>修复热门网址/最新网址的一些问题</li>
|
||||
<li>新增Atool工具 (应急工具),用于强行修改密码/配置等 <a href="https://gitee.com/tznb/TwoNav/wikis/pages?sort_id=7993451&doc_id=3767990" target="_blank">使用说明</a></li>
|
||||
<li>调整安装脚本session_name避免特定环境冲突</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<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.10-20230413</h4>
|
||||
<ul>
|
||||
<li>支持删除注册管理生成的注册码</li>
|
||||
<li>站点设置增加设为默认用户按钮(储存在浏览器Cookie,不影响其他用户)</li>
|
||||
<li>站点设置增加热门链接/最新链接/输出上限</li>
|
||||
<li>主页支持传参来浏览指定分类(配合站点设置>输出上限使用)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="layui-timeline-item">
|
||||
<i class="layui-icon layui-timeline-axis"></i>
|
||||
<div class="layui-timeline-content layui-text">
|
||||
|
||||
Reference in New Issue
Block a user