Browse Source

Merge pull request #96 from helloxz/dev

0.9.24
pull/117/head 0.9.24
xiaoz 2 years ago committed by GitHub
parent
commit
4febbe9378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 176
      class/Api.php
  2. 28
      controller/admin.php
  3. 28
      controller/api.php
  4. 6
      controller/init.php
  5. 3
      controller/login.php
  6. 12
      data/update.log
  7. 14
      functions/helper.php
  8. 4
      templates/admin/403.php
  9. 7
      templates/admin/imp_link.php
  10. 1
      templates/admin/left.php
  11. 4
      templates/admin/login.php
  12. 132
      templates/admin/setting/backup.php
  13. 13
      templates/admin/setting/site.php
  14. 19
      templates/admin/setting/subscribe.php
  15. 34
      templates/admin/setting/theme.php
  16. 4
      templates/admin/static/embed.js
  17. 28
      templates/admin/static/style.css
  18. 14
      templates/default/index.php
  19. 2
      version.txt

176
class/Api.php

@ -1603,6 +1603,22 @@ class Api {
return FALSE; return FALSE;
} }
} }
/**
* name:验证订阅,订阅不存在,则阻止
*/
public function check_is_subscribe(){
$result = $this->is_subscribe();
if( $result === FALSE ) {
$this->return_json(-2000,'','该功能需要订阅后才能使用!');
}
else if( $result === TRUE ) {
return TRUE;
}
else{
$this->return_json(-2000,'','该功能需要订阅后才能使用!');
}
}
/** /**
* 无脑下载更新程序 * 无脑下载更新程序
*/ */
@ -1731,5 +1747,165 @@ class Api {
return $html; return $html;
} }
/**
* name:数据库备份接口
*/
public function backup_db(){
//验证请求
$this->auth($token);
//验证订阅
$this->check_is_subscribe();
$backup_dir = 'data/backup/';
//判断目录是否存在,不存在则创建
if( !is_dir($backup_dir) ) {
try {
mkdir($backup_dir,0755);
} catch (\Throwable $th) {
$this->return_json(-2000,'','备份目录创建失败,请检查目录权限!');
}
}
//尝试拷贝数据库进行备份
try {
//获取当前版本信息
$current_version = explode("-",file_get_contents("version.txt"));
$current_version = str_replace("v","",$current_version[0]);
$db_name = 'onenav_'.date("YmdHi",time()).'_'.$current_version.'.db3';
$backup_db_path = $backup_dir.$db_name;
copy('data/onenav.db3',$backup_db_path);
$this->return_json(200,$db_name,'success');
} catch (\Throwable $th) {
$this->return_json(-2000,'','备份目录创建失败,请检查目录权限!');
}
}
/**
* name:数据库备份列表
*/
public function backup_db_list() {
//验证请求
$this->auth($token);
//验证订阅
$this->check_is_subscribe();
//备份目录
$backup_dir = 'data/backup/';
//遍历备份列表
$dbs = scandir($backup_dir);
$newdbs = $dbs;
//去除.和..
for ($i=0; $i < count($dbs); $i++) {
if( ($dbs[$i] == '.') || ($dbs[$i] == '..') ) {
unset($newdbs[$i]);
}
}
//将删除后的数组重新赋值
$dbs = $newdbs;
//获取备份列表个数
$num = count($dbs);
//排序处理,按时间从大到小排序
rsort($dbs,2);
//如果大于10个,则删减为10个
if( $num > 10 ) {
for ($i=$num; $i > 10; $i--) {
//物理删除数据库
unlink($backup_dir.$dbs[$i-1]);
//删除数组最后一个元素
array_pop($dbs);
}
$count = 10;
}
else{
$count = $num;
}
//声明一个空数组
$data = [];
//遍历数据库,获取时间,大小
foreach ($dbs as $key => $value) {
$arr['id'] = $key;
$arr['name'] = $value;
$arr['mtime'] = date("Y-m-d H:i:s",filemtime($backup_dir.$value));
$arr['size'] = (filesize($backup_dir.$value) / 1024).'KB';
$data[$key] = $arr;
}
$datas = [
'code' => 0,
'msg' => '',
'count' => $count,
'data' => $data
];
exit(json_encode($datas));
}
/**
* name:删除单个数据库备份
* @param $name:数据库名称
*/
public function del_backup_db($name) {
//验证请求
$this->auth($token);
//验证订阅
$this->check_is_subscribe();
//使用正则表达式判断数据库名称是否合法
$pattern = '/^onenav_[0-9\-]+_[0-9.]+(db3)$/';
if( !preg_match_all($pattern,$name) ) {
$this->return_json(-2000,'','数据库名称不合法!');
}
//数据库目录
$backup_dir = 'data/backup/';
//删除数据库
try {
unlink($backup_dir.$name);
$this->return_json(200,'',"备份数据库已被删除!");
} catch (\Throwable $th) {
$this->return_json(-2000,'',"删除失败,请检查目录权限!");
}
}
/**
* name:恢复数据库备份
* @param $name:备份数据库名称
*/
public function restore_db($name) {
//验证请求
$this->auth($token);
//验证订阅
$this->check_is_subscribe();
//使用正则表达式判断数据库名称是否合法
$pattern = '/^onenav_[0-9\-]+_[0-9.]+(db3)$/';
if( !preg_match_all($pattern,$name) ) {
$this->return_json(-2000,'','数据库名称不合法!');
}
//数据库目录
$backup_dir = 'data/backup/';
//恢复数据库
try {
copy($backup_dir.$name,'data/onenav.db3');
$this->return_json(200,'','数据库已回滚为'.$name);
} catch (\Throwable $th) {
$this->return_json(-2000,'',"回滚失败,请检查目录权限!");
}
}
} }

