Skip to content

Commit

Permalink
Merge pull request #180 from helloxz/dev
Browse files Browse the repository at this point in the history
0.9.34
  • Loading branch information
helloxz authored Jan 15, 2024
2 parents d5003b4 + 91d3fc9 commit ebfba6c
Show file tree
Hide file tree
Showing 23 changed files with 582 additions and 425 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.33
helloz/onenav:0.9.34
```
* 第一个`80`是自定义访问端口,可以自行修改,第二个`80`是容器端口,请勿修改
* `/data/onenav`:本机挂载目录,用于持久存储Onenav数据
* `0.9.33`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号
* `0.9.34`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号

> 更多说明,请参考帮助文档:https://dwz.ovh/onenav
Expand Down
14 changes: 13 additions & 1 deletion class/Api.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* name:API核心类
* update:2020/12
* update:2024/01
* author:xiaoz<[email protected]>
* blog:xiaoz.me
*/
Expand Down Expand Up @@ -339,6 +339,18 @@ public function imp_link($token,$filename,$fid,$property = 0){
//过滤$filename
$filename = str_replace('../','',$filename);
$filename = str_replace('./','',$filename);
// 获取文件名称的后缀
$suffix = explode('.',$filename);
// 如果没有后缀,则不合法,通过数组长度判断后缀
if( count($suffix) < 2 ) {
$this->err_msg(-2000,'文件不合法!');
}
// 获取文件后缀
$suffix = strtolower(end($suffix));
if( ( $suffix != 'html' ) && ( $suffix != 'htm' ) ) {
$this->err_msg(-2000,'文件不合法!');
}

$this->auth($token);
//检查文件是否存在
if ( !file_exists($filename) ) {
Expand Down
11 changes: 11 additions & 0 deletions controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
$version = new_get_version();

$page = empty($_GET['page']) ? 'index' : $_GET['page'];
// 正则判断page,只能允许字符+数字和下划线组合
$pattern = "/^[a-zA-Z0-9_\/]+$/";
if ( !preg_match($pattern,$page) ) {
exit('非法请求!');
}


//如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面
if( $page == 'index' ) {
Expand Down Expand Up @@ -323,6 +329,11 @@ function check_auth($user,$password){
}
}

// 判断$page文件是否存在,不存在,则终止执行
$full_page_path = 'templates/admin/'.$page;
if( !file_exists($full_page_path) ) {
exit("file does not exist!");
}

// 载入前台首页模板
require('templates/admin/'.$page);
2 changes: 1 addition & 1 deletion controller/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,4 @@ function global_search() {
function upload_backup(){
global $api;
$api->general_upload('data/backup/',['db3']);
}
}
4 changes: 4 additions & 0 deletions controller/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// 获取链接数量,默认为30
$link_num = empty( $site['link_num'] ) ? 30 : intval($site['link_num']);



//如果已经登录,获取所有分类和链接
// 载入辅助函数
require('functions/helper.php');
Expand Down Expand Up @@ -77,6 +79,8 @@ function get_limit_links($fid) {
}
//如果没有登录,只获取公有链接
else{
// 检查分类是否全私有,如果是,则跳转到登录界面
check_all_cat();
//查询分类目录
$categorys = [];
//查询一级分类目录,分类fid为0的都是一级分类
Expand Down
10 changes: 10 additions & 0 deletions controller/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ function init($data){
if( empty($data['username']) || empty($data['password']) ) {
err_msg(-2000,'用户名或密码不能为空!');
}
// 正则验证用户名
$u_patt = '/^[0-9a-z]{3,32}$/';
if( !preg_match($u_patt,$data['username']) ) {
err_msg(-2000,'用户名格式不正确!');
}
// 正则验证密码
$p_patt = '/^[0-9a-zA-Z!@#%^*.()]{6,16}$/';
if( !preg_match($p_patt,$data['password']) ) {
err_msg(-2000,'密码格式不正确!');
}
$config_file = "data/config.php";
//检查配置文件是否存在,存在则不允许设置
if( file_exists($config_file) ) {
Expand Down
17 changes: 16 additions & 1 deletion data/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,19 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");

20231207
1. 新增技术支持按钮
2. 数据备份页面新增上传备份功能
2. 数据备份页面新增上传备份功能

20240109
1. 修复page参数注入问题
2. init控制器后端过滤username和password
3. imp_link方法只允许删除 .htm 或 .html 文件,避免任意文件删除

20240110
1. 新增辅助函数:check_all_cat() 用于判断分类是否全为私有,全私有则跳转到登录页
2. 升级LayUI版本至 v2.9.3
3. 修复主题有可用更新时,不显示更新提示的BUG
4. 修复baisuTwo主题右键复制无效的问题
5. 默认主题修改为默认隐藏链接描述

20240115
1. PC后台新增:分类数量/链接数量/PHP版本显示
23 changes: 23 additions & 0 deletions functions/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,27 @@ function getCurrentUrlDomain() {

return $domain;

}


/**
* name:检查分类是否全私有,如果是,则跳转到登录界面
*/
function check_all_cat(){
global $db;
// 统计所有分类的数量
$count = $db->count("on_categorys","*");
// 统计私有分类的数量
$count_private = $db->count("on_categorys","*",[
"property" => 1
]);
// 判断数量是否一致,一致则说明全部是私有
if( $count == $count_private ) {
// 判断用户是否登录,未登录则跳转
if( !is_login() ) {
header("Location:/index.php?c=login");
exit;
}

}
}
2 changes: 1 addition & 1 deletion static/layui/css/layui.css

Large diffs are not rendered by default.

Binary file modified static/layui/font/iconfont.eot
Binary file not shown.
Loading

0 comments on commit ebfba6c

Please sign in to comment.