From 47b10a61bc85bd95f188e8f4296eb72f80a27997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=9D=E5=8D=97=E5=90=B4=E5=BD=A6=E7=A5=96?= <9258405@qq.com> Date: Fri, 17 Jun 2022 20:56:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9B=B4=E9=93=BE=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.simple.php | 4 ++- controller/api.php | 2 ++ controller/index.php | 43 ++++++++++++++++++++++++++------ templates/admin/setting/site.php | 7 +++++- templates/default/index.php | 2 +- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/config.simple.php b/config.simple.php index 19684a0..4a39c5f 100755 --- a/config.simple.php +++ b/config.simple.php @@ -23,11 +23,13 @@ $site_setting = []; //站点标题 $site_setting['title'] = 'OneNav'; //文字Logo -$site_setting['logo'] = 'OneNav'; +$site_setting['logo'] = 'OneNav'; //站点关键词 $site_setting['keywords'] = 'OneNav,OneNav导航,OneNav书签,开源导航,开源书签,简洁导航,云链接,个人导航,个人书签'; //站点描述 $site_setting['description'] = 'OneNav是一款使用PHP + SQLite3开发的简约导航/书签管理器,免费开源。'; +//直链 +$site_setting['straight'] = ''; //这两项不要修改 $site_setting['user'] = USER; diff --git a/controller/api.php b/controller/api.php index 439c64a..ebf33e2 100755 --- a/controller/api.php +++ b/controller/api.php @@ -295,6 +295,8 @@ function set_site($api) { $data['subtitle'] = htmlspecialchars($_POST['subtitle']); //获取关键词 $data['keywords'] = htmlspecialchars($_POST['keywords']); + //获取是否直链 + $data['straight'] = htmlspecialchars($_POST['straight']); //获取描述 $data['description'] = htmlspecialchars($_POST['description']); //获取自定义header diff --git a/controller/index.php b/controller/index.php index 078079b..0a150e6 100755 --- a/controller/index.php +++ b/controller/index.php @@ -22,7 +22,7 @@ if( is_login() ){ "fid" => $value['id'], "ORDER" => ["weight" => "DESC"] ]); - + foreach ($category_subs as $category_sub) { array_push($categorys,$category_sub); } @@ -44,11 +44,11 @@ if( is_login() ){ function get_links($fid) { global $db; $fid = intval($fid); - $links = $db->select('on_links','*',[ + $links = $db->select('on_links','*',[ 'fid' => $fid, 'ORDER' => ["weight" => "DESC"] ]); - return $links; + return handle_link($links); } //右键菜单标识 $onenav['right_menu'] = 'admin_menu();'; @@ -73,7 +73,7 @@ else{ 'property' => 0, "ORDER" => ["weight" => "DESC"] ]); - + foreach ($category_subs as $category_sub) { array_push($categorys,$category_sub); } @@ -95,17 +95,44 @@ else{ function get_links($fid) { global $db; $fid = intval($fid); - $links = $db->select('on_links','*',[ + $links = $db->select('on_links','*',[ 'fid' => $fid, 'property' => 0, 'ORDER' => ["weight" => "DESC"] ]); - return $links; + return handle_link($links); } //右键菜单标识 $onenav['right_menu'] = 'user_menu();'; } - +//处理得到的转换链接数据 +function handle_link($data) +{ + if (empty($data)) { + return $data; + } + global $db; + $site = $db->get('on_options', 'value', ['key' => "s_site"]); + $site = unserialize($site); + $type = 1; //模式1 原链接 + if (! empty($site['straight']) && $site['straight'] == "open") { + //有且只有开关的时候 才处理 + $type = 2; //模式2 新链接 + } + $hrefLink = ""; + foreach ($data as &$value) { + switch ($type) { + case "1": + $hrefLink = "/index.php?c=click&id=" . $value['id']; + break; + case "2": + $hrefLink = $value['url']; + break; + } + $value['href_link'] = $hrefLink; + } + return $data; +} //获取版本号 function get_version(){ if( file_exists('version.txt') ) { @@ -116,7 +143,7 @@ function get_version(){ $version = 'null'; return $version; } -} +} //将URL转换为base64编码 function base64($url){ diff --git a/templates/admin/setting/site.php b/templates/admin/setting/site.php index 6e0f8ff..77e36a1 100644 --- a/templates/admin/setting/site.php +++ b/templates/admin/setting/site.php @@ -50,7 +50,12 @@ - +