mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
v2.0.14-20230420
This commit is contained in:
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']);
|
||||
@@ -42,7 +42,8 @@ CREATE TABLE IF NOT EXISTS `updatadb_logs` (
|
||||
UNIQUE KEY `file_name` (`file_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO "updatadb_logs" ("id", "file_name", "update_time", "status", "extra") VALUES ('1', '20230417.php', '1681719049', 'TRUE', '');
|
||||
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`;
|
||||
|
||||
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,7 +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" ("id", "file_name", "update_time", "status", "extra") VALUES ('1', '20230417.php', '1681719049', 'TRUE', '');
|
||||
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" (
|
||||
|
||||
@@ -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,7 +168,6 @@ if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit'
|
||||
define('referrer',$data['referrer']);
|
||||
}
|
||||
}
|
||||
//var_dump($themes);exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +206,6 @@ if ($page == 'menu') {
|
||||
array_push($menu,$extend);
|
||||
}
|
||||
|
||||
|
||||
//如果是管理员则追加菜单
|
||||
if($USER_DB['UserGroup'] == 'root'){
|
||||
array_push($menu,
|
||||
@@ -251,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']));
|
||||
@@ -271,7 +245,6 @@ if(!empty($page)){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//加载静态库
|
||||
function load_static($type){
|
||||
if($type == 'css'){
|
||||
|
||||
@@ -1231,10 +1231,22 @@ function write_theme(){
|
||||
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);
|
||||
|
||||
@@ -113,7 +113,7 @@ update_db("user_links", ["click[+]"=>1],['uid'=>UID,'lid'=>$id]);
|
||||
|
||||
|
||||
//读取用户主题配置
|
||||
$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);
|
||||
|
||||
@@ -43,7 +43,7 @@ $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);
|
||||
@@ -132,10 +132,11 @@ function get_links($fid) {
|
||||
$where['LIMIT'] = $site['new_link'];
|
||||
}
|
||||
$where['ORDER']['lid'] = 'DESC';
|
||||
//输出上限&不在子页面&例外主题
|
||||
}elseif($site['max_link'] > 0 && empty(Get('oc')) && !$site['ex_theme']){
|
||||
//输出上限&不在子页面&例外主题&书签分享
|
||||
}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);
|
||||
foreach ($links as $key => $link) {
|
||||
@@ -172,7 +173,7 @@ function get_links($fid) {
|
||||
//获取图标链接
|
||||
$links[$key]['ico'] = $lock ? $GLOBALS['libs'].'/Other/lock.svg' : geticourl($site['link_icon'],$link);
|
||||
}
|
||||
if($site['max_link'] > 0 && $count > $site['max_link'] && empty(Get('oc')) && !$site['ex_theme']){
|
||||
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']);
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.0.13-20230418
|
||||
v2.0.14-20230420
|
||||
@@ -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>
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
<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.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">
|
||||
|
||||
Reference in New Issue
Block a user