Skip to content

Commit

Permalink
Merge pull request #145 from helloxz/dev
Browse files Browse the repository at this point in the history
0.9.30
  • Loading branch information
helloxz authored May 9, 2023
2 parents bd4f719 + 343b5c2 commit 0ee87ac
Show file tree
Hide file tree
Showing 43 changed files with 1,398 additions and 602 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ OneNav是一款开源免费的书签(导航)管理程序,使用使用PHP +
```bash
docker run -itd --name="onenav" -p 80:80 \
-v /data/onenav:/data/wwwroot/default/data \
helloz/onenav:0.9.25
helloz/onenav:0.9.30
```
* 第一个`80`是自定义访问端口,可以自行修改,第二个`80`是容器端口,请勿修改
* `/data/onenav`:本机挂载目录,用于持久存储Onenav数据
* `0.9.25`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号
* `0.9.30`:改成OneNav最新版本号,可以通过[releases](https://github.com/helloxz/onenav/releases)查看最新版本号

> 更多说明,请参考帮助文档:https://dwz.ovh/onenav
Expand All @@ -71,12 +71,9 @@ ___
* 纽及书签:[http://www.1006788.com/](http://www.1006788.com/)
* DiscoveryNav:[https://nav.miooku.com/](https://nav.miooku.com/)

## 联系我
## OneNav交流群

* Blog:https://www.xiaoz.me/
* QQ:446199062
* QQ群:932795364
* 社区支持:[https://dwz.ovh/vd0bw](https://dwz.ovh/vd0bw)
* [https://dwz.ovh/qxsul](https://dwz.ovh/qxsul)

## 鸣谢

Expand Down
48 changes: 48 additions & 0 deletions class/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,54 @@ public function edit_link($token,$id,$fid,$title,$url,$description = '',$weight
$this->err_msg(-1011,'The URL already exists!');
}
}

/**
* name:单行链接修改
*/
public function edit_link_row(){
//验证授权
$this->auth($token);

// 获取POST请求中的JSON数据
$json_data = file_get_contents('php://input');

// 解析JSON数据为PHP对象
$obj = json_decode($json_data);

$id = intval($obj->id);
$fid = intval($obj->fid);

//查询ID是否存在
$count = $this->db->count('on_links',[ 'id' => $id]);
//如果id不存在
if( (empty($id)) || ($count == false) ) {
$this->err_msg(-1012,'link id not exists!');
}

// 拼接需要更新的数据
$data = [
'title' => trim($obj->title),
'weight' => intval($obj->weight)
];

//插入数据库
$re = $this->db->update('on_links',$data,[ 'id' => $id]);
//返回影响行数
$row = $re->rowCount();
//如果为真
if( $row ){
$id = $this->db->id();
$data = [
'code' => 0,
'msg' => 'successful'
];
exit(json_encode($data));
}
//如果插入失败
else{
$this->err_msg(-1011,'The URL already exists!');
}
}

/**
* 删除链接
Expand Down
2 changes: 1 addition & 1 deletion controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

//如果页面是修改edit_category
if ( $page == 'edit_category' ) {
if ( ($page == 'edit_category') || ($page == 'edit_category_new') ) {
//获取id
$id = intval($_GET['id']);
//查询单条分类信息
Expand Down
8 changes: 8 additions & 0 deletions controller/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ function set_site($api) {
$data['custom_footer'] = $_POST['custom_footer'];
//获取链接模式
$data['link_model'] = $_POST['link_model'];
// 获取链接数量
$data['link_num'] = $_POST['link_num'];
//序列化存储
$value = serialize($data);

Expand Down Expand Up @@ -639,4 +641,10 @@ function site_info() {
function del_link_icon() {
global $api;
$api->del_link_icon();
}

// 修改单行链接
function edit_link_row(){
global $api;
$api->edit_link_row();
}
56 changes: 53 additions & 3 deletions controller/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
/**
* 首页模板入口
*/

//获取当前站点信息
$site = $db->get('on_options','value',[ 'key' => "s_site" ]);
$site = unserialize($site);
// 获取链接数量
$link_num = empty( $site['link_num'] ) ? 20 : intval($site['link_num']);

//如果已经登录,获取所有分类和链接
// 载入辅助函数
require('functions/helper.php');
Expand Down Expand Up @@ -50,6 +57,20 @@ function get_links($fid) {
]);
return $links;
}
//根据category id查询有限链接
function get_limit_links($fid) {
global $db;
global $link_num;
$fid = intval($fid);
$links = $db->select('on_links','*',[
'fid' => $fid,
'ORDER' => ["weight" => "DESC"],
'LIMIT' => $link_num
]);

return $links;
}

//右键菜单标识
$onenav['right_menu'] = 'admin_menu();';
}
Expand Down Expand Up @@ -94,6 +115,7 @@ function get_category_sub($id) {
//根据category id查询链接
function get_links($fid) {
global $db;
global $link_num;
$fid = intval($fid);
$links = $db->select('on_links','*',[
'fid' => $fid,
Expand All @@ -102,10 +124,40 @@ function get_links($fid) {
]);
return $links;
}
//根据category id查询有限链接
function get_limit_links($fid) {
global $db;
$fid = intval($fid);
$links = $db->select('on_links','*',[
'fid' => $fid,
'property' => 0,
'ORDER' => ["weight" => "DESC"],
'LIMIT' => $link_num
]);
return $links;
}
//右键菜单标识
$onenav['right_menu'] = 'user_menu();';
}

// 新增一个可变函数,来根据不同的情况使用不同的方法查询分类下的链接
$get_links = 'get_limit_links';
//获取分类ID
$cid = @$_GET['cid'];

// 如果存在分类ID,则只查询这个分类
if ( !empty($cid) ) {
foreach ($categorys as $key => $tmp) {
if( $tmp['id'] == $cid ) {
$empty_cat[0] = $tmp;
break;
}
}
$get_links = 'get_links';
unset($categorys);
$categorys[0] = $empty_cat[0];
}

//获取版本号
function get_version(){
if( file_exists('version.txt') ) {
Expand Down Expand Up @@ -166,9 +218,7 @@ function base64($url){
exit("<h1>主题参数错误!</h1>");
}
}
//获取当前站点信息
$site = $db->get('on_options','value',[ 'key' => "s_site" ]);
$site = unserialize($site);


//获取主题配置信息
if( file_exists("templates/".$template."/config.json") ) {
Expand Down
19 changes: 18 additions & 1 deletion data/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,21 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
2. 修复360搜索引擎出现的BUG
3. 修复通过分类筛选链接自定义图标不显示问题
4. 修复未登录情况下,API不显示链接列表的BUG
5. heimdall主题新增页脚部分
5. heimdall主题新增页脚部分

20230425
1. 链接ico图标由favicon.rss.ink 替换为 favicon.png.pub
2. 新增baisuNew主题
3. 升级LayUI到 2.8.x(BUG待进一步测试)

20230506
1. 链接列表可以快速修改标题和权重
2. 订阅成功后刷新当前订阅页面
3. 编辑分类改为当前页iframe方式
4. default/baisuNew/baisuTwo/5iux/webstack主题完成 0.9.30 适配改造,优化了链接显示数量
5. 订阅页面检测域名方式优化,去除了带端口号的情况

20230507
1. 修复平板电脑登录时循环重定向的BUG
2. 优化了后台页面,去除了顶部重复按钮,添加了加群按钮
3. 后台左侧导航栏,点击后高亮显示
13 changes: 12 additions & 1 deletion functions/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function jump_mobile() {
$ua = $_SERVER['HTTP_USER_AGENT'];

if( stristr($ua,'iphone') || stristr($ua,'android') ) {
header("Location: /index.php?c=admin");
header("Location: /index.php?c=mobile#/");
exit;
}
}
Expand Down Expand Up @@ -174,4 +174,15 @@ function get_all_themes() {

$tpls = array_unique($tpls);
return $tpls;
}

// 获取HOST,需要去除端口号
function get_host(){
$host = $_SERVER['HTTP_HOST'];
$parsed_host = parse_url($host);
//var_dump($parsed_host);
if (isset($parsed_host['port']) && $parsed_host['port'] != 80 && $parsed_host['port'] != 443) {
$host = $parsed_host['host'];
}
return $host;
}
1 change: 1 addition & 0 deletions static/layui-2.6.8/css/layui.css

Large diffs are not rendered by default.

File renamed without changes.
Binary file added static/layui-2.6.8/font/iconfont.eot
Binary file not shown.
Loading

0 comments on commit 0ee87ac

Please sign in to comment.