28
controller/admin.php

@ -9,18 +9,18 @@ require('functions/helper.php');
check_auth($site_setting['user'],$site_setting['password']); check_auth($site_setting['user'],$site_setting['password']);
//获取版本号 //获取版本号
function get_version(){ // function get_version(){
if( file_exists('version.txt') ) { // if( file_exists('version.txt') ) {
$version = @file_get_contents('version.txt'); // $version = @file_get_contents('version.txt');
return $version; // return $version;
} // }
else{ // else{
$version = 'null'; // $version = 'null';
return $version; // return $version;
} // }
} // }
//获取版本号 //获取版本号
$version = get_version(); $version = new_get_version();
$page = empty($_GET['page']) ? 'index' : $_GET['page']; $page = empty($_GET['page']) ? 'index' : $_GET['page'];
//如果页面是修改edit_category //如果页面是修改edit_category
@ -86,6 +86,12 @@ if( $page == 'setting/api' ) {
//查询SecretKey //查询SecretKey
$SecretKey = $db->get('on_options','*',[ 'key' => 'SecretKey' ])['value']; $SecretKey = $db->get('on_options','*',[ 'key' => 'SecretKey' ])['value'];
}
//备份页面
if( $page == 'setting/backup' ) {
} }
//如果页面是修改link //如果页面是修改link

28
controller/api.php

@ -301,6 +301,8 @@ function set_site($api) {
$data['custom_header'] = $_POST['custom_header']; $data['custom_header'] = $_POST['custom_header'];
//获取自定义footer //获取自定义footer
$data['custom_footer'] = $_POST['custom_footer']; $data['custom_footer'] = $_POST['custom_footer'];
//获取链接模式
$data['link_model'] = $_POST['link_model'];
//序列化存储 //序列化存储
$value = serialize($data); $value = serialize($data);
@ -530,3 +532,29 @@ function down_theme() {
$api->down_theme($data); $api->down_theme($data);
} }
//备份数据库
function backup_db() {
global $api;
$api->backup_db();
}
//数据库备份列表
function backup_db_list() {
global $api;
$api->backup_db_list();
}
//删除单个数据库备份
function del_backup_db() {
global $api;
$name = @$_REQUEST['name'];
$api->del_backup_db($name);
}
//回滚数据库
function restore_db() {
global $api;
$name = @$_REQUEST['name'];
$api->restore_db($name);
}

6
controller/init.php

