Skip to content

Commit

Permalink
Merge pull request #174 from helloxz/dev
Browse files Browse the repository at this point in the history
0.9.33
  • Loading branch information
helloxz authored Dec 7, 2023
2 parents 2410d87 + 11e6761 commit d5003b4
Show file tree
Hide file tree
Showing 13 changed files with 359 additions and 85 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.32
helloz/onenav:0.9.33
```
* 第一个`80`是自定义访问端口,可以自行修改,第二个`80`是容器端口,请勿修改
* `/data/onenav`:本机挂载目录,用于持久存储Onenav数据
* `0.9.32`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号
* `0.9.33`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号

> 更多说明,请参考帮助文档:https://dwz.ovh/onenav
Expand Down
52 changes: 52 additions & 0 deletions class/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,58 @@ public function upload($token,$type){
}
}
}
/**
* name:通用上传接口
* @param1:指定上传路径
* @param2:指定允许的后缀名称,是一个数组
*/
public function general_upload($path,$suffixs){
// 验证权限
$this->auth($token);
// 存在错误,上传失败
if ($_FILES["file"]["error"] > 0)
{
$this->err_msg(-1015,'File upload failed!');
}
else
{
$filename = $_FILES["file"]["name"];
//获取文件后缀
$suffix = explode('.',$filename);
$suffix = strtolower(end($suffix));

//临时文件位置
$temp = $_FILES["file"]["tmp_name"];

// 遍历$suffixs后缀文件,判断是否允许
foreach ($suffixs as $key => $value) {
if( $suffix == $value ) {
$allow = true;
break;
}
}

// 如果是不允许的文件,则删除
if( $allow !== TRUE ) {
//删除临时文件
unlink($filename);
$this->err_msg(-1014,'Unsupported file suffix name!');
}

// 如果是允许的文件,则移动到指定目录,path格式为data/
if( copy($temp,$path.$filename) ) {
$data = [
'code' => 0,
'file_name' => $path.$filename
];
exit(json_encode($data));
}
else{
// 复制文件失败了
$this->err_msg(-2000,'上传失败,请检查' + $path + '目录权限!');
}
}
}

/**
* 图标上传
Expand Down
6 changes: 6 additions & 0 deletions controller/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,4 +661,10 @@ function set_cat_batch() {
function global_search() {
global $api;
$api->global_search();
}

// 上传数据备份文件
function upload_backup(){
global $api;
$api->general_upload('data/backup/',['db3']);
}
11 changes: 10 additions & 1 deletion data/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,13 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
2. 修复查询分类链接要求输入关键词的BUG
3. 修改Medoo默认获取模式为关联数组,避免过多冗余数据
4. 重构OneNav Chrome扩展
5. 后台获取API页面,新增API域名显示
5. 后台获取API页面,新增API域名显示

20231114
1. 优化后台首页信息显示
2. 优化主题商城主题展示效果
3. 修改登录页面静态资源参数被宝塔拦截问题

20231207
1. 新增技术支持按钮
2. 数据备份页面新增上传备份功能
1 change: 1 addition & 0 deletions templates/admin/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<li class="layui-nav-item"><a href="/index.php?c=admin&page=link_list"><i class="layui-icon layui-icon-link"></i> 我的链接</a></li>
<li class="layui-nav-item"><a href="/index.php?c=admin&page=add_link"><i class="layui-icon layui-icon-add-circle-fine"></i> 添加链接</a></li> -->
<li class="layui-nav-item"><a title = "加入OneNav交流群" target = "_blank" href="https://dwz.ovh/qxsul"><i class="layui-icon layui-icon-group"></i> 交流群</a></li>
<li class="layui-nav-item"><a onclick = "support()" title = "请求OneNav技术支持" href="javascript:;"><i class="layui-icon layui-icon-help"></i> 技术支持</a></li>

</ul>
<ul class="layui-nav layui-layout-right">
Expand Down
96 changes: 73 additions & 23 deletions templates/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,93 @@
<div style="padding: 15px;">
<div class="layui-container" style = "margin-top:2em;">
<div class="layui-row layui-col-space18">
<div class="layui-col-lg4">
<div class = "admin-msg">当前版本:<span id = "current_version"><?php echo file_get_contents('version.txt'); ?></span>
<span id = "update_msg" style = "display:none;">(<a style = "color: #FF5722;" href = "https://github.com/helloxz/onenav/releases" title = "下载最新版OneNav" target = "_blank" id="current_version">有可用更新</a>)</span>
</div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>当前版本</h2>
<p class="text">
<span id = "current_version">
<?php echo file_get_contents('version.txt'); ?></span>
<span id = "update_msg" style = "display:none;">(<a style = "color: #FF5722;" href = "https://github.com/helloxz/onenav/releases" title = "下载最新版OneNav" target = "_blank" id="current_version">有可用更新</a>)</span>
</p>
</div>
</div>
<div class="layui-col-lg4">

<div class="layui-col-lg3">
<div class = "admin-msg">
最新版本:<span><span id = "getting">获取中...</span><a href = "https://github.com/helloxz/onenav/releases" title = "下载最新版OneNav" target = "_blank" id="latest_version"></a></span>
(<a href="/index.php?c=admin&page=setting/subscribe" title = "订阅后可一键更新">一键更新</a>)
<h2>最新版本</h2>
<p class="text" id = "new_version">
<i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i>
</p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">交流群:<a target = "_blank" rel = "nofollow" href="https://dwz.ovh/qxsul" title = "点此加入OneNav交流群">https://dwz.ovh/qxsul</a></div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">社区支持:<a href="https://dwz.ovh/vd0bw" rel = "nofollow" target="_blank" title="访问下问社区">https://dwz.ovh/vd0bw</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>交流群</h2>
<p class="text">
<a target = "_blank" rel = "nofollow" href="https://dwz.ovh/qxsul" title = "点此加入OneNav交流群">https://dwz.ovh/qxsul</a>
</p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">项目地址:<a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">https://github.com/helloxz/onenav</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>社区支持</h2>
<p class="text">
<a href="https://dwz.ovh/vd0bw" rel = "nofollow" target="_blank" title="访问下问社区">https://dwz.ovh/vd0bw</a>
</p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">帮助文档:<a href="https://dwz.ovh/onenav" rel = "nofollow" target="_blank">https://dwz.ovh/onenav</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>项目地址</h2>
<p class="text"><a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">https://github.com/helloxz/onenav</a></p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">作者博客: <a href="https://www.xiaoz.me/" rel = "nofollow" target="_blank">https://www.xiaoz.me/</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>帮助文档</h2>
<p class="text"><a href="https://dwz.ovh/onenav" rel = "nofollow" target="_blank">https://dwz.ovh/onenav</a></p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">捐赠地址: <a href="https://dwz.ovh/donation" rel = "nofollow" target="_blank">https://dwz.ovh/donation</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>作者博客</h2>
<p class="text">
<a href="https://blog.xiaoz.org/" rel = "nofollow" target="_blank">https://blog.xiaoz.org/</a>
</p>
</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">Chrome浏览器扩展: <a href="https://dwz.ovh/4kxn2" title = "适用于Chromium内核的浏览器扩展" rel = "nofollow" target="_blank">https://dwz.ovh/4kxn2</a></div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>购买订阅</h2>
<p class="text">
<a href="https://dwz.ovh/69h9q" rel = "nofollow" target="_blank">https://dwz.ovh/69h9q</a>
</p>
</div>
</div>

<div class="layui-col-lg3">
<div class = "admin-msg">
<h2>Chrome浏览器扩展</h2>
<p class="text">
<a href="https://dwz.ovh/4kxn2" title = "适用于Chromium内核的浏览器扩展" rel = "nofollow" target="_blank">https://dwz.ovh/4kxn2</a>
</p>
</div>
</div>

<!-- 日志输出窗口 -->
<div class="layui-col-lg12">
<p><h3 style = "padding-bottom:1em;">日志输出:</h3></p>
<textarea id = "console_log" name="desc" rows="20" placeholder="日志输出控制台" class="layui-textarea" readonly="readonly"></textarea>
<blockquote class="layui-elem-quote" id = "console_log">

</blockquote>
<!-- <textarea id = "console_log" name="desc" rows="20" placeholder="日志输出控制台" class="layui-textarea" readonly="readonly"></textarea> -->
</div>
<!-- 日志输出窗口END -->

Expand Down
2 changes: 1 addition & 1 deletion templates/admin/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ function alt(text) {
</script>
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>'"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
</html>
58 changes: 57 additions & 1 deletion templates/admin/setting/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<li>订阅用户可以对数据库进行本地备份和回滚</li>
<li>备份数据库仅保存最近10份数据</li>
<li>该功能仅辅助备份使用,无法确保100%数据安全,因此定期对整个站点打包备份仍然是必要的</li>
<li>如果您需要迁移数据,步骤为:立即备份 > 下载备份到本地 > 新安装OneNav > 上传备份 > 回滚</li>
</ol>
</div>
</div>
Expand All @@ -27,23 +28,78 @@
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 操作选项END -->

<!-- 头部工具栏 -->
<script type="text/html" id="toolbarheader">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="backup">立即备份</button>

</div>
</script>
<!-- 头部工具栏END -->

<!-- 上传按钮 -->
<div class="upload-backup">
<button type="button" class="layui-btn layui-btn-sm upload-bakcup" lay-options="{accept: 'file'}">
<i class="layui-icon layui-icon-upload"></i>
上传备份
</button>
</div>
<!-- 上传按钮END -->

</div>


</div>
</div>


<?php include_once(dirname(__DIR__).'/footer.php'); ?>

<script>
layui.use(['table'],function(){
layui.use(['table','upload'],function(){
var table = layui.table;
var upload = layui.upload;
// 渲染上传
// 渲染
upload.render({
elem: '.upload-bakcup', // 绑定多个元素
url: '/index.php?c=api&method=upload_backup', // 设置上传接口
accept: 'file', // 普通文件
exts:'db3', // 允许的后缀
before: function(obj){ // 选择文件后
layer.load();
var files = obj.pushFile();
let file = Object.values(files)[0];

// 得到文件名
let name = file.name;
// 正则判断文件名是否符合规范,文件名格式如:onenav_202312071528_0.9.32.db3
let reg = /^onenav_[0-9]{12}_[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}\.db3$/;
if( !reg.test(name) ) {
layer.msg('文件格式不正确!',{icon:5});
// 关闭loading
layer.closeAll('loading');
return false;
}

},
done: function(res){
layer.msg('上传成功!',{icon:1});
table.reload('tableid', {
where: { //设定异步数据接口的额外参数,任意设
aaaaaa: 'xxx'
}
});

layer.closeAll('loading');
},
error: function(index, upload){
layer.msg('上传出错!',{icon:5});
layer.closeAll('loading');
}
});

// 渲染表格
table.render({
elem: '#mytable'
Expand Down
Loading

0 comments on commit d5003b4

Please sign in to comment.