Browse Source

Merge pull request #119 from helloxz/dev

0.9.28
main 0.9.28
xiaoz 2 years ago committed by GitHub
parent
commit
1f4b482dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .htaccess
  2. 134
      class/Api.php
  3. 20
      controller/api.php
  4. 2
      controller/click.php
  5. 67
      controller/index.php
  6. 7
      data/update.log
  7. BIN
      db/onenav.simple.db3
  8. 1
      db/sql/20221129.sql
  9. 66
      functions/helper.php
  10. BIN
      static/images/default.png
  11. BIN
      static/images/white64.png
  12. 10
      templates/admin/add_category.php
  13. 28
      templates/admin/add_link.php
  14. 10
      templates/admin/edit_category.php
  15. 40
      templates/admin/edit_link.php
  16. 5
      templates/admin/footer.php
  17. 5
      templates/admin/header.php
  18. 1
      templates/admin/imp_link.php
  19. 1
      templates/admin/setting/share.php
  20. 8
      templates/admin/setting/site.php
  21. 1
      templates/admin/setting/subscribe.php
  22. 4
      templates/admin/setting/theme.php
  23. 165
      templates/admin/static/embed.js
  24. 11
      templates/admin/static/style.css
  25. 2
      templates/universal/assets/index.css
  26. 12
      templates/universal/assets/index.js
  27. 2
      version.txt

1
.htaccess

@ -1,5 +1,4 @@
RewriteEngine On RewriteEngine On
RewriteRule '^click\/(.*)$' /index.php?c=click&id=$1 [L] RewriteRule '^click\/(.*)$' /index.php?c=click&id=$1 [L]
RewriteRule '^api\/(.*)?(.*)$' /index.php?c=api&method=$1&$2 [L] RewriteRule '^api\/(.*)?(.*)$' /index.php?c=api&method=$1&$2 [L]
RewriteRule login /index.php?c=login [NC,L]
RewriteRule .*.(db3|rar|gz|json)$ - [F] RewriteRule .*.(db3|rar|gz|json)$ - [F]

134
class/Api.php

