From 5b6925aafaa0cfcdf1eec6bf0fdf0f51a706f600 Mon Sep 17 00:00:00 2001
From: "MI15\\Win" <10359480+tznb@user.noreply.gitee.com>
Date: Tue, 25 Apr 2023 17:14:13 +0800
Subject: [PATCH] v2.0.16-20230425
---
index.php | 2 +-
system/UseFew/export_data.php | 12 +-
system/admin.php | 10 +-
system/api.php | 12 +-
system/api_root.php | 1 +
system/index.php | 25 +-
system/login.php | 4 +
system/version.txt | 2 +-
templates/admin/js/home-root.js | 4 +-
.../js/lay-module/tableSelect/tableSelect.js | 2 +-
templates/admin/js/link.js | 2 +-
templates/admin/js/link_list.js | 2 +-
templates/admin/js/link_sort.js | 2 +-
templates/admin/page/LoginDevice.php | 2 +-
templates/admin/page/SiteSetting.php | 6 +-
templates/admin/page/data_control.php | 2 +-
templates/admin/page/expand/apply-admin.php | 2 +-
templates/admin/page/home.php | 2 +
templates/admin/page/pwd_group.php | 2 +-
templates/admin/page/root/import_data.php | 4 +-
templates/admin/page/root/reg_control.php | 2 +-
templates/admin/page/root/sys_log.php | 2 +-
templates/admin/page/root/sys_setting.php | 14 +-
templates/admin/page/root/user_control.php | 2 +-
templates/admin/page/share.php | 2 +-
templates/admin/page/theme_guide.php | 84 ++++
templates/admin/page/theme_home.php | 2 +-
templates/admin/page/updatelog.php | 18 +
templates/guide/default/config.php | 78 ++++
templates/guide/default/index.php | 39 ++
templates/guide/default/info.json | 13 +
templates/guide/default/main.css | 419 ++++++++++++++++++
templates/guide/default/screenshot.jpg | Bin 0 -> 38909 bytes
templates/login/default/index.php | 4 +-
templates/transit/default/index.php | 77 ++--
35 files changed, 781 insertions(+), 75 deletions(-)
create mode 100644 templates/admin/page/theme_guide.php
create mode 100644 templates/guide/default/config.php
create mode 100644 templates/guide/default/index.php
create mode 100644 templates/guide/default/info.json
create mode 100644 templates/guide/default/main.css
create mode 100644 templates/guide/default/screenshot.jpg
diff --git a/index.php b/index.php
index 46ccddd..9a69120 100644
--- a/index.php
+++ b/index.php
@@ -38,7 +38,7 @@ define('libs',$global_config['Libs']);
define('SysVer',Get_Version());
define('Debug',$global_config['Debug'] == 1);
-if($c !== $global_config["Register"]){
+if($c != $global_config["Register"]){
$u = Get('u');
if(empty($u) && $global_config['Sub_domain'] == 1 && is_subscribe('bool')){
$cut = explode('.',$_SERVER["HTTP_HOST"]);
diff --git a/system/UseFew/export_data.php b/system/UseFew/export_data.php
index deb4f2a..c9f4b89 100644
--- a/system/UseFew/export_data.php
+++ b/system/UseFew/export_data.php
@@ -21,8 +21,8 @@ if($_GET['type'] == 'create' ){
msg(-1,'导出失败');
}
}
- $_SESSION['download'][$key] = $tempnam;
- msgA(['code'=>1,'msg'=>'success','key'=>$key,'name'=>$tempnam]);
+ $_SESSION['download']["$key"] = $tempnam;
+ msgA(['code'=>1,'msg'=>'success','key'=>$key]);
}else{
msg(-1,'密码错误');
}
@@ -30,7 +30,7 @@ if($_GET['type'] == 'create' ){
//验证Key
if(!is_file($_SESSION['download'][$_GET['key']])){
- exit("Key错误,请在后台重新导出!");
+ exit("Key错误,请在后台重新导出!".$_SESSION['download']["{$_GET['key']}"]);
}else{
if($_GET['type'] == 'html' ){
header("Cache-Control: public");
@@ -59,7 +59,8 @@ if(!is_file($_SESSION['download'][$_GET['key']])){
//生成数据
function create_data(){
if($_POST['type'] == 'html' ){
- $tempnam = tempnam(null,'export_html_');
+ $key = md5(uniqid().Get_Rand_Str(8));
+ $tempnam = DIR ."/data/temp/export_html_{$key}.html";
$file = fopen($tempnam, "w") or msg(-1,'载入临时文件失败');
fwrite($file,base64_decode("PCFET0NUWVBFIE5FVFNDQVBFLUJvb2ttYXJrLWZpbGUtMT4NCjwhLS0gVGhpcyBpcyBhbiBhdXRvbWF0aWNhbGx5IGdlbmVyYXRlZCBmaWxlLg0KICAgICBJdCB3aWxsIGJlIHJlYWQgYW5kIG92ZXJ3cml0dGVuLg0KICAgICBETyBOT1QgRURJVCEgLS0+DQo8TUVUQSBIVFRQLUVRVUlWPSJDb250ZW50LVR5cGUiIENPTlRFTlQ9InRleHQvaHRtbDsgY2hhcnNldD1VVEYtOCI+DQo8VElUTEU+T25lTmF2IEV4dGVuZCBCb29rbWFya3M8L1RJVExFPg0KPEgxPk9uZU5hdiBFeHRlbmQgQm9va21hcmtzPC9IMT4NCjxETD48cD4NCg=="));
fwrite($file,'
书签栏
'."\n");
@@ -94,7 +95,8 @@ function create_data(){
}
if($_POST['type'] == 'db3'){
- $tempnam = tempnam(null,'export_db3_');
+ $key = md5(uniqid().Get_Rand_Str(8));
+ $tempnam = DIR ."/data/temp/export_db3_{$key}.db3";
try { //初始化数据库
class MyDB extends SQLite3 {function __construct() {} }
$MyDB = new MyDB();
diff --git a/system/admin.php b/system/admin.php
index 655bb2c..c02e073 100644
--- a/system/admin.php
+++ b/system/admin.php
@@ -68,7 +68,7 @@ if($page == 'config_home'){
$theme_config = empty($theme_config['config']) ? []:$theme_config['config'];
//读取用户主题配置
- if(!in_array($_GET['fn'],['home','login','register','transit'])){
+ if(!in_array($_GET['fn'],['home','login','register','transit','guide'])){
msg(-1,"参数错误");
}
$theme_config_db = get_db('user_config','v',['t'=>'theme_'.$_GET['fn'],'k'=>$theme,'uid'=>UID]);
@@ -79,7 +79,7 @@ if($page == 'config_home'){
$theme_config = array_merge ($theme_config,$theme_config_db);
}
//配置为空
- if(empty($theme_config)){
+ if(empty($theme_config) || !check_purview('theme_in',1) || !check_purview('theme_set',1)){
exit("获取主题配置失败
");
}
require $config_path;
@@ -87,7 +87,11 @@ if($page == 'config_home'){
}
//主题设置页面
-if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit' || $page == 'theme_register') {
+if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit' || $page == 'theme_register' || $page == 'theme_guide') {
+ if(!check_purview('theme_in',1)){
+ require(DIR.'/templates/admin/page/404.php');
+ exit;
+ }
$fn = str_replace('theme_','',$page);
$dirs = get_dir_list(DIR.'/templates/'.$fn);
diff --git a/system/api.php b/system/api.php
index bb3bc69..6d91139 100644
--- a/system/api.php
+++ b/system/api.php
@@ -1104,7 +1104,7 @@ function other_testing_link(){
//主题下载/更新/删除
function write_theme(){
global $global_config;
- $fn = $_POST['fn'];if($_GET['type'] != 'config' && !in_array($fn,['home','login','transit','register'])){msg(-1,'fn参数错误');}
+ $fn = $_POST['fn'];if($_GET['type'] != 'config' && !in_array($fn,['home','login','transit','register','guide'])){msg(-1,'fn参数错误');}
if($_GET['type'] == 'download'){
is_root();
if($global_config['offline']){msg(-1,"离线模式禁止下载主题!");} //离线模式
@@ -1191,13 +1191,16 @@ function write_theme(){
$type = $_POST['type'];
$name = $_POST['name'];
//如果是注册模板则必须是root权限
- if($fn == 'register'){is_root();}
+ if($fn == 'register' || $fn == 'guide'){is_root();}
//相关检测
if ( !preg_match("/^[a-zA-Z0-9_-]{1,64}$/",$name) ) {
msg(-1,"主题名称不合法!");
}elseif(!is_dir(DIR."/templates/$fn/".$name)){
msg(-1,'主题不存在');
+ }elseif(!check_purview('theme_in',1)){
+ msg(-1,'无权限');
}
+
//读取用户模板配置
require DIR."/system/templates.php";
//判断设置的类型
@@ -1219,6 +1222,9 @@ function write_theme(){
}elseif($fn == 'register'){
$global_templates['register'] = $name;
update_db('global_config',['v'=>$global_templates],['k'=>'s_templates'],[1,'注册模板设置成功']);
+ }elseif($fn == 'guide'){
+ $global_templates['guide'] = $name;
+ update_db('global_config',['v'=>$global_templates],['k'=>'s_templates'],[1,'引导页模板设置成功']);
}
//更新数据
update_db('user_config',['v'=>$s_templates],['uid'=>UID,'k'=>'s_templates'],[1,'设置成功']);
@@ -1237,7 +1243,7 @@ function write_theme(){
msg(-1,"获取模板类型错误");
}
$fn = empty($GET['fn']) ? $_GET['template_type'] : $GET['fn'];
- if(!in_array($fn,['home','login','register','transit'])){
+ if(!in_array($fn,['home','login','register','transit','guide'])){
msg(-1,"参数错误");
}
//0420 END
diff --git a/system/api_root.php b/system/api_root.php
index 5b4cd9b..03263cb 100644
--- a/system/api_root.php
+++ b/system/api_root.php
@@ -500,6 +500,7 @@ function write_sys_settings(){
'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'=>'强制私有参数错误'],
+ 'default_page'=>['int'=>true,'min'=>0,'max'=>2,'msg'=>'默认页面参数错误'],
'copyright'=>['empty'=>true],
'global_header'=>['empty'=>true],
'global_footer'=>['empty'=>true],
diff --git a/system/index.php b/system/index.php
index 96d107b..86c7d67 100644
--- a/system/index.php
+++ b/system/index.php
@@ -5,7 +5,7 @@ define('is_login',is_login());
//判断用户组,是否允许未登录时访问主页
if(!is_login && ($global_config['Privacy'] == 1 || !check_purview('Common_home',1))){
header("HTTP/1.1 302 Moved Permanently");
- header("Location: ./?c=admin");
+ header("Location: ./?c=admin&u=".U);
exit;
}
//载入站点设置
@@ -15,11 +15,32 @@ $site['Title'] = $site['title'].(empty($site['subtitle'])?'':' - '.$site['subt
$copyright = empty($global_config['copyright'])?'Copyright © TwoNav':$global_config['copyright'];
$ICP = empty($global_config['ICP'])?'':''.$global_config['ICP'].'';
$favicon = ( !empty($site['site_icon_file'])) ? $site['site_icon'] : './favicon.ico';
+
//读取默认模板信息
require DIR ."/system/templates.php";
+//引导页
+if(!empty($global_config['default_page']) && $global_config['default_page'] == 2){
+ if(empty(Get('u')) && empty($_COOKIE['Default_User'])){
+ $theme = $global_templates['guide'];
+ $dir_path = DIR.'/templates/guide/'.$global_templates['guide'];
+ $index_path = $dir_path.'/index.php';
+ if(!is_file($index_path)){
+ $dir_path= DIR.'/templates/guide/default';
+ $index_path = $dir_path.'/index.php';
+ }
+ $theme_dir = str_replace(DIR.'/templates/guide',"./templates/guide",$dir_path);
+ $theme_info = json_decode(@file_get_contents($dir_path.'/info.json'),true);
+ $theme_config = empty($theme_info['config']) ? []:$theme_info['config'];
+ $theme_config_db = get_db('user_config','v',['t'=>'theme_guide','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);
+ require($index_path);
+ exit;
+ }
+}
//参数指定主题优先
$theme = trim(@$_GET['theme']);
-if ( !empty ($theme) ){
+if ( !empty ($theme) && check_purview('theme_in',1)){
$dir_path = DIR.'/templates/home/'.$theme;
$index_path = $dir_path.'/index.php';
}else{
diff --git a/system/login.php b/system/login.php
index 8762e77..4670fcd 100644
--- a/system/login.php
+++ b/system/login.php
@@ -48,6 +48,10 @@ if(Get_MD5_Password($Password,$USER_DB["RegTime"]) === $USER_DB["Password"]){
}else{
$url = preg_match('/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i',$_SERVER['HTTP_USER_AGENT']) ? "./?c=index&u={$USER_DB['User']}" : "./?c=admin&u={$USER_DB['User']}";
}
+ //默认页面
+ if(!empty($global_config['default_page'])){
+ setcookie('Default_User', $User, strtotime("+360 day"),"/",'',false,false);
+ }
msgA(['code'=>1,'msg'=>'登录成功','url'=>$url]);
}else{
update_db("user_log", ["description" => "请求登录>账户或密码错误"], ["id"=>$log_id]);
diff --git a/system/version.txt b/system/version.txt
index c1c6da4..e9ae985 100644
--- a/system/version.txt
+++ b/system/version.txt
@@ -1 +1 @@
-v2.0.15-20230422
\ No newline at end of file
+v2.0.16-20230425
\ No newline at end of file
diff --git a/templates/admin/js/home-root.js b/templates/admin/js/home-root.js
index 765758d..54f23e2 100644
--- a/templates/admin/js/home-root.js
+++ b/templates/admin/js/home-root.js
@@ -48,7 +48,7 @@ layui.use(['layer','miniTab'], function(){
//如果失败
if(up_info.code != 1){
layer.closeAll();
- layer.alert(up_info.msg ?? "错误代码:404",{icon:2,title:'更新失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
+ layer.alert(up_info.msg || "错误代码:404",{icon:2,title:'更新失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
return;
}
//设为异步模式
@@ -70,7 +70,7 @@ layui.use(['layer','miniTab'], function(){
request_update();
}else{
layer.closeAll();
- layer.alert(data.msg ?? "未知错误,请联系开发者!",{icon:5,title:up_info.info[i-1],anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
+ layer.alert(data.msg || "未知错误,请联系开发者!",{icon:5,title:up_info.info[i-1],anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
}
});
}
diff --git a/templates/admin/js/lay-module/tableSelect/tableSelect.js b/templates/admin/js/lay-module/tableSelect/tableSelect.js
index 53dc2d0..3e3a1ed 100644
--- a/templates/admin/js/lay-module/tableSelect/tableSelect.js
+++ b/templates/admin/js/lay-module/tableSelect/tableSelect.js
@@ -47,7 +47,7 @@ layui.define(['table', 'jquery', 'form'], function (exports) {
//判断是否多搜索条件
if(opt.searchType == 'more'){
$.each(opt.searchList, function (index, item) {
- tableBox += '';
+ tableBox += '';
});
}else{
tableBox += '';
diff --git a/templates/admin/js/link.js b/templates/admin/js/link.js
index d182d52..7e42b2d 100644
--- a/templates/admin/js/link.js
+++ b/templates/admin/js/link.js
@@ -79,7 +79,7 @@ layui.use(['form','upload','miniTab'], function () {
form_data.icon = res.icon;
$("#icon").val(res.icon);
}else{
- layer.msg(res.msg ?? '上传失败', {icon: 5});
+ layer.msg(res.msg || '上传失败', {icon: 5});
}
},error: function(){
diff --git a/templates/admin/js/link_list.js b/templates/admin/js/link_list.js
index e4b0314..9c285d3 100644
--- a/templates/admin/js/link_list.js
+++ b/templates/admin/js/link_list.js
@@ -7,7 +7,7 @@ layui.use(['form','table','dropdown','miniTab'], function () {
var categorys = [];
var IDs = [];
var api = get_api('read_link_list'); //列表接口
- var limit = localStorage.getItem(u + "_limit")??50; //尝试读取本地记忆数据,没有就默认50
+ var limit = localStorage.getItem(u + "_limit") || 50; //尝试读取本地记忆数据,没有就默认50
var pwds = [];
miniTab.listen();
//渲染表格
diff --git a/templates/admin/js/link_sort.js b/templates/admin/js/link_sort.js
index cbf629f..73a2ad6 100644
--- a/templates/admin/js/link_sort.js
+++ b/templates/admin/js/link_sort.js
@@ -3,7 +3,7 @@ layui.use(['form','table'], function () {
var table = layui.table;
var data_tr,table_page;
var api = get_api('read_link_list'); //列表接口
- var limit = localStorage.getItem(u + "_limit")??50; //尝试读取本地记忆数据,没有就默认50
+ var limit = localStorage.getItem(u + "_limit") || 50; //尝试读取本地记忆数据,没有就默认50
var cols=[[ //表头
{type:'radio'} //开启单选框
diff --git a/templates/admin/page/LoginDevice.php b/templates/admin/page/LoginDevice.php
index ac47c30..b32a57c 100644
--- a/templates/admin/page/LoginDevice.php
+++ b/templates/admin/page/LoginDevice.php
@@ -18,7 +18,7 @@ layui.use(['form','table'], function () {
var table = layui.table;
var form = layui.form;
var api = get_api('read_login_info'); //列表接口
- var limit = localStorage.getItem(u + "_limit")??50; //尝试读取本地记忆数据,没有就默认50
+ var limit = localStorage.getItem(u + "_limit") || 50; //尝试读取本地记忆数据,没有就默认50
var cols=[[ //表头
{field: 'id', title: 'ID', width:60, sort: true,hide:true}
diff --git a/templates/admin/page/SiteSetting.php b/templates/admin/page/SiteSetting.php
index 84dbd94..b346c28 100644
--- a/templates/admin/page/SiteSetting.php
+++ b/templates/admin/page/SiteSetting.php
@@ -134,9 +134,9 @@
-
+
-
+
@@ -184,7 +184,7 @@ layui.use(['jquery','form','upload'], function () {
$.removeCookie("Default_User");
$("#sdhp").text('设为默认主页')
}else{
- $.cookie("Default_User",u);
+ $.cookie("Default_User",u,{expires: 360});
$("#sdhp").text('取消默认主页')
}
layer.msg("设置成功", {icon: 1});
diff --git a/templates/admin/page/data_control.php b/templates/admin/page/data_control.php
index 41e170b..eb68f2d 100644
--- a/templates/admin/page/data_control.php
+++ b/templates/admin/page/data_control.php
@@ -303,7 +303,7 @@ layui.use(['layer','element','upload','form','table'], function(){
if(res.code == 1){
$("#imp_link button").removeClass("layui-btn-disabled");
}else{
- layer.alert(res.msg ?? "上传异常,请刷新重试
若无法解决请联系技术支持",{icon:5,title:'上传失败',anim: 2,closeBtn: 0,btn: ['刷新页面']},function () {location.reload();});
+ layer.alert(res.msg || "上传异常,请刷新重试
若无法解决请联系技术支持",{icon:5,title:'上传失败',anim: 2,closeBtn: 0,btn: ['刷新页面']},function () {location.reload();});
}
},error: function(){
layer.alert("上传异常,请刷新重试
若无法解决请联系技术支持",{icon:5,title:'错误',anim: 2,closeBtn: 0,btn: ['刷新页面']},function () {location.reload();});
diff --git a/templates/admin/page/expand/apply-admin.php b/templates/admin/page/expand/apply-admin.php
index e68ad1f..0d73e77 100644
--- a/templates/admin/page/expand/apply-admin.php
+++ b/templates/admin/page/expand/apply-admin.php
@@ -179,7 +179,7 @@ layui.use(['element','table','layer','form','util','dropdown'], function(){
var form = layui.form;
var dropdown = layui.dropdown;
var layer = layui.layer;
- var limit = localStorage.getItem(u + "_limit")??50;
+ var limit = localStorage.getItem(u + "_limit") || 50;
form.val('conf', );
//表头
diff --git a/templates/admin/page/home.php b/templates/admin/page/home.php
index 4c55470..de2522f 100644
--- a/templates/admin/page/home.php
+++ b/templates/admin/page/home.php
@@ -171,12 +171,14 @@ require 'header.php';
站点设置
+
+
diff --git a/templates/admin/page/pwd_group.php b/templates/admin/page/pwd_group.php
index abcc764..9e565ba 100644
--- a/templates/admin/page/pwd_group.php
+++ b/templates/admin/page/pwd_group.php
@@ -29,7 +29,7 @@ layui.use(['form','table'], function () {
var table = layui.table;
var form = layui.form;
var api = get_api('read_pwd_group_list'); //列表接口
- var limit = localStorage.getItem(u + "_limit")??50;
+ var limit = localStorage.getItem(u + "_limit") || 50;
var load_list = function () {
table.render({
diff --git a/templates/admin/page/root/import_data.php b/templates/admin/page/root/import_data.php
index 75795c9..5c8c8ab 100644
--- a/templates/admin/page/root/import_data.php
+++ b/templates/admin/page/root/import_data.php
@@ -94,7 +94,7 @@ layui.use(['layer','form','miniTab'], function () {
layer.msg('导入完毕', {icon: 1});
}else{
layer.closeAll();
- layer.alert(data.msg ?? "未知错误,请联系开发者!",{icon:5,title:'导入失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
+ layer.alert(data.msg || "未知错误,请联系开发者!",{icon:5,title:'导入失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
}
});
return;
@@ -110,7 +110,7 @@ layui.use(['layer','form','miniTab'], function () {
request_import();
}else{
layer.closeAll();
- layer.alert(data.msg ?? "未知错误,请联系开发者!",{icon:5,title:'导入失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
+ layer.alert(data.msg || "未知错误,请联系开发者!",{icon:5,title:'导入失败',anim: 2,shadeClose: false,closeBtn: 0,btn: ['知道了']});
}
});
}
diff --git a/templates/admin/page/root/reg_control.php b/templates/admin/page/root/reg_control.php
index 463d364..44769d7 100644
--- a/templates/admin/page/root/reg_control.php
+++ b/templates/admin/page/root/reg_control.php
@@ -78,7 +78,7 @@ layui.use(['table','layer','form'], function(){
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
- var limit = localStorage.getItem(u + "_limit")??50;
+ var limit = localStorage.getItem(u + "_limit") || 50;
var cols=[[ //表头
diff --git a/templates/admin/page/root/sys_log.php b/templates/admin/page/root/sys_log.php
index 23a992e..5163da0 100644
--- a/templates/admin/page/root/sys_log.php
+++ b/templates/admin/page/root/sys_log.php
@@ -49,7 +49,7 @@ layui.use(['table','layer','form'], function () {
var form = layui.form;
var table = layui.table;
var layer = layui.layer;
- var limit = localStorage.getItem(u + "_limit")??50;
+ var limit = localStorage.getItem(u + "_limit") || 50;
var api = get_api('read_log');
var IDs = [];
diff --git a/templates/admin/page/root/sys_setting.php b/templates/admin/page/root/sys_setting.php
index 06ba2ed..4a3f4a4 100644
--- a/templates/admin/page/root/sys_setting.php
+++ b/templates/admin/page/root/sys_setting.php
@@ -16,7 +16,19 @@ $title='系统设置';require(dirname(__DIR__).'/header.php');
默认主页的账号,优先级:Get>Cookie/Host>默认用户>admin
-
+
+
+