diff --git a/class/Api.php b/class/Api.php index ed5e9f4..c30d39b 100755 --- a/class/Api.php +++ b/class/Api.php @@ -198,6 +198,9 @@ class Api { * 批量导入链接 */ public function imp_link($token,$filename,$fid,$property = 0){ + //过滤$filename + $filename = str_replace('../','',$filename); + $filename = str_replace('./','',$filename); $this->auth($token); //检查文件是否存在 if ( !file_exists($filename) ) { @@ -549,6 +552,49 @@ class Api { } exit(json_encode($datas)); } + /** + * 查询单个分类信息 + * 此函数接收一个数组 + */ + public function get_a_category($data) { + $id = $data['id']; + $token = $data['token']; + + $category_info = $this->db->get("on_categorys","*",[ + "id" => $id + ]); + + //var_dump($category_info); + + //如果是公开分类,则直接返回 + if ( $category_info['property'] == "0" ) { + $datas = [ + 'code' => 0, + 'data' => $category_info + ]; + + } + //如果是私有链接,并且认证通过 + elseif( $category_info['property'] == "1" ) { + if ( ( $this->auth($token) ) || ( $this->is_login() ) ) { + $datas = [ + 'code' => 0, + 'data' => $category_info + ]; + } + + //exit(json_encode($datas)); + } + //如果是其它情况,则显示为空 + else{ + $datas = [ + 'code' => 0, + 'data' => [] + ]; + //exit(json_encode($datas)); + } + exit(json_encode($datas)); + } /** * 验证是否登录 */ diff --git a/controller/api.php b/controller/api.php index fbf9946..d8c017a 100755 --- a/controller/api.php +++ b/controller/api.php @@ -168,6 +168,18 @@ function get_link_info($api) { $api->get_link_info($token,$url); } +/** + * 根据ID获取单个分类信息 + */ +function get_a_category($api) { + //获取token + $data['token'] = @$_POST['token']; + //获取分类ID + $data['id'] = intval(trim($_POST['id'])); + //var_dump($data); + $api->get_a_category($data); +} + /** * 获取一个链接的信息,指存储在数据库的信息 */ diff --git a/data/update.log b/data/update.log index 5d0aa01..412b1c1 100755 --- a/data/update.log +++ b/data/update.log @@ -57,7 +57,9 @@ CREATE INDEX on_options_key_IDX ON on_options ("key"); 4. 新增数据库安全检查 5. 新增备用链接功能 6. 新增过渡跳转页面 - 1. 还没添加自定义js - 2. 考虑描述过长要不要隐藏 7. 修复后台链接无法分页问题 - 1. 还没仔细测试是否有问题 \ No newline at end of file + +20220312 +1. 新增API:根据ID查询单个分类信息 +2. 修复后台编辑链接,分类信息显示不正确 +3. 书签导入时文件名过滤 \ No newline at end of file diff --git a/functions/helper.php b/functions/helper.php index 8f571e3..106a6db 100755 --- a/functions/helper.php +++ b/functions/helper.php @@ -34,4 +34,15 @@ function is_login(){ else{ return false; } +} + +//后续全局函数全部以g_命名开头 +function g_extend_js() { + //载入js扩展 + if( file_exists('data/extend.js') ) { + echo ''; + } + else{ + echo ''; + } } \ No newline at end of file diff --git a/templates/admin/click.php b/templates/admin/click.php index 01de2dd..1c7c719 100755 --- a/templates/admin/click.php +++ b/templates/admin/click.php @@ -9,7 +9,7 @@