Compare commits

...

3 Commits

Author SHA1 Message Date
MI15\Win ccae67f236 v2.0.15-20230422 2023-04-22 20:37:34 +08:00
MI15\Win 87566c39f3 v2.0.14-20230420 2023-04-20 21:03:34 +08:00
MI15\Win 5cae5af159 v2.0.13-20230418 2023-04-18 13:17:09 +08:00
24 changed files with 276 additions and 98 deletions
+1
View File
@@ -73,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);
+1 -1
View File
@@ -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>');
}
}
+23
View 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']);
+2 -1
View File
@@ -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`;
+22 -4
View File
@@ -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,'注册成功');
+23
View 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']);
+2 -1
View File
@@ -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" (
+5 -32
View File
@@ -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,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'){
+14 -2
View File
@@ -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
//获取请求方法
@@ -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']);
+23 -4
View File
@@ -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);
@@ -499,6 +499,7 @@ 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],
@@ -519,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 ?"保存成功,未检测到有效授权,带*号的配置无法为你保存":"保存成功")]);
@@ -631,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,'保存成功');
}
}
+16 -24
View File
@@ -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']));
$favicon = ( !empty($site['site_icon_file'])) ? $site['site_icon'] : './favicon.ico';
$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,21 +105,15 @@ 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>';
//统计点击数
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]));
//读取用户主题配置
$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);
@@ -143,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;
+8 -8
View File
@@ -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,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);
@@ -133,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) {
@@ -173,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']);
}
+1 -1
View File
@@ -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)){
+5 -7
View File
@@ -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
View File
@@ -1 +1 @@
v2.0.12-20230417
v2.0.15-20230422
@@ -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'] .'.&nbsp;[&nbsp;'. $value['type'] .'&nbsp;]&nbsp;[&nbsp;'. $value['title'].'&nbsp;]'; ?>&emsp;
<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> &emsp;
</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(" ","&nbsp;",$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>
+2 -2
View File
@@ -25,7 +25,7 @@ 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 $data['value']?>" class="layui-input">
<input type="text" name="_<?php echo $data['name']?>" autocomplete="off" value="<?php echo htmlentities($data['value'])?>" class="layui-input">
</div>
</div>
<?php
@@ -35,7 +35,7 @@ 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 $data['value']?></textarea>
<textarea name="_<?php echo $data['name']?>" class="layui-textarea"><?php echo htmlentities($data['value'])?></textarea>
</div>
</div>
<?php
+11
View File
@@ -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>
+3
View File
@@ -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>
+68 -3
View File
@@ -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>
-1
View File
@@ -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 -2
View File
@@ -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});
+33
View File
@@ -2,6 +2,39 @@
<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">