Browse Source

Merge pull request #174 from helloxz/dev

0.9.33
main 0.9.33
xiaoz 12 months ago committed by GitHub
parent
commit
d5003b44e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.md
  2. 52
      class/Api.php
  3. 6
      controller/api.php
  4. 9
      data/update.log
  5. 1
      templates/admin/header.php
  6. 90
      templates/admin/index.php
  7. 2
      templates/admin/login.php
  8. 58
      templates/admin/setting/backup.php
  9. 57
      templates/admin/setting/theme.php
  10. 58
      templates/admin/static/embed.js
  11. 67
      templates/admin/static/style.css
  12. 0
      templates/index.html
  13. 2
      version.txt

4
README.md

@ -53,11 +53,11 @@ OneNav是一款开源免费的书签(导航)管理程序,使用使用PHP + @@ -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

52
class/Api.php

@ -566,6 +566,58 @@ class Api { @@ -566,6 +566,58 @@ class Api {
}
}
}
/**
* 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 + '目录权限!');
}
}
}
/**
* 图标上传

6
controller/api.php

@ -662,3 +662,9 @@ function global_search() { @@ -662,3 +662,9 @@ function global_search() {
global $api;
$api->global_search();
}
// 上传数据备份文件
function upload_backup(){
global $api;
$api->general_upload('data/backup/',['db3']);
}

9
data/update.log

@ -249,3 +249,12 @@ CREATE INDEX on_options_key_IDX ON on_options ("key"); @@ -249,3 +249,12 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
3. 修改Medoo默认获取模式为关联数组,避免过多冗余数据
4. 重构OneNav Chrome扩展
5. 后台获取API页面,新增API域名显示
20231114
1. 优化后台首页信息显示
2. 优化主题商城主题展示效果
3. 修改登录页面静态资源参数被宝塔拦截问题
20231207
1. 新增技术支持按钮
2. 数据备份页面新增上传备份功能

1
templates/admin/header.php

@ -27,6 +27,7 @@ @@ -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">

90
templates/admin/index.php

@ -7,43 +7,93 @@ @@ -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>
<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 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 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>
<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 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>
<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://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://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://dwz.ovh/onenav" rel = "nofollow" target="_blank">https://dwz.ovh/onenav</a></p>
</div>
</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-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 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>
<!-- 日志输出窗口 -->
<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 -->

2
templates/admin/login.php

@ -100,5 +100,5 @@ @@ -100,5 +100,5 @@
</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
templates/admin/setting/backup.php

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
<li>订阅用户可以对数据库进行本地备份和回滚</li>
<li>备份数据库仅保存最近10份数据</li>
<li>该功能仅辅助备份使用,无法确保100%数据安全,因此定期对整个站点打包备份仍然是必要的</li>
<li>如果您需要迁移数据,步骤为:立即备份 > 下载备份到本地 > 新安装OneNav > 上传备份 > 回滚</li>
</ol>
</div>
</div>
@ -27,14 +28,28 @@ @@ -27,14 +28,28 @@
<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>
@ -42,8 +57,49 @@ @@ -42,8 +57,49 @@
<?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'

57
templates/admin/setting/theme.php

@ -16,22 +16,26 @@ @@ -16,22 +16,26 @@
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<div class="layui-row layui-col-space24">
<!-- 主题列表new -->
<?php foreach ($themes as $key => $theme) {
//var_dump($theme['info']->name);
?>
<!-- 主题列表 -->
<div class="layui-col-lg3 layui-col-md6 layui-col-sm12">
<fieldset style = "padding:1em;border:0px;height:280px;border:1px dashed #1E9FFF;box-shadow: 2px 2px 3px #888888;color:#666666">
<legend style = "font-size:24px;" id="<?php echo $key; ?>">
<div class="layui-col-md3">
<div class="layui-card custom-card">
<div class="layui-card-header">
<?php echo $key; ?> - <?php echo $theme['info']->version ?>
<span class="renewable" style="color:#FF5722;font-size:14px;"></span>
</legend>
<?php if( $current_them == $key ) { ?>
<span style = "color:#ff5722;">(使用中)</span>
<?php } ?>
</div>
<div class="layui-card-body">
<!-- 主题图片 -->
<div class = "screenshot"><p><img layer-src="<?php echo $theme['info']->screenshot; ?>" src="<?php echo $theme['info']->screenshot; ?>" alt=""></p></div>
<!-- 主题图片END -->
<p>
<hr>
<div class = "thme-btns">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" onclick = "set_theme('<?php echo $key; ?>')">使用</button>
<button type="button" class="layui-btn layui-btn-sm" onclick = "theme_detail('<?php echo $key; ?>')">详情</button>
@ -39,16 +43,15 @@ @@ -39,16 +43,15 @@
<button type="button" class="layui-btn layui-btn-sm" onclick = "update_theme('<?php echo $key; ?>','<?php echo $theme['info']->version; ?>')">更新</button>
<a class="layui-btn layui-btn-sm" target = "_blank" href="/index.php?theme=<?php echo $key; ?>">预览</a>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick = "delete_theme('<?php echo $key; ?>')">删除</button>
<?php if( $current_them == $key ) { ?>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger">当前</button>
<?php } ?>
</div>
</div>
</div>
</p>
</fieldset>
</div>
<!-- 主题列表END -->
</div>
<?php } ?>
<!-- 主题列表new END -->
</div>
</div>
<hr>
@ -60,22 +63,28 @@ @@ -60,22 +63,28 @@
//var_dump($theme['info']->name);
?>
<!-- 在线主题列表 -->
<div class="layui-col-lg3 layui-col-md6 layui-col-sm12">
<fieldset style = "padding:1em;border:0px;height:280px;border:1px dashed #1E9FFF;box-shadow: 2px 2px 3px #888888;color:#666666">
<legend style = "font-size:24px;"><?php echo $key; ?> - <?php echo $theme->version ?></legend>
<div class="layui-col-md3">
<div class="layui-card custom-card">
<div class="layui-card-header">
<?php echo $key; ?> - <?php echo $theme->version ?>
</div>
<div class="layui-card-body">
<!-- 主题图片 -->
<div class = "screenshot"><p><img layer-src="<?php echo $theme->screenshot; ?>" src="<?php echo $theme->screenshot; ?>" alt=""></p></div>
<div class = "screenshot">
<p><img layer-src="<?php echo $theme->screenshot; ?>" src="<?php echo $theme->screenshot; ?>" alt=""></p>
</div>
<!-- 主题图片END -->
<p>
<hr>
<div class = "thme-btns">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" onclick = "down_theme('<?php echo $key; ?>','download')">下载</button>
<a class="layui-btn layui-btn-sm" title = "查看<?php echo $key; ?>演示" target = "_blank" href="https://nav.rss.ink/index.php?theme=<?php echo $key; ?>">查看演示</a>
<!-- <button type="button" class="layui-btn layui-btn-sm" onclick = "theme_detail_online('<?php echo $key; ?>')">详情</button> -->
</div>
</p>
</fieldset>
</div>
</div>
</div>
</div>
<!-- 主题列表END -->
<?php } ?>

58
templates/admin/static/embed.js

@ -976,17 +976,17 @@ function check_weak_password(){ @@ -976,17 +976,17 @@ function check_weak_password(){
}
//检测数据库是否可能被下载
function check_db_down(){
$("#console_log").append("检查数据库是否可被下载...\n");
$("#console_log").append("检查数据库是否可被下载...<br />");
$.ajax({
type:"HEAD",
async:false,
url:"/data/onenav.db3",
statusCode: {
200: function() {
$("#console_log").append("危险!!!危险!!!危险!!!数据库可被下载,请尽快参考帮助文档:https://dwz.ovh/jvr2t 加固安全设置!\n\n");
$("#console_log").append("危险!!!危险!!!危险!!!数据库可被下载,请尽快参考帮助文档:https://dwz.ovh/jvr2t 加固安全设置!<br /><br />");
},
403:function() {
$("#console_log").append("您的数据库看起来是安全的!\n\n");
$("#console_log").append("您的数据库看起来是安全的!<br />");
}
}
});
@ -995,18 +995,19 @@ function check_db_down(){ @@ -995,18 +995,19 @@ function check_db_down(){
//获取待更新数据库列表,http://onenav.com/index.php?c=api&method=exe_sql&name=on_db_logs.sql
function get_sql_update_list() {
$("#console_log").append("正在检查数据库更新...\n");
$("#console_log").append("----------------------------------------------------------------------<br />");
$("#console_log").append("正在检查数据库更新...<br />");
$.get("index.php?c=api&method=get_sql_update_list",function(data,status){
if ( data.code == 0 ) {
//如果没有可用更新,直接结束
if ( data.data.length == 0 ) {
$("#console_log").append("当前无可用更新!\n");
$("#console_log").append("当前无可用更新!<br />");
return false;
}
else{
$("#console_log").append("检查到可更新SQL列表:\n");
$("#console_log").append("正在准备更新...\n");
$("#console_log").append("检查到可更新SQL列表:<br />");
$("#console_log").append("正在准备更新...<br />");
for(i in data.data) {
sqlname = data.data[i];
//$("#console_log").append(data.data[i] + "\n");
@ -1045,12 +1046,20 @@ function getQueryVariable(variable) @@ -1045,12 +1046,20 @@ function getQueryVariable(variable)
function get_latest_version(){
$.post("/index.php?c=api&method=get_latest_version",function(data,status){
//console.log(data.data);
$("#getting").hide();
//获取最新版本
let latest_version = data.data;
$("#latest_version").text(latest_version);
// 改变显示内容
let new_version = `
<a href="https://github.com/helloxz/onenav/releases" title="下载最新版OneNav" target="_blank" id="latest_version">${latest_version}</a>
[<a href="/index.php?c=admin&page=setting/subscribe" title="订阅后可一键更新">一键更新</a>]
`;
$("#new_version").html(new_version);
$("#new_version").show();
//获取当前版本
let current_version = $("#current_version").text();
@ -1203,3 +1212,36 @@ $(document).ready(function() { @@ -1203,3 +1212,36 @@ $(document).ready(function() {
}
});
});
// 获取当前域名
function getCurrentDomain() {
// 获取协议(包括末尾的冒号和斜杠)
var protocol = window.location.protocol;
// 获取域名
var hostname = window.location.hostname;
// 获取端口号
var port = window.location.port;
// 检查端口号是否为80或443,并相应地调整URL
if (port === "80" || port === "443" || port === "") {
return protocol + "//" + hostname;
} else {
return protocol + "//" + hostname + ":" + port;
}
}
// 技术支持函数
function support() {
let domain = getCurrentDomain();
let description = "域名:" + domain;
let support_url = "https://support.xiuping.net/service/index?lang=zh_CN&product_id=1&description=" + description;
layer.open({
type: 2,
title: false,
shadeClose: true,
shade: 0.8,
area: ['700px', '780px'],
content: support_url // iframe 的 url
});
}

67
templates/admin/static/style.css

@ -62,15 +62,28 @@ @@ -62,15 +62,28 @@
display: none;
}
.admin-msg{
background-color: #f2f2f2;
line-height: 14px;
padding:1em;
padding: 16px;
background-color: #F8F8F8;
border-radius: 5px;
color:#888888;
color: #999;
height:56px;
}
.admin-msg:hover{
background-color: #eeeeee;
/*榧犳爣鍙樻垚灏忔墜*/
cursor: pointer;
}
.admin-msg a{
color:#01AAED;
}
.admin-msg h2{
font-size:18px;
color:#16b777;
}
.admin-msg .text{
padding:14px 0 2px 0;
}
/* 上传按钮 */
#up_html{
margin-left:auto;
@ -135,13 +148,17 @@ @@ -135,13 +148,17 @@
.place-holder{
padding-bottom: 3em;
}
.screenshot {
/* .screenshot {
height:220px;
}
} */
.screenshot img{
max-width: auto;
max-height: 200px;
max-width:96%;
width: 100%;
height:240px;
/*自动裁剪图片*/
object-fit: cover;
border-radius: 3px;
/*鼠标移动到上面变成小手*/
cursor: pointer;
}
#progress{
@ -159,3 +176,35 @@ @@ -159,3 +176,35 @@
height: 38px;
width: 38px;
}
.custom-card {
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.06); /* 更细微的阴影 */
transition: 0.3s;
border-radius: 10px; /* 圆角边框 */
background-color: #f9f9f9; /* 非常淡的灰色背景 */
}
.custom-card:hover {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.1);
transform: scale(1.03); /* 稍微缩放的悬停效果 */
}
.layui-card-header {
font-weight: bold; /* 自定义标题样式 */
color: #333; /* 字体颜色 */
font-size: 16px;
}
.layui-card-body {
color: #333; /* 内容字体颜色 */
font-size: 14px; /* 字体大小 */
}
.thme-btns {
text-align: center;
padding:6px 0 6px 0;
}
.upload-backup{
margin-top: 16px;
}

0
templates/index.html

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.32-20230714
v0.9.33-20231207
Loading…
Cancel
Save