v2.0.39-20230913

This commit is contained in:
MI15\Win
2023-09-13 13:41:29 +08:00
parent 98cf84b16c
commit cdeea3ff36
30 changed files with 144 additions and 71 deletions

View File

@@ -226,7 +226,7 @@ function echo_Atool(){
<head>
<meta charset="UTF-8">
<title>ATool 工具箱</title>
<link rel="stylesheet" href="../static/Layui/v2.8.10/css/layui.css">
<link rel="stylesheet" href="../static/Layui/v2.8.17/css/layui.css">
<style>
html, body {min-width: 1200px;background-color: #fff;position: relative;}
.page-wrapper {width: 1200px;margin: 0 auto;padding: 0 15px;}
@@ -278,7 +278,7 @@ function echo_Atool(){
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del_otp" title="移除OTP登录验证">删OTP</a>
</div>
</script>
<script src="../static/Layui/v2.8.10/layui.js"></script>
<script src="../static/Layui/v2.8.17/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>
@@ -415,7 +415,7 @@ function echo_verify(){ ?>
<head>
<meta charset="UTF-8">
<title>ATool 工具箱</title>
<link rel="stylesheet" href="../static/Layui/v2.8.10/css/layui.css">
<link rel="stylesheet" href="../static/Layui/v2.8.17/css/layui.css">
<link rel="stylesheet" href="../static/Other/login.css">
</head>
<body>
@@ -440,7 +440,7 @@ function echo_verify(){ ?>
</div>
</div>
<script src = "../static/jquery/jquery-3.6.0.min.js"></script>
<script src = "../static/Layui/v2.8.10/layui.js"></script>
<script src = "../static/Layui/v2.8.17/layui.js"></script>
<script src = '../static/jquery/jquery.md5.js'></script>
<script>
layui.use(['form','jquery'], function () {

View File

@@ -68,7 +68,12 @@ if($page == 'config_home'){
if(!in_array($_GET['fn'],['home','login','register','transit','guide','article','verify','guestbook','apply'])){
msg(-1,"参数错误");
}
$theme_config_db = get_db('user_config','v',['t'=>'theme_'.$_GET['fn'],'k'=>$theme,'uid'=>UID]);
if(in_array($_GET['fn'],['guide','register'])){
$theme_config_db = get_db('user_config','v',['k'=>'theme_'.$theme,'uid'=>UID]);
}else{
$theme_config_db = get_db('user_config','v',['t'=>'theme_'.$_GET['fn'],'k'=>$theme,'uid'=>UID]);
}
$theme_config_db = unserialize($theme_config_db);
//如果不为空则合并数据

View File

@@ -1641,7 +1641,11 @@ function write_theme(){
msg(-1,"参数错误");
}
//0420 END
write_user_config($_GET['t'],$_POST,'theme_' . $fn,'主题配置');
if(in_array($fn,['guide','register'])){
write_global_config("theme_{$fn}_{$_GET['t']}",$_POST,'主题配置');
}else{
write_user_config($_GET['t'],$_POST,'theme_' . $fn,'主题配置');
}
msg(1,"保存成功!");
}
}

View File

@@ -520,9 +520,9 @@ function write_sys_settings(){
if($_POST['Login'] == $_POST['Register']){
msg(-1,'注册入口名不能和登录入口名相同');
}elseif(!preg_match("/^[a-zA-Z0-9]+$/",$_POST['Register'])){
msg(-1,'注册入口错误,仅允许使用字母和数字');
msg(-1,'注册入口错误,仅允许使用字母和数字');
}elseif(!preg_match("/^[a-zA-Z0-9]+$/",$_POST['Login'])){
msg(-1,'登陆入口错误,仅允许使用字母和数字');
msg(-1,'登陆入口错误,仅允许使用字母和数字');
}elseif(empty($_POST['Default_User']) || !get_db("global_user", "User", [ "User"=>$_POST['Default_User'] ]) ){
msg(-1,'默认账号不存在');
}elseif(!empty($_POST['default_UserGroup']) && empty(get_db('user_group','code',['code' => $_POST['default_UserGroup']]))){
@@ -539,6 +539,14 @@ function write_sys_settings(){
}
}
//自定义登录入口和注册入口检测
$prohibits = ['admin','click','api','ico','icon','verify','apply','guestbook','article','sitemap'];
if(in_array($_POST['Login'],$prohibits)){
msg(-1,'此登录入口名已被系统使用');
}
if(in_array($_POST['Register'],$prohibits)){
msg(-1,'此注册入口名已被系统使用');
}
//长度限制
foreach (['c_name','c_desc','l_name','l_url','l_key','l_desc'] as $name){
$length_limit[$name] = is_subscribe('bool') ? intval($_POST[$name]) : 0;
@@ -567,6 +575,7 @@ function write_sys_settings(){
'global_footer'=>['empty'=>true],
'api_extend'=>['empty'=>true],
'c_code'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'自定义代码参数错误'],
'static_link'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'静态链接参数错误'],
//更新设置
'Update_Source'=>['empty'=>true],
'Update_Overtime'=>['int'=>true,'min'=>3,'max'=>60,'msg'=>'资源超时参数错误'],
@@ -596,6 +605,7 @@ function write_sys_settings(){
if($_POST['guestbook'] == 1){$o_config['guestbook'] = 0;$filter = true;}
if($_POST['link_extend'] == 1){$o_config['link_extend'] = 0;$filter = true;}
if($_POST['article'] == 1){$o_config['article'] = 0;$filter = true;}
if($_POST['static_link'] == 1){$o_config['static_link'] = 0;$filter = true;}
}
//检测于下载文章管理依赖资源
clearstatcache();

View File

@@ -37,7 +37,7 @@ function create_sitemap($sitemap_config,$sitemap_path,$u){
$today = date("Y-m-d\TH:i:s", time());
//域名
$host = $_SERVER['HTTP_HOST']; // 获取主机名
$port = isset($_SERVER['SERVER_PORT']) ? ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) : ''; // 获取端口号
$port = isset($_SERVER['SERVER_PORT']) ? ($_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT']) : ''; // 获取端口号
$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; // 获取协议
$host = $scheme.$host.$port;
//用户主页 0.关闭 1.动态地址 2.静态地址 3.二级域名
@@ -106,6 +106,20 @@ function create_sitemap($sitemap_config,$sitemap_path,$u){
}
}
}
//文章页面
if($sitemap_config['article_page'] > 0){
$article_list = select_db('user_article_list',['id','up_time'],['state'=>1,'uid'=>UID]);
foreach ($article_list as $data) {
if($sitemap_config['article_page'] == '2'){
$locurl = "{$host}/{$u}/article/{$data['id']}.html";
}else{
$locurl = "{$host}/index.php?c=article&id={$data['id']}&u={$u}";
}
$url = createUrlElement($xml, $locurl, date("Y-m-d\TH:i:s", $data['up_time']), $sitemap_config['article_page_changefreq'], $sitemap_config['article_page_weight']);
$urlset->appendChild($url);
}
}
//保存 XML 内容到文件
$xml->save($sitemap_path);

View File

@@ -174,7 +174,12 @@ function get_links($fid) {
}
if($click || $site['link_model'] != 'direct'){
$links[$key]['url'] = "./index.php?c=click&id={$link['id']}&u=".U;
if($GLOBALS['global_config']['static_link'] == 1){
$links[$key]['url'] = "/{$u}/click/{$link['id']}.html";
}else{
$links[$key]['url'] = "./index.php?c=click&id={$link['id']}&u=".U;
}
if($lock){
$links[$key]['real_url'] = $links[$key]['url']; //篡改真实URL,防止泄密
if(isset($share['sid'])){
@@ -202,7 +207,11 @@ function get_links($fid) {
if( intval($site['article_visual'] ?? '1') > 0 && $GLOBALS['theme_info']['support']['article'] != 'notdisplay'){
$articles = get_article_list($fid);
foreach ($articles['data'] as $article) {
$url = "./index.php?c=article&id={$article['id']}&u={$u}";
if($GLOBALS['global_config']['static_link'] == 1){
$url = "/{$u}/article/{$article['id']}.html";
}else{
$url = "./index.php?c=article&id={$article['id']}&u={$u}";
}
if($site['article_icon'] == '1'){ //站点图标
$icon = $GLOBALS['favicon'];
}elseif($site['article_icon'] == '2' && !empty($article['cover'])){ //封面

View File

@@ -4,8 +4,8 @@ if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Fou
//初始化
session_name('TwoNav_initial');
session_start();
$layui['js'] = './static/Layui/v2.8.10/layui.js';
$layui['css'] = './static/Layui/v2.8.10/css/layui.css';
$layui['js'] = './static/Layui/v2.8.17/layui.js';
$layui['css'] = './static/Layui/v2.8.17/css/layui.css';
//判断请求类型
if($_SERVER['REQUEST_METHOD'] === 'POST'){

View File

@@ -3,7 +3,7 @@
//读取全局模板配置
$global_templates = unserialize(get_db("global_config",'v', ["k" => "s_templates"]));
if(defined('UID')){
if(defined('UID') && $c != 'guide'){
//读取用户模板配置
$s_templates = unserialize(get_db("user_config", "v", ["uid"=>UID,"k"=>"s_templates"]));
//没找到用户模板配置
@@ -65,11 +65,12 @@ if($c == 'index'){
}elseif($c == 'guide'){ //引导页,由主页修改$c
$theme = $global_templates['guide'];
$dir_path = DIR.'/templates/guide';
$s_site = unserialize( get_db("global_config", "v", ["k" => "s_site"]));//读入默认站点配置
}
//模板类型(用于读取配置)
$templates_type = substr($dir_path, strrpos($dir_path, "/") + 1) ;
$config_type = in_array($templates_type,['guide','register']) ? 'global' : 'user';
//无权限或不存在使用默认
if( !check_purview('theme_in',1) || !is_file("{$dir_path}/{$theme}/index.php")){
$theme = 'default';
@@ -87,23 +88,20 @@ $theme_info = json_decode(@file_get_contents($dir_path.'/info.json'),true);
//主题配置(默认)
$theme_config = empty($theme_info['config']) ? []:$theme_info['config'];
if(defined('UID')){
//主题配置(用户)
//读取主题配置
if(defined('UID') && !in_array($templates_type,['guide','register'])){
$theme_config_db = get_db('user_config','v',['t'=>"theme_{$templates_type}",'k'=>$theme,'uid'=>UID]);
$theme_config_db = unserialize($theme_config_db);
}else{
//主题配置(用户)
$theme_config_db = get_db('global_config','v',['t'=>"theme_{$templates_type}",'k'=>$theme]);
$theme_config_db = unserialize($theme_config_db);
$theme_config_db = get_db('global_config','v',['k'=>"theme_{$templates_type}_{$theme}"]);
}
$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']}.".time() : $theme_info['version'];
if(defined('UID')){
if($config_type == 'user'){
//载入站点设置
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
//如果没有权限则清除自定义代码
@@ -223,6 +221,11 @@ function get_article_list($category = 0,$limit = 0){
$data['category_name'] = $categorys[$data['category']] ?? 'Null';
$data['title'] = htmlspecialchars($data['title'],ENT_QUOTES);
$data['summary'] = htmlspecialchars($data['summary'],ENT_QUOTES);
if($GLOBALS['global_config']['static_link'] == 1){
$data['url'] = "/{$GLOBALS['u']}/article/{$data['id']}.html";
}else{
$data['url'] = "./index.php?c=article&id={$data['id']}&u={$GLOBALS['u']}";
}
}
return ['data'=>$datas,'count'=>$count];
}

View File

@@ -1 +1 @@
v2.0.38-20230906
v2.0.39-20230913