From 1d379543f5876a96791bf4821b04572183978cb1 Mon Sep 17 00:00:00 2001
From: "MI15\\Win" <10359480+tznb@user.noreply.gitee.com>
Date: Fri, 28 Jul 2023 00:19:25 +0800
Subject: [PATCH] v2.0.32-20230727
---
index.php | 2 +-
system/MySQL/20230723.php | 40 ++
system/MySQL/install.sql | 42 ++-
system/SQLite/20230723.php | 40 ++
system/SQLite/install.sql | 39 +-
system/admin.php | 13 +-
system/api.php | 67 +++-
system/api_article.php | 210 +++++++++++
system/api_compatible.php | 56 ++-
system/api_root.php | 26 +-
system/expand/article.php | 58 +++
system/firewall.php | 4 +-
system/index.php | 11 +-
system/public.php | 14 +-
system/version.txt | 2 +-
templates/admin/js/link.js | 22 ++
templates/admin/js/link_list.js | 3 +-
templates/admin/page/expand/article-edit.php | 252 +++++++++++++
templates/admin/page/expand/article-list.php | 372 +++++++++++++++++++
templates/admin/page/link_extend.php | 25 +-
templates/admin/page/root/mail_set.php | 9 +
templates/admin/page/root/sys_setting.php | 12 +
templates/admin/page/theme_article.php | 83 +++++
templates/admin/page/theme_home.php | 1 +
templates/admin/page/updatelog.php | 16 +
templates/article/default/index.css | 145 ++++++++
templates/article/default/index.php | 46 +++
templates/article/default/info.json | 9 +
templates/article/default/screenshot.jpg | Bin 0 -> 94001 bytes
29 files changed, 1580 insertions(+), 39 deletions(-)
create mode 100644 system/MySQL/20230723.php
create mode 100644 system/SQLite/20230723.php
create mode 100644 system/api_article.php
create mode 100644 system/expand/article.php
create mode 100644 templates/admin/page/expand/article-edit.php
create mode 100644 templates/admin/page/expand/article-list.php
create mode 100644 templates/admin/page/theme_article.php
create mode 100644 templates/article/default/index.css
create mode 100644 templates/article/default/index.php
create mode 100644 templates/article/default/info.json
create mode 100644 templates/article/default/screenshot.jpg
diff --git a/index.php b/index.php
index 2e7bf6c..105927c 100644
--- a/index.php
+++ b/index.php
@@ -74,7 +74,7 @@ if(empty($c) || $c == 'index'){
require "./system/login.php";//登陆
}elseif(in_array($c,['admin','click','api','ico','icon','verify'])){
require "./system/{$c}.php";
-}elseif(in_array($c,['apply','guestbook'])){
+}elseif(in_array($c,['apply','guestbook','article'])){
if($global_config['Maintenance'] != 0){Amsg(-1,'网站正在进行维护,请稍后再试!');}
require "./system/expand/{$c}.php";
}else{
diff --git a/system/MySQL/20230723.php b/system/MySQL/20230723.php
new file mode 100644
index 0000000..7893907
--- /dev/null
+++ b/system/MySQL/20230723.php
@@ -0,0 +1,40 @@
+$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
+}else{
+ msg(-1,'数据库更新失败');
+}
diff --git a/system/MySQL/install.sql b/system/MySQL/install.sql
index de1de6a..07d45c8 100644
--- a/system/MySQL/install.sql
+++ b/system/MySQL/install.sql
@@ -26,7 +26,8 @@ CREATE TABLE IF NOT EXISTS `user_count` (
`uid` int(10) UNSIGNED NOT NULL COMMENT '用户ID',
`k` varchar(32) NOT NULL COMMENT '键',
`v` bigint(10) UNSIGNED DEFAULT '0' COMMENT '值',
- `t` varchar(32) NOT NULL COMMENT '类型'
+ `t` varchar(32) NOT NULL COMMENT '类型',
+ `e` text NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -46,7 +47,8 @@ INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALU
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230420.php', '1681977368', 'TRUE', '');
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230518.php', '1684393068', 'TRUE', '');
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230522.php', '1684762253', 'TRUE', '');
-INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230715.php', '1684762253', 'TRUE', '');
+INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230715.php', '1689427853', 'TRUE', '');
+INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230723.php', '1690119053', 'TRUE', '');
-- 创建用户表
DROP TABLE IF EXISTS `global_user`;
@@ -195,7 +197,9 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置'),
-('icon_pull', '图标拉取', '允许用户拉取链接图标');
+('icon_pull', '图标拉取', '允许用户拉取链接图标'),
+('article', '文章管理', '允许使用文章管理功能'),
+('article_image', '文章图片', '允许在文章编辑器上传图片');
-- 注册码列表
DROP TABLE IF EXISTS `regcode_list`;
@@ -274,4 +278,34 @@ CREATE TABLE IF NOT EXISTS `global_icon` (
`file_mime` text NOT NULL COMMENT 'MIME类型',
`extend` text NOT NULL COMMENT '预留扩展',
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
\ No newline at end of file
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+
+-- 用户文章分类
+CREATE TABLE IF NOT EXISTS `user_article_categorys` (
+ `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `uid` varchar(32) NOT NULL COMMENT '用户id',
+ `name` varchar(64) NOT NULL COMMENT '名称',
+ `weight` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
+ `add_time` int(10) UNSIGNED NOT NULL COMMENT '创建时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+
+-- 用户文章列表
+CREATE TABLE IF NOT EXISTS `user_article_list` (
+ `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `uid` varchar(32) NOT NULL COMMENT '用户id',
+ `title` text NOT NULL COMMENT '标题',
+ `category` int(10) UNSIGNED NOT NULL COMMENT '分类id',
+ `state` int(10) UNSIGNED NOT NULL COMMENT '状态',
+ `password` text NOT NULL COMMENT '访问密码',
+ `top` int(10) UNSIGNED NOT NULL COMMENT '置顶',
+ `add_time` int(10) UNSIGNED NOT NULL COMMENT '创建时间',
+ `up_time` int(10) UNSIGNED NOT NULL COMMENT '修改时间',
+ `browse_count` int(10) UNSIGNED NOT NULL COMMENT '浏览次数',
+ `summary` text NOT NULL COMMENT '摘要',
+ `content` text NOT NULL COMMENT '内容',
+ `cover` text NOT NULL COMMENT '封面',
+ `extend` text NOT NULL COMMENT '扩展',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+
diff --git a/system/SQLite/20230723.php b/system/SQLite/20230723.php
new file mode 100644
index 0000000..dbd2959
--- /dev/null
+++ b/system/SQLite/20230723.php
@@ -0,0 +1,40 @@
+$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
+}else{
+ msg(-1,'数据库更新失败');
+}
\ No newline at end of file
diff --git a/system/SQLite/install.sql b/system/SQLite/install.sql
index 01c0659..c3e5a8b 100644
--- a/system/SQLite/install.sql
+++ b/system/SQLite/install.sql
@@ -23,7 +23,8 @@ CREATE TABLE IF NOT EXISTS "user_count" (
"uid" integer(10) NOT NULL,
"k" text(32) NOT NULL DEFAULT "",
"v" integer(10) NOT NULL DEFAULT 0,
- "t" text(32) NOT NULL DEFAULT ""
+ "t" text(32) NOT NULL DEFAULT "",
+ "e" text NOT NULL DEFAULT ""
);
-- 数据库升级记录
@@ -38,7 +39,9 @@ CREATE TABLE IF NOT EXISTS "updatadb_logs" (
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', '');
INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230522.php', '1684762253', 'TRUE', '');
-INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230715.php', '1684762253', 'TRUE', '');
+INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230715.php', '1689427853', 'TRUE', '');
+INSERT INTO "updatadb_logs" ("file_name", "update_time", "status", "extra") VALUES ('20230723.php', '1690119053', 'TRUE', '');
+
-- 创建用户表
CREATE TABLE IF NOT EXISTS "global_user" (
@@ -167,7 +170,9 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置'),
-('icon_pull', '图标拉取', '允许用户拉取链接图标');
+('icon_pull', '图标拉取', '允许用户拉取链接图标'),
+('article', '文章管理', '允许使用文章管理功能'),
+('article_image', '文章图片', '允许在文章编辑器上传图片');
-- 注册码列表
CREATE TABLE IF NOT EXISTS "regcode_list" (
@@ -240,4 +245,30 @@ CREATE TABLE IF NOT EXISTS "global_icon" (
"extend" text NOT NULL DEFAULT "",
CONSTRAINT "id" UNIQUE ("id" ASC)
);
-
+-- 用户文章分类
+CREATE TABLE IF NOT EXISTS "user_article_categorys" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "uid" integer(10) NOT NULL,
+ "name" text NOT NULL DEFAULT "",
+ "weight" integer NOT NULL,
+ "add_time" integer(10) NOT NULL,
+ CONSTRAINT "id" UNIQUE ("id" ASC)
+);
+-- 用户文章列表
+CREATE TABLE "user_article_list" (
+ "id" integer PRIMARY KEY AUTOINCREMENT,
+ "uid" integer(10) NOT NULL,
+ "title" TEXT NOT NULL DEFAULT "",
+ "category" integer NOT NULL,
+ "state" integer(1) DEFAULT 0,
+ "password" TEXT NOT NULL DEFAULT "",
+ "top" integer(10),
+ "add_time" integer(10),
+ "up_time" integer(10),
+ "browse_count" integer DEFAULT 0,
+ "summary" TEXT,
+ "content" TEXT,
+ "cover" TEXT,
+ "extend" TEXT,
+ CONSTRAINT "id" UNIQUE ("id" ASC)
+);
\ No newline at end of file
diff --git a/system/admin.php b/system/admin.php
index 83ff638..f970311 100644
--- a/system/admin.php
+++ b/system/admin.php
@@ -83,7 +83,7 @@ if($page == 'config_home'){
}
//主题设置页面
-if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit' || $page == 'theme_register' || $page == 'theme_guide') {
+if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit' || $page == 'theme_register' || $page == 'theme_guide' || $page == 'theme_article') {
if(!check_purview('theme_in',1)){
require(DIR.'/templates/admin/page/404.php');
exit;
@@ -208,7 +208,9 @@ if ($page == 'menu') {
if($global_config['guestbook'] == 1 && check_purview('guestbook',1)){
array_push($extend,['title'=>'留言管理','href'=>'expand/guestbook-admin','icon'=>'fa fa-commenting-o']);
}
-
+ if($global_config['article'] == 1 && check_purview('article',1)){
+ array_push($extend,['title'=>'文章管理','href'=>'expand/article-list','icon'=>'fa fa-file-text-o']);
+ }
if(!empty($extend)){
$extend = ['title'=>'扩展功能','icon'=>'fa fa-folder-open-o','href'=>'','child'=> $extend];
array_push($menu,$extend);
@@ -242,6 +244,13 @@ if(empty($page)){
exit;
}
+// 插件编辑链接跳转
+if($page === 'edit_link' && !empty($_GET['id'])){
+ header("HTTP/1.1 302 Moved Permanently");
+ header("Location: ./index.php?c=admin&page=link_edit&u=".U."&id=".$_GET['id']);
+ exit;
+}
+
//页面文件不存在时载入404
if(!empty($page)){
if(!is_file(DIR.'/templates/admin/page/'.$page.'.php')){
diff --git a/system/api.php b/system/api.php
index 0476906..e079aca 100644
--- a/system/api.php
+++ b/system/api.php
@@ -5,9 +5,10 @@ header("Access-Control-Allow-Headers: Access-Control-Allow-Private-Network,Conte
AccessControl();
//鉴权验证 Cookie验证通过,验证二级密码,Cookie验证失败时尝试验证token
+if(!empty(trim($_REQUEST['token']))){ $_COOKIE = []; } //兼容浏览器插件,避免干扰
+
//获取请求方法
$method = htmlspecialchars(trim($_GET['method']),ENT_QUOTES);
-
$LoginConfig = unserialize($USER_DB['LoginConfig']);
if(!is_login()){
//没登录,根据API模式来限制
@@ -21,7 +22,7 @@ if(!is_login()){
if($api_model != 'compatible+open'){
Amsg(-1,'非开放模式,token不能为空!');
}
- if(in_array($method,['link_list','get_a_link','q_category_link','category_list','get_a_category','check_login'])){
+ if(in_array($method,['link_list','get_a_link','q_category_link','category_list','get_a_category','check_login','app_info'])){
define('Access_Type','open'); //数据访问类型:仅开放
require 'api_compatible.php';
exit;
@@ -462,7 +463,10 @@ function write_link(){
@unlink($_FILES["file"]["tmp_name"]);
msg(-1,'文件格式不被支持!');
}
-
+ //限制文件大小
+ if(filesize($_FILES["file"]["tmp_name"]) > 1 * 1024 * 1024){
+ msg(-1,'文件大小超限');
+ }
session_start();
$sid = $_POST['page_sid'];
//添加链接
@@ -516,7 +520,39 @@ function write_link(){
}else{
msg(-1,'参数错误');
}
-
+ //扩展上传图片
+ }elseif($_GET['type'] == 'extend_up_img'){
+ //权限检测
+ if(!check_purview('Upload_icon',1)){
+ msg(-1,'您的用户组无权限上传图片');
+ }elseif(empty($_FILES["file"]) || $_FILES["file"]["error"] > 0){
+ msg(-1,'文件上传失败');
+ }
+
+ //取后缀并判断是否支持
+ $suffix = strtolower(end(explode('.',$_FILES["file"]["name"])));
+ if(!preg_match('/^(jpg|jpeg|png|ico|bmp|svg)$/',$suffix)){
+ @unlink($_FILES["file"]["tmp_name"]);
+ msg(-1,'文件格式不被支持!');
+ }
+ //限制文件大小
+ if(filesize($_FILES["file"]["tmp_name"]) > 1 * 1024 * 1024){
+ msg(-1,'文件大小超限');
+ }
+ //文件临时路径
+ $path = DIR . "/data/user/{$u}/upload";
+ //检测目录,不存在则创建!
+ if(!Check_Path($path)){
+ msg(-1,'创建upload目录失败,请检查权限');
+ }
+ $tmp_name = 'LE_'.uniqid().'.'.$suffix;
+ //移动文件
+ if(!move_uploaded_file($_FILES["file"]["tmp_name"],"{$path}/{$tmp_name}")) {
+ msg(-1,'上传失败,请检查目录权限');
+ }else{
+ msgA(['code'=>1,'msg'=>'上传成功','url'=>"./data/user/".U.'/upload/'.$tmp_name]);
+ }
+
//删除图标
}elseif($_GET['type'] === 'del_images'){
session_start();
@@ -875,7 +911,7 @@ function write_link(){
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'])){
+ if(!in_array($data['type'],['text','textarea','up_img'])){
msgA( ['code' => -1,'msg' => '类型错误'] );
}
}
@@ -889,7 +925,7 @@ function write_link(){
$datas = [];
foreach ($lists as $key => $data ){
- array_push($datas,['title'=>$data['title'],'name'=>$data['name'],'weight'=>$data['weight'],'type'=>$data['type'],'default'=> "{$data['default']}"]);
+ array_push($datas,['title'=>$data['title'],'name'=>$data['name'],'weight'=>$data['weight'],'type'=>$data['type'],'default'=> "{$data['default']}",'tip'=>$data['tip']]);
}
//根据序号排序
usort($datas, function($a, $b) {
@@ -1272,7 +1308,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','guide'])){msg(-1,'fn参数错误');}
+ $fn = $_POST['fn'];if($_GET['type'] != 'config' && !in_array($fn,['home','login','transit','register','guide','article'])){msg(-1,'fn参数错误');}
if($_GET['type'] == 'download'){
is_root();
if($global_config['offline']){msg(-1,"离线模式禁止下载主题!");} //离线模式
@@ -1393,6 +1429,8 @@ function write_theme(){
$s_templates['login'] = $name;
}elseif($fn == 'transit'){
$s_templates['transit'] = $name;
+ }elseif($fn == 'article'){
+ $s_templates['article'] = $name;
}elseif($fn == 'register'){
$global_templates['register'] = $name;
update_db('global_config',['v'=>$global_templates],['k'=>'s_templates'],[1,'注册模板设置成功']);
@@ -1417,7 +1455,7 @@ function write_theme(){
msg(-1,"获取模板类型错误");
}
$fn = empty($GET['fn']) ? $_GET['template_type'] : $GET['fn'];
- if(!in_array($fn,['home','login','register','transit','guide'])){
+ if(!in_array($fn,['home','login','register','transit','guide','article'])){
msg(-1,"参数错误");
}
//0420 END
@@ -1617,6 +1655,8 @@ function read_data(){
curl_setopt($ch, CURLOPT_URL, $_POST['url']);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+
$start = microtime(true);
$response = curl_exec($ch);
$end = microtime(true);
@@ -1735,6 +1775,17 @@ function other_local_backup(){
require DIR . '/system/UseFew/local_backup.php';
exit;
}
+//读文章
+function read_article(){
+ require DIR . '/system/api_article.php';
+ exit;
+}
+//写文章
+function write_article(){
+ require DIR . '/system/api_article.php';
+ exit;
+}
+
//获取链接信息
function other_get_link_info(){
global $global_config;
diff --git a/system/api_article.php b/system/api_article.php
new file mode 100644
index 0000000..a052fa6
--- /dev/null
+++ b/system/api_article.php
@@ -0,0 +1,210 @@
+> '.$type);
+}
+
+//上传图片
+function uploadImage(){
+ global $u;
+ //权限检测
+ if(!check_purview('article_image',1)){
+ msgA(['errno'=>-1,'message'=>'您的用户组无权限上传图片']);
+ }elseif(empty($_FILES["file"]) || $_FILES["file"]["error"] > 0){
+ msgA(['errno'=>-1,'message'=>'文件上传失败']);
+ }
+
+ //取后缀并判断是否支持
+ $suffix = strtolower(end(explode('.',$_FILES["file"]["name"])));
+ if(!preg_match('/^(jpg|png|gif|bmp|jpeg|svg)$/',$suffix)){
+ @unlink($_FILES["file"]["tmp_name"]);
+ msgA(['errno'=>-1,'message'=>'文件格式不被支持']);
+ }
+ //限制文件大小
+ if(filesize($_FILES["file"]["tmp_name"]) > 5 * 1024 * 1024){
+ msgA(['errno'=>-1,'message'=>'文件大小超限']);
+ }
+ //文件临时路径
+ $ym = date("Ym");
+ $path = DIR . "/data/user/{$u}/upload/{$ym}/";
+ //检测目录,不存在则创建!
+ if(!Check_Path($path)){
+ msgA(['errno'=>-1,'message'=>'创建upload目录失败,请检查权限']);
+ }
+ $tmp_name = 'AI_'.uniqid().'.'.$suffix;
+ //移动文件
+ if(!move_uploaded_file($_FILES["file"]["tmp_name"],"{$path}/{$tmp_name}")) {
+ msgA(['errno'=>-1,'message'=>'上传失败,请检查目录权限']);
+ }else{
+ msgA(['errno'=>0,'data'=>['url'=>"./data/user/{$u}/upload/{$ym}/$tmp_name",'alt'=>$_FILES["file"]["name"],'href'=>''],'message'=>'上传成功']);
+ }
+}
+
+//上传视频
+function uploadVideo(){
+ msgA(['errno'=>-1,'message'=>'未开放']);
+ global $u;
+ //权限检测
+ if(!check_purview('article_image',1)){
+ msgA(['errno'=>-1,'message'=>'您的用户组无权限上传视频']);
+ }elseif(empty($_FILES["file"]) || $_FILES["file"]["error"] > 0){
+ msgA(['errno'=>-1,'message'=>'文件上传失败']);
+ }
+
+ //取后缀并判断是否支持
+ $suffix = strtolower(end(explode('.',$_FILES["file"]["name"])));
+ if(!preg_match('/^(avi|mp4|wma|rmvb|rm|flash|3gp|flv)$/',$suffix)){
+ @unlink($_FILES["file"]["tmp_name"]);
+ msgA(['errno'=>-1,'message'=>'文件格式不被支持']);
+ }
+ //限制文件大小
+ if(filesize($_FILES["file"]["tmp_name"]) > 20 * 1024 * 1024){
+ msgA(['errno'=>-1,'message'=>'文件大小超限']);
+ }
+ //文件临时路径
+ $ym = date("Ym");
+ $path = DIR . "/data/user/{$u}/upload/{$ym}/";
+ //检测目录,不存在则创建!
+ if(!Check_Path($path)){
+ msgA(['errno'=>-1,'message'=>'创建upload目录失败,请检查权限']);
+ }
+ $tmp_name = 'AV_'.uniqid().'.'.$suffix;
+ //移动文件
+ if(!move_uploaded_file($_FILES["file"]["tmp_name"],"{$path}/{$tmp_name}")) {
+ msgA(['errno'=>-1,'message'=>'上传失败,请检查目录权限']);
+ }else{
+ msgA(['errno'=>0,'data'=>['url'=>"./data/user/{$u}/upload/{$ym}/$tmp_name",'alt'=>$_FILES["file"]["name"],'href'=>''],'message'=>'上传成功']);
+ }
+}
+
+//获取文章列表
+function article_list(){
+ $where['uid'] = UID;
+ //分类筛选
+ if(intval(@$_POST['category']) > 0){
+ $where['AND']['category'] = intval(@$_POST['category']);
+ }
+ //状态筛选
+ if(intval(@$_POST['state']) > 0){
+ $where['AND']['state'] = intval(@$_POST['state']);
+ }
+ //关键字筛选
+ $query = $_POST['keyword'];
+ if(!empty($query)){
+ $where['AND']['OR'] = ["title[~]" => $query,"summary[~]" => $query,"content[~]" => $query];
+ }
+ //统计条数
+ $count = count_db('user_article_list',$where);
+ //分页
+ $page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
+ $limit = empty(intval($_REQUEST['limit'])) ? 50 : intval($_REQUEST['limit']);
+ $offset = ($page - 1) * $limit; //起始行号
+ $where['LIMIT'] = [$offset,$limit];
+ $where['ORDER']['weight'] = 'ASC';
+
+ $datas = select_db('user_article_list',['id','title','category','category_name','state','password','top','add_time','up_time','browse_count','summary'],$where);
+
+ $categorys = select_db('user_article_categorys',['id','name'],['uid'=>UID]);
+
+ foreach (select_db('user_article_categorys',['id','name'],['uid'=>UID]) as $data) {
+ $categorys[$data['id']] = $data['name'];
+ }
+
+ foreach ($datas as &$data) {
+ $data['category_name'] = $categorys[$data['category']];
+ }
+ msgA(['code'=>1,'count'=>$count,'data'=>$datas]);
+}
+
+//保存文章
+function save_article(){
+ check_category($_POST['category']);$time = time();
+ if(empty($_POST['id'])){
+ insert_db('user_article_list',[
+ 'uid'=>UID,
+ 'title'=>$_POST['title'],
+ 'category'=>$_POST['category'],
+ 'state'=>$_POST['state'],
+ 'password'=>'',
+ 'top'=>0,
+ 'add_time'=>$time,
+ 'up_time'=>$time,
+ 'browse_count'=>0,
+ 'summary'=>$_POST['summary'],
+ 'content'=>$_POST['content'],
+ 'cover'=>'',
+ 'extend'=>''
+ ],[1,'保存成功']);
+ }else{
+ if(!has_db('user_article_list',['uid'=>UID,'id'=>$_POST['id']])){
+ msg(-1,'文章id错误');
+ }
+ update_db('user_article_list',[
+ 'title'=>$_POST['title'],
+ 'category'=>$_POST['category'],
+ 'state'=>$_POST['state'],
+ 'up_time'=>$time,
+ 'summary'=>$_POST['summary'],
+ 'content'=>$_POST['content'],
+ ],['uid'=>UID,'id'=>$_POST['id']],[1,'保存成功']);
+ }
+
+
+}
+//删除文章
+function del_article(){
+ $id = json_decode($_POST['id']);
+ delete_db('user_article_list',['uid'=>UID,'id'=>$id],[1,'删除成功']);
+}
+//分类列表
+function category_list(){
+ $where['uid'] = UID;
+ $where['ORDER']['weight'] = 'ASC';
+ $data = select_db('user_article_categorys',['id','name','weight','add_time'],$where);
+ msgA(['code'=>1,'count'=>count($data),'data'=>$data]);
+}
+//添加分类
+function add_category(){
+ $name = trim($_POST['name']);
+ $time = time();
+ if(empty($name)){
+ msg(-1,'分类名称不能为空');
+ }
+ if(has_db('user_article_categorys',['uid'=>UID,'name'=>$name])){
+ msg(-1,'分类名称已存在');
+ }
+ insert_db('user_article_categorys',[
+ 'uid'=>UID,
+ 'name'=>$name,
+ 'weight'=>0,
+ 'add_time'=>$time
+ ],[1,'添加成功']);
+ msg(-1,'添加失败');
+}
+//删除分类
+function del_category(){
+ check_category($_POST['id']);
+ delete_db('user_article_categorys',['uid'=>UID,'id'=>$_POST['id']],[1,'删除成功']);
+}
+//保存分类
+function save_category(){
+ check_category($_POST['id']);
+ update_db('user_article_categorys',['name'=>$_POST['name'],'weight'=>$_POST['weight']],['uid'=>UID,'id'=>$_POST['id']],[1,'更新成功']);
+}
+//检查分类
+function check_category($id){
+ if(empty($id)){
+ msg(-1,'分类ID不能为空');
+ }
+ if(!has_db('user_article_categorys',['uid'=>UID,'id'=>$id])){
+ msg(-1,'分类不存在');
+ }
+}
+
diff --git a/system/api_compatible.php b/system/api_compatible.php
index 799b81c..147e467 100644
--- a/system/api_compatible.php
+++ b/system/api_compatible.php
@@ -1,6 +1,6 @@
> '.$method);
@@ -42,6 +42,50 @@ function add_link(){
insert_db('user_links',$data);
msgA(['code'=>0,'id'=>$lid]);
}
+//删除链接
+function del_link(){
+ $lid = intval(trim($_REQUEST['id']));
+ if(empty($lid)){
+ msg(-1,'id不能为空');
+ }
+ $where['lid'] = $lid;
+ $where['uid'] = UID;
+ if(!has_db('user_links',$where)){
+ msg(-1,'链接id不存在');
+ }
+ delete_db('user_links',$where,[0,'删除成功']);
+}
+
+//搜索链接
+function global_search(){
+ $keyword = htmlspecialchars($_REQUEST['keyword']);
+
+ if( strlen($keyword) < 2 ) {
+ msg(-2000,'关键字的长度太短');
+ }elseif( strlen($keyword) > 32 ) {
+ msg(-2000,'关键字长度过长');
+ }
+
+ $where['uid'] = UID;
+ $where['status'] = 1;
+ $where['AND']['OR'] = ["title[~]" => $keyword,"url[~]" => $keyword, "url_standby[~]" => $keyword,"description[~]" => $keyword];
+ $where['ORDER'] = ['weight'=>'DESC'];
+ $field = ['lid(id)','fid','status','property','title','url','url_standby','weight','description','click','add_time','up_time'];
+ $data = select_db('user_links',$field,$where);
+
+ // 查询出分类名称
+ $categorys = select_db('user_categorys',['cid(id)','name'],['uid'=>UID,'status'=>1]);
+ // 遍历分类,以id作为键名
+ foreach ($categorys as $category) {
+ $newCategorys[$category['id']] = $category['name'];
+ }
+ // 遍历查询的数据,然后添加父级分类名称
+ foreach ($data as $key => $value) {
+ $data[$key]['category_name'] = $newCategorys[$value['fid']];
+ }
+
+ msgA(['code'=>0,'msg'=>'获取成功','count'=>count($data),'data'=>$data]);
+}
//查询链接列表
function link_list(){
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
@@ -68,7 +112,6 @@ function get_a_link(){
$lid = intval(trim($_REQUEST['id']));
if(empty($lid)){
msg(-1,'id不能为空');
-
}
$where['lid'] = $lid;
$where['uid'] = UID;
@@ -135,6 +178,15 @@ function get_a_category(){
}
}
+function app_info(){
+ $data['php_version'] = floatval(PHP_VERSION);
+ $data['onenav_version'] = SysVer;
+ $data['cat_num'] = count_db('user_categorys',['uid'=>UID])??0;
+ $data['link_num'] = count_db('user_links',['uid'=>UID])??0;
+ $data['username'] = U;
+ msgA(['code'=>200,'msg'=>'success','data'=>$data]);
+}
+
//是否已登录
function check_login(){
if(Access_Type == 'open'){
diff --git a/system/api_root.php b/system/api_root.php
index 341c93d..95b22d5 100644
--- a/system/api_root.php
+++ b/system/api_root.php
@@ -555,6 +555,7 @@ function write_sys_settings(){
'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'=>'链接扩展参数错误'],
+ 'article'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'文章管理参数错误']
];
$o_config = [];
foreach ($datas as $key => $data){
@@ -575,9 +576,30 @@ function write_sys_settings(){
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;}
+ if($_POST['article'] == 1){$o_config['article'] = 0;$filter = true;}
+ }
+ //检测于下载文章管理依赖资源
+ clearstatcache();
+ if($o_config['article'] == 1 && ( !is_file('./static/wangEditor/wangEditor.js') || !is_file('./static/wangEditor/wangEditor.css'))){
+ $filePath = "./data/temp/wangEdito.tar.gz";
+ if(downFile('https://update.lm21.top/TwoNav/updata/wangEdito.tar.gz','wangEdito.tar.gz','./data/temp/')){
+ $file_md5 = md5_file($filePath);
+ if($file_md5 != "95f830656ba8972cca39a1ddd6ebaeda"){
+ unlink($filePath);
+ msg(-1,'效验wangEdito失败
!');
+ }
+ }else{
+ msg(-1,'下载wangEdito失败,请重试!
如需手动安装可联系技术支持!');
+ }
+ try {
+ $phar = new PharData($filePath);
+ $phar->extractTo('./static/', null, true);
+ unlink($filePath);
+ clearstatcache();
+ } catch (Exception $e) {
+ msg(-1,'安装wangEdito失败');
+ }
}
-
-
update_db("global_config", ["v" => $o_config], ["k" => "o_config"],[1,($filter ?"保存成功,未检测到有效授权,带*号的配置无法为你保存":"保存成功")]);
}
diff --git a/system/expand/article.php b/system/expand/article.php
new file mode 100644
index 0000000..58485a6
--- /dev/null
+++ b/system/expand/article.php
@@ -0,0 +1,58 @@
+UID,'k'=>'s_site']));
+$site['Title'] = $site['title'].(empty($site['subtitle'])?'':' - '.$site['subtitle']);
+//免费用户请保留版权,谢谢!
+$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";
+$dir_path = DIR.'/templates/article/'.$s_templates['article'];
+$theme_dir = str_replace(DIR.'/templates/article',"./templates/article",$dir_path);
+$path = $dir_path.'/index.php';
+//检查是否存在,不存在则使用默认
+if(!is_file($path)){
+ $path= DIR.'/templates/article/default/index.php';
+}
+
+//统计点击数
+update_db("user_article_list", ["browse_count[+]"=>1],['uid'=>UID,'id'=>$id]);
+
+//读取用户主题配置
+$theme_config_db = unserialize(get_db('user_config','v',['t'=>'theme_article','k'=>$s_templates['article'],'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??[]);
+
+require $path;
+exit;
+
+//返回404
+function Not_Found() {
+ header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;
+}
\ No newline at end of file
diff --git a/system/firewall.php b/system/firewall.php
index 8b3dd8f..dded5c8 100644
--- a/system/firewall.php
+++ b/system/firewall.php
@@ -11,7 +11,9 @@ foreach($_POST as $key =>$value){
if($method =='write_site_setting' && ($key =='custom_header' || $key =='custom_footer')){
continue;
}
-
+ if($method == 'write_article'){
+ continue;
+ }
if(preg_match('/<(iframe|script|body|img|layer|div|meta|style|base|object|input)/i',$value)){
$code = 2001;
}elseif(preg_match('/(onmouseover|onerror|onload)\=/i',$value)){
diff --git a/system/index.php b/system/index.php
index a29cda7..3b16941 100644
--- a/system/index.php
+++ b/system/index.php
@@ -163,7 +163,7 @@ function get_links($fid) {
$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);
+ $links = select_db('user_links',['lid(id)','fid','property','title','url(real_url)','url_standby','description','icon','click','pid','extend'],$where);
foreach ($links as $key => $link) {
$click = false; $lock = false;
@@ -198,6 +198,15 @@ function get_links($fid) {
//获取图标链接
$links[$key]['ico'] = $lock ? $GLOBALS['libs'].'/Other/lock.svg' : geticourl($site['link_icon'],$link);
}
+ //处理扩展信息
+ if($GLOBALS['global_config']['link_extend'] == 1 && check_purview('link_extend',1) && in_array($GLOBALS['theme_info']['support']['link_extend'],["true","1"])){
+ foreach ($links as &$link) {
+ if(!empty($link['extend'])){
+ $link = array_merge ($link,unserialize($link['extend']));
+ }
+ }
+
+ }
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']);
diff --git a/system/public.php b/system/public.php
index 630e45b..fb7189e 100644
--- a/system/public.php
+++ b/system/public.php
@@ -445,10 +445,10 @@ function is_subscribe($type = 'bool'){
$count = count($host);
if($count != 2){
$data['host'] = $host[$count-2].'.'.$host[$count-1];
- //如果存在端口则去除
- if(preg_match("/(.+):\d+/",$data['host'],$host)) {
- $data['host'] = $host[1];
- }
+ }
+ //如果存在端口则去除
+ if(preg_match("/(.+):\d+/",$data['host'],$host)) {
+ $data['host'] = $host[1];
}
}
if(!stristr($data['domain'],$data['host'])){
@@ -745,15 +745,15 @@ function send_email($config){
function count_ip(){
$ip = Get_IP(); //取访客IP
$k = date('Ymd'); $t = 'ip_list';
- $ip_list = get_db('user_count','v',['uid'=>UID,'k'=>$k,'t'=>$t]); //取列表
+ $ip_list = get_db('user_count','e',['uid'=>UID,'k'=>$k,'t'=>$t]); //取列表
$ip_list = empty($ip_list) ? [] : unserialize($ip_list); //反序列化
//判断IP是否存在列表中
if(!in_array($ip, $ip_list)){
$ip_list[] = $ip; //加入列表
if(!has_db('user_count',['uid'=>UID,'t'=>$t,'k'=>$k])){
- insert_db("user_count", ['uid'=>UID,"k"=>$k,"v"=>$ip_list,'t'=>$t]);
+ insert_db("user_count", ['uid'=>UID,"k"=>$k,"e"=>$ip_list,'t'=>$t]);
}else{
- update_db("user_count", ["v"=>$ip_list],['uid'=>UID,'t'=>$t,'k'=>$k]);
+ update_db("user_count", ["e"=>$ip_list],['uid'=>UID,'t'=>$t,'k'=>$k]);
}
write_user_count($k,'ip_count');//访问ip数+1
}
diff --git a/system/version.txt b/system/version.txt
index da0400a..449d313 100644
--- a/system/version.txt
+++ b/system/version.txt
@@ -1 +1 @@
-v2.0.31-20230720
\ No newline at end of file
+v2.0.32-20230727
\ No newline at end of file
diff --git a/templates/admin/js/link.js b/templates/admin/js/link.js
index ee1ef72..1614187 100644
--- a/templates/admin/js/link.js
+++ b/templates/admin/js/link.js
@@ -204,6 +204,28 @@ layui.use(module, function () {
}
}
+
+ //链接扩展上传图片
+ upload.render({
+ elem: '.extend_up_img'
+ ,url: get_api('write_link','extend_up_img')
+ ,exts: 'jpg|jpeg|png|ico|bmp|svg'
+ ,acceptMime: 'image/*'
+ ,accept: 'file'
+ ,size: 1024
+ ,done: function(res){
+ if(res.code == 1){
+ let inpu = this.item.closest('.layui-form-item').find('input[name^="_"]');
+ inpu.val(res.url);
+ }else{
+ layer.msg(res.msg || '上传失败', {icon: 5});
+ }
+ },error: function(){
+ layer.msg("上传异常,请刷新重试", {icon: 5});
+ }
+ });
+
+
//layui>end
});
diff --git a/templates/admin/js/link_list.js b/templates/admin/js/link_list.js
index 5da3ffb..fefc3d8 100644
--- a/templates/admin/js/link_list.js
+++ b/templates/admin/js/link_list.js
@@ -376,6 +376,7 @@ layui.use(['form','table','dropdown','miniTab'], function () {
,{field:'name',title:'字段名',edit:'text',width:256}
,{field:'type',title:'类型',edit:'text',width:256}
,{field:'default',title:'默认值',edit:'text',width:256}
+ ,{field:'tip',title:'提示内容',edit:'text',width:256}
,{ title:'操作',toolbar:'#link_extend_toolbar',align:'center',width:118}
]]
});
@@ -530,7 +531,7 @@ layui.use(['form','table','dropdown','miniTab'], function () {
"title": "请输入标题",
"name":"请输入字段名(大小写字母或数字)",
"weight":(max_weight + 1),
- "type":"请输入 text 或 textarea",
+ "type":"请输入 text 或 textarea 或 up_img",
"default":""
});
table.reload('link_extend_list', {data: data});
diff --git a/templates/admin/page/expand/article-edit.php b/templates/admin/page/expand/article-edit.php
new file mode 100644
index 0000000..91efb4d
--- /dev/null
+++ b/templates/admin/page/expand/article-edit.php
@@ -0,0 +1,252 @@
+UID,'id'=>$article_id])){
+ $data = get_db('user_article_list','*',['uid'=>UID,'id'=>$article_id]);
+ //var_dump($data);
+ }else{
+ $mode = 'add';
+ }
+
+}
+
+$title = $mode == 'add' ? '添加文章' : '编辑文章';
+
+function echo_article_category(){
+ $where['uid'] = UID;
+ foreach (select_db('user_article_categorys','*',$where) as $category) {
+ echo "";
+ }
+}
+
+require dirname(__DIR__).'/header.php' ?>
+
+
+