From fd5e9910e57901980231c4b5884f04858adf8a2e Mon Sep 17 00:00:00 2001 From: xiaoz Date: Fri, 14 Jul 2023 16:09:47 +0800 Subject: [PATCH] 0.9.32 --- README.md | 4 ++-- README_EN.md | 4 ++-- class/Api.php | 6 ++++++ data/update.log | 9 ++++++++- functions/helper.php | 17 +++++++++++++++++ templates/admin/link_list.php | 7 ++++++- templates/admin/setting/api.php | 9 ++++++++- version.txt | 2 +- 8 files changed, 50 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6727b6a..8716113 100755 --- a/README.md +++ b/README.md @@ -53,11 +53,11 @@ OneNav是一款开源免费的书签(导航)管理程序,使用使用PHP + ```bash docker run -itd --name="onenav" -p 80:80 \ -v /data/onenav:/data/wwwroot/default/data \ - helloz/onenav:0.9.30 + helloz/onenav:0.9.32 ``` * 第一个`80`是自定义访问端口,可以自行修改,第二个`80`是容器端口,请勿修改 * `/data/onenav`:本机挂载目录,用于持久存储Onenav数据 -* `0.9.31`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号 +* `0.9.32`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号 > 更多说明,请参考帮助文档:https://dwz.ovh/onenav diff --git a/README_EN.md b/README_EN.md index 3c103d7..3e219f4 100644 --- a/README_EN.md +++ b/README_EN.md @@ -53,11 +53,11 @@ OneNav is an open-source, free bookmark (navigation) management program develope ```bash docker run -itd --name="onenav" -p 80:80 \ -v /data/onenav:/data/wwwroot/default/data \ - helloz/onenav:0.9.31 + helloz/onenav:0.9.32 ``` * The first `80` is the customized access port, which can be modified, and the second `80` is the container port, please do not modify * `/data/onenav`: Local mount directory for persistent storage of Onenav data -* `0.9.31`: Replace with the latest version number of OneNav, which can be found through [releases](https://github.com/helloxz/onenav/releases) +* `0.9.32`: Replace with the latest version number of OneNav, which can be found through [releases](https://github.com/helloxz/onenav/releases) > For more instructions, please refer to the help document: https://dwz.ovh/onenav diff --git a/class/Api.php b/class/Api.php index 94a2846..64b662b 100644 --- a/class/Api.php +++ b/class/Api.php @@ -11,6 +11,8 @@ define("API_URL","https://onenav.xiaoz.top"); class Api { protected $db; public function __construct($db){ + // 修改默认获取模式为关联数组 + $db->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->db = $db; //返回json类型 header('Content-Type:application/json; charset=utf-8'); @@ -171,6 +173,10 @@ class Api { * name:验证方法 */ protected function auth($token){ + // 当方法没有传递token的时候,则先尝试通过POST/GET获取token + if( empty($token) ) { + $token = empty( $_POST['token'] ) ? $_GET['token'] : $_POST['token']; + } //计算正确的token:用户名 + TOKEN $SecretKey = @$this->db->get('on_options','*',[ 'key' => 'SecretKey' ])['value']; $token_yes = md5(USER.$SecretKey); diff --git a/data/update.log b/data/update.log index e536185..fb6b4a9 100755 --- a/data/update.log +++ b/data/update.log @@ -241,4 +241,11 @@ CREATE INDEX on_options_key_IDX ON on_options ("key"); b. 进入更多链接遮罩左侧导航栏 c. 进入更多链接,显示返回按钮 4. 优化5iux主题 -5. 优化webstack主题 \ No newline at end of file +5. 优化webstack主题 + +20230714 +1. API认证函数增加了尝试自动获取token,避免部分函数忘记获取token,导致token认证失败 +2. 修复查询分类链接要求输入关键词的BUG +3. 修改Medoo默认获取模式为关联数组,避免过多冗余数据 +4. 重构OneNav Chrome扩展 +5. 后台获取API页面,新增API域名显示 \ No newline at end of file diff --git a/functions/helper.php b/functions/helper.php index 8e55633..76dd67f 100755 --- a/functions/helper.php +++ b/functions/helper.php @@ -185,4 +185,21 @@ function get_host(){ $host = $parsed_host['host']; } return $host; +} + +// 获取当前域名,比如https://nav.rss.ink +function getCurrentUrlDomain() { + + $url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; + + $url_parts = parse_url($url); + + $domain = $url_parts['scheme'] . '://' . $url_parts['host']; + + if(!empty($url_parts['port'])) { + $domain .= ':' . $url_parts['port']; + } + + return $domain; + } \ No newline at end of file diff --git a/templates/admin/link_list.php b/templates/admin/link_list.php index 5f2c822..a409f1e 100755 --- a/templates/admin/link_list.php +++ b/templates/admin/link_list.php @@ -28,7 +28,7 @@
- +
@@ -120,6 +120,11 @@ layui.use(['table','form'], function(){ console.log(data.field); let keyword = data.field.keyword; + if( keyword.length < 2 ) { + layer.msg("关键词过短!",{icon:5}); + return false; + } + //渲染链接列表 table.render({ elem: '#link_list' diff --git a/templates/admin/setting/api.php b/templates/admin/setting/api.php index 35db7b2..9696ebe 100644 --- a/templates/admin/setting/api.php +++ b/templates/admin/setting/api.php @@ -8,7 +8,7 @@
- API使用说明,请参考:https://dwz.ovh/viot5 + API使用说明,请参考:https://dwz.ovh/viot5
@@ -22,6 +22,13 @@
+
+ +
+ +
+
+
diff --git a/version.txt b/version.txt index 25fa41c..34ad9a0 100755 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.9.31-20230628 \ No newline at end of file +v0.9.32-20230714 \ No newline at end of file