Browse Source

20220314

pull/53/head
xiaoz 3 years ago
parent
commit
76a12549c2
  1. 46
      class/Api.php
  2. 12
      controller/api.php
  3. 8
      data/update.log
  4. 11
      functions/helper.php
  5. 7
      templates/admin/click.php
  6. 2
      templates/admin/edit_link.php
  7. 2
      templates/admin/login.php
  8. 15
      templates/admin/static/embed.js
  9. 2
      version.txt

46
class/Api.php

@ -198,6 +198,9 @@ class Api { @@ -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 { @@ -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));
}
/**
* 验证是否登录
*/

12
controller/api.php

@ -168,6 +168,18 @@ function get_link_info($api) { @@ -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);
}
/**
* 获取一个链接的信息,指存储在数据库的信息
*/

8
data/update.log

@ -57,7 +57,9 @@ CREATE INDEX on_options_key_IDX ON on_options ("key"); @@ -57,7 +57,9 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
4. 新增数据库安全检查
5. 新增备用链接功能
6. 新增过渡跳转页面
1. 还没添加自定义js
2. 考虑描述过长要不要隐藏
7. 修复后台链接无法分页问题
1. 还没仔细测试是否有问题
20220312
1. 新增API:根据ID查询单个分类信息
2. 修复后台编辑链接,分类信息显示不正确
3. 书签导入时文件名过滤

11
functions/helper.php

@ -35,3 +35,14 @@ function is_login(){ @@ -35,3 +35,14 @@ function is_login(){
return false;
}
}
//后续全局函数全部以g_命名开头
function g_extend_js() {
//载入js扩展
if( file_exists('data/extend.js') ) {
echo '<script src = "data/extend.js"></script>';
}
else{
echo '';
}
}

7
templates/admin/click.php

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
<link rel="stylesheet" href="https://lib.sinaapp.com/js/bootstrap/4.3.1/css/bootstrap.min.css" type="" media=""/>
<style>
.prevent-overflow{
width:280px;
width:260px;
overflow: hidden;/*超出部分隐藏*/
white-space: nowrap;/*不换行*/
text-overflow:ellipsis;/*超出部分文字以...显示dsds*/
@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
<body>
<div class="container" style = "margin-top:2em;">
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="col-sm-8 offset-sm-2">
<!-- 新建一个表格 -->
<h2>链接信息:</h2>
<table class="table">
@ -92,9 +92,10 @@ @@ -92,9 +92,10 @@
<?php echo $msg; ?>
</div>
<hr>
<div class="xcdn-footer">Powered by <a href="https://www.xiaoz.me/" title = "小z博客" rel = "nofollow" target = "_blank">xiaoz</a></div>
<div class="xcdn-footer">&copy;2022 Powered by <a href="https://www.xiaoz.me/" title = "小z博客" rel = "nofollow" target = "_blank">xiaoz</a></div>
</div>
</div>
</div>
<?php g_extend_js(); ?>
</body>
</html>

2
templates/admin/edit_link.php

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">选择框</label>
<label class="layui-form-label">所属分类</label>
<div class="layui-input-block">
<select name="fid" lay-verify="required" lay-search>
<option value="<?php echo $link['fid'] ?>"><?php echo $cat_name; ?></option>

2
templates/admin/login.php

@ -58,6 +58,6 @@ @@ -58,6 +58,6 @@
<script src = 'https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js'></script>
<script src = 'https://libs.xiaoz.top/layui/v2.5.4/layui.js'></script>
<script src="templates/admin/static/embed.js"></script>
<script src="templates/admin/static/embed.js></script>
</body>
</html>

15
templates/admin/static/embed.js

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
// 2022014
layui.use(['element','table','layer','form','upload'], function(){
var element = layui.element;
var table = layui.table;
@ -345,6 +346,7 @@ layui.use(['element','table','layer','form','upload'], function(){ @@ -345,6 +346,7 @@ layui.use(['element','table','layer','form','upload'], function(){
upload.render({
elem: '#up_html' //绑定元素
,url: 'index.php?c=api&method=upload' //上传接口
,accept:'file'
,exts: 'html|HTML'
,done: function(res){
//console.log(res);
@ -432,7 +434,7 @@ function check_weak_password(){ @@ -432,7 +434,7 @@ function check_weak_password(){
}
//检测数据库是否可能被下载
function check_db_down(){
$("#console_log").append("正则检查数据库是否可被下载...\n");
$("#console_log").append("检查数据库是否可被下载...\n");
$.ajax({
type:"HEAD",
async:false,
@ -485,3 +487,14 @@ function exe_sql(sqlname) { @@ -485,3 +487,14 @@ function exe_sql(sqlname) {
}});
}
//获取GET参数,参考:https://www.runoob.com/w3cnote/js-get-url-param.html
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.16-20220308
v0.9.17-20220314
Loading…
Cancel
Save