@ -12,6 +12,7 @@ function check_env() {
$ext = get_loaded_extensions(); $ext = get_loaded_extensions();
//检查PHP版本,需要大于5.6小于8.0 //检查PHP版本,需要大于5.6小于8.0
$php_version = floatval(PHP_VERSION); $php_version = floatval(PHP_VERSION);
$uri = $_SERVER["REQUEST_URI"];
if( ( $php_version < 5.6 ) || ( $php_version > 8 ) ) { if( ( $php_version < 5.6 ) || ( $php_version > 8 ) ) {
exit("当前PHP版本{$php_version}不满足要求,需要5.6 <= PHP <= 7.4"); exit("当前PHP版本{$php_version}不满足要求,需要5.6 <= PHP <= 7.4");
@ -25,6 +26,11 @@ function check_env() {
if( file_exists("data/config.php") ) { if( file_exists("data/config.php") ) {
exit("配置文件已存在,无需再次初始化!"); exit("配置文件已存在,无需再次初始化!");
} }
//检查是否是二级目录
$pattern = '/\/[a-z0-9\/]+$/';
if( preg_match_all($pattern,$uri) ) {
exit("暂不支持二级目录安装!");
}
return TRUE; return TRUE;
} }

3
controller/login.php

@ -14,6 +14,9 @@ $key = md5($username.$password.'onenav'.$_SERVER['HTTP_USER_AGENT']);
//获取cookie //获取cookie
$cookie = $_COOKIE['key']; $cookie = $_COOKIE['key'];
//获取版本号
$version = new_get_version();
//如果已经登录,直接跳转 //如果已经登录,直接跳转
if( is_login() ){ if( is_login() ){
header('location:index.php?c=admin'); header('location:index.php?c=admin');

12
data/update.log

@ -145,3 +145,15 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
20220609 20220609
1. 其它优化和BUG修复 1. 其它优化和BUG修复
20220610
1. 登录页面的.css/.js 加上版本号
2. 403页面静态资源本地化
20220830
1. 去掉默认主题的About链接
2. 二级目录安装检测提示(需要测试)
3. 默认主题支持直链模式,其它主题陆续支持
4. 程序更新完毕后自动跳转到后台首页更新数据库
5. 主题更新检测
6. 新增数据库备份功能

14
functions/helper.php

@ -64,3 +64,17 @@ function curl_get($url,$timeout = 10) {
curl_close($curl); curl_close($curl);
return $html; return $html;
} }
//获取版本号,新写的
function new_get_version(){
if( file_exists('version.txt') ) {
$version = @file_get_contents('version.txt');
$version = explode("-",$version)[0];
$version = str_replace("v","",$version);
return $version;
}
else{
$version = 'null';
return $version;
}
}

4
templates/admin/403.php

@ -7,7 +7,7 @@
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://lib.sinaapp.com/js/bootstrap/4.3.1/css/bootstrap.min.css" type="" media=""/> <link rel="stylesheet" href="static/bootstrap4/css/bootstrap.min.css" type="" media=""/>
</head> </head>
<body> <body>
<div class="container" style = "margin-top:2em;"> <div class="container" style = "margin-top:2em;">
@ -20,7 +20,7 @@
<?php echo $msg; ?> <?php echo $msg; ?>
</div> </div>
<hr> <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">Powered by <a href="https://www.onenav.top/" title = "开源免费的书签管理系统" target = "_blank">OneNav</a></div>
</div> </div>
</div> </div>
</div> </div>

7
templates/admin/imp_link.php

@ -5,7 +5,12 @@
<!-- 内容主体区域 --> <!-- 内容主体区域 -->
<div class="layui-row content-body place-holder"> <div class="layui-row content-body place-holder">
<div class="layui-col-lg6 layui-col-md-offset3"> <div class="layui-col-lg6 layui-col-md-offset3">
<div class="setting-msg">仅支持 <em>.html</em> 格式导入,导入时会自动创建不存在的分类,使用前请参考<a href="https://dwz.ovh/ij3mq" target="_blank" rel = "nofollow">帮助文档</a></div> <div class="page-msg">
<ol>
<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>
</ol>
</div>
<!-- 上传 --> <!-- 上传 -->
<div class="layui-upload-drag" id="up_html"> <div class="layui-upload-drag" id="up_html">
<i class="layui-icon layui-icon-upload"></i> <i class="layui-icon layui-icon-upload"></i>

1
templates/admin/left.php

@ -31,6 +31,7 @@
<dd><a href="/index.php?c=admin&page=setting/site">站点设置</a></dd> <dd><a href="/index.php?c=admin&page=setting/site">站点设置</a></dd>
<dd><a href="/index.php?c=admin&page=setting/theme">主题设置</a></dd> <dd><a href="/index.php?c=admin&page=setting/theme">主题设置</a></dd>
<dd><a href="/index.php?c=admin&page=setting/transition_page">过渡页面</a></dd> <dd><a href="/index.php?c=admin&page=setting/transition_page">过渡页面</a></dd>
<dd><a href="/index.php?c=admin&page=setting/backup">数据备份</a></dd>
<dd><a href="/index.php?c=admin&page=setting/api">获取API</a></dd> <dd><a href="/index.php?c=admin&page=setting/api">获取API</a></dd>
</dl> </dl>
</li> </li>

4
templates/admin/login.php

@ -5,7 +5,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./templates/admin/static/css/new.css"> <link rel="stylesheet" href="./templates/admin/static/css/new.css?v=<?php echo $version; ?>'">
<link rel='stylesheet' href='static/layui/css/layui.css'> <link rel='stylesheet' href='static/layui/css/layui.css'>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>OneNav管理员登录</title> <title>OneNav管理员登录</title>
@ -98,5 +98,5 @@
</script> </script>
<script src = 'static/js/jquery.min.js'></script> <script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script> <script src = 'static/layui/layui.js'></script>
<script src="templates/admin/static/embed.js"></script> <script src="templates/admin/static/embed.js?v=<?php echo $version; ?>'"></script>
</html> </html>

132
templates/admin/setting/backup.php

@ -0,0 +1,132 @@
<?php echo $transition_page['control']; ?>
<!-- API页面设置 -->
<?php require_once(dirname(__DIR__).'/header.php'); ?>
<?php include_once(dirname(__DIR__).'/left.php'); ?>
<div class="layui-body">
<!-- 内容主体区域 -->
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="page-msg">
<ol>
<li>订阅用户可以对数据库进行本地备份和回滚</li>
<li>备份数据库仅保存最近10份数据</li>
<li>该功能仅辅助备份使用,无法确保100%数据安全,因此定期对整个站点打包备份仍然是必要的</li>
</ol>
</div>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<!-- 数据表格 -->
<table class="layui-hide" id="mytable" lay-filter="mytable"></table>
<!-- 数据表格END -->
<!-- 最右侧的操作选项 -->
<script type="text/html" id="tooloption">
<a class="layui-btn layui-btn-xs" lay-event="restore">回滚</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 操作选项END -->
<!-- 头部工具栏 -->
<script type="text/html" id="toolbarheader">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="backup">立即备份</button>
</div>
</script>
<!-- 头部工具栏END -->
</div>
</div>
</div>
<?php include_once(dirname(__DIR__).'/footer.php'); ?>
<script>
layui.use(['table'],function(){
var table = layui.table;
// 渲染表格
table.render({
elem: '#mytable'
,id: 'tableid'
,url:'/index.php?c=api&method=backup_db_list' // 此处为静态模拟数据,实际使用时需换成真实接口
,toolbar: '#toolbarheader'
,totalRow: true // 开启合计行
,cols: [[
{field:'id', width:80, title: '序号'}
,{field:'name', title:'数据库文件名',width:300}
,{field:'mtime', width:80, title: '备份时间', width:240}
,{field:'size', width:115, title: '数据库大小'}
,{fixed: 'right', title:'操作', toolbar: '#tooloption'}
]]
});
// 渲染表格END
// 表头工具栏
//触发事件
table.on('toolbar(mytable)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'backup':
$.get("/index.php?c=api&method=backup_db",function(data,status){
if( data.code == 200 ) {
layer.msg('备份成功!',{icon:1});
//刷新表格
table.reload('tableid', {
where: { //设定异步数据接口的额外参数,任意设
aaaaaa: 'xxx'
}
});
}
else{
layer.msg(data.msg,{icon:5});
}
});
break;
};
});
// 表头工具栏END
//单元格工具事件
table.on('tool(mytable)', function(obj){ // 注:test 是 table 原始标签的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的 DOM 对象(如果有的话)
if(layEvent === 'restore'){ //回滚
layer.confirm('确定回滚吗?', {icon:3,title:'提示'},function(index){
$.get("/index.php?c=api&method=restore_db",{name:data.name},function(data,status){
if(data.code == 200) {
layer.close(index);
layer.msg('回滚成功!',{icon:1})
}
else{
layer.close(index);
layer.msg(data.msg,{icon:5})
}
});
});
} else if(layEvent === 'del'){ //删除
layer.confirm('确定删除吗?', {icon:3,title:'提示'},function(index){
$.get("/index.php?c=api&method=del_backup_db",{name:data.name},function(data,status){
if(data.code == 200) {
obj.del(); // 删除对应行(tr)的 DOM 结构,并更新缓存
layer.close(index);
}
else{
layer.msg(data.msg,{icon:5})
layer.close(index);
}
});
});
}
});
//单元格工具事件END
});
</script>

13
templates/admin/setting/site.php

@ -44,6 +44,19 @@
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label">直链模式</label>
<div class="layui-input-block">
<?php if( $site['link_model'] === 'direct' ) { ?>
<input type="radio" name="link_model" value="jump" title="关闭">
<input type="radio" name="link_model" value="direct" title="开启" checked>
<?php }else{ ?>
<input type="radio" name="link_model" value="jump" title="关闭" checked>
<input type="radio" name="link_model" value="direct" title="开启">
<?php } ?>
</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">

19
templates/admin/setting/subscribe.php

@ -15,6 +15,7 @@
<li>3. 可享受一对一售后服务(仅限高级版和商业版)</li> <li>3. 可享受一对一售后服务(仅限高级版和商业版)</li>
<li>4. 可帮助OneNav持续发展,让OneNav变得更加美好</li> <li>4. 可帮助OneNav持续发展,让OneNav变得更加美好</li>
<li>5. 更多高级功能(自定义版权、广告管理等)</li> <li>5. 更多高级功能(自定义版权、广告管理等)</li>
<li>6. 数据库备份</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -176,11 +177,25 @@
//校验新版本 //校验新版本
$.get("/index.php?c=api&method=check_version",{version:new_version},function(data,status){ $.get("/index.php?c=api&method=check_version",{version:new_version},function(data,status){
if(data.code == 200) { if(data.code == 200) {
update_status("100%","更新完成,请前往后台检查<a href = '/index.php?c=admin'>更新数据库</a>!"); update_status("100%","更新完成,5s后自动跳转到后台首页检查数据库更新!");
$("#update_log").append("更新完成,请前往后台检查<a href = '/index.php?c=admin'>更新数据库</a><br />"); $("#update_log").append("更新完成,5s后自动跳转到后台首页检查数据库更新<br />");
//$("#btn_update").show(); //$("#btn_update").show();
//$("#btn_updating").hide(); //$("#btn_updating").hide();
$("#btn_updating").show(); $("#btn_updating").show();
//备份数据库
$.get("/index.php?c=api&method=backup_db",function(data,status){
if( data.code == 200 ) {
console.log('数据库备份成功!');
//3s后跳转到后台首页,方便更新数据库
setTimeout(() => {
window.location = "/index.php?c=admin";
}, 5000);
}
else{
layer.msg('数据库备份失败,请检查目录权限',{icon:5});
}
});
} }
else { else {
update_error(data.msg); update_error(data.msg);

34
templates/admin/setting/theme.php

@ -22,7 +22,10 @@
<!-- 主题列表 --> <!-- 主题列表 -->
<div class="layui-col-lg3 layui-col-md6 layui-col-sm12"> <div class="layui-col-lg3 layui-col-md6 layui-col-sm12">
<fieldset style = "padding:1em;border:0px;height:280px;border:1px dashed #1E9FFF;box-shadow: 2px 2px 3px #888888;color:#666666"> <fieldset style = "padding:1em;border:0px;height:280px;border:1px dashed #1E9FFF;box-shadow: 2px 2px 3px #888888;color:#666666">
<legend style = "font-size:24px;"><?php echo $key; ?> - <?php echo $theme['info']->version ?></legend> <legend style = "font-size:24px;" id="<?php echo $key; ?>">
<?php echo $key; ?> - <?php echo $theme['info']->version ?>
<span class="renewable" style="color:#FF5722;font-size:14px;"></span>
</legend>
<!-- 主题图片 --> <!-- 主题图片 -->
<div class = "screenshot"><p><img layer-src="<?php echo $theme['info']->screenshot; ?>" src="<?php echo $theme['info']->screenshot; ?>" alt=""></p></div> <div class = "screenshot"><p><img layer-src="<?php echo $theme['info']->screenshot; ?>" src="<?php echo $theme['info']->screenshot; ?>" alt=""></p></div>
@ -198,6 +201,35 @@ function update_theme(name,version){
} }
//遍历所有主题,检查是否有更新
function check_update(){
//请求远程主题列表
$.get("https://onenav.xiaoz.top/v1/theme_list.php",function(data,status){
let result = data.data;
//console.log(result.5iux);
for (const obj in result) {
//获取主题名称
let value = $("#" + obj).text();
//如果获取到的数据为空
if( value == '' ) {
continue;
}
//console.log(obj);
//获取最新版本
let latest_version = result[obj].version;
//获取当前版本
let current_version = value.split(' - ')[1];
//如果存在最新版本
if( latest_version > current_version ) {
console.log("#" + obj + ".renewable");
$("#" + obj + " .renewable").append(`(可更新至${latest_version})`);
}
}
});
}
check_update();
layer.photos({ layer.photos({
photos: '#layer-photos' photos: '#layer-photos'
,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)

4
templates/admin/static/embed.js

@ -294,7 +294,7 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
//初始化设置onenav密码 //初始化设置onenav密码
form.on('submit(init_onenav)', function(data){ form.on('submit(init_onenav)', function(data){
console.log(data.field.username); //console.log(data.field.username);
let username = data.field.username; let username = data.field.username;
let password = data.field.password; let password = data.field.password;
@ -302,7 +302,7 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
//正则验证用户名、密码 //正则验证用户名、密码
var u_patt = /^[0-9a-z]{3,32}$/; var u_patt = /^[0-9a-z]{3,32}$/;
if ( !u_patt.test(username) ) { if ( !u_patt.test(username) ) {
layer.msg("用户名需要3-32位的字母或数字组合!", {icon: 5}); layer.msg("用户名需要3-32位的小写字母或数字组合!", {icon: 5});
return false; return false;
} }
//正则验证密码 //正则验证密码

28
templates/admin/static/style.css

@ -100,6 +100,34 @@
-ms-box-sizing: border-box; /*IE8*/ -ms-box-sizing: border-box; /*IE8*/
box-sizing: border-box; box-sizing: border-box;
} }
.page-msg{
width:100%;
color: #FF5722;
border-left: 3px solid #FF5722;
background-color: #F0F0F0;
padding:0.8em;
border-radius: 1px;
margin-bottom:2em;
-moz-box-sizing: border-box; /*Firefox3.5+*/
-webkit-box-sizing: border-box; /*Safari3.2+*/
-o-box-sizing: border-box; /*Opera9.6*/
-ms-box-sizing: border-box; /*IE8*/
box-sizing: border-box;
}
.page-msg a{
color:#01AAED;
}
.page-msg ol li{
list-style-type:decimal;
}
.page-msg ol{
margin-left: 1.5em;
}
.setting-msg a{ .setting-msg a{
color:#01AAED; color:#01AAED;
} }

14
templates/default/index.php

@ -136,11 +136,6 @@
<!-- 华丽的分割线 --> <!-- 华丽的分割线 -->
<div class="mdui-divider"></div> <div class="mdui-divider"></div>
<!-- 华丽的分割线END --> <!-- 华丽的分割线END -->
<a href="https://www.xiaoz.me/" target="_blank" title="小z博客">
<li class="mdui-list-item mdui-ripple">
<div class="mdui-list-item-content category-name"><i class="fa fa-user-circle"></i> About</div>
</li>
</a>
<?php <?php
if ( !is_login() ) { if ( !is_login() ) {
@ -205,9 +200,16 @@
//默认描述 //默认描述
$link['description'] = empty($link['description']) ? '作者很懒,没有填写描述。' : $link['description']; $link['description'] = empty($link['description']) ? '作者很懒,没有填写描述。' : $link['description'];
$id = $link['id']; $id = $link['id'];
//直链模式
if( $site['link_model'] === 'direct' ) {
$url = $link['url'];
}
else{
$url = '/index.php?c=click&id='.$link['id'];
}
//var_dump($link); //var_dump($link);
?> ?>
<a href="/index.php?c=click&id=<?php echo $link['id']; ?>" target="_blank" title = "<?php echo $link['description']; ?>"> <a href="<?php echo $url; ?>" target="_blank" title = "<?php echo $link['description']; ?>">
<div class="mdui-col-lg-2 mdui-col-md-3 mdui-col-sm-4 mdui-col-xs-6 link-space" id = "id_<?php echo $link['id']; ?>" link-title = "<?php echo $link['title']; ?>" link-url = "<?php echo $link['url']; ?>"> <div class="mdui-col-lg-2 mdui-col-md-3 mdui-col-sm-4 mdui-col-xs-6 link-space" id = "id_<?php echo $link['id']; ?>" link-title = "<?php echo $link['title']; ?>" link-url = "<?php echo $link['url']; ?>">
<!-- 用来搜索匹配使用 --> <!-- 用来搜索匹配使用 -->
<span style = "display:none;"><?php echo $link['url']; ?></span> <span style = "display:none;"><?php echo $link['url']; ?></span>

2
version.txt

@ -1 +1 @@
v0.9.23-20220609 v0.9.24-20220801
Loading…
Cancel
Save