Browse Source

0.9.28

pull/119/head
xiaoz 2 years ago
parent
commit
effe4efca8
  1. 1
      .htaccess
  2. 106
      class/Api.php
  3. 12
      controller/api.php
  4. 67
      controller/index.php
  5. 7
      data/update.log
  6. BIN
      db/onenav.simple.db3
  7. 1
      db/sql/20221129.sql
  8. 66
      functions/helper.php
  9. 0
      static/images/default.png
  10. BIN
      static/images/white64.png
  11. 10
      templates/admin/add_category.php
  12. 18
      templates/admin/add_link.php
  13. 10
      templates/admin/edit_category.php
  14. 28
      templates/admin/edit_link.php
  15. 5
      templates/admin/footer.php
  16. 5
      templates/admin/header.php
  17. 1
      templates/admin/imp_link.php
  18. 1
      templates/admin/setting/share.php
  19. 8
      templates/admin/setting/site.php
  20. 1
      templates/admin/setting/subscribe.php
  21. 3
      templates/admin/setting/theme.php
  22. 147
      templates/admin/static/embed.js
  23. 11
      templates/admin/static/style.css
  24. 2
      templates/universal/assets/index.css
  25. 12
      templates/universal/assets/index.js
  26. 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]

106
class/Api.php

@ -227,9 +227,13 @@ class Api {
'description' => htmlspecialchars($description,ENT_QUOTES), 'description' => htmlspecialchars($description,ENT_QUOTES),
'add_time' => time(), 'add_time' => time(),
'weight' => $weight, 'weight' => $weight,
'property' => $property, 'property' => $property
'font_icon' => $font_icon
]; ];
//如果$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);
//返回影响行数 //返回影响行数
@ -539,11 +543,28 @@ class Api {
* 图标上传 * 图标上传
* type:上传类型 * type:上传类型
*/ */
public function uploadImages($token,$type){ public function uploadImages($token){
$this->auth($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) if ($_FILES["file"]["error"] > 0)
{ {
$this->err_msg(-1015,'File upload failed!'); //$this->err_msg(-1015,'File upload failed!');
$this->return_json(-2000,'','File upload failed!');
} }
else else
{ {
@ -555,20 +576,33 @@ class Api {
//临时文件位置 //临时文件位置
$temp = $_FILES["file"]["tmp_name"]; $temp = $_FILES["file"]["tmp_name"];
if( $suffix != 'ico' && $suffix != 'jpg' && $suffix != 'png' && $suffix != 'bmp' ) { if( $suffix != 'ico' && $suffix != 'jpg' && $suffix != 'jpeg' && $suffix != 'png' && $suffix != 'bmp' && $suffix != 'gif' && $suffix != 'svg' ) {
//删除临时文件 //删除临时文件
unlink($filename); @unlink($filename);
$this->err_msg(-1014,'Unsupported file suffix name!'); @unlink($temp);
$this->return_json(-2000,'','Unsupported file suffix name!');
} }
$newfilename='upload/'.time().'.'.$suffix; //上传路径,格式为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);
}
if( copy($temp,$newfilename) ) { //$newfilename = 'upload/'.time().'.'.$suffix;
//移动临时文件到指定上传路径
if( move_uploaded_file($temp,$upload_path) ) {
$data = [ $data = [
'code' => 0, 'file_name' => $upload_path
'file_name' => $newfilename
]; ];
exit(json_encode($data)); $this->return_json(200,$data,'success');
}
else{
$this->return_json(-2000,'','上传失败,请检查目录权限!');
} }
} }
} }
@ -613,6 +647,12 @@ class Api {
public function edit_link($token,$id,$fid,$title,$url,$description = '',$weight = 0,$property = 0,$url_standby = '',$font_icon = ''){ 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([
@ -636,9 +676,16 @@ class Api {
'description' => htmlspecialchars($description,ENT_QUOTES), 'description' => htmlspecialchars($description,ENT_QUOTES),
'up_time' => time(), 'up_time' => time(),
'weight' => $weight, 'weight' => $weight,
'property' => $property, 'property' => $property
'font_icon' => $font_icon
]; ];
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]);
//返回影响行数 //返回影响行数
@ -2227,6 +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,'','图标删除失败,请检查目录权限!');
}
}
} }

12
controller/api.php

@ -242,12 +242,12 @@ function upload($api){
$api->upload($token,$type); $api->upload($token,$type);
} }
// 上传图标 // 上传图标
function uploadImages($api){ function uploadImages(){
global $api;
//获取token //获取token
$token = empty( $_POST['token'] ) ? $_GET['token'] : $_POST['token']; $token = empty( $_POST['token'] ) ? $_GET['token'] : $_POST['token'];
//获取上传类型 //获取上传类型
$type = $_GET['type']; $api->uploadImages($token);
$api->uploadImages($token,$type);
} }
//书签导入 //书签导入
function imp_link($api) { function imp_link($api) {
@ -634,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();
}

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;
}

0
upload/default.png → static/images/default.png

Before

Width:  |  Height:  |  Size: 1.4 KiB

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>

18
templates/admin/add_link.php

@ -32,15 +32,22 @@
<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:810px;">
<button type="button" id = "iconUpload" name="iconUpload" class="layui-btn"><i class="layui-icon">&#xe67c;</i>上传图标</button> <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> </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">
<input type="url" id = "font_icon" name="font_icon" placeholder="请输入图标链接,如果没有,请留空" autocomplete="off" class="layui-input"> <input type="url" id = "font_icon" name="font_icon" placeholder="请输入图标链接,如果没有,请留空(可输入外部https链接)" autocomplete="off" class="layui-input">
</div> </div>
</div> </div>
@ -73,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>

28
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">
@ -40,8 +40,15 @@
<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:810px;">
<button type="button" id = "iconUpload" name="iconUpload" class="layui-btn"><i class="layui-icon">&#xe67c;</i>上传图标</button> <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> </div>
@ -81,25 +88,24 @@
<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>
@ -107,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 -->

3
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>

147
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;
@ -88,13 +165,15 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
{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){ ,{field: 'font_icon', title: '图标', width:60, templet:function(d){
if(d.font_icon==null) if(d.font_icon == null || d.font_icon == "")
{ {
return '<img src="upload/default.png" width="28" height="28">'; return '<img src="static/images/default.png" width="28" height="28">';
} }
else else
{ {
return '<img src="'+d.font_icon+'" width="28" height="28">'; 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}
@ -636,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});
@ -661,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});
@ -737,21 +823,34 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
elem: '#iconUpload' //绑定元素 elem: '#iconUpload' //绑定元素
,url: 'index.php?c=api&method=uploadImages' //上传接口 ,url: 'index.php?c=api&method=uploadImages' //上传接口
,accept:'file' ,accept:'file'
,exts: 'ico|jpg|png|bmp' ,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){ ,done: function(res){
//console.log(res); //console.log(res);
//上传完毕回调 //上传完毕回调
if( res.code == 0 ) { if( res.code == 200 ) {
$("#font_icon").val(res.file_name); $("#font_icon").val(res.data.file_name);
//显示图标
$("#show_icon img").attr("src","/" + res.data.file_name + "?random" + getRandStr(4));
} }
else if( res.code < 0) { else if( res.code < 0) {
layer.msg(res.err_msg, {icon: 5}); layer.msg(res.msg, {icon: 5});
layer.close(); layer.close();
} }
} }
,error: function(){ ,error: function(){
//请求异常回调 layer.msg("发生预料之外的错误!", {icon: 5});
layer.close();
} }
}); });
}); });
@ -997,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-20221128 v0.9.28-20221201
Loading…
Cancel
Save