@ -176,7 +176,9 @@ class Api {
$token_yes = md5(USER.$SecretKey); $token_yes = md5(USER.$SecretKey);
//获取header中的X-token //获取header中的X-token
$xtoken = $_SERVER['HTTP_X_TOKEN']; $xtoken = $_SERVER['HTTP_X_TOKEN'];
if( $xtoken === $token_yes ) {
//如果通过header传递token,且验证通过
if( !empty($xtoken) && ($xtoken === $token_yes) ) {
return TRUE; return TRUE;
} }
//如果token为空,则验证cookie //如果token为空,则验证cookie
@ -204,7 +206,7 @@ class Api {
/** /**
* name:添加链接 * name:添加链接
*/ */
public function add_link($token,$fid,$title,$url,$description = '',$weight = 0,$property = 0,$url_standby = ''){ public function add_link($token,$fid,$title,$url,$description = '',$weight = 0,$property = 0,$url_standby = '',$font_icon = ''){
$this->auth($token); $this->auth($token);
$fid = intval($fid); $fid = intval($fid);
//检测链接是否合法 //检测链接是否合法
@ -227,6 +229,11 @@ class Api {
'weight' => $weight, 'weight' => $weight,
'property' => $property 'property' => $property
]; ];
//如果$font_icon不为空,才一起追加写入数据库
if( !empty($font_icon) ) {
$data['font_icon'] = $font_icon;
}
//插入数据库 //插入数据库
$re = $this->db->insert('on_links',$data); $re = $this->db->insert('on_links',$data);
//返回影响行数 //返回影响行数
@ -531,6 +538,75 @@ class Api {
} }
} }
} }
/**
* 图标上传
* type:上传类型
*/
public function uploadImages($token){
$this->auth($token);
//获取icon名称
$icon_name = $_POST['icon_name'];
//获取老文件名称,然后删除
$old_pic = $_POST['old_pic'];
//如果老文件名称合法,则删除
$pattern = "/^data\/upload\/[0-9]+\/[0-9a-zA-Z]+\.(jpg|jpeg|png|bmp|gif|svg)$/";
//如果名称不合法,则终止执行
if( preg_match($pattern,$old_pic) ){
@unlink($old_pic);
}
//如果名称是空的
if( empty($icon_name) ) {
$this->return_json(-2000,'','获取图标名称失败!');
}
if ($_FILES["file"]["error"] > 0)
{
//$this->err_msg(-1015,'File upload failed!');
$this->return_json(-2000,'','File upload failed!');
}
else
{
//根据时间生成文件名
$filename = $_FILES["file"]["name"];
//获取文件后缀
$suffix = explode('.',$filename);
$suffix = strtolower(end($suffix));
//临时文件位置
$temp = $_FILES["file"]["tmp_name"];
if( $suffix != 'ico' && $suffix != 'jpg' && $suffix != 'jpeg' && $suffix != 'png' && $suffix != 'bmp' && $suffix != 'gif' && $suffix != 'svg' ) {
//删除临时文件
@unlink($filename);
@unlink($temp);
$this->return_json(-2000,'','Unsupported file suffix name!');
}
//上传路径,格式为data/upload/202212/1669689755.png
$upload_path = "data/upload/".date( "Ym", time() ).'/'.$icon_name.'.'.$suffix;
//如果目录不存在,则创建
$upload_dir = dirname($upload_path);
if( !is_dir( $upload_dir ) ) {
//递归创建目录
mkdir($upload_dir,0755,true);
}
//$newfilename = 'upload/'.time().'.'.$suffix;
//移动临时文件到指定上传路径
if( move_uploaded_file($temp,$upload_path) ) {
$data = [
'file_name' => $upload_path
];
$this->return_json(200,$data,'success');
}
else{
$this->return_json(-2000,'','上传失败,请检查目录权限!');
}
}
}
/** /**
* 导出HTML链接进行备份 * 导出HTML链接进行备份
*/ */
@ -568,9 +644,15 @@ class Api {
/** /**
* name:修改链接 * name:修改链接
*/ */
public function edit_link($token,$id,$fid,$title,$url,$description = '',$weight = 0,$property = 0,$url_standby = ''){ public function edit_link($token,$id,$fid,$title,$url,$description = '',$weight = 0,$property = 0,$url_standby = '',$font_icon = ''){
$this->auth($token); $this->auth($token);
$fid = intval($fid); $fid = intval($fid);
/**
* name:获取更新类型
* description:主要是因为兼容部分之前老的接口,老的接口不用变动,只能从OneNav后台添加图标,因此增加type判断是否是OneNav后台
* console:指从OneNav后台进行更新
*/
$type = trim($_GET['type']);
//检测链接是否合法 //检测链接是否合法
//$this->check_link($fid,$title,$url); //$this->check_link($fid,$title,$url);
$this->check_link([ $this->check_link([
@ -596,6 +678,14 @@ class Api {
'weight' => $weight, 'weight' => $weight,
'property' => $property 'property' => $property
]; ];
if( !empty($font_icon) ) {
$data['font_icon'] = $font_icon;
}
//如果是从OneNav后台更新,则无论如何都要加上font_icon
if( $type === 'console' ) {
$data['font_icon'] = $font_icon;
}
//插入数据库 //插入数据库
$re = $this->db->update('on_links',$data,[ 'id' => $id]); $re = $this->db->update('on_links',$data,[ 'id' => $id]);
//返回影响行数 //返回影响行数
@ -824,9 +914,9 @@ class Api {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}"; $sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
} }
//通过header获取token成功 //通过header获取token成功
else if( $this->auth("") ) { // else if( $this->auth("") ) {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}"; // $sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
} // }
//如果token验证通过 //如果token验证通过
elseif( (!empty($token)) && ($this->auth($token)) ) { elseif( (!empty($token)) && ($this->auth($token)) ) {
@ -2184,5 +2274,37 @@ class Api {
$this->return_json(200,$site,'success'); $this->return_json(200,$site,'success');
} }
/**
* name:删除链接图标
*/
public function del_link_icon(){
//验证授权
$this->auth($token);
//获取图标路径
$icon_path = trim($_POST['icon_path']);
//正则判断路径是否合法
$pattern = "/^data\/upload\/[0-9]+\/[0-9a-zA-Z]+\.(jpg|jpeg|png|bmp|gif|svg)$/";
//如果名称不合法,则终止执行
if( !preg_match($pattern,$icon_path) ){
$this->return_json(-2000,'','非法路径!');
}
//继续执行
//检查图标是否存在
if( !is_file($icon_path) ) {
$this->return_json(-2000,'','图标文件不存在,无需删除!');
}
//执行删除操作
if( unlink($icon_path) ) {
$this->return_json(200,'','success');
}
else{
$this->return_json(-2000,'','图标删除失败,请检查目录权限!');
}
}
} }

20
controller/api.php

@ -107,8 +107,9 @@ function add_link($api){
$description = empty($_POST['description']) ? '' : $_POST['description']; $description = empty($_POST['description']) ? '' : $_POST['description'];
$weight = empty($_POST['weight']) ? 0 : intval($_POST['weight']); $weight = empty($_POST['weight']) ? 0 : intval($_POST['weight']);
$property = empty($_POST['property']) ? 0 : 1; $property = empty($_POST['property']) ? 0 : 1;
$font_icon = empty($_POST['font_icon']) ? '' : $_POST['font_icon'];
$api->add_link($token,$fid,$title,$url,$description,$weight,$property,$url_standby); $api->add_link($token,$fid,$title,$url,$description,$weight,$property,$url_standby,$font_icon);
} }
/** /**
@ -128,8 +129,9 @@ function edit_link($api){
$description = empty($_POST['description']) ? '' : $_POST['description']; $description = empty($_POST['description']) ? '' : $_POST['description'];
$weight = empty($_POST['weight']) ? 0 : intval($_POST['weight']); $weight = empty($_POST['weight']) ? 0 : intval($_POST['weight']);
$property = empty($_POST['property']) ? 0 : 1; $property = empty($_POST['property']) ? 0 : 1;
$font_icon = empty($_POST['font_icon']) ? '' : $_POST['font_icon'];
$api->edit_link($token,$id,$fid,$title,$url,$description,$weight,$property,$url_standby); $api->edit_link($token,$id,$fid,$title,$url,$description,$weight,$property,$url_standby,$font_icon);
} }
@ -239,6 +241,14 @@ function upload($api){
$type = $_GET['type']; $type = $_GET['type'];
$api->upload($token,$type); $api->upload($token,$type);
} }
// 上传图标
function uploadImages(){
global $api;
//获取token
$token = empty( $_POST['token'] ) ? $_GET['token'] : $_POST['token'];
//获取上传类型
$api->uploadImages($token);
}
//书签导入 //书签导入
function imp_link($api) { function imp_link($api) {
//获取token //获取token
@ -624,3 +634,9 @@ function site_info() {
global $api; global $api;
$api->site_info(); $api->site_info();
} }
//删除图标
function del_link_icon() {
global $api;
$api->del_link_icon();
}

2
controller/click.php

@ -13,7 +13,7 @@ if(empty($id)) {
} }
//查询链接信息 //查询链接信息
$link = $db->get('on_links',['id','fid','url','url_standby','property','click','title','description'],[ $link = $db->get('on_links',['id','fid','url','url_standby','property','click','title','description','font_icon'],[
'id' => $id 'id' => $id
]); ]);

67
controller/index.php

@ -149,12 +149,28 @@ else{
$template = $db->get("on_options","value",[ $template = $db->get("on_options","value",[
"key" => "theme" "key" => "theme"
]); ]);
//获取用户传递的主题参数
$theme = trim( @$_GET['theme'] );
//如果用户传递了主题参数
if( !empty($theme) ) {
//获取所有主题
$themes = get_all_themes();
//查找主题是否存在
if( array_search($theme,$themes) !== FALSE ) {
//改变默认主题
$template = $theme;
}
else{
//主题不存在,终止执行
exit("<h1>主题参数错误!</h1>");
}
}
//获取当前站点信息 //获取当前站点信息
$site = $db->get('on_options','value',[ 'key' => "s_site" ]); $site = $db->get('on_options','value',[ 'key' => "s_site" ]);
$site = unserialize($site); $site = unserialize($site);
//获取主题配置信息 //获取主题配置信息
//获取主题配置
if( file_exists("templates/".$template."/config.json") ) { if( file_exists("templates/".$template."/config.json") ) {
$config_file = "templates/".$template."/config.json"; $config_file = "templates/".$template."/config.json";
} }
@ -189,6 +205,53 @@ else{
$tpl_dir = 'data/templates/'; $tpl_dir = 'data/templates/';
} }
//定义搜索引擎
$search_engines = [
"baidu" => [
"name" => "百度",
"url" => "https://www.baidu.com/s?ie=utf-8&word="
],
"google" => [
"name" => "Google",
"url" => "https://www.google.com/search?q="
],
"bing" => [
"name" => "必应",
"url" => "https://cn.bing.com/search?FORM=BESBTB&q="
],
"sogou" => [
"name" => "搜狗",
"url" => "https://www.sogou.com/web?query="
],
"360" => [
"name" => "360搜索",
"url" => "https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&ssid=&q="
],
"zhihu" => [
"name" => "知乎",
"url" => "https://www.zhihu.com/search?type=content&q="
],
"weibo" => [
"name" => "微博",
"url" => "https://s.weibo.com/weibo?q="
]
];
//获取主题的最低版本要求
$info_json = @file_get_contents($tpl_dir.$template."/info.json");
if( $info_json ) {
$info = json_decode($info_json);
$min_version = @$info->require->min;
//获取到了最低版本
if( !empty($min_version) ) {
//如果主程序不满足主题要求
if( new_get_version() < $min_version ) {
$onenav_version = new_get_version();
exit($template."主题要求最低OneNav版本为:".$min_version.",您当前OneNav版本为:".$onenav_version.",请先<a title = 'OneNav升级说明' href = 'https://dwz.ovh/br5wt' target = '_blank'>升级OneNav版本!</a>");
}
}
}
//载入主题
require($tpl_dir.$template.'/index.php'); require($tpl_dir.$template.'/index.php');
?>

7
data/update.log

@ -174,3 +174,10 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
20221117 20221117
1. 修复获取分类目录失败的BUG 1. 修复获取分类目录失败的BUG
20221129
1. 新增链接自定义图标支持
2. 修复书签分享私有链接无法查看的BUG
3. 带上?theme=参数可以指定主题
4. 新增heimdall主题
5. 新增OneNav主程序是否满足主题要求的检测

BIN
db/onenav.simple.db3

Binary file not shown.

1
db/sql/20221129.sql

@ -0,0 +1 @@
ALTER TABLE on_links ADD font_icon TEXT(512);

66
functions/helper.php

@ -109,3 +109,69 @@ function jump_mobile() {
exit; exit;
} }
} }
//获取所有主题
function get_all_themes() {
//主题目录
$tpl_dir1 = dirname(__DIR__).'/templates/';
//备用主题目录
$tpl_dir2 = dirname(__DIR__).'/data/templates/';
//声明两个空数组用来存放模板目录列表
$tpl_one = [];
$tpl_two = [];
//遍历第一个目录
foreach ( scandir($tpl_dir1) as $value) {
//完整的路径
$path = $tpl_dir1.$value;
//如果是目录,则push到目录列表1
if( is_dir($path) ) {
switch ($value) {
case '.':
case '..':
case 'admin':
case 'mobile':
case 'universal':
continue;
break;
default:
array_push($tpl_one,$value);
break;
}
}
else{
continue;
}
}
//如果第二个目录存在,则遍历
if( is_dir($tpl_dir2) ) {
foreach ( scandir($tpl_dir2) as $value) {
//完整的路径
$path = $tpl_dir2.$value;
//如果是目录,则push到目录列表1
if( is_dir($path) ) {
switch ($value) {
case '.':
case '..':
case 'admin':
continue;
break;
default:
array_push($tpl_two,$value);
break;
}
}
else{
continue;
}
}
}
//合并目录
//现在$tpl_one是合并后的完整主题列表
$tpls = array_merge($tpl_one,$tpl_two);
$tpls = array_unique($tpls);
return $tpls;
}

BIN
static/images/default.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/white64.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

10
templates/admin/add_category.php

@ -23,9 +23,12 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label for="" class="layui-form-label">字体图标:</label> <label for="" class="layui-form-label">字体图标:</label>
<div class="layui-input-block"> <div class="layui-input-inline" style = "width:240px;">
<input name="font_icon" type="text" id="iconHhys2" value="" lay-filter="iconHhys2" class="layui-input"> <input name="font_icon" type="text" id="iconHhys2" value="" lay-filter="iconHhys2" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-word-aux">
图标对照表可参考:<a rel = "nofollow" target = "_blank" href="https://fontawesome.dashgame.com/">FontAwesome4</a>
</div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -52,13 +55,14 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">是否私有</label> <label class="layui-form-label">是否私有</label>
<div class="layui-input-block"> <div class="layui-input-inline" style = "width:240px;">
<input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否"> <input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否">
</div> </div>
<div class="layui-form-mid layui-word-aux">私有分类下的链接需要登录后才能查看。</div>
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">描述</label> <label class="layui-form-label">描述(选填)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name="description" placeholder="请输入内容" class="layui-textarea"></textarea> <textarea name="description" placeholder="请输入内容" class="layui-textarea"></textarea>
</div> </div>

28
templates/admin/add_link.php

@ -30,6 +30,27 @@
</div> </div>
<!-- 备用链接END --> <!-- 备用链接END -->
<div class="layui-form-item">
<label class="layui-form-label">图标</label>
<div class="layui-input-inline" style="width:810px;">
<button type="button" id = "iconUpload" name="iconUpload" class="layui-btn"><i class="layui-icon">&#xe67c;</i>上传图标</button>
<button type="button" class="layui-btn layui-btn-danger" onclick="del_link_icon()">删除图标</button>
<!-- 显示图标 -->
<div id="show_icon">
<img src="static/images/white64.png" alt="">
</div>
<!-- 显示图标 -->
<div class="layui-form-mid layui-word-aux" style = "float:right;">图标最小尺寸建议为 64 * 64像素,大小不超过100KB,仅部分主题支持自定义图标!</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图标链接</label>
<div class="layui-input-block">
<input type="url" id = "font_icon" name="font_icon" placeholder="请输入图标链接,如果没有,请留空(可输入外部https链接)" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">链接名称</label> <label class="layui-form-label">链接名称</label>
<div class="layui-input-block"> <div class="layui-input-block">
@ -59,19 +80,20 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">是否私有</label> <label class="layui-form-label">是否私有</label>
<div class="layui-input-block"> <div class="layui-input-inline">
<input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否"> <input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否">
</div> </div>
<div class="layui-form-mid layui-word-aux">私有链接需要登录后才能查看!</div>
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">描述</label> <label class="layui-form-label">描述(选填)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"></textarea> <textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"></textarea>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="add_link">添加</button> <button class="layui-btn" id = "add_link" lay-submit lay-filter="add_link">添加</button>
<!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> --> <!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> -->
<a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a> <a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a>
<button type="reset" class="layui-btn layui-btn-primary">重置</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button>

10
templates/admin/edit_category.php

@ -69,9 +69,12 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label for="" class="layui-form-label">字体图标:</label> <label for="" class="layui-form-label">字体图标:</label>
<div class="layui-input-block"> <div class="layui-input-inline" style = "width:240px;">
<input name="font_icon" type="text" id="iconHhys2" value="<?php echo $category_one['font_icon']; ?>" lay-filter="iconHhys2" class="layui-input"> <input name="font_icon" type="text" id="iconHhys2" value="<?php echo $category_one['font_icon']; ?>" lay-filter="iconHhys2" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-word-aux">
图标对照表可参考:<a rel = "nofollow" target = "_blank" href="https://fontawesome.dashgame.com/">FontAwesome4</a>
</div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -84,13 +87,14 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">是否私有</label> <label class="layui-form-label">是否私有</label>
<div class="layui-input-block"> <div class="layui-input-inline" style = "width:240px;">
<input type="checkbox" name="property" value = "1" lay-skin="switch" <?php echo $category_one['checked']; ?> lay-text="是|否"> <input type="checkbox" name="property" value = "1" lay-skin="switch" <?php echo $category_one['checked']; ?> lay-text="是|否">
</div> </div>
<div class="layui-form-mid layui-word-aux">私有分类下的链接需要登录后才能查看。</div>
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">描述</label> <label class="layui-form-label">描述(选填)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name="description" placeholder="请输入内容" class="layui-textarea"><?php echo $category_one['description']; ?></textarea> <textarea name="description" placeholder="请输入内容" class="layui-textarea"><?php echo $category_one['description']; ?></textarea>
</div> </div>

40
templates/admin/edit_link.php

@ -13,7 +13,7 @@
</div> </div>
<!-- 说明提示框END --> <!-- 说明提示框END -->
<div class="layui-col-lg12"> <div class="layui-col-lg12">
<form class="layui-form"> <form class="layui-form layui-form-pane">
<div class="layui-form-item" style = "display:none;"> <div class="layui-form-item" style = "display:none;">
<label class="layui-form-label">链接ID</label> <label class="layui-form-label">链接ID</label>
<div class="layui-input-block"> <div class="layui-input-block">
@ -38,6 +38,27 @@
</div> </div>
<!-- 备用链接END --> <!-- 备用链接END -->
<div class="layui-form-item">
<label class="layui-form-label">图标</label>
<div class="layui-input-inline" style="width:810px;">
<button type="button" id = "iconUpload" name="iconUpload" class="layui-btn"><i class="layui-icon">&#xe67c;</i>上传图标</button>
<button type="button" class="layui-btn layui-btn-danger" onclick="del_link_icon()">删除图标</button>
<!-- 显示图标 -->
<div id="show_icon">
<img src="<?php echo empty( $link['font_icon'] ) ? 'static/images/white64.png' : $link['font_icon']."?random=".rand(); ?>" alt="">
</div>
<!-- 显示图标 -->
<div class="layui-form-mid layui-word-aux" style = "float:right;">图标最小尺寸建议为 64 * 64像素,大小不超过100KB,仅部分主题支持自定义图标!</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图标链接</label>
<div class="layui-input-block">
<input type="url" id = "font_icon" value = "<?php echo $link['font_icon']; ?>" name="font_icon" placeholder="请输入图标链接,如果没有,请留空" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">链接名称</label> <label class="layui-form-label">链接名称</label>
<div class="layui-input-block"> <div class="layui-input-block">
@ -67,24 +88,23 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">是否私有</label> <label class="layui-form-label">是否私有</label>
<div class="layui-input-block"> <div class="layui-input-inline">
<input type="checkbox" name="property" value = "1" lay-skin="switch" <?php echo $link['checked'];?> lay-text="是|否"> <input type="checkbox" name="property" value = "1" lay-skin="switch" <?php echo $link['checked'];?> lay-text="是|否">
</div> </div>
<div class="layui-form-mid layui-word-aux">私有链接需要登录后才能查看!</div>
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">描述</label> <label class="layui-form-label">描述(选填)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"><?php echo $link['description']; ?></textarea> <textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"><?php echo $link['description']; ?></textarea>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="edit_link">更新</button> <button class="layui-btn" lay-submit lay-filter="edit_link">更新</button>
<!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> --> <!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> -->
<a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a> <a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a>
<button type="reset" class="layui-btn layui-btn-primary">重置</button> <button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div> </div>
</form> </form>
</div> </div>
@ -93,4 +113,14 @@
<!-- 内容主题区域END --> <!-- 内容主题区域END -->
</div> </div>
<script>
$(document).ready(function(){
let font_icon = $("#font_icon").val();
console.log(font_icon);
if( font_icon == "" ) {
set_icon_name();
}
});
</script>
<?php include_once('footer.php'); ?> <?php include_once('footer.php'); ?>

5
templates/admin/footer.php

@ -3,10 +3,5 @@
© Copyright 2022.Powered by <a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">OneNav</a>. © Copyright 2022.Powered by <a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">OneNav</a>.
</div> </div>
</div> </div>
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src="static/js/md5.min.js"></script>
<script src = "static/js/clipBoard.min.js"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
</body> </body>
</html> </html>

5
templates/admin/header.php

@ -9,6 +9,11 @@
<link rel='stylesheet' href='static/layui/css/layui.css'> <link rel='stylesheet' href='static/layui/css/layui.css'>
<link rel='stylesheet' href='templates/admin/static/style.css?v=<?php echo $version; ?>'> <link rel='stylesheet' href='templates/admin/static/style.css?v=<?php echo $version; ?>'>
<link rel="stylesheet" href="static/font-awesome/4.7.0/css/font-awesome.css"> <link rel="stylesheet" href="static/font-awesome/4.7.0/css/font-awesome.css">
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src="static/js/md5.min.js"></script>
<script src = "static/js/clipBoard.min.js"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
</head> </head>
<body class="layui-layout-body"> <body class="layui-layout-body">
<div class="layui-layout layui-layout-admin"> <div class="layui-layout layui-layout-admin">

1
templates/admin/imp_link.php

@ -9,6 +9,7 @@
<ol> <ol>
<li>仅支持 <em>.html</em> 格式导入,导入时会自动创建不存在的分类,使用前请参考<a href="https://dwz.ovh/ij3mq" target="_blank" rel = "nofollow">帮助文档</a></li> <li>仅支持 <em>.html</em> 格式导入,导入时会自动创建不存在的分类,使用前请参考<a href="https://dwz.ovh/ij3mq" target="_blank" rel = "nofollow">帮助文档</a></li>
<li>导入前,建议先<a href="/index.php?c=admin&page=setting/backup">备份数据库</a></li> <li>导入前,建议先<a href="/index.php?c=admin&page=setting/backup">备份数据库</a></li>
<li>导入会自动去除重复的链接!</li>
</ol> </ol>
</div> </div>
<!-- 上传 --> <!-- 上传 -->

1
templates/admin/setting/share.php

@ -12,6 +12,7 @@
<li>订阅用户可以对指定分类下的书签进行分享</li> <li>订阅用户可以对指定分类下的书签进行分享</li>
<li>比如:您可以将某个私有分类通过设置密码的方式分享给您的好友</li> <li>比如:您可以将某个私有分类通过设置密码的方式分享给您的好友</li>
<li>若密码留空,则不需要密码也能访问</li> <li>若密码留空,则不需要密码也能访问</li>
<li>分享支持删除操作(浏览器全屏才能查看到)</li>
</ol> </ol>
</div> </div>
</div> </div>

8
templates/admin/setting/site.php

@ -24,9 +24,10 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">网站logo</label> <label class="layui-form-label">网站logo</label>
<div class="layui-input-block"> <div class="layui-input-inline">
<input type="text" name="logo" value = "<?php echo $site['logo']; ?>" autocomplete="off" placeholder="网站logo地址,部分主题可能不支持" class="layui-input"> <input type="text" name="logo" value = "<?php echo $site['logo']; ?>" autocomplete="off" placeholder="网站logo地址,部分主题可能不支持" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-word-aux">输入相对路径或者将logo<a target = "_blank" href="https://www.imgurl.org/">上传到图床</a>,然后粘贴URL,仅部分主题支持logo</div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -46,7 +47,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">直链模式</label> <label class="layui-form-label">直链模式</label>
<div class="layui-input-block"> <div class="layui-input-inline">
<?php if( $site['link_model'] === 'direct' ) { ?> <?php if( $site['link_model'] === 'direct' ) { ?>
<input type="radio" name="link_model" value="jump" title="关闭"> <input type="radio" name="link_model" value="jump" title="关闭">
<input type="radio" name="link_model" value="direct" title="开启" checked> <input type="radio" name="link_model" value="direct" title="开启" checked>
@ -55,6 +56,7 @@
<input type="radio" name="link_model" value="direct" title="开启"> <input type="radio" name="link_model" value="direct" title="开启">
<?php } ?> <?php } ?>
</div> </div>
<div class="layui-form-mid layui-word-aux">开启直链模式后将直接打开目标地址,不二次跳转,仅部分主题支持!</div>
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
@ -65,7 +67,7 @@
</div> </div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">自定义header</label> <label class="layui-form-label">自定义header(可放统计代码或者自定义CSS样式)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name = "custom_header" placeholder="您可以自定义<header>...</header>之间的内容,如果您不清楚,请勿填写!" rows = "8" class="layui-textarea"><?php echo $site['custom_header']; ?></textarea> <textarea name = "custom_header" placeholder="您可以自定义<header>...</header>之间的内容,如果您不清楚,请勿填写!" rows = "8" class="layui-textarea"><?php echo $site['custom_header']; ?></textarea>
</div> </div>

1
templates/admin/setting/subscribe.php

@ -21,6 +21,7 @@
<div class="setting-msg"> <div class="setting-msg">
<p>1. 系统检测到您的域名为<strong style="color:#31BDEC;"><code><?php echo $_SERVER['HTTP_HOST']; ?></code></strong>,购买订阅时请填写此域名!</p> <p>1. 系统检测到您的域名为<strong style="color:#31BDEC;"><code><?php echo $_SERVER['HTTP_HOST']; ?></code></strong>,购买订阅时请填写此域名!</p>
<p>2. 若域名填写错误或更换域名,请前往<a title = "修改OneNav订阅域名" href="https://www.onenav.top/msub.html" target="_blank">https://www.onenav.top/msub.html</a>修改订阅!</p> <p>2. 若域名填写错误或更换域名,请前往<a title = "修改OneNav订阅域名" href="https://www.onenav.top/msub.html" target="_blank">https://www.onenav.top/msub.html</a>修改订阅!</p>
<p>3. Docker用户或IP访问的用户,请参考<a href="https://dwz.ovh/cve3d" target="_blank">没有域名购买订阅</a></p>
</div> </div>
</div> </div>
<!-- 说明提示框END --> <!-- 说明提示框END -->

4
templates/admin/setting/theme.php

@ -8,7 +8,7 @@
<div class="layui-col-lg12"> <div class="layui-col-lg12">
<div class="setting-msg"> <div class="setting-msg">
<p>1. 主题更换及设置说明,请参考:<a href="https://dwz.ovh/yoyaf" target = "_blank" title = "主题更换及设置说明">https://dwz.ovh/yoyaf</a></p> <p>1. 主题更换及设置说明,请参考:<a href="https://dwz.ovh/yoyaf" target = "_blank" title = "主题更换及设置说明">https://dwz.ovh/yoyaf</a></p>
<p>2. 为了分摊服务器成本,主题下载和更新需要订阅用户才能使用,敬请谅解!订阅地址:<a href="https://dwz.ovh/69h9q" rel="nofollow" target="_blank" title="购买订阅服务">https://dwz.ovh/69h9q</a></p> <p>2. 主题本身不收取费用,但为了分摊服务器存储和带宽成本,主题下载和更新需要订阅用户才能使用,敬请谅解!订阅地址:<a href="https://dwz.ovh/69h9q" rel="nofollow" target="_blank" title="购买订阅服务">https://dwz.ovh/69h9q</a></p>
<p>3. 部分主题来自其它开源项目,OneNav仅做适配,主题版权归原作者所有</p> <p>3. 部分主题来自其它开源项目,OneNav仅做适配,主题版权归原作者所有</p>
<p>4. 主题提交请联系QQ:446199062</p> <p>4. 主题提交请联系QQ:446199062</p>
</div> </div>
@ -37,6 +37,7 @@
<button type="button" class="layui-btn layui-btn-sm" onclick = "theme_detail('<?php echo $key; ?>')">详情</button> <button type="button" class="layui-btn layui-btn-sm" onclick = "theme_detail('<?php echo $key; ?>')">详情</button>
<button type="button" class="layui-btn layui-btn-sm" onclick = "theme_config('<?php echo $key; ?>')">参数设置</button> <button type="button" class="layui-btn layui-btn-sm" onclick = "theme_config('<?php echo $key; ?>')">参数设置</button>
<button type="button" class="layui-btn layui-btn-sm" onclick = "update_theme('<?php echo $key; ?>','<?php echo $theme['info']->version; ?>')">更新</button> <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> <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick = "delete_theme('<?php echo $key; ?>')">删除</button>
<?php if( $current_them == $key ) { ?> <?php if( $current_them == $key ) { ?>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger">当前</button> <button type="button" class="layui-btn layui-btn-sm layui-btn-danger">当前</button>
@ -70,6 +71,7 @@
<p> <p>
<div class="layui-btn-group"> <div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" onclick = "down_theme('<?php echo $key; ?>','download')">下载</button> <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> --> <!-- <button type="button" class="layui-btn layui-btn-sm" onclick = "theme_detail_online('<?php echo $key; ?>')">详情</button> -->
</div> </div>
</p> </p>

165
templates/admin/static/embed.js

@ -5,6 +5,83 @@ layui.config({
}); });
/**
* 随机生成字符串
* 参考https://blog.csdn.net/jiciqiang/article/details/121915750
* @param len 指定生成字符串长度
*/
function getRandomString(len){
let _charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789',
min = 0,
max = _charStr.length-1,
_str = ''; //定义随机字符串 变量
//判断是否指定长度,否则默认长度为15
len = len || 15;
//循环生成字符串
for(var i = 0, index; i < len; i++){
index = (function(randomIndexFunc, i){
return randomIndexFunc(min, max, i, randomIndexFunc);
})(function(min, max, i, _self){
let indexTemp = Math.floor(Math.random()*(max-min+1)+min),
numStart = _charStr.length - 10;
if(i==0&&indexTemp >=numStart){
indexTemp = _self(min, max, i, _self);
}
return indexTemp ;
}, i);
_str += _charStr[index];
}
return _str;
}
//生成6位随机数并存储到sessionStorage
function set_icon_name(){
sessionStorage.icon_name = getRandomString(6);
}
//获取icon名称
function get_icon_name(){
let icon_name;
//从表单获取
let tmp_name = $("#font_icon").val();
if( tmp_name == undefined ) {
return false;
}
tmp_name = tmp_name.split("/");
tmp_name = tmp_name.pop();
tmp_name = tmp_name.split(".");
tmp_name = tmp_name[0];
icon_name = tmp_name;
//如果不存在,则从session获取
if( icon_name == "" || icon_name == undefined ) {
icon_name = sessionStorage.icon_name;
}
//如果session也不存在,则重新设置一个
if( icon_name == "" || icon_name == undefined ) {
set_icon_name();
icon_name = sessionStorage.icon_name;
}
//最后返回
return icon_name;
}
//获取老图标的完整路径
function get_old_pic() {
let old_pic = $("#font_icon").val();
if( old_pic != undefined ) {
return old_pic;
}
else{
return '';
}
}
// 2022014 // 2022014
layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
var element = layui.element; var element = layui.element;
@ -21,6 +98,9 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
,page: true //开启分页 ,page: true //开启分页
,cols: [[ //表头 ,cols: [[ //表头
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'} {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
,{field: 'font_icon', title: '图标', width:60, templet: function(d){
return '<i class="fa-lg '+d.font_icon+'"></i>';
}}
,{field: 'name', title: '分类名称', width:160} ,{field: 'name', title: '分类名称', width:160}
,{field: 'fname', title: '父级分类', width:160} ,{field: 'fname', title: '父级分类', width:160}
,{field: 'add_time', title: '添加时间', width:160, sort: true,templet:function(d){ ,{field: 'add_time', title: '添加时间', width:160, sort: true,templet:function(d){
@ -84,6 +164,18 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
,cols: [[ //表头 ,cols: [[ //表头
{type:'checkbox'} //开启复选框 {type:'checkbox'} //开启复选框
,{field: 'id', title: 'ID', width:80, sort: true} ,{field: 'id', title: 'ID', width:80, sort: true}
,{field: 'font_icon', title: '图标', width:60, templet:function(d){
if(d.font_icon == null || d.font_icon == "")
{
return '<img src="static/images/default.png" width="28" height="28">';
}
else
{
let random = getRandStr(4);
let font_icon = d.font_icon;
return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
}
}}
// ,{field: 'fid', title: '分类ID',sort:true, width:90} // ,{field: 'fid', title: '分类ID',sort:true, width:90}
,{field: 'category_name', title: '所属分类',sort:true,width:120} ,{field: 'category_name', title: '所属分类',sort:true,width:120}
,{field: 'url', title: 'URL',width:140,templet:function(d){ ,{field: 'url', title: 'URL',width:140,templet:function(d){
@ -623,7 +715,14 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
$.post('/index.php?c=api&method=add_link',data.field,function(data,status){ $.post('/index.php?c=api&method=add_link',data.field,function(data,status){
//如果添加成功 //如果添加成功
if(data.code == 0) { if(data.code == 0) {
//重新设置图标
set_icon_name();
layer.msg('已添加!', {icon: 1}); layer.msg('已添加!', {icon: 1});
//禁用按钮
$("#add_link").addClass("layui-btn-disabled");
setTimeout(()=>{
window.location.reload();
},1500);
} }
else{ else{
layer.msg(data.err_msg, {icon: 5}); layer.msg(data.err_msg, {icon: 5});
@ -648,7 +747,7 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
}); });
//更新链接 //更新链接
form.on('submit(edit_link)', function(data){ form.on('submit(edit_link)', function(data){
$.post('/index.php?c=api&method=edit_link',data.field,function(data,status){ $.post('/index.php?c=api&method=edit_link&type=console',data.field,function(data,status){
//如果添加成功 //如果添加成功
if(data.code == 0) { if(data.code == 0) {
layer.msg('已更新!', {icon: 1}); layer.msg('已更新!', {icon: 1});
@ -720,6 +819,40 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
} }
}); });
upload.render({
elem: '#iconUpload' //绑定元素
,url: 'index.php?c=api&method=uploadImages' //上传接口
,accept:'file'
,exts: 'ico|jpg|jpeg|png|bmp|svg',
size:100
,data: {
//传递图片名称
"icon_name":get_icon_name(),
//传递老图片名称,接口先将老图片删除
"old_pic":get_old_pic()
},
choose:function(obj){
this.data.old_pic = get_old_pic();
}
,done: function(res){
//console.log(res);
//上传完毕回调
if( res.code == 200 ) {
$("#font_icon").val(res.data.file_name);
//显示图标
$("#show_icon img").attr("src","/" + res.data.file_name + "?random" + getRandStr(4));
}
else if( res.code < 0) {
layer.msg(res.msg, {icon: 5});
layer.close();
}
}
,error: function(){
layer.msg("发生预料之外的错误!", {icon: 5});
layer.close();
}
});
}); });
function get_link_info() { function get_link_info() {
@ -963,3 +1096,33 @@ function getRandStr(n) {
} }
return res; return res;
} }
//删除图标
function del_link_icon(){
let icon_path = $("#font_icon").val();
//如果图标为空
if( icon_path == "" ) {
layer.msg("图标为空,无需删除!",{icon:1});
return true;
}
console.log(icon_path.indexOf("http"));
//如果图标包含http开头,则是网络图片,直接清空即可
if( icon_path.indexOf("http") >= 0 ) {
//置空
$("#font_icon").val("");
$("#show_icon img").attr("src","");
layer.msg("图标已清空,请保存!",{icon:1});
return true;
}
$.post("/index.php?c=api&method=del_link_icon",{icon_path:icon_path},function(data,status){
if( data.code == 200 ) {
$("#font_icon").val("");
$("#show_icon img").attr("src","");
layer.msg("图标已删除,请保存!",{icon:1});
}
else{
layer.msg(data.msg,{icon:5});
}
});
}

11
templates/admin/static/style.css

@ -148,3 +148,14 @@
display:none; display:none;
margin-top:1em; margin-top:1em;
} }
#show_icon{
display:inline-block;width:38px;height:38px;border:1px solid #F6F6F6;
position: relative;
/* bottom: 9px; */
}
#show_icon img{
height: 38px;
width: 38px;
}

2
templates/universal/assets/index.css

File diff suppressed because one or more lines are too long

12
templates/universal/assets/index.js

File diff suppressed because one or more lines are too long

2
version.txt

@ -1 +1 @@
v0.9.27-20221117 v0.9.28-20221201
Loading…
Cancel
Save